[Mesa-dev] [PATCH 2/2] i965: Assert array index on access to vec4_visitor's arrays.

Ian Romanick idr at freedesktop.org
Wed Feb 26 14:30:43 PST 2014


Did you piglit run this?  I applied it on current master, and about 
2,700 piglit tests assert.

On 12/30/2013 01:44 AM, Petri Latvala wrote:
> Signed-off-by: Petri Latvala <petri.latvala at intel.com>
> ---
>   src/mesa/drivers/dri/i965/brw_vec4.cpp         | 2 ++
>   src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 6 ++++++
>   2 files changed, 8 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
> index fb57707..4dc0482 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
> @@ -411,6 +411,7 @@ vec4_visitor::pack_uniform_registers()
>      /* Now, figure out a packing of the live uniform vectors into our
>       * push constants.
>       */
> +   assert(uniforms < uniform_array_size);

All of the tests that I looked at (about a dozen) hit this assertion.

>      for (int src = 0; src < uniforms; src++) {
>         int size = this->uniform_vector_size[src];
>
> @@ -1393,6 +1394,7 @@ vec4_visitor::setup_uniforms(int reg)
>       * matter what, or the GPU would hang.
>       */
>      if (brw->gen < 6 && this->uniforms == 0) {
> +      assert(this->uniforms < this->uniform_array_size);
>         this->uniform_vector_size[this->uniforms] = 1;
>
>         prog_data->param = reralloc(NULL, prog_data->param, const float *, 4);
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> index a93fdc5..8d4c557 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> @@ -662,6 +662,7 @@ vec4_visitor::setup_uniform_values(ir_variable *ir)
>                                  storage->type->matrix_columns);
>
>         for (unsigned s = 0; s < vector_count; s++) {
> +         assert(uniforms < uniform_array_size);
>            uniform_vector_size[uniforms] = storage->type->vector_elements;
>
>            int i;
> @@ -685,6 +686,7 @@ vec4_visitor::setup_uniform_clipplane_values()
>      gl_clip_plane *clip_planes = brw_select_clip_planes(ctx);
>
>      for (int i = 0; i < key->nr_userclip_plane_consts; ++i) {
> +      assert(this->uniforms < uniform_array_size);
>         this->uniform_vector_size[this->uniforms] = 4;
>         this->userplane[i] = dst_reg(UNIFORM, this->uniforms);
>         this->userplane[i].type = BRW_REGISTER_TYPE_F;
> @@ -715,6 +717,7 @@ vec4_visitor::setup_builtin_uniform_values(ir_variable *ir)
>   					    (gl_state_index *)slots[i].tokens);
>         float *values = &this->prog->Parameters->ParameterValues[index][0].f;
>
> +      assert(this->uniforms < uniform_array_size);
>         this->uniform_vector_size[this->uniforms] = 0;
>         /* Add each of the unique swizzled channels of the element.
>          * This will end up matching the size of the glsl_type of this field.
> @@ -725,6 +728,7 @@ vec4_visitor::setup_builtin_uniform_values(ir_variable *ir)
>   	 last_swiz = swiz;
>
>   	 prog_data->param[this->uniforms * 4 + j] = &values[swiz];
> +	 assert(this->uniforms < uniform_array_size);
>   	 if (swiz <= last_swiz)
>   	    this->uniform_vector_size[this->uniforms]++;
>         }
> @@ -983,6 +987,7 @@ vec4_visitor::visit(ir_variable *ir)
>         /* Track how big the whole uniform variable is, in case we need to put a
>          * copy of its data into pull constants for array access.
>          */
> +      assert(this->uniforms < uniform_array_size);
>         this->uniform_size[this->uniforms] = type_size(ir->type);
>
>         if (!strncmp(ir->name, "gl_", 3)) {
> @@ -3228,6 +3233,7 @@ vec4_visitor::move_uniform_array_access_to_pull_constants()
>
>   	    pull_constant_loc[uniform] = prog_data->nr_pull_params / 4;
>
> +	    assert(uniform < uniform_array_size);
>   	    for (int j = 0; j < uniform_size[uniform] * 4; j++) {
>   	       prog_data->pull_param[prog_data->nr_pull_params++]
>                     = values[j];
>



More information about the mesa-dev mailing list