<div dir="ltr"><div>Reviewed-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>><br><br></div>Marek<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 19, 2018 at 8:32 AM, Timothy Arceri <span dir="ltr"><<a href="mailto:tarceri@itsqueeze.com" target="_blank">tarceri@itsqueeze.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">i965 and gallium handle the atomic buffer index differently. It was<br>
just by luck that the single piglit test for this was passing.<br>
<br>
For gallium we use the atomic binding so that we match the handling<br>
in st_bind_atomics().<br>
<br>
On radeonsi this fixes the CTS test:<br>
KHR-GL43.shader_storage_<wbr>buffer_object.advanced-write-<wbr>fragment<br>
<br>
It also fixes tressfx hair rendering in Tomb Raider.<br>
---<br>
src/compiler/nir/nir.h | 3 ++-<br>
src/compiler/nir/nir_lower_<wbr>atomics.c | 15 ++++++++++-----<br>
src/mesa/drivers/dri/i965/brw_<wbr>link.cpp | 2 +-<br>
src/mesa/state_tracker/st_<wbr>glsl_to_nir.cpp | 2 +-<br>
4 files changed, 14 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
index e7a8afcad1..06f8a1076f 100644<br>
--- a/src/compiler/nir/nir.h<br>
+++ b/src/compiler/nir/nir.h<br>
@@ -2716,7 +2716,8 @@ typedef struct nir_lower_bitmap_options {<br>
void nir_lower_bitmap(nir_shader *shader, const nir_lower_bitmap_options *options);<br>
<br>
bool nir_lower_atomics(nir_shader *shader,<br>
- const struct gl_shader_program *shader_program);<br>
+ const struct gl_shader_program *shader_program,<br>
+ bool use_binding_as_idx);<br>
bool nir_lower_atomics_to_ssbo(nir_<wbr>shader *shader, unsigned ssbo_offset);<br>
bool nir_lower_to_source_mods(nir_<wbr>shader *shader);<br>
<br>
diff --git a/src/compiler/nir/nir_lower_<wbr>atomics.c b/src/compiler/nir/nir_lower_<wbr>atomics.c<br>
index bdab4b8737..6b046bc426 100644<br>
--- a/src/compiler/nir/nir_lower_<wbr>atomics.c<br>
+++ b/src/compiler/nir/nir_lower_<wbr>atomics.c<br>
@@ -38,7 +38,7 @@<br>
static bool<br>
lower_instr(nir_intrinsic_<wbr>instr *instr,<br>
const struct gl_shader_program *shader_program,<br>
- nir_shader *shader)<br>
+ nir_shader *shader, bool use_binding_as_idx)<br>
{<br>
nir_intrinsic_op op;<br>
switch (instr->intrinsic) {<br>
@@ -98,9 +98,12 @@ lower_instr(nir_intrinsic_<wbr>instr *instr,<br>
void *mem_ctx = ralloc_parent(instr);<br>
unsigned uniform_loc = instr->variables[0]->var-><wbr>data.location;<br>
<br>
+ unsigned idx = use_binding_as_idx ?<br>
+ instr->variables[0]->var-><wbr>data.binding :<br>
+ shader_program->data-><wbr>UniformStorage[uniform_loc].<wbr>opaque[shader->info.stage].<wbr>index;<br>
+<br>
nir_intrinsic_instr *new_instr = nir_intrinsic_instr_create(<wbr>mem_ctx, op);<br>
- nir_intrinsic_set_base(new_<wbr>instr,<br>
- shader_program->data-><wbr>UniformStorage[uniform_loc].<wbr>opaque[shader->info.stage].<wbr>index);<br>
+ nir_intrinsic_set_base(new_<wbr>instr, idx);<br>
<br>
nir_load_const_instr *offset_const =<br>
nir_load_const_instr_create(<wbr>mem_ctx, 1, 32);<br>
@@ -174,7 +177,8 @@ lower_instr(nir_intrinsic_<wbr>instr *instr,<br>
<br>
bool<br>
nir_lower_atomics(nir_shader *shader,<br>
- const struct gl_shader_program *shader_program)<br>
+ const struct gl_shader_program *shader_program,<br>
+ bool use_binding_as_idx)<br>
{<br>
bool progress = false;<br>
<br>
@@ -184,7 +188,8 @@ nir_lower_atomics(nir_shader *shader,<br>
nir_foreach_instr_safe(instr, block) {<br>
if (instr->type == nir_instr_type_intrinsic)<br>
progress |= lower_instr(nir_instr_as_<wbr>intrinsic(instr),<br>
- shader_program, shader);<br>
+ shader_program, shader,<br>
+ use_binding_as_idx);<br>
}<br>
}<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_link.cpp b/src/mesa/drivers/dri/i965/<wbr>brw_link.cpp<br>
index b08b56a935..274a738cbb 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_link.cpp<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_link.cpp<br>
@@ -299,7 +299,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)<br>
brw_shader_gather_info(prog-><wbr>nir, prog);<br>
<br>
NIR_PASS_V(prog->nir, nir_lower_samplers, shProg);<br>
- NIR_PASS_V(prog->nir, nir_lower_atomics, shProg);<br>
+ NIR_PASS_V(prog->nir, nir_lower_atomics, shProg, false);<br>
NIR_PASS_V(prog->nir, nir_lower_atomics_to_ssbo,<br>
prog->nir->info.num_abos);<br>
<br>
diff --git a/src/mesa/state_tracker/st_<wbr>glsl_to_nir.cpp b/src/mesa/state_tracker/st_<wbr>glsl_to_nir.cpp<br>
index 6f3fa248f1..fb45cf2d5e 100644<br>
--- a/src/mesa/state_tracker/st_<wbr>glsl_to_nir.cpp<br>
+++ b/src/mesa/state_tracker/st_<wbr>glsl_to_nir.cpp<br>
@@ -428,7 +428,7 @@ st_glsl_to_nir_post_opts(<wbr>struct st_context *st, struct gl_program *prog,<br>
st_set_prog_affected_state_<wbr>flags(prog);<br>
<br>
NIR_PASS_V(nir, st_nir_lower_builtin);<br>
- NIR_PASS_V(nir, nir_lower_atomics, shader_program);<br>
+ NIR_PASS_V(nir, nir_lower_atomics, shader_program, true);<br>
<br>
if (st->ctx->_Shader->Flags & GLSL_DUMP) {<br>
_mesa_log("\n");<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.14.3<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>