nir/opt_access: check restrict before marking a variable as readonly

ACCESS_NON_WRITEABLE means that the memory is read-only, not the variable,
so we have to check for aliasing first.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6483>
This commit is contained in:
Rhys Perry 2020-12-01 14:34:48 +00:00 committed by Marge Bot
parent e646f6d30e
commit 2448d13e0f
1 changed files with 13 additions and 4 deletions

View File

@ -134,10 +134,19 @@ process_variable(struct access_state *state, nir_variable *var)
if (var->data.access & ACCESS_CAN_REORDER)
return false;
if (!(var->data.access & ACCESS_NON_WRITEABLE) &&
!_mesa_set_search(state->vars_written, var)) {
var->data.access |= ACCESS_NON_WRITEABLE;
return true;
if (!(var->data.access & ACCESS_NON_WRITEABLE)) {
if ((var->data.access & ACCESS_RESTRICT) &&
!_mesa_set_search(state->vars_written, var)) {
var->data.access |= ACCESS_NON_WRITEABLE;
return true;
}
bool is_buffer = var->data.mode == nir_var_mem_ssbo ||
glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_BUF;
if (is_buffer ? !state->buffers_written : !state->images_written) {
var->data.access |= ACCESS_NON_WRITEABLE;
return true;
}
}
return false;