diff --git a/reference/shaders/comp/bake_gradient.comp b/reference/shaders/comp/bake_gradient.comp index 41facc8..7b0bb34 100644 --- a/reference/shaders/comp/bake_gradient.comp +++ b/reference/shaders/comp/bake_gradient.comp @@ -9,8 +9,8 @@ layout(binding = 4, std140) uniform UBO layout(binding = 0) uniform mediump sampler2D uHeight; layout(binding = 1) uniform mediump sampler2D uDisplacement; -layout(binding = 2, rgba16f) uniform mediump writeonly image2D iHeightDisplacement; -layout(binding = 3, rgba16f) uniform mediump writeonly image2D iGradJacobian; +layout(binding = 2, rgba16f) uniform writeonly mediump image2D iHeightDisplacement; +layout(binding = 3, rgba16f) uniform writeonly mediump image2D iGradJacobian; mediump float jacobian(mediump vec2 dDdx, mediump vec2 dDdy) { diff --git a/reference/shaders/comp/coherent-image.comp b/reference/shaders/comp/coherent-image.comp new file mode 100644 index 0000000..97da666 --- /dev/null +++ b/reference/shaders/comp/coherent-image.comp @@ -0,0 +1,15 @@ +#version 310 es +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 1, std430) coherent restrict writeonly buffer SSBO +{ + ivec4 value; +} _10; + +layout(binding = 3, r32i) uniform coherent readonly mediump iimage2D uImage; + +void main() +{ + _10.value = imageLoad(uImage, ivec2(10)); +} + diff --git a/reference/shaders/comp/image.comp b/reference/shaders/comp/image.comp index 7479905..b2bf0d6 100644 --- a/reference/shaders/comp/image.comp +++ b/reference/shaders/comp/image.comp @@ -1,8 +1,8 @@ #version 310 es layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -layout(binding = 0, rgba8) uniform mediump readonly image2D uImageIn; -layout(binding = 1, rgba8) uniform mediump writeonly image2D uImageOut; +layout(binding = 0, rgba8) uniform readonly mediump image2D uImageIn; +layout(binding = 1, rgba8) uniform writeonly mediump image2D uImageOut; void main() { diff --git a/reference/shaders/vert/texture_buffer.vert b/reference/shaders/vert/texture_buffer.vert index 0a198e7..e9442ce 100644 --- a/reference/shaders/vert/texture_buffer.vert +++ b/reference/shaders/vert/texture_buffer.vert @@ -2,7 +2,7 @@ #extension GL_OES_texture_buffer : require layout(binding = 4) uniform highp samplerBuffer uSamp; -layout(binding = 5, rgba32f) uniform highp readonly imageBuffer uSampo; +layout(binding = 5, rgba32f) uniform readonly highp imageBuffer uSampo; void main() { diff --git a/shaders/comp/coherent-image.comp b/shaders/comp/coherent-image.comp new file mode 100644 index 0000000..fd6e280 --- /dev/null +++ b/shaders/comp/coherent-image.comp @@ -0,0 +1,14 @@ +#version 310 es +layout(local_size_x = 1) in; + +layout(binding = 1) coherent restrict writeonly buffer SSBO +{ + ivec4 value; +}; + +layout(r32i, binding = 3) coherent readonly restrict uniform mediump iimage2D uImage; + +void main() +{ + value = imageLoad(uImage, ivec2(10)); +} diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 54c8766..5a92a0f 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -1001,8 +1001,6 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) if (flags & (1ull << DecorationBinding)) attr.push_back(join("binding = ", dec.binding)); - if (flags & (1ull << DecorationCoherent)) - attr.push_back("coherent"); if (flags & (1ull << DecorationOffset)) attr.push_back(join("offset = ", dec.offset)); @@ -6075,17 +6073,20 @@ string CompilerGLSL::to_qualifiers_glsl(uint32_t id) res += to_interpolation_qualifiers(flags); if (var) res += to_storage_qualifiers_glsl(*var); - res += to_precision_qualifiers_glsl(id); - auto &type = expression_type(id); + auto &type = expression_type(id); if (type.image.dim != DimSubpassData && type.image.sampled == 2) { + if (flags & (1ull << DecorationCoherent)) + res += "coherent "; if (flags & (1ull << DecorationNonWritable)) res += "readonly "; if (flags & (1ull << DecorationNonReadable)) res += "writeonly "; } + res += to_precision_qualifiers_glsl(id); + return res; }