nir: Add nir_var_mem_image
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4743>
This commit is contained in:

committed by
Marge Bot

parent
872750bb96
commit
de3705edb0
@@ -189,6 +189,7 @@ nir_shader_add_variable(nir_shader *shader, nir_variable *var)
|
||||
case nir_var_uniform:
|
||||
case nir_var_mem_ubo:
|
||||
case nir_var_mem_ssbo:
|
||||
case nir_var_mem_image:
|
||||
case nir_var_mem_shared:
|
||||
case nir_var_system_value:
|
||||
case nir_var_mem_push_const:
|
||||
|
@@ -140,6 +140,7 @@ typedef enum {
|
||||
nir_var_shader_call_data = (1 << 12),
|
||||
/** Ray hit attributes */
|
||||
nir_var_ray_hit_attrib = (1 << 13),
|
||||
nir_var_mem_image = (1 << 14),
|
||||
nir_var_read_only_modes = nir_var_shader_in | nir_var_uniform |
|
||||
nir_var_system_value | nir_var_mem_constant |
|
||||
nir_var_mem_ubo,
|
||||
@@ -147,7 +148,7 @@ typedef enum {
|
||||
nir_var_vec_indexable_modes = nir_var_mem_ubo | nir_var_mem_ssbo |
|
||||
nir_var_mem_shared | nir_var_mem_global |
|
||||
nir_var_mem_push_const,
|
||||
nir_num_variable_modes = 14,
|
||||
nir_num_variable_modes = 15,
|
||||
nir_var_all = (1 << nir_num_variable_modes) - 1,
|
||||
} nir_variable_mode;
|
||||
MESA_DEFINE_CPP_ENUM_BITFIELD_OPERATORS(nir_variable_mode)
|
||||
@@ -356,7 +357,7 @@ typedef struct nir_variable {
|
||||
*
|
||||
* \sa nir_variable_mode
|
||||
*/
|
||||
unsigned mode:14;
|
||||
unsigned mode:15;
|
||||
|
||||
/**
|
||||
* Is the variable read-only?
|
||||
|
@@ -603,6 +603,7 @@ nir_variable_mode_is_uniform(nir_variable_mode mode) {
|
||||
case nir_var_mem_ssbo:
|
||||
case nir_var_mem_shared:
|
||||
case nir_var_mem_global:
|
||||
case nir_var_mem_image:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@@ -834,7 +834,7 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
|
||||
shader->info.bit_sizes_float = 0;
|
||||
shader->info.bit_sizes_int = 0;
|
||||
|
||||
nir_foreach_uniform_variable(var, shader) {
|
||||
nir_foreach_variable_with_modes(var, shader, nir_var_mem_image | nir_var_uniform) {
|
||||
/* Bindless textures and images don't use non-bindless slots.
|
||||
* Interface blocks imply inputs, outputs, UBO, or SSBO, which can only
|
||||
* mean bindless.
|
||||
|
@@ -115,9 +115,11 @@ gather_intrinsic(struct access_state *state, nir_intrinsic_instr *instr)
|
||||
state->images_written |= write;
|
||||
}
|
||||
|
||||
if (var->data.mode == nir_var_uniform && read)
|
||||
if ((var->data.mode == nir_var_uniform ||
|
||||
var->data.mode == nir_var_mem_image) && read)
|
||||
_mesa_set_add(state->vars_read, var);
|
||||
if (var->data.mode == nir_var_uniform && write)
|
||||
if ((var->data.mode == nir_var_uniform ||
|
||||
var->data.mode == nir_var_mem_image) && write)
|
||||
_mesa_set_add(state->vars_written, var);
|
||||
break;
|
||||
|
||||
@@ -187,7 +189,8 @@ process_variable(struct access_state *state, nir_variable *var)
|
||||
{
|
||||
const struct glsl_type *type = glsl_without_array(var->type);
|
||||
if (var->data.mode != nir_var_mem_ssbo &&
|
||||
!(var->data.mode == nir_var_uniform && glsl_type_is_image(type)))
|
||||
!(var->data.mode == nir_var_uniform && glsl_type_is_image(type)) &&
|
||||
var->data.mode != nir_var_mem_image)
|
||||
return false;
|
||||
|
||||
/* Ignore variables we've already marked */
|
||||
@@ -343,7 +346,8 @@ nir_opt_access(nir_shader *shader, const nir_opt_access_options *options)
|
||||
|
||||
nir_foreach_variable_with_modes(var, shader, nir_var_uniform |
|
||||
nir_var_mem_ubo |
|
||||
nir_var_mem_ssbo)
|
||||
nir_var_mem_ssbo |
|
||||
nir_var_mem_image)
|
||||
var_progress |= process_variable(&state, var);
|
||||
|
||||
nir_foreach_function(func, shader) {
|
||||
|
@@ -104,6 +104,7 @@ block_check_for_allowed_instrs(nir_block *block, unsigned *count,
|
||||
switch (deref->modes) {
|
||||
case nir_var_shader_in:
|
||||
case nir_var_uniform:
|
||||
case nir_var_mem_image:
|
||||
/* Don't try to remove flow control around an indirect load
|
||||
* because that flow control may be trying to avoid invalid
|
||||
* loads.
|
||||
|
@@ -464,6 +464,8 @@ get_variable_mode_str(nir_variable_mode mode, bool want_local_global_mode)
|
||||
return "push_const";
|
||||
case nir_var_mem_constant:
|
||||
return "constant";
|
||||
case nir_var_mem_image:
|
||||
return "image";
|
||||
case nir_var_shader_temp:
|
||||
return want_local_global_mode ? "shader_temp" : "";
|
||||
case nir_var_function_temp:
|
||||
@@ -522,11 +524,12 @@ print_var_decl(nir_variable *var, print_state *state)
|
||||
fprintf(fp, "%s %s", glsl_get_type_name(var->type),
|
||||
get_var_name(var, state));
|
||||
|
||||
if (var->data.mode == nir_var_shader_in ||
|
||||
var->data.mode == nir_var_shader_out ||
|
||||
var->data.mode == nir_var_uniform ||
|
||||
var->data.mode == nir_var_mem_ubo ||
|
||||
var->data.mode == nir_var_mem_ssbo) {
|
||||
if (var->data.mode & (nir_var_shader_in |
|
||||
nir_var_shader_out |
|
||||
nir_var_uniform |
|
||||
nir_var_mem_ubo |
|
||||
nir_var_mem_ssbo |
|
||||
nir_var_mem_image)) {
|
||||
const char *loc = NULL;
|
||||
char buf[4];
|
||||
|
||||
|
@@ -627,9 +627,8 @@ union packed_instr {
|
||||
unsigned instr_type:4;
|
||||
unsigned deref_type:3;
|
||||
unsigned cast_type_same_as_last:1;
|
||||
unsigned modes:14; /* deref_var redefines this */
|
||||
unsigned modes:15; /* deref_var redefines this */
|
||||
unsigned packed_src_ssa_16bit:1; /* deref_var redefines this */
|
||||
unsigned _pad:1; /* deref_var redefines this */
|
||||
unsigned dest:8;
|
||||
} deref;
|
||||
struct {
|
||||
@@ -970,7 +969,7 @@ static void
|
||||
write_deref(write_ctx *ctx, const nir_deref_instr *deref)
|
||||
{
|
||||
assert(deref->deref_type < 8);
|
||||
assert(deref->modes < (1 << 14));
|
||||
assert(deref->modes < (1 << 15));
|
||||
|
||||
union packed_instr header;
|
||||
header.u32 = 0;
|
||||
|
@@ -1747,7 +1747,8 @@ nir_validate_shader(nir_shader *shader, const char *when)
|
||||
nir_var_mem_ssbo |
|
||||
nir_var_mem_shared |
|
||||
nir_var_mem_push_const |
|
||||
nir_var_mem_constant;
|
||||
nir_var_mem_constant |
|
||||
nir_var_mem_image;
|
||||
|
||||
if (gl_shader_stage_is_callable(shader->info.stage))
|
||||
valid_modes |= nir_var_shader_call_data;
|
||||
|
Reference in New Issue
Block a user