Mesa (master): glsl: add gl_Vertex, gl_Normal, etc to list of active attributes

Brian Paul brianp at kemper.freedesktop.org
Wed Aug 12 18:43:04 UTC 2009


Module: Mesa
Branch: master
Commit: 8f9ee069250fe65bc19c5859963ee85db96e24e1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8f9ee069250fe65bc19c5859963ee85db96e24e1

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Aug 12 12:31:57 2009 -0600

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.

---

 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 826bc3d..d1e91d3 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;
 }
 




More information about the mesa-commit mailing list