nir: Add a new nir_var_mem_constant variable mode
authorJason Ekstrand <jason@jlekstrand.net>
Tue, 18 Aug 2020 19:02:21 +0000 (14:02 -0500)
committerMarge Bot <eric+marge@anholt.net>
Tue, 1 Sep 2020 20:50:03 +0000 (20:50 +0000)
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6379>

src/compiler/nir/nir.c
src/compiler/nir/nir.h
src/compiler/nir/nir_print.c
src/compiler/nir/nir_serialize.c
src/compiler/nir/nir_validate.c

index 79e4ae3002703a663e0afb78834030c9f377c245..e9e21e61e8ad12c49069253c341512c757115d5f 100644 (file)
@@ -115,6 +115,7 @@ nir_shader_add_variable(nir_shader *shader, nir_variable *var)
    case nir_var_mem_ssbo:
    case nir_var_mem_shared:
    case nir_var_system_value:
+   case nir_var_mem_constant:
       break;
 
    case nir_var_mem_global:
index ecd806523b3054e156c8ceb0aa886372460f5a9c..28f513691268d2c1a81b76b31a4f4b4fa65caacc 100644 (file)
@@ -121,7 +121,8 @@ typedef enum {
    nir_var_mem_shared      = (1 << 8),
    nir_var_mem_global      = (1 << 9),
    nir_var_mem_push_const  = (1 << 10), /* not actually used for variables */
-   nir_num_variable_modes  = 11,
+   nir_var_mem_constant    = (1 << 11),
+   nir_num_variable_modes  = 12,
    nir_var_all             = (1 << nir_num_variable_modes) - 1,
 } nir_variable_mode;
 MESA_DEFINE_CPP_ENUM_BITFIELD_OPERATORS(nir_variable_mode)
@@ -330,7 +331,7 @@ typedef struct nir_variable {
        *
        * \sa nir_variable_mode
        */
-      unsigned mode:11;
+      unsigned mode:12;
 
       /**
        * Is the variable read-only?
index 07d1cdc3c79c31dcd412ff688647bb6abdf4719f..e31de358172ca778466707e6635541389577f534 100644 (file)
@@ -465,6 +465,8 @@ get_variable_mode_str(nir_variable_mode mode, bool want_local_global_mode)
       return "shared";
    case nir_var_mem_global:
       return "global";
+   case nir_var_mem_constant:
+      return "constant";
    case nir_var_shader_temp:
       return want_local_global_mode ? "shader_temp" : "";
    case nir_var_function_temp:
index 1d0b696db878528c9fe72387a944af24535a6638..2a0e51807873e5cb96bfa6ecff578d10fec4a805 100644 (file)
@@ -637,9 +637,9 @@ union packed_instr {
       unsigned instr_type:4;
       unsigned deref_type:3;
       unsigned cast_type_same_as_last:1;
-      unsigned mode:10; /* deref_var redefines this */
+      unsigned mode:12; /* deref_var redefines this */
       unsigned packed_src_ssa_16bit:1; /* deref_var redefines this */
-      unsigned _pad:5;  /* deref_var redefines this */
+      unsigned _pad:3;  /* deref_var redefines this */
       unsigned dest:8;
    } deref;
    struct {
@@ -981,7 +981,7 @@ static void
 write_deref(write_ctx *ctx, const nir_deref_instr *deref)
 {
    assert(deref->deref_type < 8);
-   assert(deref->mode < (1 << 10));
+   assert(deref->mode < (1 << 12));
 
    union packed_instr header;
    header.u32 = 0;
index 32c13eb2d5ec45f90ebcf7d5278a9679eec73a9e..9d2dfbc820675d7f7385f69824e536674e294e84 100644 (file)
@@ -509,7 +509,8 @@ validate_deref_instr(nir_deref_instr *instr, validate_state *state)
          validate_assert(state, instr->mode == nir_var_mem_ubo ||
                                 instr->mode == nir_var_mem_ssbo ||
                                 instr->mode == nir_var_mem_shared ||
-                                instr->mode == nir_var_mem_global);
+                                instr->mode == nir_var_mem_global ||
+                                instr->mode == nir_var_mem_constant);
       }
    }
 }
@@ -1336,7 +1337,8 @@ nir_validate_shader(nir_shader *shader, const char *when)
       nir_var_mem_ubo |
       nir_var_system_value |
       nir_var_mem_ssbo |
-      nir_var_mem_shared;
+      nir_var_mem_shared |
+      nir_var_mem_constant;
 
    exec_list_validate(&shader->variables);
    nir_foreach_variable_in_shader(var, shader)