diff options
author | Petri Latvala <[email protected]> | 2014-02-27 16:15:05 +0200 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2014-02-28 15:05:38 -0800 |
commit | 59989a4a92e638415d50e9acdd0685eb56eb17f3 (patch) | |
tree | 250e2bcb06a2a890e4406ef67d6b2a1519924b31 /src | |
parent | 7189fce237cc7f4bc76a85cca8bcf75756d9affc (diff) |
i965: Assert array index on access to vec4_visitor's arrays.
v2: vec4_visitor::pack_uniform_registers(): Use correct comparison in the
assert, this->uniforms is already adjusted. Compare the actual value used to
index uniform_size and uniform_vector_size instead.
Signed-off-by: Petri Latvala <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4.cpp | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index fcb7365c5d1..c30afaecda6 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -422,6 +422,7 @@ vec4_visitor::pack_uniform_registers() * push constants. */ for (int src = 0; src < uniforms; src++) { + assert(src < uniform_array_size); int size = this->uniform_vector_size[src]; if (!uniform_used[src]) { @@ -1404,6 +1405,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; stage_prog_data->param = diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index cc92a8acc89..88ee929e27c 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -664,6 +664,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; @@ -687,6 +688,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; @@ -717,6 +719,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. @@ -727,6 +730,7 @@ vec4_visitor::setup_builtin_uniform_values(ir_variable *ir) last_swiz = swiz; stage_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]++; } @@ -976,6 +980,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)) { @@ -3302,6 +3307,7 @@ vec4_visitor::move_uniform_array_access_to_pull_constants() pull_constant_loc[uniform] = stage_prog_data->nr_pull_params / 4; + assert(uniform < uniform_array_size); for (int j = 0; j < uniform_size[uniform] * 4; j++) { stage_prog_data->pull_param[stage_prog_data->nr_pull_params++] = values[j]; |