summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/slang_link.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-11-24 13:04:04 -0700
committerBrian Paul <brian.paul@tungstengraphics.com>2008-11-24 13:05:54 -0700
commitb730d0d3e9b202b17a0815cb820fc9905f35cb98 (patch)
treef2bba95c89dd434b0e3bdc598de7d361d59b114c /src/mesa/shader/slang/slang_link.c
parentd52e8543b61ec5b8b8d9b1574a28ae2472fe4c56 (diff)
mesa: add gl_program::Input/OutputFlags[] array
These arrays will indicate per-input or per-output options for vertex/fragment programs such as centroid-sampling and invariance.
Diffstat (limited to 'src/mesa/shader/slang/slang_link.c')
-rw-r--r--src/mesa/shader/slang/slang_link.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 6b895013af..08d7540372 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -89,16 +89,39 @@ bits_agree(GLbitfield flags1, GLbitfield flags2, GLbitfield bit)
* Linking varying vars involves rearranging varying vars so that the
* vertex program's output varyings matches the order of the fragment
* program's input varyings.
+ * We'll then rewrite instructions to replace PROGRAM_VARYING with either
+ * PROGRAM_INPUT or PROGRAM_OUTPUT depending on whether it's a vertex or
+ * fragment shader.
+ * This is also where we set program Input/OutputFlags to indicate
+ * which inputs are centroid-sampled, invariant, etc.
*/
static GLboolean
link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
{
GLuint *map, i, firstVarying, newFile;
+ GLbitfield *inOutFlags;
map = (GLuint *) malloc(prog->Varying->NumParameters * sizeof(GLuint));
if (!map)
return GL_FALSE;
+ /* Varying variables are treated like other vertex program outputs
+ * (and like other fragment program inputs). The position of the
+ * first varying differs for vertex/fragment programs...
+ * Also, replace File=PROGRAM_VARYING with File=PROGRAM_INPUT/OUTPUT.
+ */
+ if (prog->Target == GL_VERTEX_PROGRAM_ARB) {
+ firstVarying = VERT_RESULT_VAR0;
+ newFile = PROGRAM_OUTPUT;
+ inOutFlags = prog->OutputFlags;
+ }
+ else {
+ assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB);
+ firstVarying = FRAG_ATTRIB_VAR0;
+ newFile = PROGRAM_INPUT;
+ inOutFlags = prog->InputFlags;
+ }
+
for (i = 0; i < prog->Varying->NumParameters; i++) {
/* see if this varying is in the linked varying list */
const struct gl_program_parameter *var = prog->Varying->Parameters + i;
@@ -132,12 +155,14 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
var->Flags);
}
- /* map varying[i] to varying[j].
+ /* Map varying[i] to varying[j].
+ * Plus, set prog->Input/OutputFlags[] as described above.
* Note: the loop here takes care of arrays or large (sz>4) vars.
*/
{
GLint sz = var->Size;
while (sz > 0) {
+ inOutFlags[firstVarying + j] = var->Flags;
/*printf("Link varying from %d to %d\n", i, j);*/
map[i++] = j++;
sz -= 4;
@@ -147,21 +172,6 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
}
- /* Varying variables are treated like other vertex program outputs
- * (and like other fragment program inputs). The position of the
- * first varying differs for vertex/fragment programs...
- * Also, replace File=PROGRAM_VARYING with File=PROGRAM_INPUT/OUTPUT.
- */
- if (prog->Target == GL_VERTEX_PROGRAM_ARB) {
- firstVarying = VERT_RESULT_VAR0;
- newFile = PROGRAM_OUTPUT;
- }
- else {
- assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB);
- firstVarying = FRAG_ATTRIB_VAR0;
- newFile = PROGRAM_INPUT;
- }
-
/* OK, now scan the program/shader instructions looking for varying vars,
* replacing the old index with the new index.
*/