From 12131096fa421952fd198b1edb5bf5865803b8eb Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Thu, 21 Mar 2019 22:58:30 -0700 Subject: [PATCH] spirv: Restrict use of descriptor intrinsics to Vulkan In ARB_gl_spirv we'll be able to use variables for uniform buffers, so don't use the descriptor intrinsics to lower the block access. Reviewed-by: Jason Ekstrand --- src/compiler/spirv/vtn_variables.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index 1a9ca0745fa..a7d74a0cf46 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -100,6 +100,8 @@ static nir_ssa_def * vtn_variable_resource_index(struct vtn_builder *b, struct vtn_variable *var, nir_ssa_def *desc_array_index) { + vtn_assert(b->options->environment == NIR_SPIRV_VULKAN); + if (!desc_array_index) { vtn_assert(glsl_type_is_struct_or_ifc(var->type->type)); desc_array_index = nir_imm_int(&b->nb, 0); @@ -134,6 +136,8 @@ static nir_ssa_def * vtn_resource_reindex(struct vtn_builder *b, enum vtn_variable_mode mode, nir_ssa_def *base_index, nir_ssa_def *offset_index) { + vtn_assert(b->options->environment == NIR_SPIRV_VULKAN); + nir_intrinsic_instr *instr = nir_intrinsic_instr_create(b->nb.shader, nir_intrinsic_vulkan_resource_reindex); @@ -161,6 +165,8 @@ static nir_ssa_def * vtn_descriptor_load(struct vtn_builder *b, enum vtn_variable_mode mode, nir_ssa_def *desc_index) { + vtn_assert(b->options->environment == NIR_SPIRV_VULKAN); + nir_intrinsic_instr *desc_load = nir_intrinsic_instr_create(b->nb.shader, nir_intrinsic_load_vulkan_descriptor); @@ -196,7 +202,8 @@ vtn_nir_deref_pointer_dereference(struct vtn_builder *b, nir_deref_instr *tail; if (base->deref) { tail = base->deref; - } else if (vtn_pointer_is_external_block(b, base)) { + } else if (b->options->environment == NIR_SPIRV_VULKAN && + vtn_pointer_is_external_block(b, base)) { nir_ssa_def *block_index = base->block_index; /* We dereferencing an external block pointer. Correctness of this -- 2.30.2