nir: Drop the ssbo_offset to atomic lowering.
authorEric Anholt <eric@anholt.net>
Fri, 20 Dec 2019 21:52:06 +0000 (13:52 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 21 Jan 2020 18:06:23 +0000 (10:06 -0800)
The arguments passed in were:
- prog->info.num_ssbos
- prog->nir->info.num_ssbos
- arbitrary values for standalone compilers

The num_ssbos should match between the prog's info and prog->nir's info
until this lowering happens.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3240>

src/compiler/nir/nir.h
src/compiler/nir/nir_lower_atomics_to_ssbo.c
src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
src/gallium/drivers/lima/standalone/lima_compiler_cmdline.c
src/mesa/drivers/dri/i965/brw_link.cpp
src/mesa/state_tracker/st_glsl_to_nir.cpp

index 0ac3f45cceca00d1bb4b60ad04b3be1741b01fba..6f72e43cf60f490d6ebd6506c7285c47d49b9bc7 100644 (file)
@@ -4100,7 +4100,7 @@ typedef struct nir_lower_bitmap_options {
 
 void nir_lower_bitmap(nir_shader *shader, const nir_lower_bitmap_options *options);
 
-bool nir_lower_atomics_to_ssbo(nir_shader *shader, unsigned ssbo_offset);
+bool nir_lower_atomics_to_ssbo(nir_shader *shader);
 
 typedef enum  {
    nir_lower_int_source_mods = 1 << 0,
index df6f959c4b5d1d5b011ebc3db5f5b63cb9bb91e7..a72c20e54910ef4c8e469abc30b7a189a2049bde 100644 (file)
@@ -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
@@ -161,8 +162,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) {
index 271ee23a9c20480ad91cc4999793556fd8b0dd1d..aa680a3aae6d57850211ee2ec7d3c231c5230c7e 100644 (file)
@@ -142,7 +142,7 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
        NIR_PASS_V(nir, nir_lower_var_copies);
        nir_print_shader(nir, stdout);
        NIR_PASS_V(nir, gl_nir_lower_atomics, prog, true);
-       NIR_PASS_V(nir, nir_lower_atomics_to_ssbo, 8);
+       NIR_PASS_V(nir, nir_lower_atomics_to_ssbo);
        nir_print_shader(nir, stdout);
 
        switch (stage) {
index c040d6a0657803f2166b307ed90e27538f5f48bf..e43dc2dc303bf9b2511bc1ed5d88b01e08b38c23 100644 (file)
@@ -135,7 +135,7 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
    NIR_PASS_V(nir, nir_lower_var_copies);
    nir_print_shader(nir, stdout);
    NIR_PASS_V(nir, gl_nir_lower_atomics, prog, true);
-   NIR_PASS_V(nir, nir_lower_atomics_to_ssbo, 8);
+   NIR_PASS_V(nir, nir_lower_atomics_to_ssbo);
    nir_print_shader(nir, stdout);
 
    switch (stage) {
index c439fcbc93088d7027e329ce70362cacd838c4cc..67e4a36103fb5aada477b514228cfe24b70bd030 100644 (file)
@@ -332,8 +332,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
       brw_shader_gather_info(prog->nir, prog);
 
       NIR_PASS_V(prog->nir, gl_nir_lower_atomics, shProg, false);
-      NIR_PASS_V(prog->nir, nir_lower_atomics_to_ssbo,
-                 prog->nir->info.num_ssbos);
+      NIR_PASS_V(prog->nir, nir_lower_atomics_to_ssbo);
 
       nir_sweep(prog->nir);
 
index fadd1b4ba81ee2a639ce12002dd2ab99b63b6663..35464c982a6b0835f077b43c3a8b0d2159cd4c34 100644 (file)
@@ -504,7 +504,7 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog,
    nir_remove_dead_variables(nir, mask);
 
    if (!st->has_hw_atomics)
-      NIR_PASS_V(nir, nir_lower_atomics_to_ssbo, prog->info.num_ssbos);
+      NIR_PASS_V(nir, nir_lower_atomics_to_ssbo);
 
    st_finalize_nir_before_variants(nir);