From 93c26ed25a8968d2eb1d4551a361f05e72a0e547 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Fri, 12 Apr 2024 17:31:21 -0300 Subject: [PATCH] add a graphics test for some shader IO variables --- .../expected/love.test.graphics.Shader-3.png | Bin 0 -> 71 bytes testing/tests/graphics.lua | 52 ++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 testing/output/expected/love.test.graphics.Shader-3.png diff --git a/testing/output/expected/love.test.graphics.Shader-3.png b/testing/output/expected/love.test.graphics.Shader-3.png new file mode 100644 index 0000000000000000000000000000000000000000..846cd5a644273c4a43206ed97d9ad2b36e994fc8 GIT binary patch literal 71 zcmeAS@N?(olHy`uVBq!ia0vp^0wBx?BpA#)4xIr~e4Z|jAr*6yfBc`{D8j<<*H8Z8 T;RV(YK`K05{an^LB{Ts586y(j literal 0 HcmV?d00001 diff --git a/testing/tests/graphics.lua b/testing/tests/graphics.lua index 82a98d301..2a58f50b0 100644 --- a/testing/tests/graphics.lua +++ b/testing/tests/graphics.lua @@ -950,6 +950,58 @@ love.test.graphics.Shader = function(test) local imgdata2 = love.graphics.readbackTexture(canvas3) test:compareImg(imgdata2) + if love.graphics.getSupported().glsl3 then + local shader8 = love.graphics.newShader[[ + #pragma language glsl3 + #ifdef GL_ES + precision highp float; + #endif + + varying vec4 VaryingUnused1; + varying mat3 VaryingMatrix; + flat varying ivec4 VaryingInt; + + #ifdef VERTEX + in vec4 VertexPosition; + in ivec4 IntAttributeUnused; + + void vertexmain() + { + VaryingMatrix = mat3(vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1)); + VaryingInt = ivec4(1, 1, 1, 1); + love_Position = TransformProjectionMatrix * VertexPosition; + } + #endif + + #ifdef PIXEL + out ivec4 outData; + + void pixelmain() + { + outData = ivec4(VaryingMatrix[1][1] > 0.0 ? 1 : 0, 1, VaryingInt.x, 1); + } + #endif + ]] + + local canvas4 = love.graphics.newCanvas(16, 16, {format="rgba32i"}) + love.graphics.push("all") + love.graphics.setCanvas(canvas4) + love.graphics.setShader(shader8) + love.graphics.rectangle("fill", 0, 0, 16, 16) + love.graphics.pop() + + local intimagedata = love.graphics.readbackTexture(canvas4) + local imgdata3 = love.image.newImageData(16, 16, "rgba8") + for y=0, 15 do + for x=0, 15 do + local ir, ig, ib, ia = intimagedata:getInt32(4 * 4 * (y * 16 + x), 4) + imgdata3:setPixel(x, y, ir, ig, ib, ia) + end + end + test:compareImg(imgdata3) + else + test:assertTrue(true, "skip shader IO test") + end end