i965: Add asserts to check that we don't realloc ParameterValues.
authorEric Anholt <eric@anholt.net>
Wed, 21 Nov 2012 21:11:32 +0000 (13:11 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 28 Dec 2012 18:53:36 +0000 (10:53 -0800)
Things are even more restrictive than they used to be, so I've made
mistakes in this area.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_vec4.cpp
src/mesa/drivers/dri/i965/brw_vec4.h

index ede2979b9157dbdc7a9655e3ef319b9d4b0be2f9..fcde3dad1b3a6c69ba915760f0edc69080fb004e 100644 (file)
@@ -2454,6 +2454,7 @@ fs_visitor::setup_payload_gen6()
 bool
 fs_visitor::run()
 {
+   sanity_param_count = fp->Base.Parameters->NumParameters;
    uint32_t orig_nr_params = c->prog_data.nr_params;
 
    if (intel->gen >= 6)
@@ -2567,6 +2568,13 @@ fs_visitor::run()
       (void) orig_nr_params;
    }
 
+   /* If any state parameters were appended, then ParameterValues could have
+    * been realloced, in which case the driver uniform storage set up by
+    * _mesa_associate_uniform_storage() would point to freed memory.  Make
+    * sure that didn't happen.
+    */
+   assert(sanity_param_count == fp->Base.Parameters->NumParameters);
+
    return !failed;
 }
 
index ca242df3d7487e3d6bb27249fd6097f4be9aa9f5..75d6cf739b23b7fd30572766a0a75b622a44028c 100644 (file)
@@ -417,6 +417,7 @@ public:
 
    const struct gl_fragment_program *fp;
    struct brw_wm_compile *c;
+   unsigned int sanity_param_count;
 
    /* Delayed setup of c->prog_data.params[] due to realloc of
     * ParamValues[] during compile.
index 079bbab51ec629c47faa425fa006599a5a91c527..d5b7cb76f6f01465bece0ca28914dc0e02fbd750 100644 (file)
@@ -1239,6 +1239,8 @@ vec4_visitor::emit_shader_time_write(enum shader_time_shader_type type,
 bool
 vec4_visitor::run()
 {
+   sanity_param_count = vp->Base.Parameters->NumParameters;
+
    if (INTEL_DEBUG & DEBUG_SHADER_TIME)
       emit_shader_time_begin();
 
@@ -1317,6 +1319,13 @@ vec4_visitor::run()
          break;
    }
 
+   /* If any state parameters were appended, then ParameterValues could have
+    * been realloced, in which case the driver uniform storage set up by
+    * _mesa_associate_uniform_storage() would point to freed memory.  Make
+    * sure that didn't happen.
+    */
+   assert(sanity_param_count == vp->Base.Parameters->NumParameters);
+
    return !failed;
 }
 
index 359a5aed041f3b33d030570014d7347ca5126fc1..6aab4c0ffde62a81f44c0fec27b0b77cbdd990a8 100644 (file)
@@ -227,6 +227,7 @@ public:
    const struct gl_vertex_program *vp;
    struct brw_vs_compile *c;
    struct brw_vs_prog_data *prog_data;
+   unsigned int sanity_param_count;
 
    char *fail_msg;
    bool failed;