* limitations under the License.
*
*/ /*!
-* \file gl4cShaderGroupVoteTests.cpp
+* \file glcShaderGroupVoteTests.cpp
* \brief Conformance tests for the ARB_shader_group_vote functionality.
*/ /*-------------------------------------------------------------------*/
-#include "gl4cShaderGroupVoteTests.hpp"
+#include "glcShaderGroupVoteTests.hpp"
#include "gluContextInfo.hpp"
#include "gluDefs.hpp"
#include "gluDrawUtil.hpp"
#include "glwEnums.hpp"
#include "glwFunctions.hpp"
#include "tcuRenderTarget.hpp"
+#include "tcuTestLog.hpp"
using namespace glw;
-namespace gl4cts
+namespace glcts
{
+enum TextureSize
+{
+ RENDER_WIDTH = 16,
+ RENDER_HEIGHT = 16
+};
+
ShaderGroupVoteTestCaseBase::ComputeShader::ComputeShader(const std::string& name, const std::string& shader)
: m_name(name), m_shader(shader), m_program(NULL), m_compileOnly(true)
{
}
ShaderGroupVoteTestCaseBase::ComputeShader::ComputeShader(const std::string& name, const std::string& shader,
- const tcu::Vec4& desiredColor)
+ const tcu::IVec4& desiredColor)
: m_name(name), m_shader(shader), m_program(NULL), m_desiredColor(desiredColor), m_compileOnly(false)
{
}
if (!m_program->isOk())
{
+ context.getTestContext().getLog()
+ << tcu::TestLog::Message << m_shader << m_program->getShaderInfo(glu::SHADERTYPE_COMPUTE).infoLog
+ << m_program->getProgramInfo().infoLog << tcu::TestLog::EndMessage;
TCU_FAIL("Shader compilation failed");
}
}
// output image
gl.bindTexture(GL_TEXTURE_2D, *outputTexture);
- gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32UI, 16, 16);
+ gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, RENDER_WIDTH, RENDER_HEIGHT);
gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading image data failed");
// bind image
- gl.bindImageTexture(2, *outputTexture, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32UI);
+ gl.bindImageTexture(2, *outputTexture, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA8);
GLU_EXPECT_NO_ERROR(gl.getError(), "bindImageTexture failed");
// dispatch compute
gl.dispatchCompute(1, 1, 1);
GLU_EXPECT_NO_ERROR(gl.getError(), "dispatchCompute failed");
+ glu::GLSLVersion glslVersion = glu::getContextTypeGLSLVersion(context.getRenderContext().getType());
+ const char* versionDeclaration = glu::getGLSLVersionDeclaration(glslVersion);
+
// render output texture
- std::string vs = "#version 450 core\n"
- "in highp vec2 position;\n"
- "in vec2 inTexcoord;\n"
- "out vec2 texcoord;\n"
- "void main()\n"
- "{\n"
- " texcoord = inTexcoord;\n"
- " gl_Position = vec4(position, 0.0, 1.0);\n"
- "}\n";
-
- std::string fs = "#version 450 core\n"
- "uniform sampler2D sampler;\n"
- "in vec2 texcoord;\n"
- "out vec4 color;\n"
- "void main()\n"
- "{\n"
- " color = texture(sampler, texcoord);\n"
- "}\n";
+ std::string vs = versionDeclaration;
+ vs += "\n"
+ "in highp vec2 position;\n"
+ "in highp vec2 inTexcoord;\n"
+ "out highp vec2 texcoord;\n"
+ "void main()\n"
+ "{\n"
+ " texcoord = inTexcoord;\n"
+ " gl_Position = vec4(position, 0.0, 1.0);\n"
+ "}\n";
+
+ std::string fs = versionDeclaration;
+ fs += "\n"
+ "uniform highp sampler2D sampler;\n"
+ "in highp vec2 texcoord;\n"
+ "out highp vec4 color;\n"
+ "void main()\n"
+ "{\n"
+ " color = texture(sampler, texcoord);\n"
+ "}\n";
glu::ProgramSources sources;
sources.sources[glu::SHADERTYPE_VERTEX].push_back(vs);
glu::VertexArrayBinding vertexArrays[] = { glu::va::Float("position", 2, 4, 0, position),
glu::va::Float("inTexcoord", 2, 4, 0, texCoord) };
+ gl.viewport(0, 0, RENDER_WIDTH, RENDER_HEIGHT);
glu::draw(context.getRenderContext(), renderShader.getProgram(), DE_LENGTH_OF_ARRAY(vertexArrays), vertexArrays,
glu::pr::TriangleStrip(DE_LENGTH_OF_ARRAY(quadIndices), quadIndices));
TCU_CHECK_MSG(validationResult, validationErrorMsg.c_str());
}
-bool ShaderGroupVoteTestCaseBase::ComputeShader::validateColor(tcu::Vec4 testedColor, tcu::Vec4 desiredColor)
+bool ShaderGroupVoteTestCaseBase::ComputeShader::validateScreenPixels(deqp::Context& context, tcu::IVec4 desiredColor)
{
- const float epsilon = 0.008f;
- return de::abs(testedColor.x() - desiredColor.x()) < epsilon &&
- de::abs(testedColor.y() - desiredColor.y()) < epsilon &&
- de::abs(testedColor.z() - desiredColor.z()) < epsilon;
-}
-
-bool ShaderGroupVoteTestCaseBase::ComputeShader::validateScreenPixels(deqp::Context& context, tcu::Vec4 desiredColor)
-{
- const glw::Functions& gl = context.getRenderContext().getFunctions();
- const tcu::RenderTarget renderTarget = context.getRenderContext().getRenderTarget();
- tcu::IVec2 size(renderTarget.getWidth(), renderTarget.getHeight());
-
- glw::GLfloat* pixels = new glw::GLfloat[size.x() * size.y() * 4];
-
- // clear buffer
- for (int x = 0; x < size.x(); ++x)
- {
- for (int y = 0; y < size.y(); ++y)
- {
- int mappedPixelPosition = y * size.x() + x;
-
- pixels[mappedPixelPosition * 4 + 0] = -1.0f;
- pixels[mappedPixelPosition * 4 + 1] = -1.0f;
- pixels[mappedPixelPosition * 4 + 2] = -1.0f;
- pixels[mappedPixelPosition * 4 + 3] = -1.0f;
- }
- }
+ const glw::Functions& gl = context.getRenderContext().getFunctions();
+ std::size_t totalSize = RENDER_WIDTH * RENDER_HEIGHT * 4;
+ std::vector<glw::GLubyte> pixels(totalSize, 128);
// read pixels
- gl.readPixels(0, 0, size.x(), size.y(), GL_RGBA, GL_FLOAT, pixels);
+ gl.readPixels(0, 0, RENDER_WIDTH, RENDER_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[0]);
- // validate pixels
- bool validationResult = true;
-
- for (int x = 0; x < size.x(); ++x)
+ // compare pixels to desired color
+ for (std::size_t i = 0; i < totalSize; i += 4)
{
- for (int y = 0; y < size.y(); ++y)
- {
- int mappedPixelPosition = y * size.x() + x;
-
- tcu::Vec4 color(pixels[mappedPixelPosition * 4 + 0], pixels[mappedPixelPosition * 4 + 1],
- pixels[mappedPixelPosition * 4 + 2], pixels[mappedPixelPosition * 4 + 3]);
-
- if (!validateColor(color, desiredColor))
- {
- validationResult = false;
- }
- }
+ if ((pixels[i + 0] != desiredColor.x()) || (pixels[i + 1] != desiredColor.y()) ||
+ (pixels[i + 2] != desiredColor.z()))
+ return false;
}
- delete[] pixels;
-
- return validationResult;
+ return true;
}
/** Constructor.
* @param name Test name
* @param description Test description
*/
-ShaderGroupVoteTestCaseBase::ShaderGroupVoteTestCaseBase(deqp::Context& context, const char* name,
- const char* description)
+ShaderGroupVoteTestCaseBase::ShaderGroupVoteTestCaseBase(deqp::Context& context, ExtParameters& extParam,
+ const char* name, const char* description)
: TestCaseBase(context, glcts::ExtParameters(glu::GLSL_VERSION_450, glcts::EXTENSIONTYPE_EXT), name, description)
- , m_glslFunctionPostfix("")
-
+ , m_extensionSupported(true)
{
- glu::ContextType contextType = m_context.getRenderContext().getType();
- bool contextSupportsGL46 = glu::contextSupports(contextType, glu::ApiType::core(4, 6));
- m_extensionSupported =
- contextSupportsGL46 || context.getContextInfo().isExtensionSupported("GL_ARB_shader_group_vote");
+ glu::ContextType contextType = m_context.getRenderContext().getType();
+ m_specializationMap["VERSION"] = glu::getGLSLVersionDeclaration(extParam.glslVersion);
- if (contextSupportsGL46)
+ if (glu::contextSupports(contextType, glu::ApiType::core(4, 6)))
{
- m_specializationMap["VERSION"] = "#version 460 core";
- m_specializationMap["GROUP_VOTE_EXTENSION"] = "";
- m_specializationMap["ALL_INVOCATIONS_FUNC"] = "allInvocations";
- m_specializationMap["ANY_INVOCATION_FUNC"] = "anyInvocation";
- m_specializationMap["ALL_INVOCATIONS_EQUAL_FUNC"] = "allInvocationsEqual";
+ m_specializationMap["GROUP_VOTE_EXTENSION"] = "";
+ m_specializationMap["EXT_TYPE"] = "";
}
else
{
- m_specializationMap["VERSION"] = "#version 450 core";
- m_specializationMap["GROUP_VOTE_EXTENSION"] = "#extension GL_ARB_shader_group_vote : enable";
- m_specializationMap["ALL_INVOCATIONS_FUNC"] = "allInvocationsARB";
- m_specializationMap["ANY_INVOCATION_FUNC"] = "anyInvocationARB";
- m_specializationMap["ALL_INVOCATIONS_EQUAL_FUNC"] = "allInvocationsEqualARB";
- m_glslFunctionPostfix = "ARB";
+ bool isCoreGL = glu::isContextTypeGLCore(contextType);
+ std::string extensionName = isCoreGL ? "GL_ARB_shader_group_vote" : "GL_EXT_shader_group_vote";
+ m_extensionSupported = context.getContextInfo().isExtensionSupported(extensionName.c_str());
+ std::stringstream extensionString;
+ extensionString << "#extension " + extensionName + " : enable";
+
+ m_specializationMap["GROUP_VOTE_EXTENSION"] = extensionString.str();
+ m_specializationMap["EXT_TYPE"] = isCoreGL ? "ARB" : "EXT";
}
}
*
* @param context Rendering context
*/
-ShaderGroupVoteAvailabilityTestCase::ShaderGroupVoteAvailabilityTestCase(deqp::Context& context)
- : ShaderGroupVoteTestCaseBase(context, "ShaderGroupVoteAvailabilityTestCase", "Implements ...")
+ShaderGroupVoteAvailabilityTestCase::ShaderGroupVoteAvailabilityTestCase(deqp::Context& context,
+ ExtParameters& extParam)
+ : ShaderGroupVoteTestCaseBase(context, extParam, "availability", "Implements ...")
{
const char* shader = "${VERSION}\n"
"${GROUP_VOTE_EXTENSION}\n"
- "layout(rgba32f, binding = 2) writeonly uniform highp image2D destImage;\n"
+ "layout(rgba8, binding = 2) writeonly uniform highp image2D destImage;\n"
"layout(local_size_x = 16, local_size_y = 16) in;\n"
"void main (void)\n"
"{\n"
" vec4 outColor = vec4(0.0);\n"
- " outColor.r = ${ALL_INVOCATIONS_FUNC}(true) ? 1.0 : 0.0;\n"
- " outColor.g = ${ANY_INVOCATION_FUNC}(true) ? 1.0 : 0.0;\n"
- " outColor.b = ${ALL_INVOCATIONS_EQUAL_FUNC}(true) ? 1.0 : 0.0;\n"
+ " outColor.r = allInvocations${EXT_TYPE}(true) ? 1.0 : 0.0;\n"
+ " outColor.g = anyInvocation${EXT_TYPE}(true) ? 1.0 : 0.0;\n"
+ " outColor.b = allInvocationsEqual${EXT_TYPE}(true) ? 1.0 : 0.0;\n"
" imageStore(destImage, ivec2(gl_GlobalInvocationID.xy), outColor);\n"
"}\n";
- std::string cs = specializeShader(1, &shader);
- m_shaders.push_back(new ComputeShader("availability", cs));
+
+ m_shaders.push_back(new ComputeShader("availability", specializeShader(1, &shader)));
}
/** Constructor.
* @param name Test name
* @param description Test description
*/
-ShaderGroupVoteFunctionTestCaseBase::ShaderGroupVoteFunctionTestCaseBase(deqp::Context& context, const char* name,
+ShaderGroupVoteFunctionTestCaseBase::ShaderGroupVoteFunctionTestCaseBase(deqp::Context& context,
+ ExtParameters& extParam, const char* name,
const char* description)
- : ShaderGroupVoteTestCaseBase(context, name, description)
+ : ShaderGroupVoteTestCaseBase(context, extParam, name, description)
{
- m_shaderBase = "${VERSION}\n"
- "${GROUP_VOTE_EXTENSION}\n"
- "layout(rgba32f, binding = 2) writeonly uniform highp image2D destImage;\n"
- "layout(local_size_x = 16, local_size_y = 16) in;\n"
- "void main (void)\n"
- "{\n"
- " bool result = ${FUNC_RESULT};\n"
- " vec4 outColor = vec4(vec3(result ? 1.0 : 0.0), 1.0);\n"
- " imageStore(destImage, ivec2(gl_GlobalInvocationID.xy), outColor);\n"
- "}\n";
+ m_shaderBase += "${VERSION}\n"
+ "${GROUP_VOTE_EXTENSION}\n"
+ "layout(rgba8, binding = 2) writeonly uniform highp image2D destImage;\n"
+ "layout(local_size_x = 16, local_size_y = 16) in;\n"
+ "void main (void)\n"
+ "{\n"
+ " bool result = ${FUNC}${EXT_TYPE}(${FUNC_PARAMETER});\n"
+ " vec4 outColor = vec4(vec3(result ? 1.0 : 0.0), 1.0);\n"
+ " imageStore(destImage, ivec2(gl_GlobalInvocationID.xy), outColor);\n"
+ "}\n";
}
/** Constructor.
*
* @param context Rendering context
*/
-ShaderGroupVoteAllInvocationsTestCase::ShaderGroupVoteAllInvocationsTestCase(deqp::Context& context)
- : ShaderGroupVoteFunctionTestCaseBase(context, "ShaderGroupVoteAllInvocationsTestCase", "Implements ...")
+ShaderGroupVoteAllInvocationsTestCase::ShaderGroupVoteAllInvocationsTestCase(deqp::Context& context,
+ ExtParameters& extParam)
+ : ShaderGroupVoteFunctionTestCaseBase(context, extParam, "all_invocations", "Implements ...")
{
- m_specializationMap["FUNC_RESULT"] = "allInvocations" + m_glslFunctionPostfix + "(true)";
+ const char* shaderBase = m_shaderBase.c_str();
+ m_specializationMap["FUNC"] = "allInvocations";
+ m_specializationMap["FUNC_PARAMETER"] = "true";
+
m_shaders.push_back(
- new ComputeShader("allInvocationsARB", specializeShader(1, &m_shaderBase), tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f)));
+ new ComputeShader("allInvocationsARB", specializeShader(1, &shaderBase), tcu::IVec4(255, 255, 255, 255)));
}
/** Constructor.
*
* @param context Rendering context
*/
-ShaderGroupVoteAnyInvocationTestCase::ShaderGroupVoteAnyInvocationTestCase(deqp::Context& context)
- : ShaderGroupVoteFunctionTestCaseBase(context, "ShaderGroupVoteAnyInvocationTestCase", "Implements ...")
+ShaderGroupVoteAnyInvocationTestCase::ShaderGroupVoteAnyInvocationTestCase(deqp::Context& context,
+ ExtParameters& extParam)
+ : ShaderGroupVoteFunctionTestCaseBase(context, extParam, "any_invocation", "Implements ...")
{
- m_specializationMap["FUNC_RESULT"] = "anyInvocation" + m_glslFunctionPostfix + "(false)";
+ const char* shaderBase = m_shaderBase.c_str();
+ m_specializationMap["FUNC"] = "anyInvocation";
+ m_specializationMap["FUNC_PARAMETER"] = "false";
+
m_shaders.push_back(
- new ComputeShader("anyInvocationARB", specializeShader(1, &m_shaderBase), tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f)));
+ new ComputeShader("anyInvocationARB", specializeShader(1, &shaderBase), tcu::IVec4(0, 0, 0, 255)));
}
/** Constructor.
*
* @param context Rendering context
*/
-ShaderGroupVoteAllInvocationsEqualTestCase::ShaderGroupVoteAllInvocationsEqualTestCase(deqp::Context& context)
- : ShaderGroupVoteFunctionTestCaseBase(context, "ShaderGroupVoteAllInvocationsEqualTestCase", "Implements ...")
+ShaderGroupVoteAllInvocationsEqualTestCase::ShaderGroupVoteAllInvocationsEqualTestCase(deqp::Context& context,
+ ExtParameters& extParam)
+ : ShaderGroupVoteFunctionTestCaseBase(context, extParam, "all_invocations_equal", "Implements ...")
{
- m_specializationMap["FUNC_RESULT"] = "allInvocationsEqual" + m_glslFunctionPostfix + "(true)";
- m_shaders.push_back(new ComputeShader("allInvocationsEqual", specializeShader(1, &m_shaderBase),
- tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f)));
+ const char* shaderBase = m_shaderBase.c_str();
+ m_specializationMap["FUNC"] = "allInvocationsEqual";
+ m_specializationMap["FUNC_PARAMETER"] = "true";
+ m_shaders.push_back(
+ new ComputeShader("allInvocationsEqualARB", specializeShader(1, &shaderBase), tcu::IVec4(255, 255, 255, 255)));
- m_specializationMap["FUNC_RESULT"] = "allInvocationsEqual" + m_glslFunctionPostfix + "(false)";
- m_shaders.push_back(new ComputeShader("allInvocationsEqual", specializeShader(1, &m_shaderBase),
- tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f)));
+ m_specializationMap["FUNC"] = "allInvocationsEqual";
+ m_specializationMap["FUNC_PARAMETER"] = "false";
+ m_shaders.push_back(
+ new ComputeShader("allInvocationsEqualARB", specializeShader(1, &shaderBase), tcu::IVec4(255, 255, 255, 255)));
}
/** Constructor.
* @param context Rendering context.
*/
ShaderGroupVote::ShaderGroupVote(deqp::Context& context)
- : TestCaseGroup(context, "shader_group_vote_tests",
- "Verify conformance of CTS_ARB_shader_group_vote implementation")
+ : TestCaseGroup(context, "shader_group_vote",
+ "Verify conformance of shader_group_vote functionality implementation")
{
}
/** Initializes the test group contents. */
void ShaderGroupVote::init()
{
- addChild(new ShaderGroupVoteAvailabilityTestCase(m_context));
- addChild(new ShaderGroupVoteAllInvocationsTestCase(m_context));
- addChild(new ShaderGroupVoteAnyInvocationTestCase(m_context));
- addChild(new ShaderGroupVoteAllInvocationsEqualTestCase(m_context));
+ glu::GLSLVersion glslVersion = getContextTypeGLSLVersion(m_context.getRenderContext().getType());
+ ExtParameters extParam = glcts::ExtParameters(glslVersion, glcts::EXTENSIONTYPE_EXT);
+
+ addChild(new ShaderGroupVoteAvailabilityTestCase(m_context, extParam));
+ addChild(new ShaderGroupVoteAllInvocationsTestCase(m_context, extParam));
+ addChild(new ShaderGroupVoteAnyInvocationTestCase(m_context, extParam));
+ addChild(new ShaderGroupVoteAllInvocationsEqualTestCase(m_context, extParam));
}
-} /* gl4cts namespace */
+} /* glcts namespace */