summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-12-17 13:59:55 -0700
committerBrian <[email protected]>2007-12-17 14:00:35 -0700
commit8978627ad0e236796758d4912822b3428a649987 (patch)
tree99f7ec8cec9bdb0948c65d276d167be911f9f0c5 /src
parentaeb53622814d340323c766dd33e1dd9a25f33e7a (diff)
Emit declarations for constants (references to the const buffer)
Diffstat (limited to 'src')
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.c58
1 files changed, 57 insertions, 1 deletions
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index bccabd8004d..c8b76978f12 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -597,6 +597,19 @@ make_sampler_decl(GLuint index)
return decl;
}
+/** Reference into a constant buffer */
+static struct tgsi_full_declaration
+make_constant_decl(GLuint first, GLuint last)
+{
+ struct tgsi_full_declaration decl;
+ decl = tgsi_default_full_declaration();
+ decl.Declaration.File = TGSI_FILE_CONSTANT;
+ decl.Declaration.Declare = TGSI_DECLARE_RANGE;
+ decl.u.DeclarationRange.First = first;
+ decl.u.DeclarationRange.Last = last;
+ return decl;
+}
+
/**
@@ -788,7 +801,7 @@ tgsi_translate_mesa_program(
/* immediates/literals */
for (i = 0; program->Parameters && i < program->Parameters->NumParameters;
- i++) {
+ i++) {
if (program->Parameters->Parameters[i].Type == PROGRAM_CONSTANT) {
struct tgsi_full_immediate fullimm
= make_immediate(program->Parameters->ParameterValues[i],
@@ -802,6 +815,49 @@ tgsi_translate_mesa_program(
}
}
+ /* constant buffer refs */
+ {
+ GLint start = -1, end = -1;
+
+ for (i = 0;
+ program->Parameters && i < program->Parameters->NumParameters;
+ i++) {
+ GLboolean emit = (i == program->Parameters->NumParameters - 1);
+
+ switch (program->Parameters->Parameters[i].Type) {
+ case PROGRAM_ENV_PARAM:
+ case PROGRAM_STATE_VAR:
+ case PROGRAM_NAMED_PARAM:
+ case PROGRAM_UNIFORM:
+ if (start == -1) {
+ /* begin a sequence */
+ start = i;
+ end = i;
+ }
+ else {
+ /* continue sequence */
+ end = i;
+ }
+ break;
+ default:
+ if (start != -1) {
+ /* end of sequence */
+ emit = GL_TRUE;
+ }
+ }
+
+ if (emit && start >= 0) {
+ struct tgsi_full_declaration fulldecl;
+ fulldecl = make_constant_decl( start, end );
+ ti += tgsi_build_full_declaration(&fulldecl,
+ &tokens[ti],
+ header,
+ maxTokens - ti);
+ start = end = -1;
+ }
+ }
+ }
+
/* texture samplers */
for (i = 0; i < 8; i++) {
if (program->SamplersUsed & (1 << i)) {