nir: Use var->data.mode instead of deref->mode in a few cases

We already have the variable so we know the mode exactly.  Just use that
instead of the deref mode.  If these paths ever have to handle variable
pointers (not likely since they're OpenGL-specific), we can fix them to
handle crazy deref modes then.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6332>
This commit is contained in:
Jason Ekstrand
2020-10-30 12:30:09 -05:00
committed by Marge Bot
parent 5664713d7b
commit bb5d5029b7
7 changed files with 12 additions and 11 deletions

View File

@@ -87,7 +87,7 @@ lower_impl(nir_builder *b, nir_instr *instr, bool bindless_only)
return false;
}
bool bindless = deref->mode != nir_var_uniform || var->data.bindless;
bool bindless = var->data.mode != nir_var_uniform || var->data.bindless;
if (bindless_only && !bindless)
return false;

View File

@@ -634,8 +634,8 @@ nir_lower_io_block(nir_block *block,
nir_ssa_def *offset;
nir_ssa_def *vertex_index = NULL;
unsigned component_offset = var->data.location_frac;
bool bindless_type_size = mode == nir_var_shader_in ||
mode == nir_var_shader_out ||
bool bindless_type_size = var->data.mode == nir_var_shader_in ||
var->data.mode == nir_var_shader_out ||
var->data.bindless;
if (nir_deref_instr_is_known_out_of_bounds(deref)) {

View File

@@ -314,11 +314,11 @@ nir_lower_io_to_scalar_early_instr(nir_builder *b, nir_instr *instr, void *data)
return false;
nir_deref_instr *deref = nir_src_as_deref(intr->src[0]);
nir_variable_mode mode = deref->mode;
if (!(mode & state->mask))
if (!(deref->mode & state->mask))
return false;
nir_variable *var = nir_deref_instr_get_variable(deref);
nir_variable_mode mode = var->data.mode;
/* TODO: add patch support */
if (var->data.patch)

View File

@@ -442,10 +442,10 @@ nir_lower_io_to_vector_impl(nir_function_impl *impl, nir_variable_mode modes)
const unsigned loc = get_slot(old_var);
const unsigned old_frac = old_var->data.location_frac;
nir_variable *new_var = old_deref->mode == nir_var_shader_in ?
nir_variable *new_var = old_var->data.mode == nir_var_shader_in ?
new_inputs[loc][old_frac] :
new_outputs[loc][old_frac];
bool flat = old_deref->mode == nir_var_shader_in ?
bool flat = old_var->data.mode == nir_var_shader_in ?
flat_inputs[loc] : flat_outputs[loc];
if (!new_var)
break;

View File

@@ -208,7 +208,7 @@ nir_opt_large_constants(nir_shader *shader,
*/
nir_deref_instr *deref = nir_instr_as_deref(instr);
if (deref->deref_type == nir_deref_type_var &&
deref->mode == nir_var_function_temp &&
deref->var->data.mode == nir_var_function_temp &&
nir_deref_instr_has_complex_use(deref))
var_infos[deref->var->index].is_constant = false;
continue;

View File

@@ -70,8 +70,9 @@ add_var_use_deref(nir_deref_instr *deref, struct set *live)
/* If it's not a local that never escapes the shader, then any access at
* all means we need to keep it alive.
*/
assert(deref->mode == deref->var->data.mode);
if (!(deref->mode & (nir_var_function_temp | nir_var_shader_temp | nir_var_mem_shared)) ||
if (!(deref->var->data.mode & (nir_var_function_temp |
nir_var_shader_temp |
nir_var_mem_shared)) ||
deref_used_for_not_store(deref))
_mesa_set_add(live, deref->var);
}

View File

@@ -189,7 +189,7 @@ static void scan_instruction(const struct nir_shader *nir, struct si_shader_info
nir_variable *var = deref ? nir_deref_instr_get_variable(deref) : NULL;
if (var) {
if (deref->mode != nir_var_uniform || var->data.bindless)
if (var->data.mode != nir_var_uniform || var->data.bindless)
info->uses_bindless_samplers = true;
}
} else if (instr->type == nir_instr_type_intrinsic) {