summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-06-01 12:24:31 -0700
committerJason Ekstrand <[email protected]>2015-06-01 12:25:58 -0700
commitd4cbf6a728a149e312f00c92f3d20b1da4df8117 (patch)
treee0110fa0faf0777c954c98c1112e8a33d8cceca4 /src
parent510b5c3bedced1fe4cda0f5d459c45b83914b622 (diff)
vk/compiler: Add an index_count to the bind map and check for OOB
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h5
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_nir.cpp16
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_visitor.cpp4
-rw-r--r--src/vulkan/compiler.cpp5
4 files changed, 23 insertions, 7 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index b6cdc82444c..5a35e48a481 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -360,7 +360,10 @@ struct brw_stage_prog_data {
} binding_table;
uint32_t *map_entries;
- uint32_t *bind_map[8]; /* MAX_SETS from vulkan/private.h */
+ struct {
+ uint32_t index_count;
+ uint32_t *index;
+ } bind_map[8]; /* MAX_SETS from vulkan/private.h */
GLuint nr_params; /**< number of float params/constants */
GLuint nr_pull_params;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 2623241a056..270131a73d1 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -1403,7 +1403,13 @@ fs_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
uint32_t set = shader->base.UniformBlocks[index].Set;
uint32_t binding = shader->base.UniformBlocks[index].Binding;
- surf_index = fs_reg(stage_prog_data->bind_map[set][binding]);
+ /* FIXME: We should probably assert here, but dota2 seems to hit
+ * it and we'd like to keep going.
+ */
+ if (binding >= stage_prog_data->bind_map[set].index_count)
+ binding = 0;
+
+ surf_index = fs_reg(stage_prog_data->bind_map[set].index[binding]);
} else {
assert(0 && "need more info from the ir for this.");
/* The block index is not a constant. Evaluate the index expression
@@ -1623,8 +1629,12 @@ void
fs_visitor::nir_emit_texture(nir_tex_instr *instr)
{
uint32_t set = instr->sampler_set;
- uint32_t index = instr->sampler_index;
- unsigned sampler = stage_prog_data->bind_map[set][index];
+ uint32_t binding = instr->sampler_index;
+
+ assert(binding < stage_prog_data->bind_map[set].index_count);
+ assert(stage_prog_data->bind_map[set].index[binding] < 1000);
+
+ unsigned sampler = stage_prog_data->bind_map[set].index[binding];
fs_reg sampler_reg(sampler);
/* FINISHME: We're failing to recompile our programs when the sampler is
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 07853c0d0d6..e1f47d4ec44 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -1207,7 +1207,7 @@ fs_visitor::visit(ir_expression *ir)
index = const_uniform_block->value.u[0];
set = shader->base.UniformBlocks[index].Set;
set_index = shader->base.UniformBlocks[index].Binding;
- binding = stage_prog_data->bind_map[set][set_index];
+ binding = stage_prog_data->bind_map[set].index[set_index];
surf_index = fs_reg(binding);
} else {
assert(0 && "need more info from the ir for this.");
@@ -2302,7 +2302,7 @@ fs_visitor::visit(ir_texture *ir)
assert(deref_var);
ir_variable *var = deref_var->var;
- sampler = stage_prog_data->bind_map[var->data.set][var->data.index];
+ sampler = stage_prog_data->bind_map[var->data.set].index[var->data.index];
ir_rvalue *nonconst_sampler_index =
_mesa_get_sampler_array_nonconst_index(ir->sampler);
diff --git a/src/vulkan/compiler.cpp b/src/vulkan/compiler.cpp
index 42c54fbe8d3..ead4117479c 100644
--- a/src/vulkan/compiler.cpp
+++ b/src/vulkan/compiler.cpp
@@ -80,9 +80,12 @@ set_binding_table_layout(struct brw_stage_prog_data *prog_data,
k = bias;
map = prog_data->map_entries;
for (uint32_t i = 0; i < layout->num_sets; i++) {
- prog_data->bind_map[i] = map;
+ prog_data->bind_map[i].index = map;
for (uint32_t j = 0; j < layout->set[i].layout->stage[stage].surface_count; j++)
*map++ = k++;
+
+ prog_data->bind_map[i].index_count =
+ layout->set[i].layout->stage[stage].surface_count;
}
return VK_SUCCESS;