From: Jason Ekstrand Date: Tue, 18 Aug 2020 19:02:21 +0000 (-0500) Subject: nir: Add a new nir_var_mem_constant variable mode X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e4f07f8bdc602bae665fd57bb69e293a69d89bef;p=mesa.git nir: Add a new nir_var_mem_constant variable mode Reviewed-by: Eric Anholt Reviewed-by: Jesse Natalie Reviewed-by: Karol Herbst Part-of: --- diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 79e4ae30027..e9e21e61e8a 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -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: diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index ecd806523b3..28f51369126 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -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? diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 07d1cdc3c79..e31de358172 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -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: diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c index 1d0b696db87..2a0e5180787 100644 --- a/src/compiler/nir/nir_serialize.c +++ b/src/compiler/nir/nir_serialize.c @@ -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; diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 32c13eb2d5e..9d2dfbc8206 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -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)