From: Rhys Perry Date: Thu, 21 May 2020 19:08:37 +0000 (+0100) Subject: spirv: set variables to restrict by default X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c344c083fc79938b25833ec3d473a28e6d8e8068;p=mesa.git spirv: set variables to restrict by default Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Reviewed-by: Jason Ekstrand Part-of: --- diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 7565590fbd8..2e351cc21ed 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -4171,6 +4171,7 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode, break; } + b->mem_model = w[2]; switch (w[2]) { case SpvMemoryModelSimple: case SpvMemoryModelGLSL450: diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h index 484ab853a82..059c94494a1 100644 --- a/src/compiler/spirv/vtn_private.h +++ b/src/compiler/spirv/vtn_private.h @@ -685,6 +685,9 @@ struct vtn_builder { /* when a physical memory model is choosen */ bool physical_ptrs; + + /* memory model specified by OpMemoryModel */ + unsigned mem_model; }; nir_ssa_def * diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index aad07d7556d..51b40801091 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1595,6 +1595,9 @@ apply_var_decoration(struct vtn_builder *b, case SpvDecorationRestrict: var_data->access |= ACCESS_RESTRICT; break; + case SpvDecorationAliased: + var_data->access &= ~ACCESS_RESTRICT; + break; case SpvDecorationVolatile: var_data->access |= ACCESS_VOLATILE; break; @@ -1635,7 +1638,6 @@ apply_var_decoration(struct vtn_builder *b, case SpvDecorationRowMajor: case SpvDecorationColMajor: case SpvDecorationMatrixStride: - case SpvDecorationAliased: case SpvDecorationUniform: case SpvDecorationUniformId: case SpvDecorationLinkageAttributes: @@ -2425,6 +2427,12 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, if (var_initializer) var->var->pointer_initializer = var_initializer; + if (var->mode == vtn_variable_mode_uniform || + var->mode == vtn_variable_mode_ssbo) { + /* SSBOs and images are assumed to not alias in the Simple, GLSL and Vulkan memory models */ + var->var->data.access |= b->mem_model != SpvMemoryModelOpenCL ? ACCESS_RESTRICT : 0; + } + vtn_foreach_decoration(b, val, var_decoration_cb, var); vtn_foreach_decoration(b, val, ptr_decoration_cb, val->pointer);