From 6383bc6dd4a60bc0e91ce876cbf9f064c553ff75 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Thu, 11 May 2017 11:11:48 +0200 Subject: [PATCH] Fix compute shader in robustness tests to produce an output The compute shader only writes to shared variables, which means that it doesn't produce any useful output. Shader compiler backends can see this and mark all uniform variables declared by the shader as "inactive" and remove them, which would defeat the purpose of the 'getnuniform' test and lead to a failure. Fix this by making the compute shader write to a shader storage buffer object instead, so that uniforms remain active for being involved in generating a shader output. Component: OpenGL VK-GL-CTS issue: 415 Affects: KHR-GL45.robustness.getnuniform Change-Id: I67b3fd8eb3a63012b6c46713e17c86d51b42d82e --- .../openglcts/modules/gl/gl4cRobustnessTests.cpp | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/external/openglcts/modules/gl/gl4cRobustnessTests.cpp b/external/openglcts/modules/gl/gl4cRobustnessTests.cpp index f6af558..81c3f91 100644 --- a/external/openglcts/modules/gl/gl4cRobustnessTests.cpp +++ b/external/openglcts/modules/gl/gl4cRobustnessTests.cpp @@ -1245,6 +1245,17 @@ tcu::TestNode::IterateResult GetnUniformTest::iterate() program.Init(cs /* cs */, "" /* fs */, "" /* gs */, "" /* tcs */, "" /* tes */, "" /* vs */); program.Use(); + /* Shader storage buffer */ + GLuint buf; + gl.genBuffers(1, &buf); + GLU_EXPECT_NO_ERROR(gl.getError(), "GenBuffers"); + + gl.bindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, buf); + GLU_EXPECT_NO_ERROR(gl.getError(), "BindBufferBase"); + + gl.bufferData(GL_SHADER_STORAGE_BUFFER, 16, DE_NULL, GL_STREAM_DRAW); + GLU_EXPECT_NO_ERROR(gl.getError(), "BufferData"); + /* passing uniform values */ gl.programUniform4fv(program.m_id, 11, 1, input4f); GLU_EXPECT_NO_ERROR(gl.getError(), "ProgramUniform4fv"); @@ -1297,13 +1308,15 @@ tcu::TestNode::IterateResult GetnUniformTest::iterate() m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Fail"); } + gl.deleteBuffers(1, &buf); + /* Done */ return tcu::TestNode::STOP; } std::string GetnUniformTest::getComputeShader() { - static const GLchar* cs = "#version 320 es\n" + static const GLchar* cs = "#version 430\n" "\n" "layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;\n" "\n" @@ -1311,9 +1324,11 @@ std::string GetnUniformTest::getComputeShader() "layout (location = 12) uniform ivec3 inputi;\n" "layout (location = 13) uniform uvec4 inputu;\n" "\n" - "shared float valuef;\n" - "shared int valuei;\n" - "shared uint valueu;\n" + "layout (std140, binding = 0) buffer ssbo {" + " float valuef;\n" + " int valuei;\n" + " uint valueu;\n" + "};\n" "\n" "void main()\n" "{\n" -- 2.7.4