diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 482af8e45..b5ce4cd2d 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -1632,9 +1632,9 @@ void Graphics::initCapabilities() capabilities.features[FEATURE_TEXEL_BUFFER] = gl.isBufferUsageSupported(BUFFERUSAGE_TEXEL); capabilities.features[FEATURE_COPY_TEXTURE_TO_BUFFER] = gl.isCopyTextureToBufferSupported(); capabilities.features[FEATURE_INDIRECT_DRAW] = capabilities.features[FEATURE_GLSL4]; - capabilities.features[FEATURE_VERTEX_WRITE] = true; - capabilities.features[FEATURE_PIXEL_WRITE] = true; - capabilities.features[FEATURE_IMAGE_ATOMICS] = true; + capabilities.features[FEATURE_VERTEX_WRITE] = capabilities.features[FEATURE_GLSL4]; + capabilities.features[FEATURE_PIXEL_WRITE] = capabilities.features[FEATURE_GLSL4]; + capabilities.features[FEATURE_IMAGE_ATOMICS] = capabilities.features[FEATURE_GLSL4]; static_assert(FEATURE_MAX_ENUM == 16, "Graphics::initCapabilities must be updated when adding a new graphics feature!"); capabilities.limits[LIMIT_POINT_SIZE] = gl.getMaxPointSize(); diff --git a/testing/tests/graphics.lua b/testing/tests/graphics.lua index 6f19f1581..d1621c956 100644 --- a/testing/tests/graphics.lua +++ b/testing/tests/graphics.lua @@ -1003,6 +1003,72 @@ love.test.graphics.Shader = function(test) else test:assertTrue(true, "skip shader IO test") end + + if love.graphics.getSupported().glsl4 and love.graphics.getSupported().vertexwrite and love.graphics.getSupported().pixelwrite then + local success, message = pcall(love.graphics.newShader, [[ + #pragma language glsl4 + + buffer ColorBuffer + { + vec4 colors[]; + }; + + void effect() + { + colors[0] = VaryingColor; + love_PixelColor = colors[0]; + } + ]]) + + test:assertFalse(success, "shader should not compile") + test:assertEquals("Shader validation error:\nStorage Buffer block 'ColorBuffer' must be marked as readonly in vertex and pixel shaders unless explicitly enabled.", message) + + success, message = pcall(love.graphics.newShader, [[ + #pragma language glsl4 + + buffer ColorBuffer + { + vec4 colors[]; + }; + + void effect() + { + colors[0] = VaryingColor; + love_PixelColor = colors[0]; + } + ]], { write = true }) + + test:assertTrue(success, "shader should compile") + + success, message = pcall(love.graphics.newShader, [[ + #pragma language glsl4 + + layout(rgba32f) uniform image2D RGBAImage; + + void effect() + { + love_PixelColor = VaryingColor * imageLoad(RGBAImage, ivec2(gl_FragCoord.xy)); + } + ]]) + + test:assertFalse(success, "shader should not compile") + test:assertEquals("Shader validation error:\nStorage Texture uniform variables (image2D, etc) are only allowed in compute shaders unless explicitly enabled.", message) + + success, message = pcall(love.graphics.newShader, [[ + #pragma language glsl4 + + layout(rgba32f) uniform image2D RGBAImage; + + void effect() + { + love_PixelColor = VaryingColor * imageLoad(RGBAImage, ivec2(gl_FragCoord.xy)); + } + ]], { write = true }) + + test:assertTrue(success, "shader should compile") + else + test:assertTrue(true, "skip feature test") + end end