nir: Add new option to lower invocation ID from invocation index.
authorTimur Kristóf <timur.kristof@gmail.com>
Thu, 28 Oct 2021 14:26:37 +0000 (16:26 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 16 Nov 2021 07:46:55 +0000 (07:46 +0000)
Add this as an option to nir_lower_compute_system_values_options
instead of just relying on the shader's options.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13466>

src/compiler/nir/nir.h
src/compiler/nir/nir_lower_system_values.c

index 4e83281..5806049 100644 (file)
@@ -5067,6 +5067,7 @@ typedef struct nir_lower_compute_system_values_options {
    bool has_base_workgroup_id:1;
    bool shuffle_local_ids_for_quad_derivatives:1;
    bool lower_local_invocation_index:1;
+   bool lower_cs_local_id_from_index:1;
 } nir_lower_compute_system_values_options;
 
 bool nir_lower_compute_system_values(nir_shader *shader,
index 5a60b42..a78b5e6 100644 (file)
@@ -275,7 +275,8 @@ lower_compute_system_value_instr(nir_builder *b,
       /* If lower_cs_local_id_from_index is true, then we derive the local
        * index from the local id.
        */
-      if (b->shader->options->lower_cs_local_id_from_index) {
+      if (b->shader->options->lower_cs_local_id_from_index ||
+          (options && options->lower_cs_local_id_from_index)) {
          /* We lower gl_LocalInvocationID from gl_LocalInvocationIndex based
           * on this formula:
           *