From: James Helferty Date: Wed, 6 Sep 2017 01:47:05 +0000 (-0400) Subject: Fix race in ShaderBallotFunctionRead test X-Git-Tag: upstream/0.1.0~105 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd49bc4c1acd4dec3075706beb7916fc925ffe23;p=platform%2Fupstream%2FVK-GL-CTS.git Fix race in ShaderBallotFunctionRead test The original code contained a race to write an SSBO, since it wasn't using atomics. This change replaces that code with a much simpler reimplementation of readFirstInvocationARB() by using findLSB() and ballotARB() to provide an argument to readInvocationARB(). This change also strips out a now-unused argument and related code from the shader-builder helper class, which is shared with the other shader_ballot tests. Components: OpenGL VK-GL-CTS issue: 665 Affects: * KHR-GL43/44/45.shader_ballot_tests.ShaderBallotAvailability * KHR-GL43/44/45.shader_ballot_tests.ShaderBallotBitmasks * KHR-GL43/44/45.shader_ballot_tests.ShaderBallotFunctionBallot * KHR-GL43/44/45.shader_ballot_tests.ShaderBallotFunctionRead Change-Id: Iaf121ab07e13bf450533c96c95f1b7745631c0c8 --- diff --git a/external/openglcts/modules/gl/gl4cShaderBallotTests.cpp b/external/openglcts/modules/gl/gl4cShaderBallotTests.cpp index 5f97bd29e..b5562db19 100644 --- a/external/openglcts/modules/gl/gl4cShaderBallotTests.cpp +++ b/external/openglcts/modules/gl/gl4cShaderBallotTests.cpp @@ -39,13 +39,11 @@ namespace gl4cts ShaderBallotBaseTestCase::ShaderPipeline::ShaderPipeline(glu::ShaderType testedShader, const std::string& contentSnippet, - const std::string& headSnippet, std::map specMap) : m_programRender(NULL), m_programCompute(NULL), m_testedShader(testedShader), m_specializationMap(specMap) { std::string testedHeadPart = "#extension GL_ARB_shader_ballot : enable\n" "#extension GL_ARB_gpu_shader_int64 : enable\n"; - testedHeadPart += headSnippet; std::string testedContentPart = contentSnippet; @@ -551,7 +549,7 @@ ShaderBallotBitmasksTestCase::ShaderBallotBitmasksTestCase(deqp::Context& contex std::map specMap; specMap["MASK_VAR"] = maskIter->first; specMap["MASK_OPERATOR"] = maskIter->second; - m_shaderPipelines.push_back(new ShaderPipeline((glu::ShaderType)i, colorShaderSnippet, "", specMap)); + m_shaderPipelines.push_back(new ShaderPipeline((glu::ShaderType)i, colorShaderSnippet, specMap)); } } } @@ -688,21 +686,20 @@ ShaderBallotFunctionReadTestCase::ShaderBallotFunctionReadTestCase(deqp::Context std::string readFirstInvSnippet = "float color = 1.0f - (gl_SubGroupInvocationARB / float(gl_SubGroupSizeARB));\n" "outColor = readFirstInvocationARB(vec4(color, color, color, 1.0f));\n"; - std::string readInvSnippetHead = "layout(std430, binding = 0) buffer invocationBuffer {\n" - " int invocation;\n" - "};"; - std::string readInvSnippet = "float color = 1.0 - (gl_SubGroupInvocationARB / float(gl_SubGroupSizeARB));\n" - "if(invocation == -1)\n" - "{\n" - " invocation = int(gl_SubGroupInvocationARB);\n" + "uvec2 parts = unpackUint2x32(ballotARB(true));\n" + "uint invocation;\n" + "if (parts.x != 0) {\n" + " invocation = findLSB(parts.x);\n" + "} else {\n" + " invocation = findLSB(parts.y) + 32;\n" "}\n" - "outColor = readInvocationARB(vec4(color, color, color, 1.0f), uint(invocation));\n"; + "outColor = readInvocationARB(vec4(color, color, color, 1.0f), invocation);\n"; for (unsigned int i = 0; i < glu::SHADERTYPE_LAST; ++i) { m_shaderPipelines.push_back(new ShaderPipeline((glu::ShaderType)i, readFirstInvSnippet)); - m_shaderPipelines.push_back(new ShaderPipeline((glu::ShaderType)i, readInvSnippet, readInvSnippetHead)); + m_shaderPipelines.push_back(new ShaderPipeline((glu::ShaderType)i, readInvSnippet)); } } @@ -741,26 +738,10 @@ tcu::TestNode::IterateResult ShaderBallotFunctionReadTestCase::iterate() { gl.clear(GL_COLOR_BUFFER_BIT); - glw::GLuint invocationBufferID; - gl.genBuffers(1, &invocationBufferID); - GLU_EXPECT_NO_ERROR(gl.getError(), "genBuffers failed"); - gl.bindBuffer(GL_SHADER_STORAGE_BUFFER, invocationBufferID); - GLU_EXPECT_NO_ERROR(gl.getError(), "bindBuffer failed"); - - int invocationID = -1; - gl.bufferData(GL_SHADER_STORAGE_BUFFER, sizeof(int), &invocationID, GL_DYNAMIC_COPY); - GLU_EXPECT_NO_ERROR(gl.getError(), "bufferData failed"); - gl.bindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, invocationBufferID); - GLU_EXPECT_NO_ERROR(gl.getError(), "bindBufferBase failed"); - gl.bindBuffer(GL_SHADER_STORAGE_BUFFER, 0); - GLU_EXPECT_NO_ERROR(gl.getError(), "bindBuffer failed"); - (*pipelineIter)->test(m_context); gl.flush(); - gl.deleteBuffers(1, &invocationBufferID); - bool validationResult = ShaderBallotBaseTestCase::validateScreenPixelsSameColor(m_context, tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f)); TCU_CHECK_MSG(validationResult, "Read functions result is not correct"); diff --git a/external/openglcts/modules/gl/gl4cShaderBallotTests.hpp b/external/openglcts/modules/gl/gl4cShaderBallotTests.hpp index 74b066fe9..4f12a6c5d 100644 --- a/external/openglcts/modules/gl/gl4cShaderBallotTests.hpp +++ b/external/openglcts/modules/gl/gl4cShaderBallotTests.hpp @@ -52,7 +52,6 @@ public: public: ShaderPipeline(glu::ShaderType testedShader, const std::string& contentSnippet, - const std::string& headSnippet = "", std::map specMap = std::map()); ~ShaderPipeline();