st: Do not translate program constants to immediates when
indirect addressing used.
This commit is contained in:
@@ -47,7 +47,8 @@ static GLuint
|
|||||||
map_register_file(
|
map_register_file(
|
||||||
enum register_file file,
|
enum register_file file,
|
||||||
GLuint index,
|
GLuint index,
|
||||||
const GLuint immediateMapping[] )
|
const GLuint immediateMapping[],
|
||||||
|
GLboolean indirectAccess )
|
||||||
{
|
{
|
||||||
switch( file ) {
|
switch( file ) {
|
||||||
case PROGRAM_UNDEFINED:
|
case PROGRAM_UNDEFINED:
|
||||||
@@ -66,11 +67,13 @@ map_register_file(
|
|||||||
case PROGRAM_STATE_VAR:
|
case PROGRAM_STATE_VAR:
|
||||||
case PROGRAM_NAMED_PARAM:
|
case PROGRAM_NAMED_PARAM:
|
||||||
case PROGRAM_UNIFORM:
|
case PROGRAM_UNIFORM:
|
||||||
if (immediateMapping && immediateMapping[index] != ~0)
|
if (!indirectAccess && immediateMapping && immediateMapping[index] != ~0)
|
||||||
return TGSI_FILE_IMMEDIATE;
|
return TGSI_FILE_IMMEDIATE;
|
||||||
else
|
else
|
||||||
return TGSI_FILE_CONSTANT;
|
return TGSI_FILE_CONSTANT;
|
||||||
case PROGRAM_CONSTANT:
|
case PROGRAM_CONSTANT:
|
||||||
|
if (indirectAccess)
|
||||||
|
return TGSI_FILE_CONSTANT;
|
||||||
return TGSI_FILE_IMMEDIATE;
|
return TGSI_FILE_IMMEDIATE;
|
||||||
case PROGRAM_INPUT:
|
case PROGRAM_INPUT:
|
||||||
return TGSI_FILE_INPUT;
|
return TGSI_FILE_INPUT;
|
||||||
@@ -98,7 +101,8 @@ map_register_file_index(
|
|||||||
GLuint index,
|
GLuint index,
|
||||||
const GLuint inputMapping[],
|
const GLuint inputMapping[],
|
||||||
const GLuint outputMapping[],
|
const GLuint outputMapping[],
|
||||||
const GLuint immediateMapping[])
|
const GLuint immediateMapping[],
|
||||||
|
GLboolean indirectAccess )
|
||||||
{
|
{
|
||||||
switch( file ) {
|
switch( file ) {
|
||||||
case TGSI_FILE_INPUT:
|
case TGSI_FILE_INPUT:
|
||||||
@@ -109,6 +113,8 @@ map_register_file_index(
|
|||||||
return outputMapping[index];
|
return outputMapping[index];
|
||||||
|
|
||||||
case TGSI_FILE_IMMEDIATE:
|
case TGSI_FILE_IMMEDIATE:
|
||||||
|
if (indirectAccess)
|
||||||
|
return index;
|
||||||
return immediateMapping[index];
|
return immediateMapping[index];
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -190,6 +196,7 @@ compile_instruction(
|
|||||||
const GLuint inputMapping[],
|
const GLuint inputMapping[],
|
||||||
const GLuint outputMapping[],
|
const GLuint outputMapping[],
|
||||||
const GLuint immediateMapping[],
|
const GLuint immediateMapping[],
|
||||||
|
GLboolean indirectAccess,
|
||||||
GLuint preamble_size,
|
GLuint preamble_size,
|
||||||
GLuint processor,
|
GLuint processor,
|
||||||
GLboolean *insideSubroutine)
|
GLboolean *insideSubroutine)
|
||||||
@@ -205,29 +212,32 @@ compile_instruction(
|
|||||||
fullinst->Instruction.NumSrcRegs = _mesa_num_inst_src_regs( inst->Opcode );
|
fullinst->Instruction.NumSrcRegs = _mesa_num_inst_src_regs( inst->Opcode );
|
||||||
|
|
||||||
fulldst = &fullinst->FullDstRegisters[0];
|
fulldst = &fullinst->FullDstRegisters[0];
|
||||||
fulldst->DstRegister.File = map_register_file( inst->DstReg.File, 0, NULL );
|
fulldst->DstRegister.File = map_register_file( inst->DstReg.File, 0, NULL, GL_FALSE );
|
||||||
fulldst->DstRegister.Index = map_register_file_index(
|
fulldst->DstRegister.Index = map_register_file_index(
|
||||||
fulldst->DstRegister.File,
|
fulldst->DstRegister.File,
|
||||||
inst->DstReg.Index,
|
inst->DstReg.Index,
|
||||||
inputMapping,
|
inputMapping,
|
||||||
outputMapping,
|
outputMapping,
|
||||||
NULL
|
NULL,
|
||||||
);
|
GL_FALSE );
|
||||||
fulldst->DstRegister.WriteMask = convert_writemask( inst->DstReg.WriteMask );
|
fulldst->DstRegister.WriteMask = convert_writemask( inst->DstReg.WriteMask );
|
||||||
|
|
||||||
for( i = 0; i < fullinst->Instruction.NumSrcRegs; i++ ) {
|
for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) {
|
||||||
GLuint j;
|
GLuint j;
|
||||||
|
|
||||||
fullsrc = &fullinst->FullSrcRegisters[i];
|
fullsrc = &fullinst->FullSrcRegisters[i];
|
||||||
fullsrc->SrcRegister.File = map_register_file( inst->SrcReg[i].File,
|
fullsrc->SrcRegister.File = map_register_file(
|
||||||
|
inst->SrcReg[i].File,
|
||||||
inst->SrcReg[i].Index,
|
inst->SrcReg[i].Index,
|
||||||
immediateMapping );
|
immediateMapping,
|
||||||
|
indirectAccess );
|
||||||
fullsrc->SrcRegister.Index = map_register_file_index(
|
fullsrc->SrcRegister.Index = map_register_file_index(
|
||||||
fullsrc->SrcRegister.File,
|
fullsrc->SrcRegister.File,
|
||||||
inst->SrcReg[i].Index,
|
inst->SrcReg[i].Index,
|
||||||
inputMapping,
|
inputMapping,
|
||||||
outputMapping,
|
outputMapping,
|
||||||
immediateMapping);
|
immediateMapping,
|
||||||
|
indirectAccess );
|
||||||
|
|
||||||
/* swizzle (ext swizzle also depends on negation) */
|
/* swizzle (ext swizzle also depends on negation) */
|
||||||
{
|
{
|
||||||
@@ -721,6 +731,7 @@ tgsi_translate_mesa_program(
|
|||||||
GLuint immediates[1000];
|
GLuint immediates[1000];
|
||||||
GLuint numImmediates = 0;
|
GLuint numImmediates = 0;
|
||||||
GLboolean insideSubroutine = GL_FALSE;
|
GLboolean insideSubroutine = GL_FALSE;
|
||||||
|
GLboolean indirectAccess = GL_FALSE;
|
||||||
|
|
||||||
assert(procType == TGSI_PROCESSOR_FRAGMENT ||
|
assert(procType == TGSI_PROCESSOR_FRAGMENT ||
|
||||||
procType == TGSI_PROCESSOR_VERTEX);
|
procType == TGSI_PROCESSOR_VERTEX);
|
||||||
@@ -841,7 +852,7 @@ tgsi_translate_mesa_program(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Address register.
|
/* Declare address register.
|
||||||
*/
|
*/
|
||||||
if (program->NumAddressRegs > 0) {
|
if (program->NumAddressRegs > 0) {
|
||||||
struct tgsi_full_declaration fulldecl;
|
struct tgsi_full_declaration fulldecl;
|
||||||
@@ -854,39 +865,57 @@ tgsi_translate_mesa_program(
|
|||||||
&tokens[ti],
|
&tokens[ti],
|
||||||
header,
|
header,
|
||||||
maxTokens - ti );
|
maxTokens - ti );
|
||||||
|
|
||||||
|
indirectAccess = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* immediates/literals */
|
/* immediates/literals */
|
||||||
memset(immediates, ~0, sizeof(immediates));
|
memset(immediates, ~0, sizeof(immediates));
|
||||||
|
|
||||||
for (i = 0; program->Parameters && i < program->Parameters->NumParameters;
|
/* Emit immediates only when there is no address register in use.
|
||||||
i++) {
|
* FIXME: Be smarter and recognize param arrays -- indirect addressing is
|
||||||
|
* only valid within the referenced array.
|
||||||
|
*/
|
||||||
|
if (program->Parameters && !indirectAccess) {
|
||||||
|
for (i = 0; i < program->Parameters->NumParameters; i++) {
|
||||||
if (program->Parameters->Parameters[i].Type == PROGRAM_CONSTANT) {
|
if (program->Parameters->Parameters[i].Type == PROGRAM_CONSTANT) {
|
||||||
struct tgsi_full_immediate fullimm
|
struct tgsi_full_immediate fullimm;
|
||||||
= make_immediate(program->Parameters->ParameterValues[i], 4);
|
|
||||||
ti += tgsi_build_full_immediate(&fullimm,
|
fullimm = make_immediate( program->Parameters->ParameterValues[i], 4 );
|
||||||
|
ti += tgsi_build_full_immediate(
|
||||||
|
&fullimm,
|
||||||
&tokens[ti],
|
&tokens[ti],
|
||||||
header,
|
header,
|
||||||
maxTokens - ti);
|
maxTokens - ti );
|
||||||
immediates[i] = numImmediates;
|
immediates[i] = numImmediates;
|
||||||
numImmediates++;
|
numImmediates++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* constant buffer refs */
|
/* constant buffer refs */
|
||||||
{
|
if (program->Parameters) {
|
||||||
GLint start = -1, end = -1;
|
GLint start = -1, end = -1;
|
||||||
|
|
||||||
for (i = 0;
|
for (i = 0; i < program->Parameters->NumParameters; i++) {
|
||||||
program->Parameters && i < program->Parameters->NumParameters;
|
|
||||||
i++) {
|
|
||||||
GLboolean emit = (i == program->Parameters->NumParameters - 1);
|
GLboolean emit = (i == program->Parameters->NumParameters - 1);
|
||||||
|
GLboolean matches;
|
||||||
|
|
||||||
switch (program->Parameters->Parameters[i].Type) {
|
switch (program->Parameters->Parameters[i].Type) {
|
||||||
case PROGRAM_ENV_PARAM:
|
case PROGRAM_ENV_PARAM:
|
||||||
case PROGRAM_STATE_VAR:
|
case PROGRAM_STATE_VAR:
|
||||||
case PROGRAM_NAMED_PARAM:
|
case PROGRAM_NAMED_PARAM:
|
||||||
case PROGRAM_UNIFORM:
|
case PROGRAM_UNIFORM:
|
||||||
|
matches = GL_TRUE;
|
||||||
|
break;
|
||||||
|
case PROGRAM_CONSTANT:
|
||||||
|
matches = indirectAccess;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
matches = GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matches) {
|
||||||
if (start == -1) {
|
if (start == -1) {
|
||||||
/* begin a sequence */
|
/* begin a sequence */
|
||||||
start = i;
|
start = i;
|
||||||
@@ -896,8 +925,8 @@ tgsi_translate_mesa_program(
|
|||||||
/* continue sequence */
|
/* continue sequence */
|
||||||
end = i;
|
end = i;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
default:
|
else {
|
||||||
if (start != -1) {
|
if (start != -1) {
|
||||||
/* end of sequence */
|
/* end of sequence */
|
||||||
emit = GL_TRUE;
|
emit = GL_TRUE;
|
||||||
@@ -906,11 +935,13 @@ tgsi_translate_mesa_program(
|
|||||||
|
|
||||||
if (emit && start >= 0) {
|
if (emit && start >= 0) {
|
||||||
struct tgsi_full_declaration fulldecl;
|
struct tgsi_full_declaration fulldecl;
|
||||||
|
|
||||||
fulldecl = make_constant_decl( start, end );
|
fulldecl = make_constant_decl( start, end );
|
||||||
ti += tgsi_build_full_declaration(&fulldecl,
|
ti += tgsi_build_full_declaration(
|
||||||
|
&fulldecl,
|
||||||
&tokens[ti],
|
&tokens[ti],
|
||||||
header,
|
header,
|
||||||
maxTokens - ti);
|
maxTokens - ti );
|
||||||
start = end = -1;
|
start = end = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -920,25 +951,27 @@ tgsi_translate_mesa_program(
|
|||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
if (program->SamplersUsed & (1 << i)) {
|
if (program->SamplersUsed & (1 << i)) {
|
||||||
struct tgsi_full_declaration fulldecl;
|
struct tgsi_full_declaration fulldecl;
|
||||||
|
|
||||||
fulldecl = make_sampler_decl( i );
|
fulldecl = make_sampler_decl( i );
|
||||||
ti += tgsi_build_full_declaration(&fulldecl,
|
ti += tgsi_build_full_declaration(
|
||||||
|
&fulldecl,
|
||||||
&tokens[ti],
|
&tokens[ti],
|
||||||
header,
|
header,
|
||||||
maxTokens - ti );
|
maxTokens - ti );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < program->NumInstructions; i++) {
|
||||||
for( i = 0; i < program->NumInstructions; i++ ) {
|
|
||||||
compile_instruction(
|
compile_instruction(
|
||||||
&program->Instructions[i],
|
&program->Instructions[i],
|
||||||
&fullinst,
|
&fullinst,
|
||||||
inputMapping,
|
inputMapping,
|
||||||
outputMapping,
|
outputMapping,
|
||||||
immediates,
|
immediates,
|
||||||
|
indirectAccess,
|
||||||
preamble_size,
|
preamble_size,
|
||||||
procType,
|
procType,
|
||||||
&insideSubroutine);
|
&insideSubroutine );
|
||||||
|
|
||||||
ti += tgsi_build_full_instruction(
|
ti += tgsi_build_full_instruction(
|
||||||
&fullinst,
|
&fullinst,
|
||||||
@@ -949,4 +982,3 @@ tgsi_translate_mesa_program(
|
|||||||
|
|
||||||
return ti;
|
return ti;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user