spirv: Use nir_var_mem_constant for UniformConstant data in CL
authorJason Ekstrand <jason@jlekstrand.net>
Tue, 18 Aug 2020 20:30:26 +0000 (15:30 -0500)
committerMarge Bot <eric+marge@anholt.net>
Tue, 1 Sep 2020 20:50:04 +0000 (20:50 +0000)
For now, we leave the constant_as_global option intact and get rid of
the UBO path which no one upstream is using today.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6379>

src/compiler/spirv/nir_spirv.h
src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_private.h
src/compiler/spirv/vtn_variables.c

index 3cbd0269ffeb462ccfe60c68aeb0f45e976d02a4..dd7b5b36996eea3099861d638d1a34edd891e7f3 100644 (file)
@@ -78,6 +78,7 @@ struct spirv_to_nir_options {
    nir_address_format shared_addr_format;
    nir_address_format global_addr_format;
    nir_address_format temp_addr_format;
+   nir_address_format constant_addr_format;
 
    /* Whether UniformConstant memory should be treated as normal global memory.
     * This is usefull for CL 2.0 implementations with fine grain system SVM
index 3a886ce6556a1996780176b3630f0433a8059680..b9f1fae0115327262b1515b09148b0f99d59d526 100644 (file)
@@ -4482,8 +4482,8 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
          assert(nir_address_format_bit_size(b->options->shared_addr_format) == 32);
          assert(nir_address_format_num_components(b->options->shared_addr_format) == 1);
          if (!b->options->constant_as_global) {
-            assert(nir_address_format_bit_size(b->options->ubo_addr_format) == 32);
-            assert(nir_address_format_num_components(b->options->ubo_addr_format) == 1);
+            assert(nir_address_format_bit_size(b->options->constant_addr_format) == 32);
+            assert(nir_address_format_num_components(b->options->constant_addr_format) == 1);
          }
          break;
       case SpvAddressingModelPhysical64:
@@ -4496,8 +4496,8 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
          assert(nir_address_format_bit_size(b->options->shared_addr_format) == 64);
          assert(nir_address_format_num_components(b->options->shared_addr_format) == 1);
          if (!b->options->constant_as_global) {
-            assert(nir_address_format_bit_size(b->options->ubo_addr_format) == 64);
-            assert(nir_address_format_num_components(b->options->ubo_addr_format) == 1);
+            assert(nir_address_format_bit_size(b->options->constant_addr_format) == 64);
+            assert(nir_address_format_num_components(b->options->constant_addr_format) == 1);
          }
          break;
       case SpvAddressingModelLogical:
index c67d75a6fdd45d4b80d95bbf99e9fe870f2aacdf..300fb017257c4d203aff98b1eaffecf70706e2b0 100644 (file)
@@ -484,6 +484,7 @@ enum vtn_variable_mode {
    vtn_variable_mode_push_constant,
    vtn_variable_mode_workgroup,
    vtn_variable_mode_cross_workgroup,
+   vtn_variable_mode_constant,
    vtn_variable_mode_input,
    vtn_variable_mode_output,
    vtn_variable_mode_image,
index df80fca5dae5fc125be9ff7588f9b498920fdc4b..52c2837e9ebc0fa9d0ad95550edcd743756dca96 100644 (file)
@@ -1807,8 +1807,8 @@ vtn_storage_class_to_mode(struct vtn_builder *b,
             mode = vtn_variable_mode_cross_workgroup;
             nir_mode = nir_var_mem_global;
          } else {
-            mode = vtn_variable_mode_ubo;
-            nir_mode = nir_var_mem_ubo;
+            mode = vtn_variable_mode_constant;
+            nir_mode = nir_var_mem_constant;
          }
       } else {
          mode = vtn_variable_mode_uniform;
@@ -1885,6 +1885,9 @@ vtn_mode_to_address_format(struct vtn_builder *b, enum vtn_variable_mode mode)
    case vtn_variable_mode_cross_workgroup:
       return b->options->global_addr_format;
 
+   case vtn_variable_mode_constant:
+      return b->options->constant_addr_format;
+
    case vtn_variable_mode_function:
       if (b->physical_ptrs)
          return b->options->temp_addr_format;
@@ -2175,6 +2178,7 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
    case vtn_variable_mode_private:
    case vtn_variable_mode_uniform:
    case vtn_variable_mode_atomic_counter:
+   case vtn_variable_mode_constant:
       /* For these, we create the variable normally */
       var->var = rzalloc(b->shader, nir_variable);
       var->var->name = ralloc_strdup(var->var, val->name);