remove stray tab
[mesa.git] / src / mesa / shader / slang / slang_link2.c
index 0965f3e4c4e07b11473da314cf8cb61f54dce994..0a517aecc5f5f741f4d1dd4352300fe4eb89d627 100644 (file)
@@ -259,8 +259,10 @@ link_uniform_vars(struct gl_shader_program *shProg, struct gl_program *prog)
       if (inst->Opcode == OPCODE_TEX ||
           inst->Opcode == OPCODE_TXB ||
           inst->Opcode == OPCODE_TXP) {
+         /*
          printf("====== remap sampler from %d to %d\n",
                 inst->Sampler, map[ inst->Sampler ]);
+         */
          inst->Sampler = map[ inst->Sampler ];
       }
    }
@@ -323,6 +325,7 @@ _slang_resolve_attributes(struct gl_shader_program *shProg,
 {
    GLuint i, j;
    GLbitfield usedAttributes;
+   GLint size = 4; /* XXX fix */
 
    assert(prog->Target == GL_VERTEX_PROGRAM_ARB);
 
@@ -331,7 +334,7 @@ _slang_resolve_attributes(struct gl_shader_program *shProg,
     */
    usedAttributes = 0x0;
    for (i = 0; i < shProg->Attributes->NumParameters; i++) {
-      GLint attr = shProg->Attributes->Parameters[i].StateIndexes[1];
+      GLint attr = shProg->Attributes->Parameters[i].StateIndexes[0];
       usedAttributes |= attr;
    }
 
@@ -357,11 +360,14 @@ _slang_resolve_attributes(struct gl_shader_program *shProg,
             GLint attr;
             if (index >= 0) {
                /* found, user must have specified a binding */
-               attr = shProg->Attributes->Parameters[index].StateIndexes[1];
+               attr = shProg->Attributes->Parameters[index].StateIndexes[0];
             }
             else {
-               /* not found, choose our own attribute number */
-               for (attr = 0; attr < MAX_VERTEX_ATTRIBS; attr++) {
+               /* Not found, choose our own attribute number.
+                * Start at 1 since generic attribute 0 always aliases
+                * glVertex/position.
+                */
+               for (attr = 1; attr < MAX_VERTEX_ATTRIBS; attr++) {
                   if (((1 << attr) & usedAttributes) == 0)
                      break;
                }
@@ -369,7 +375,7 @@ _slang_resolve_attributes(struct gl_shader_program *shProg,
                   /* too many!  XXX record error log */
                   return GL_FALSE;
                }
-               _mesa_add_attribute(shProg->Attributes, name, attr);
+               _mesa_add_attribute(shProg->Attributes, name, size, attr);
             }
 
             inst->SrcReg[j].Index = VERT_ATTRIB_GENERIC0 + attr;
@@ -567,7 +573,9 @@ _slang_link2(GLcontext *ctx,
    _slang_resolve_samplers(shProg, &shProg->VertexProgram->Base);
    _slang_resolve_samplers(shProg, &shProg->FragmentProgram->Base);
 
-   _slang_resolve_attributes(shProg, &shProg->VertexProgram->Base);
+   if (!_slang_resolve_attributes(shProg, &shProg->VertexProgram->Base)) {
+      /*goto cleanup;*/
+   }
 
    _slang_update_inputs_outputs(&shProg->VertexProgram->Base);
    _slang_update_inputs_outputs(&shProg->FragmentProgram->Base);