From: Brian Date: Mon, 17 Dec 2007 20:59:55 +0000 (-0700) Subject: Emit declarations for constants (references to the const buffer) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8978627ad0e236796758d4912822b3428a649987;p=mesa.git Emit declarations for constants (references to the const buffer) --- 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)) {