diff options
author | Kenneth Graunke <[email protected]> | 2014-09-11 22:07:40 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2014-09-12 16:51:52 -0700 |
commit | 0eeec2871dadf3810143efa9f91495165749be02 (patch) | |
tree | ff4edc7918424c829bd8217c5a957f33f88bc9a9 | |
parent | 8f1ccf35778b8715a2611ec83c35cd87c87d15f6 (diff) |
i965: Skip allocating UNIFORM file storage for uniforms of size 0.
Samplers take up zero slots and therefore don't exist in the params
array, nor are they included in stage_prog_data->nr_params. There's no
need to store their size in param_size, as it's only used for dealing
with arrays of "real" uniforms (ones uploaded as shader constants).
We run into all kinds of problems trying to refer to the uniform storage
for variables that don't have uniform storage. For one, we may use some
other variable's index, or access out of bounds in arrays. In the FS
backend, our extra 2 * MaxSamplerImageUnits params for texture rectangle
rescaling paper over a lot of problems. In the VS backend, we claim
samplers take up a slot, which also papers over problems.
Instead, just skip allocating storage for variables that don't have any.
Signed-off-by: Kenneth Graunke <[email protected]>
Cc: [email protected]
Reviewed-by: Ian Romanick <[email protected]>
Tested-by: Ian Romanick <[email protected]>
(cherry picked from commit 2408f166db1d81f2e9cc86b3f413ddba5ba537fa)
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 602ec1c43f2..0ed861da1aa 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -109,10 +109,10 @@ fs_visitor::visit(ir_variable *ir) * ir_binop_ubo_load expressions and not ir_dereference_variable for UBO * variables, so no need for them to be in variable_ht. * - * Atomic counters take no uniform storage, no need to do - * anything here. + * Some uniforms, such as samplers and atomic counters, have no actual + * storage, so we should ignore them. */ - if (ir->is_in_uniform_block() || ir->type->contains_atomic()) + if (ir->is_in_uniform_block() || type_size(ir->type) == 0) return; if (dispatch_width == 16) { diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index bb000509dc8..fe8a0dfba46 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -1023,10 +1023,10 @@ vec4_visitor::visit(ir_variable *ir) * ir_binop_ubo_load expressions and not ir_dereference_variable for UBO * variables, so no need for them to be in variable_ht. * - * Atomic counters take no uniform storage, no need to do - * anything here. + * Some uniforms, such as samplers and atomic counters, have no actual + * storage, so we should ignore them. */ - if (ir->is_in_uniform_block() || ir->type->contains_atomic()) + if (ir->is_in_uniform_block() || type_size(ir->type) == 0) return; /* Track how big the whole uniform variable is, in case we need to put a |