diff options
author | Marek Olšák <[email protected]> | 2017-05-17 00:26:06 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-05-18 22:15:02 +0200 |
commit | 767868ff6d2842e1ac93ba086c1c30a8c8a68e24 (patch) | |
tree | 717142e3a3e207e42f1e8b4f8ff74ed5d0153e0e /src | |
parent | 1468e29e0285e8878c6112f810fae5ab87c426e9 (diff) |
glsl_to_tgsi: declare all SSBOs and atomics when indirect indexing is used
Only the first array element was declared, so tgsi_shader_info::
shader_buffers_declared didn't match what the shader was using.
Reviewed-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 9620ef760f3..76cd4dc3a5e 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -420,7 +420,6 @@ public: uint32_t samplers_used; glsl_base_type sampler_types[PIPE_MAX_SAMPLERS]; int sampler_targets[PIPE_MAX_SAMPLERS]; /**< One of TGSI_TEXTURE_* */ - int buffers_used; int images_used; int image_targets[PIPE_MAX_SHADER_IMAGES]; unsigned image_formats[PIPE_MAX_SHADER_IMAGES]; @@ -4543,7 +4542,6 @@ glsl_to_tgsi_visitor::glsl_to_tgsi_visitor() num_immediates = 0; num_address_regs = 0; samplers_used = 0; - buffers_used = 0; images_used = 0; indirect_addr_consts = false; wpos_transform_const = -1; @@ -4581,7 +4579,6 @@ static void count_resources(glsl_to_tgsi_visitor *v, gl_program *prog) { v->samplers_used = 0; - v->buffers_used = 0; v->images_used = 0; foreach_in_list(glsl_to_tgsi_instruction, inst, &v->instructions) { @@ -4607,12 +4604,9 @@ count_resources(glsl_to_tgsi_visitor *v, gl_program *prog) if (inst->resource.file != PROGRAM_UNDEFINED && ( is_resource_instruction(inst->op) || inst->op == TGSI_OPCODE_STORE)) { - if (inst->resource.file == PROGRAM_BUFFER) { - v->buffers_used |= 1 << inst->resource.index; - } else if (inst->resource.file == PROGRAM_MEMORY) { + if (inst->resource.file == PROGRAM_MEMORY) { v->use_shared_memory = true; - } else { - assert(inst->resource.file == PROGRAM_IMAGE); + } else if (inst->resource.file == PROGRAM_IMAGE) { for (int i = 0; i < inst->sampler_array_size; i++) { unsigned idx = inst->sampler_base + i; v->images_used |= 1 << idx; @@ -6580,16 +6574,20 @@ st_translate_program( } } - for (i = 0; i < frag_const->MaxAtomicBuffers; i++) { - if (program->buffers_used & (1 << i)) { - t->buffers[i] = ureg_DECL_buffer(ureg, i, true); + /* Declare atomic and shader storage buffers. */ + { + struct gl_program *prog = program->prog; + + for (i = 0; i < prog->info.num_abos; i++) { + unsigned index = prog->sh.AtomicBuffers[i]->Binding; + assert(index < frag_const->MaxAtomicBuffers); + t->buffers[index] = ureg_DECL_buffer(ureg, index, true); } - } - for (; i < frag_const->MaxAtomicBuffers + frag_const->MaxShaderStorageBlocks; - i++) { - if (program->buffers_used & (1 << i)) { - t->buffers[i] = ureg_DECL_buffer(ureg, i, false); + assert(prog->info.num_ssbos <= frag_const->MaxShaderStorageBlocks); + for (i = 0; i < prog->info.num_ssbos; i++) { + unsigned index = frag_const->MaxAtomicBuffers + i; + t->buffers[index] = ureg_DECL_buffer(ureg, index, false); } } |