llvmpipe: check for texture usage in all scenes
[mesa.git] / src / mesa / shader / prog_parameter_layout.c
index 8f2b30622036251513a6cfbf334828b34117d418..a8885738321d64390fa938bbb87b919bb8a79c7b 100644 (file)
@@ -72,14 +72,11 @@ copy_indirect_accessed_array(struct gl_program_parameter_list *src,
                             unsigned first, unsigned count)
 {
    const int base = dst->NumParameters;
-   unsigned i;
-   unsigned j;
-
+   unsigned i, j;
 
    for (i = first; i < (first + count); i++) {
       struct gl_program_parameter *curr = & src->Parameters[i];
 
-
       if (curr->Type == PROGRAM_CONSTANT) {
         j = dst->NumParameters;
       } else {
@@ -93,10 +90,15 @@ copy_indirect_accessed_array(struct gl_program_parameter_list *src,
 
       assert(j == dst->NumParameters);
 
+      /* copy src parameter [i] to dest parameter [j] */
       memcpy(& dst->Parameters[j], curr,
             sizeof(dst->Parameters[j]));
       memcpy(dst->ParameterValues[j], src->ParameterValues[i],
             sizeof(GLfloat) * 4);
+
+      /* Pointer to the string name was copied.  Null-out src param name
+       * to prevent double free later.
+       */
       curr->Name = NULL;
 
       dst->NumParameters++;
@@ -106,18 +108,20 @@ copy_indirect_accessed_array(struct gl_program_parameter_list *src,
 }
 
 
-int
+/**
+ * XXX description???
+ * \return GL_TRUE for success, GL_FALSE for failure
+ */
+GLboolean
 _mesa_layout_parameters(struct asm_parser_state *state)
 {
    struct gl_program_parameter_list *layout;
    struct asm_instruction *inst;
    unsigned i;
 
-
    layout =
       _mesa_new_parameter_list_sized(state->prog->Parameters->NumParameters);
 
-
    /* PASS 1:  Move any parameters that are accessed indirectly from the
     * original parameter list to the new parameter list.
     */
@@ -128,12 +132,12 @@ _mesa_layout_parameters(struct asm_parser_state *state)
             */
            if (!inst->SrcReg[i].Symbol->pass1_done) {
               const int new_begin =
-                 copy_indirect_accessed_array(state->prog->Parameters, layout, 
+                 copy_indirect_accessed_array(state->prog->Parameters, layout,
                      inst->SrcReg[i].Symbol->param_binding_begin,
                      inst->SrcReg[i].Symbol->param_binding_length);
 
               if (new_begin < 0) {
-                 return 0;
+                 return GL_FALSE;
               }
 
               inst->SrcReg[i].Symbol->param_binding_begin = new_begin;
@@ -151,7 +155,6 @@ _mesa_layout_parameters(struct asm_parser_state *state)
       }
    }
 
-
    /* PASS 2:  Move any parameters that are not accessed indirectly from the
     * original parameter list to the new parameter list.
     */
@@ -161,7 +164,6 @@ _mesa_layout_parameters(struct asm_parser_state *state)
         const int idx = inst->SrcReg[i].Base.Index;
         unsigned swizzle = SWIZZLE_NOOP;
 
-
         /* All relative addressed operands were processed on the first
          * pass.  Just skip them here.
          */
@@ -169,7 +171,6 @@ _mesa_layout_parameters(struct asm_parser_state *state)
            continue;
         }
 
-
         if ((inst->SrcReg[i].Base.File <= PROGRAM_VARYING )
             || (inst->SrcReg[i].Base.File >= PROGRAM_WRITE_ONLY)) {
            continue;
@@ -205,9 +206,8 @@ _mesa_layout_parameters(struct asm_parser_state *state)
       }
    }
 
-
    _mesa_free_parameter_list(state->prog->Parameters);
    state->prog->Parameters = layout;
 
-   return 1;
+   return GL_TRUE;
 }