Merge pull request #995 from KhronosGroup/fix-980
GLSL: Support std430 in UBOs with scalar layout.
This commit is contained in:
commit
d2134bbb71
@ -0,0 +1,24 @@
|
||||
#version 450
|
||||
#extension GL_EXT_scalar_block_layout : require
|
||||
|
||||
layout(set = 0, binding = 0, std430) uniform UBO
|
||||
{
|
||||
float a[1024];
|
||||
vec3 b[2];
|
||||
} _17;
|
||||
|
||||
layout(set = 0, binding = 1, std430) uniform UBOEnhancedLayout
|
||||
{
|
||||
layout(offset = 0) float c[1024];
|
||||
layout(offset = 4096) vec3 d[2];
|
||||
layout(offset = 10000) float e;
|
||||
} _30;
|
||||
|
||||
layout(location = 0) out float FragColor;
|
||||
layout(location = 0) flat in int vIndex;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = (_17.a[vIndex] + _30.c[vIndex]) + _30.e;
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
#version 450
|
||||
#extension GL_EXT_scalar_block_layout : require
|
||||
|
||||
layout(set = 0, binding = 0, std430) uniform UBO
|
||||
{
|
||||
float a[1024];
|
||||
vec3 b[2];
|
||||
} _17;
|
||||
|
||||
layout(set = 0, binding = 1, std430) uniform UBOEnhancedLayout
|
||||
{
|
||||
layout(offset = 0) float c[1024];
|
||||
layout(offset = 4096) vec3 d[2];
|
||||
layout(offset = 10000) float e;
|
||||
} _30;
|
||||
|
||||
layout(location = 0) out float FragColor;
|
||||
layout(location = 0) flat in int vIndex;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = (_17.a[vIndex] + _30.c[vIndex]) + _30.e;
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
#version 450
|
||||
#extension GL_EXT_scalar_block_layout : require
|
||||
|
||||
layout(std430, binding = 0) uniform UBO
|
||||
{
|
||||
float a[1024];
|
||||
vec3 b[2];
|
||||
};
|
||||
|
||||
layout(std430, binding = 1) uniform UBOEnhancedLayout
|
||||
{
|
||||
float c[1024];
|
||||
vec3 d[2];
|
||||
layout(offset = 10000) float e;
|
||||
};
|
||||
|
||||
layout(location = 0) flat in int vIndex;
|
||||
layout(location = 0) out float FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = a[vIndex] + c[vIndex] + e;
|
||||
}
|
@ -1519,9 +1519,9 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var)
|
||||
return res;
|
||||
}
|
||||
|
||||
string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, bool check_std430)
|
||||
string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, bool support_std430_without_scalar_layout)
|
||||
{
|
||||
if (check_std430 && buffer_is_packing_standard(type, BufferPackingStd430))
|
||||
if (support_std430_without_scalar_layout && buffer_is_packing_standard(type, BufferPackingStd430))
|
||||
return "std430";
|
||||
else if (buffer_is_packing_standard(type, BufferPackingStd140))
|
||||
return "std140";
|
||||
@ -1530,7 +1530,8 @@ string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, bool check
|
||||
require_extension_internal("GL_EXT_scalar_block_layout");
|
||||
return "scalar";
|
||||
}
|
||||
else if (check_std430 && buffer_is_packing_standard(type, BufferPackingStd430EnhancedLayout))
|
||||
else if (support_std430_without_scalar_layout &&
|
||||
buffer_is_packing_standard(type, BufferPackingStd430EnhancedLayout))
|
||||
{
|
||||
if (options.es && !options.vulkan_semantics)
|
||||
SPIRV_CROSS_THROW("Push constant block cannot be expressed as neither std430 nor std140. ES-targets do "
|
||||
@ -1561,6 +1562,21 @@ string CompilerGLSL::buffer_to_packing_standard(const SPIRType &type, bool check
|
||||
require_extension_internal("GL_EXT_scalar_block_layout");
|
||||
return "scalar";
|
||||
}
|
||||
else if (!support_std430_without_scalar_layout && options.vulkan_semantics &&
|
||||
buffer_is_packing_standard(type, BufferPackingStd430))
|
||||
{
|
||||
// UBOs can support std430 with GL_EXT_scalar_block_layout.
|
||||
require_extension_internal("GL_EXT_scalar_block_layout");
|
||||
return "std430";
|
||||
}
|
||||
else if (!support_std430_without_scalar_layout && options.vulkan_semantics &&
|
||||
buffer_is_packing_standard(type, BufferPackingStd430EnhancedLayout))
|
||||
{
|
||||
// UBOs can support std430 with GL_EXT_scalar_block_layout.
|
||||
set_extended_decoration(type.self, SPIRVCrossDecorationPacked);
|
||||
require_extension_internal("GL_EXT_scalar_block_layout");
|
||||
return "std430";
|
||||
}
|
||||
else
|
||||
{
|
||||
SPIRV_CROSS_THROW("Buffer block cannot be expressed as any of std430, std140, scalar, even with enhanced "
|
||||
|
@ -525,7 +525,7 @@ protected:
|
||||
|
||||
bool buffer_is_packing_standard(const SPIRType &type, BufferPackingStandard packing, uint32_t start_offset = 0,
|
||||
uint32_t end_offset = ~(0u));
|
||||
std::string buffer_to_packing_standard(const SPIRType &type, bool enable_std430);
|
||||
std::string buffer_to_packing_standard(const SPIRType &type, bool support_std430_without_scalar_layout);
|
||||
|
||||
uint32_t type_to_packed_base_size(const SPIRType &type, BufferPackingStandard packing);
|
||||
uint32_t type_to_packed_alignment(const SPIRType &type, const Bitset &flags, BufferPackingStandard packing);
|
||||
|
Loading…
Reference in New Issue
Block a user