diff options
author | Brian Paul <[email protected]> | 2009-08-12 12:31:57 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-08-12 12:35:13 -0600 |
commit | 8f9ee069250fe65bc19c5859963ee85db96e24e1 (patch) | |
tree | fd87dbc9b67ea8bfed2bb451c066d99c452b1c3b | |
parent | fd5eda1423dff38ea1af589f7abd47b002a4f5ed (diff) |
glsl: add gl_Vertex, gl_Normal, etc to list of active attributes
If a vertex shader uses gl_Vertex, gl_Normal, etc, we need to include them
when the user queries the list of active attributes. Before this we were
just including the user-defined attributes.
-rw-r--r-- | src/mesa/shader/slang/slang_link.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 826bc3dd157..d1e91d306d9 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -328,6 +328,7 @@ _slang_resolve_attributes(struct gl_shader_program *shProg, GLint attribMap[MAX_VERTEX_GENERIC_ATTRIBS]; GLuint i, j; GLbitfield usedAttributes; /* generics only, not legacy attributes */ + GLbitfield inputsRead = 0x0; assert(origProg != linkedProg); assert(origProg->Target == GL_VERTEX_PROGRAM_ARB); @@ -371,6 +372,10 @@ _slang_resolve_attributes(struct gl_shader_program *shProg, for (i = 0; i < linkedProg->NumInstructions; i++) { struct prog_instruction *inst = linkedProg->Instructions + i; for (j = 0; j < 3; j++) { + if (inst->SrcReg[j].File == PROGRAM_INPUT) { + inputsRead |= (1 << inst->SrcReg[j].Index); + } + if (inst->SrcReg[j].File == PROGRAM_INPUT && inst->SrcReg[j].Index >= VERT_ATTRIB_GENERIC0) { /* @@ -432,6 +437,20 @@ _slang_resolve_attributes(struct gl_shader_program *shProg, } } + /* Handle pre-defined attributes here (gl_Vertex, gl_Normal, etc). + * When the user queries the active attributes we need to include both + * the user-defined attributes and the built-in ones. + */ + for (i = VERT_ATTRIB_POS; i < VERT_ATTRIB_GENERIC0; i++) { + if (inputsRead & (1 << i)) { + _mesa_add_attribute(linkedProg->Attributes, + _slang_vert_attrib_name(i), + 1, /* size */ + _slang_vert_attrib_type(i), + -1 /* attrib/input */); + } + } + return GL_TRUE; } |