diff --git a/reference/shaders/desktop-only/comp/enhanced-layouts.comp b/reference/shaders/desktop-only/comp/enhanced-layouts.comp new file mode 100644 index 0000000..d3ea41b --- /dev/null +++ b/reference/shaders/desktop-only/comp/enhanced-layouts.comp @@ -0,0 +1,14 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct Foo +{ + int a; + int b; + int c; +}; + +void main() +{ +} + diff --git a/shaders/desktop-only/comp/enhanced-layouts.comp b/shaders/desktop-only/comp/enhanced-layouts.comp new file mode 100644 index 0000000..46062ea --- /dev/null +++ b/shaders/desktop-only/comp/enhanced-layouts.comp @@ -0,0 +1,37 @@ +#version 450 + +struct Foo +{ + int a; + int b; + int c; +}; + +layout(std140, binding = 0) uniform UBO +{ + layout(offset = 4) int a; + layout(offset = 8) int b; + layout(offset = 16) Foo foo; + layout(offset = 48) int c[8]; +} ubo; + +layout(std140, binding = 1) buffer SSBO1 +{ + layout(offset = 4) int a; + layout(offset = 8) int b; + layout(offset = 16) Foo foo; + layout(offset = 48) int c[8]; +} ssbo1; + +layout(std430, binding = 2) buffer SSBO2 +{ + layout(offset = 4) int a; + layout(offset = 8) int b; + layout(offset = 16) Foo foo; + layout(offset = 48) int c[8]; +} ssbo2; + +void main() +{ +} + diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 45c1ffe..24321da 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -1114,6 +1114,7 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) attr.push_back("std140"); else if (ssbo_is_packing_standard(type, BufferPackingStd140EnhancedLayout)) { + attr.push_back("std140"); // Fallback time. We might be able to use the ARB_enhanced_layouts to deal with this difference, // however, we can only use layout(offset) on the block itself, not any substructs, so the substructs better be the appropriate layout. // Enhanced layouts seem to always work in Vulkan GLSL, so no need for extensions there.