diff --git a/reference/shaders-no-opt/asm/comp/empty-ubo-block.noeliminate.asm.comp b/reference/shaders-no-opt/asm/comp/empty-ubo-block.noeliminate.asm.comp new file mode 100644 index 00000000..98a2b706 --- /dev/null +++ b/reference/shaders-no-opt/asm/comp/empty-ubo-block.noeliminate.asm.comp @@ -0,0 +1,12 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 15, std140) uniform type_Primitive +{ + int empty_struct_member; +} Primitive; + +void main() +{ +} + diff --git a/shaders-no-opt/asm/comp/empty-ubo-block.noeliminate.asm.comp b/shaders-no-opt/asm/comp/empty-ubo-block.noeliminate.asm.comp new file mode 100644 index 00000000..d791c7c4 --- /dev/null +++ b/shaders-no-opt/asm/comp/empty-ubo-block.noeliminate.asm.comp @@ -0,0 +1,21 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 460 + OpName %main "main" + OpName %type_Primitive "type_Primitive" + OpName %Primitive "Primitive" + OpDecorate %type_Primitive Block + OpDecorate %Primitive DescriptorSet 0 + OpDecorate %Primitive Binding 15 + %void = OpTypeVoid + %3 = OpTypeFunction %void +%type_Primitive = OpTypeStruct +%_ptr_Uniform_type_Primitive = OpTypePointer Uniform %type_Primitive + %Primitive = OpVariable %_ptr_Uniform_type_Primitive Uniform + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 56639f0c..83434e5a 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -2465,6 +2465,10 @@ void CompilerGLSL::emit_buffer_block_native(const SPIRVariable &var) i++; } + // Don't declare empty blocks in GLSL, this is not allowed. + if (type_is_empty(type) && !backend.supports_empty_struct) + statement("int empty_struct_member;"); + // var.self can be used as a backup name for the block name, // so we need to make sure we don't disturb the name here on a recompile. // It will need to be reset if we have to recompile.