From 1dd99a15a4e0ffeabe0d50cbb402045e8e34d875 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolai=20H=C3=A4hnle?= Date: Thu, 13 Oct 2016 12:36:42 +0200 Subject: [PATCH] st/glsl_to_tgsi: fix atomic counter addressing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When more than one atomic counter buffer is in use, UniformStorage[n].opaque is set up to contain indices that are contiguous across all used buffers. This appears to be used by i965 via NIR, but for TGSI we do not treat atomic counter buffers as opaque, so using the data in the opaque array is incorrect. Fixes GL45-CTS.compute_shader.resource-atomic-counter. Cc: mesa-stable@lists.freedesktop.org Reviewed-by: Marek Olšák --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index a7ea19f..682c034 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -552,7 +552,8 @@ public: unsigned *array_size, unsigned *base, unsigned *index, - st_src_reg *reladdr); + st_src_reg *reladdr, + bool opaque); void calc_deref_offsets(ir_dereference *head, ir_dereference *tail, unsigned *array_elements, @@ -3254,7 +3255,7 @@ glsl_to_tgsi_visitor::visit_atomic_counter_intrinsic(ir_call *ir) st_src_reg offset; unsigned array_size = 0, base = 0, index = 0; - get_deref_offsets(deref, &array_size, &base, &index, &offset); + get_deref_offsets(deref, &array_size, &base, &index, &offset, false); if (offset.file != PROGRAM_UNDEFINED) { emit_asm(ir, TGSI_OPCODE_MUL, st_dst_reg(offset), @@ -3585,7 +3586,7 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir) st_src_reg image(PROGRAM_IMAGE, 0, GLSL_TYPE_UINT); get_deref_offsets(img, &sampler_array_size, &sampler_base, - (unsigned int *)&image.index, &reladdr); + (unsigned int *)&image.index, &reladdr, true); if (reladdr.file != PROGRAM_UNDEFINED) { image.reladdr = ralloc(mem_ctx, st_src_reg); *image.reladdr = reladdr; @@ -3967,7 +3968,8 @@ glsl_to_tgsi_visitor::get_deref_offsets(ir_dereference *ir, unsigned *array_size, unsigned *base, unsigned *index, - st_src_reg *reladdr) + st_src_reg *reladdr, + bool opaque) { GLuint shader = _mesa_program_enum_to_shader_stage(this->prog->Target); unsigned location = 0; @@ -3992,7 +3994,8 @@ glsl_to_tgsi_visitor::get_deref_offsets(ir_dereference *ir, *array_size = 1; } - if (location != 0xffffffff) { + if (opaque) { + assert(location != 0xffffffff); *base += this->shader_program->UniformStorage[location].opaque[shader].index; *index += this->shader_program->UniformStorage[location].opaque[shader].index; } @@ -4246,7 +4249,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir) } get_deref_offsets(ir->sampler, &sampler_array_size, &sampler_base, - &sampler_index, &reladdr); + &sampler_index, &reladdr, true); if (reladdr.file != PROGRAM_UNDEFINED) emit_arl(ir, sampler_reladdr, reladdr); -- 2.7.4