the get_register_pointer() function was pretty well broken in a few ways
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 29 Jun 2004 00:03:59 +0000 (00:03 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 29 Jun 2004 00:03:59 +0000 (00:03 +0000)
src/mesa/shader/nvvertexec.c

index 91577d319ab55147f816bd79ed54c0055222e707..30e925e6e29087ff536b9683e5f2b9f5b7dc4aa4 100644 (file)
@@ -163,19 +163,9 @@ _mesa_init_vp_per_primitive_registers(GLcontext *ctx)
    else {
       /* Using and ARB vertex program */
       if (ctx->VertexProgram.Current->Parameters) {
-         GLuint i;
-
-         /* Grab the state */                    
+         /* Grab the state GL state and put into registers */
          _mesa_load_state_parameters(ctx,
                                      ctx->VertexProgram.Current->Parameters);
-
-         /* And copy it into the program state */
-         for (i = 0; i < ctx->VertexProgram.Current->Parameters->NumParameters;
-              i++) {
-            MEMCPY(ctx->VertexProgram.Parameters[i], 
-                &ctx->VertexProgram.Current->Parameters->Parameters[i].Values,
-                4 * sizeof(GLfloat));                          
-         }                               
       }
    }
 }
@@ -252,19 +242,23 @@ get_register_pointer( const struct vp_src_register *source,
    else {
       switch (source->File) {
          case PROGRAM_TEMPORARY:
+            ASSERT(source->Index < MAX_NV_VERTEX_PROGRAM_TEMPS);
             return state->Temporaries[source->Index];
          case PROGRAM_INPUT:
+            ASSERT(source->Index < MAX_NV_VERTEX_PROGRAM_INPUTS);
             return state->Inputs[source->Index];
          case PROGRAM_LOCAL_PARAM:
-            /* XXX fix */
-            return state->Temporaries[source->Index]; 
+            ASSERT(source->Index < MAX_PROGRAM_LOCAL_PARAMS);
+            return state->Current->Base.LocalParams[source->Index];
          case PROGRAM_ENV_PARAM:
+            ASSERT(source->Index < MAX_NV_VERTEX_PROGRAM_PARAMS);
             return state->Parameters[source->Index];
          case PROGRAM_STATE_VAR:
-            return state->Parameters[source->Index];
+            ASSERT(source->Index < state->Current->Parameters->NumParameters);
+            return state->Current->Parameters->Parameters[source->Index].Values;
          default:
             _mesa_problem(NULL,
-                          "Bad source register file in fetch_vector4(vp)");
+                          "Bad source register file in get_register_pointer");
             return NULL;
       }
    }
@@ -397,7 +391,6 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
       /* XXX: This could go elsewhere */
       ctx->VertexProgram.Current->OutputsWritten |= 0x1;
    }
-
    for (inst = program->Instructions; ; inst++) {
 
       if (ctx->VertexProgram.CallbackEnabled &&