X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fcompiler%2Fnir%2Fnir_lower_atomics_to_ssbo.c;h=b9ba4e4b273a6a6ad994ff3837fe26af6887eb19;hb=18e464cfc05cdae59af8d00f214a6477a72b8ac7;hp=df6f959c4b5d1d5b011ebc3db5f5b63cb9bb91e7;hpb=10dc4ac4c5d6dbe3df1f2b75229804e7aa5f86f1;p=mesa.git diff --git a/src/compiler/nir/nir_lower_atomics_to_ssbo.c b/src/compiler/nir/nir_lower_atomics_to_ssbo.c index df6f959c4b5..b9ba4e4b273 100644 --- a/src/compiler/nir/nir_lower_atomics_to_ssbo.c +++ b/src/compiler/nir/nir_lower_atomics_to_ssbo.c @@ -32,7 +32,8 @@ #endif /* - * Remap atomic counters to SSBOs, starting from the passed in ssbo_offset. + * Remap atomic counters to SSBOs, starting from the shader's next SSBO slot + * (info.num_ssbos). */ static bool @@ -126,10 +127,16 @@ lower_instr(nir_intrinsic_instr *instr, unsigned ssbo_offset, nir_builder *b) break; } - if (new_instr->intrinsic == nir_intrinsic_load_ssbo || - new_instr->intrinsic == nir_intrinsic_store_ssbo) + if (new_instr->intrinsic == nir_intrinsic_load_ssbo) { nir_intrinsic_set_align(new_instr, 4, 0); + /* we could be replacing an intrinsic with fixed # of dest + * num_components with one that has variable number. So + * best to take this from the dest: + */ + new_instr->num_components = instr->dest.ssa.num_components; + } + nir_ssa_dest_init(&new_instr->instr, &new_instr->dest, instr->dest.ssa.num_components, instr->dest.ssa.bit_size, NULL); @@ -144,11 +151,6 @@ lower_instr(nir_intrinsic_instr *instr, unsigned ssbo_offset, nir_builder *b) nir_ssa_def_rewrite_uses(&instr->dest.ssa, nir_src_for_ssa(&new_instr->dest.ssa)); } - /* we could be replacing an intrinsic with fixed # of dest num_components - * with one that has variable number. So best to take this from the dest: - */ - new_instr->num_components = instr->dest.ssa.num_components; - return true; } @@ -161,8 +163,9 @@ is_atomic_uint(const struct glsl_type *type) } bool -nir_lower_atomics_to_ssbo(nir_shader *shader, unsigned ssbo_offset) +nir_lower_atomics_to_ssbo(nir_shader *shader) { + unsigned ssbo_offset = shader->info.num_ssbos; bool progress = false; nir_foreach_function(function, shader) { @@ -185,7 +188,7 @@ nir_lower_atomics_to_ssbo(nir_shader *shader, unsigned ssbo_offset) if (progress) { /* replace atomic_uint uniforms with ssbo's: */ unsigned replaced = 0; - nir_foreach_variable_safe(var, &shader->uniforms) { + nir_foreach_uniform_variable_safe(var, shader) { if (is_atomic_uint(var->type)) { exec_node_remove(&var->node);