GLSL/HLSL: Disallow VariablePointers capability outright.
Cannot be supported, error out early.
diff --git a/reference/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.invalid.nofxc.asm.comp b/reference/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.nofxc.asm.comp
similarity index 100%
rename from reference/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.invalid.nofxc.asm.comp
rename to reference/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.nofxc.asm.comp
diff --git a/reference/shaders-no-opt/asm/comp/storage-buffer-basic.invalid.asm.comp b/reference/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp
similarity index 100%
rename from reference/shaders-no-opt/asm/comp/storage-buffer-basic.invalid.asm.comp
rename to reference/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp
diff --git a/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.invalid.nofxc.asm.comp b/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.nofxc.asm.comp
similarity index 95%
rename from shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.invalid.nofxc.asm.comp
rename to shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.nofxc.asm.comp
index edb1a05..db9a849 100644
--- a/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.invalid.nofxc.asm.comp
+++ b/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.nofxc.asm.comp
@@ -4,9 +4,9 @@
; Bound: 31
; Schema: 0
OpCapability Shader
- OpCapability VariablePointers
+ ;OpCapability VariablePointers
OpExtension "SPV_KHR_storage_buffer_storage_class"
- OpExtension "SPV_KHR_variable_pointers"
+ ;OpExtension "SPV_KHR_variable_pointers"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %22 "main" %gl_WorkGroupID
OpSource OpenCL_C 120
diff --git a/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.invalid.nofxc.asm.comp b/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp
similarity index 95%
copy from shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.invalid.nofxc.asm.comp
copy to shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp
index edb1a05..db9a849 100644
--- a/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.invalid.nofxc.asm.comp
+++ b/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp
@@ -4,9 +4,9 @@
; Bound: 31
; Schema: 0
OpCapability Shader
- OpCapability VariablePointers
+ ;OpCapability VariablePointers
OpExtension "SPV_KHR_storage_buffer_storage_class"
- OpExtension "SPV_KHR_variable_pointers"
+ ;OpExtension "SPV_KHR_variable_pointers"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %22 "main" %gl_WorkGroupID
OpSource OpenCL_C 120
diff --git a/shaders-no-opt/asm/comp/storage-buffer-basic.invalid.asm.comp b/shaders-no-opt/asm/comp/storage-buffer-basic.invalid.asm.comp
deleted file mode 100644
index edb1a05..0000000
--- a/shaders-no-opt/asm/comp/storage-buffer-basic.invalid.asm.comp
+++ /dev/null
@@ -1,57 +0,0 @@
-; SPIR-V
-; Version: 1.0
-; Generator: Codeplay; 0
-; Bound: 31
-; Schema: 0
- OpCapability Shader
- OpCapability VariablePointers
- OpExtension "SPV_KHR_storage_buffer_storage_class"
- OpExtension "SPV_KHR_variable_pointers"
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %22 "main" %gl_WorkGroupID
- OpSource OpenCL_C 120
- OpDecorate %15 SpecId 0
- ;OpDecorate %16 SpecId 1
- OpDecorate %17 SpecId 2
- OpDecorate %_runtimearr_float ArrayStride 4
- OpMemberDecorate %_struct_4 0 Offset 0
- OpDecorate %_struct_4 Block
- OpDecorate %gl_WorkGroupID BuiltIn WorkgroupId
- OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
- OpDecorate %20 DescriptorSet 0
- OpDecorate %20 Binding 0
- OpDecorate %21 DescriptorSet 0
- OpDecorate %21 Binding 1
- %float = OpTypeFloat 32
-%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float
-%_runtimearr_float = OpTypeRuntimeArray %float
- %_struct_4 = OpTypeStruct %_runtimearr_float
-%_ptr_StorageBuffer__struct_4 = OpTypePointer StorageBuffer %_struct_4
- %uint = OpTypeInt 32 0
- %void = OpTypeVoid
- %8 = OpTypeFunction %void
- %v3uint = OpTypeVector %uint 3
-%_ptr_Input_v3uint = OpTypePointer Input %v3uint
-%_ptr_Input_uint = OpTypePointer Input %uint
-%_ptr_Private_v3uint = OpTypePointer Private %v3uint
- %uint_0 = OpConstant %uint 0
-%gl_WorkGroupID = OpVariable %_ptr_Input_v3uint Input
- %15 = OpSpecConstant %uint 1
- %16 = OpConstant %uint 2
- %17 = OpSpecConstant %uint 3
-%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %15 %16 %17
- %19 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize
- %20 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer
- %21 = OpVariable %_ptr_StorageBuffer__struct_4 StorageBuffer
- %22 = OpFunction %void None %8
- %23 = OpLabel
- %24 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_0
- %25 = OpLoad %uint %24
- %26 = OpAccessChain %_ptr_StorageBuffer_float %21 %uint_0 %25
- %27 = OpLoad %float %26
- %28 = OpAccessChain %_ptr_StorageBuffer_float %20 %uint_0 %25
- %29 = OpLoad %float %28
- %30 = OpFAdd %float %27 %29
- OpStore %28 %30
- OpReturn
- OpFunctionEnd
diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp
index f1653e2..ecc5fb3 100644
--- a/spirv_glsl.cpp
+++ b/spirv_glsl.cpp
@@ -502,6 +502,10 @@
}
break;
+ case CapabilityVariablePointers:
+ case CapabilityVariablePointersStorageBuffer:
+ SPIRV_CROSS_THROW("VariablePointers capability is not supported in GLSL.");
+
default:
break;
}
diff --git a/spirv_hlsl.cpp b/spirv_hlsl.cpp
index 94210e7..f79e2be 100644
--- a/spirv_hlsl.cpp
+++ b/spirv_hlsl.cpp
@@ -5616,6 +5616,12 @@
if (hlsl_options.shader_model < 51)
SPIRV_CROSS_THROW(
"Shader model 5.1 or higher is required to use bindless resources or NonUniformResourceIndex.");
+ break;
+
+ case CapabilityVariablePointers:
+ case CapabilityVariablePointersStorageBuffer:
+ SPIRV_CROSS_THROW("VariablePointers capability is not supported in HLSL.");
+
default:
break;
}