diff options
author | Brian Paul <[email protected]> | 2010-07-30 14:27:03 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2010-07-30 14:29:19 -0600 |
commit | b3e3d0da586812c61f7bd3933a9a3c2511b8d55b (patch) | |
tree | c161235865ad8a6b1e43bb85c5a0e5a1dcc02480 /src | |
parent | 56643096f1eb01eefa1a532ac096b32d23b6b8ba (diff) |
st/mesa: better handling of indirect addressing of temp/const register files
With gl_program::IndirectRegisterFiles we can distinguish between indirect
addressing of constants vs. temporaries. In the case of temporaries,
declare all temps up front sequentially.
Fixes fd.o bug 29305.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/state_tracker/st_mesa_to_tgsi.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 97186f8dadf..1a499e66d03 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -44,6 +44,15 @@ #include "util/u_math.h" #include "util/u_memory.h" + +#define PROGRAM_ANY_CONST ((1 << PROGRAM_LOCAL_PARAM) | \ + (1 << PROGRAM_ENV_PARAM) | \ + (1 << PROGRAM_STATE_VAR) | \ + (1 << PROGRAM_NAMED_PARAM) | \ + (1 << PROGRAM_CONSTANT) | \ + (1 << PROGRAM_UNIFORM)) + + struct label { unsigned branch_target; unsigned token; @@ -1059,6 +1068,16 @@ st_translate_mesa_program( t->address[0] = ureg_DECL_address( ureg ); } + if (program->IndirectRegisterFiles & (1 << PROGRAM_TEMPORARY)) { + /* If temps are accessed with indirect addressing, declare temporaries + * in sequential order. Else, we declare them on demand elsewhere. + */ + for (i = 0; i < program->NumTemporaries; i++) { + /* XXX use TGSI_FILE_TEMPORARY_ARRAY when it's supported by ureg */ + t->temps[i] = ureg_DECL_temporary( t->ureg ); + } + } + /* Emit constants and immediates. Mesa uses a single index space * for these, so we put all the translated regs in t->constants. */ @@ -1069,7 +1088,7 @@ st_translate_mesa_program( ret = PIPE_ERROR_OUT_OF_MEMORY; goto out; } - + for (i = 0; i < program->Parameters->NumParameters; i++) { switch (program->Parameters->Parameters[i].Type) { case PROGRAM_ENV_PARAM: @@ -1080,13 +1099,14 @@ st_translate_mesa_program( t->constants[i] = ureg_DECL_constant( ureg, i ); break; - /* Emit immediates only when there is no address register - * in use. FIXME: Be smarter and recognize param arrays: + /* Emit immediates only when there's no indirect addressing of + * the const buffer. + * FIXME: Be smarter and recognize param arrays: * indirect addressing is only valid within the referenced * array. */ case PROGRAM_CONSTANT: - if (program->NumAddressRegs > 0) + if (program->IndirectRegisterFiles & PROGRAM_ANY_CONST) t->constants[i] = ureg_DECL_constant( ureg, i ); else t->constants[i] = |