SPIRV-Cross/reference/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk
Hans-Kristian Arntzen f1b411c9e8 GLSL: Deal with buffer_reference_align.
This is somewhat awkward to support, but the best effort we can do here
is to analyze various Load/Store opcodes and deduce the ideal overall
alignment based on this. This is not a 100% perfect solution, but should
be correct for any reasonable use case.

Also fix various nitpicks with BDA support while I'm at it.
2021-11-07 17:11:46 +01:00

36 lines
834 B
Plaintext

#version 450
#extension GL_EXT_buffer_reference : require
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
layout(buffer_reference) buffer RO;
layout(buffer_reference) buffer RW;
layout(buffer_reference) buffer WO;
layout(buffer_reference, buffer_reference_align = 16, std430) readonly buffer RO
{
vec4 v[];
};
layout(buffer_reference, buffer_reference_align = 16, std430) restrict buffer RW
{
vec4 v[];
};
layout(buffer_reference, buffer_reference_align = 16, std430) coherent writeonly buffer WO
{
vec4 v[];
};
layout(push_constant, std430) uniform Registers
{
RO ro;
RW rw;
WO wo;
} registers;
void main()
{
registers.rw.v[gl_GlobalInvocationID.x] = registers.ro.v[gl_GlobalInvocationID.x];
registers.wo.v[gl_GlobalInvocationID.x] = registers.ro.v[gl_GlobalInvocationID.x];
}