#include "tcuTextureUtil.hpp"
#include "tcuVectorUtil.hpp"
#include "tcuFormatUtil.hpp"
+#include "tcuStringTemplate.hpp"
#include "gluContextInfo.hpp"
#include "gluShaderProgram.hpp"
#include "gluRenderContext.hpp"
namespace deqp
{
+
+using std::map;
+using std::string;
+
namespace gles31
{
namespace Functional
, m_distanceThreshold (0.0f)
{
// approximate Bates distribution as normal
- const float variance = (1.0f / (12.0f * m_numSamples));
+ const float variance = (1.0f / (12.0f * (float)m_numSamples));
const float standardDeviation = deFloatSqrt(variance);
// 95% of means of sample positions are within 2 standard deviations if
DE_UNREF(position);
DE_ASSERT(m_isStatisticallySignificant);
- const tcu::Vec2 avgPosition (testColor.getGreen() / 255.0f, testColor.getBlue() / 255.0f);
+ const tcu::Vec2 avgPosition ((float)testColor.getGreen() / 255.0f, (float)testColor.getBlue() / 255.0f);
const tcu::Vec2 distanceFromCenter = tcu::abs(avgPosition - tcu::Vec2(0.5f, 0.5f));
return distanceFromCenter.x() < m_distanceThreshold && distanceFromCenter.y() < m_distanceThreshold;
if (!verifier.verify(color, tcu::IVec2(x,y)))
{
error = true;
- errorMask.setPixel(x, y, tcu::RGBA::red);
+ errorMask.setPixel(x, y, tcu::RGBA::red());
}
}
void MultisampleRenderCase::init (void)
{
- if (!m_context.getContextInfo().isExtensionSupported("GL_OES_sample_variables"))
- throw tcu::NotSupportedError("Test requires GL_OES_sample_variables extension");
+ const bool isES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
+ if (!isES32 && !m_context.getContextInfo().isExtensionSupported("GL_OES_sample_variables"))
+ TCU_THROW(NotSupportedError, "Test requires GL_OES_sample_variables extension or a context version 3.2 or higher.");
MultisampleShaderRenderUtil::MultisampleRenderCase::init();
}
std::string NumSamplesCase::genFragmentSource (int numTargetSamples) const
{
- std::ostringstream buf;
+ std::ostringstream buf;
+ const bool isES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
+ map<string, string> args;
+ args["GLSL_VERSION_DECL"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
+ args["GLSL_EXTENSION"] = isES32 ? "" : "#extension GL_OES_sample_variables : require";
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
"layout(location = 0) out mediump vec4 fragColor;\n"
"void main (void)\n"
"{\n"
" fragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
"}\n";
- return buf.str();
+ return tcu::StringTemplate(buf.str()).specialize(args);
}
bool NumSamplesCase::verifyImage (const tcu::Surface& resultImage)
{
DE_UNREF(numTargetSamples);
- std::ostringstream buf;
+ std::ostringstream buf;
+ const bool isES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
+ map<string, string> args;
+ args["GLSL_VERSION_DECL"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
+ args["GLSL_EXTENSION"] = isES32 ? "" : "#extension GL_OES_sample_variables : require";
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
"layout(location = 0) out mediump vec4 fragColor;\n"
"uniform mediump int u_maxSamples;\n"
"void main (void)\n"
" fragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
"}\n";
- return buf.str();
+ return tcu::StringTemplate(buf.str()).specialize(args);
}
bool MaxSamplesCase::verifyImage (const tcu::Surface& resultImage)
DE_ASSERT(numTargetSamples != 0);
std::ostringstream buf;
+ const bool isES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
+ map<string, string> args;
+ args["GLSL_VERSION_DECL"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
+ args["GLSL_EXTENSION"] = isES32 ? "" : "#extension GL_OES_sample_variables : require";
if (m_vericationMode == VERIFY_USING_SAMPLES)
{
// encode the id to the output, and then verify it during sampling
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
"layout(location = 0) out mediump vec4 fragColor;\n"
"void main (void)\n"
"{\n"
if (numTargetSamples == 1)
{
// single sample, just verify value is 0
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
"layout(location = 0) out mediump vec4 fragColor;\n"
"void main (void)\n"
"{\n"
else
{
// select only one sample per PIXEL
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
"in highp vec4 v_position;\n"
"layout(location = 0) out mediump vec4 fragColor;\n"
"void main (void)\n"
else
DE_ASSERT(false);
- return buf.str();
+ return tcu::StringTemplate(buf.str()).specialize(args);
}
bool SampleIDCase::verifyImage (const tcu::Surface& resultImage)
{
// sample id should be sample index
const int threshold = 255 / 4 / m_numTargetSamples + 1;
- const float sampleIdColor = sampleNdx / (float)m_numTargetSamples;
+ const float sampleIdColor = (float)sampleNdx / (float)m_numTargetSamples;
m_testCtx.getLog() << tcu::TestLog::Message << "Verifying sample " << (sampleNdx+1) << "/" << (int)resultBuffers.size() << tcu::TestLog::EndMessage;
allOk &= verifyImageWithVerifier(resultBuffers[sampleNdx], m_testCtx.getLog(), ColorVerifier(tcu::Vec3(0.0f, sampleIdColor, 1.0f), tcu::IVec3(1, threshold, 1)), false);
DE_ASSERT(numTargetSamples != 0);
DE_UNREF(numTargetSamples);
- const bool multisampleTarget = (m_numRequestedSamples > 0) || (m_renderTarget == TARGET_DEFAULT && m_context.getRenderTarget().getNumSamples() > 1);
+ const bool multisampleTarget = (m_numRequestedSamples > 0) || (m_renderTarget == TARGET_DEFAULT && m_context.getRenderTarget().getNumSamples() > 1);
std::ostringstream buf;
+ const bool isES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
+ map<string, string> args;
+ args["GLSL_VERSION_DECL"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
+ args["GLSL_EXTENSION"] = isES32 ? "\n" : "#extension GL_OES_sample_variables : require\n";
if (multisampleTarget)
{
// encode the position to the output, use red channel as error channel
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
"layout(location = 0) out mediump vec4 fragColor;\n"
"void main (void)\n"
"{\n"
else
{
// verify value is ok
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
"layout(location = 0) out mediump vec4 fragColor;\n"
"void main (void)\n"
"{\n"
"}\n";
}
- return buf.str();
+ return tcu::StringTemplate(buf.str()).specialize(args);
}
bool SamplePosDistributionCase::verifyImage (const tcu::Surface& resultImage)
for (int sampleNdx = 0; sampleNdx < (int)resultBuffers.size(); ++sampleNdx)
{
const tcu::RGBA color = resultBuffers[sampleNdx].getPixel(x, y);
- samplePositions[sampleNdx] = tcu::Vec2(color.getGreen() / 255.0f, color.getBlue() / 255.0f);
+ samplePositions[sampleNdx] = tcu::Vec2((float)color.getGreen() / 255.0f, (float)color.getBlue() / 255.0f);
}
// Just check there are no two samples with same positions
samplePosNotUnique = true;
uniquenessOk = false;
- errorMask.setPixel(x, y, tcu::RGBA::red);
+ errorMask.setPixel(x, y, tcu::RGBA::red());
}
}
}
}
distibutionError = true;
- errorMask.setPixel(x, y, tcu::RGBA::red);
+ errorMask.setPixel(x, y, tcu::RGBA::red());
}
}
void SamplePosCorrectnessCase::init (void)
{
+ const bool isES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
// requirements: per-invocation interpolation required
- if (!m_context.getContextInfo().isExtensionSupported("GL_OES_shader_multisample_interpolation") &&
+ if (!isES32 && !m_context.getContextInfo().isExtensionSupported("GL_OES_shader_multisample_interpolation") &&
!m_context.getContextInfo().isExtensionSupported("GL_OES_sample_shading"))
- throw tcu::NotSupportedError("Test requires GL_OES_shader_multisample_interpolation or GL_OES_sample_shading extension");
+ TCU_THROW(NotSupportedError, "Test requires GL_OES_shader_multisample_interpolation or GL_OES_sample_shading extension or a context version 3.2 or higher.");
// prefer to use the sample qualifier path
m_useSampleQualifier = m_context.getContextInfo().isExtensionSupported("GL_OES_shader_multisample_interpolation");
{
DE_UNREF(numTargetSamples);
- std::ostringstream buf;
+ std::ostringstream buf;
+ const bool isES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
+ map<string, string> args;
+ args["GLSL_VERSION_DECL"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
+ args["GLSL_EXTENSION"] = isES32 ? "" : m_useSampleQualifier ? "#extension GL_OES_shader_multisample_interpolation : require" : "";
- buf << "#version 310 es\n"
- << ((m_useSampleQualifier) ? ("#extension GL_OES_shader_multisample_interpolation : require\n") : (""))
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
<< "in highp vec4 a_position;\n"
<< ((m_useSampleQualifier) ? ("sample ") : ("")) << "out highp vec4 v_position;\n"
"void main (void)\n"
" v_position = a_position;\n"
"}\n";
- return buf.str();
+ return tcu::StringTemplate(buf.str()).specialize(args);
}
std::string SamplePosCorrectnessCase::genFragmentSource (int numTargetSamples) const
{
DE_UNREF(numTargetSamples);
- std::ostringstream buf;
+ std::ostringstream buf;
+ const bool isES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
+ map<string, string> args;
+ args["GLSL_VERSION_DECL"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
+ args["GLSL_SAMPLE_EXTENSION"] = isES32 ? "" : "#extension GL_OES_sample_variables : require";
+ args["GLSL_MULTISAMPLE_EXTENSION"] = isES32 ? "" : m_useSampleQualifier ? "#extension GL_OES_shader_multisample_interpolation : require" : "";
// encode the position to the output, use red channel as error channel
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
- << ((m_useSampleQualifier) ? ("#extension GL_OES_shader_multisample_interpolation : require\n") : (""))
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_SAMPLE_EXTENSION}\n"
+ "${GLSL_MULTISAMPLE_EXTENSION}\n"
<< ((m_useSampleQualifier) ? ("sample ") : ("")) << "in highp vec4 v_position;\n"
"layout(location = 0) out mediump vec4 fragColor;\n"
"void main (void)\n"
" fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
"}\n";
- return buf.str();
+ return tcu::StringTemplate(buf.str()).specialize(args);
}
bool SamplePosCorrectnessCase::verifyImage (const tcu::Surface& resultImage)
void SampleMaskBaseCase::init (void)
{
+ const bool isES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
// required extra extension
- if (m_runMode == RUN_PER_TWO_SAMPLES && !m_context.getContextInfo().isExtensionSupported("GL_OES_sample_shading"))
- throw tcu::NotSupportedError("Test requires GL_OES_sample_shading extension");
+ if (m_runMode == RUN_PER_TWO_SAMPLES && !isES32 && !m_context.getContextInfo().isExtensionSupported("GL_OES_sample_shading"))
+ TCU_THROW(NotSupportedError, "Test requires GL_OES_sample_shading extension or a context version 3.2 or higher.");
MultisampleRenderCase::init();
}
{
DE_ASSERT(numTargetSamples != 0);
- const bool multisampleTarget = (m_numRequestedSamples > 0) || (m_renderTarget == TARGET_DEFAULT && m_context.getRenderTarget().getNumSamples() > 1);
+ const bool multisampleTarget = (m_numRequestedSamples > 0) || (m_renderTarget == TARGET_DEFAULT && m_context.getRenderTarget().getNumSamples() > 1);
std::ostringstream buf;
+ const bool isES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
+ map<string, string> args;
+ args["GLSL_VERSION_DECL"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
+ args["GLSL_EXTENSION"] = isES32 ? "" : "#extension GL_OES_sample_variables : require";
// test supports only one sample mask word
if (numTargetSamples > 32)
- throw tcu::NotSupportedError("Sample count larger than 32 is not supported.");
+ TCU_THROW(NotSupportedError, "Sample count larger than 32 is not supported.");
if (multisampleTarget)
{
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
"layout(location = 0) out mediump vec4 fragColor;\n"
"uniform highp uint u_sampleMask;\n"
"void main (void)\n"
{
// non-multisample targets don't get multisample operations like ANDing with mask
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
"layout(location = 0) out mediump vec4 fragColor;\n"
"uniform highp uint u_sampleMask;\n"
"void main (void)\n"
"}\n";
}
- return buf.str();
+ return tcu::StringTemplate(buf.str()).specialize(args);
}
class SampleMaskCountCase : public SampleMaskBaseCase
{
DE_ASSERT(numTargetSamples != 0);
- std::ostringstream buf;
+ std::ostringstream buf;
+ const bool isES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
+ map<string, string> args;
+ args["GLSL_VERSION_DECL"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
+ args["GLSL_EXTENSION"] = isES32 ? "" : "#extension GL_OES_sample_variables : require";
// test supports only one sample mask word
if (numTargetSamples > 32)
- throw tcu::NotSupportedError("Sample count larger than 32 is not supported.");
+ TCU_THROW(NotSupportedError, "Sample count larger than 32 is not supported.");
// count the number of the bits in gl_SampleMask
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
"layout(location = 0) out mediump vec4 fragColor;\n";
if (m_runMode != RUN_PER_SAMPLE)
"}\n";
}
- return buf.str();
+ return tcu::StringTemplate(buf.str()).specialize(args);
}
class SampleMaskUniqueCase : public SampleMaskBaseCase
{
DE_ASSERT(numTargetSamples != 0);
- std::ostringstream buf;
+ std::ostringstream buf;
+ const bool isES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
+ map<string, string> args;
+ args["GLSL_VERSION_DECL"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
+ args["GLSL_EXTENSION"] = isES32 ? "" : "#extension GL_OES_sample_variables : require";
// test supports only one sample mask word
if (numTargetSamples > 32)
- throw tcu::NotSupportedError("Sample count larger than 32 is not supported.");
+ TCU_THROW(NotSupportedError, "Sample count larger than 32 is not supported.");
// find our sampleID by searching for unique bit.
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
"layout(location = 0) out mediump vec4 fragColor;\n"
"void main (void)\n"
"{\n"
" fragColor = vec4(0.0, encodedSampleId, blue, 1.0);\n"
"}\n";
- return buf.str();
+ return tcu::StringTemplate(buf.str()).specialize(args);
}
bool SampleMaskUniqueCase::verifySampleBuffers (const std::vector<tcu::Surface>& resultBuffers)
for (int sampleNdx = 0; sampleNdx < (int)resultBuffers.size(); ++sampleNdx)
{
const tcu::RGBA color = resultBuffers[sampleNdx].getPixel(x, y);
- maskBitIndices[sampleNdx] = (int)deFloatRound(color.getGreen() / 255.0f * m_numTargetSamples);
+ maskBitIndices[sampleNdx] = (int)deFloatRound((float)color.getGreen() / 255.0f * (float)m_numTargetSamples);
}
// just check there are no two invocations with the same bit index
maskNdxNotUnique = true;
uniquenessOk = false;
- errorMask.setPixel(x, y, tcu::RGBA::red);
+ errorMask.setPixel(x, y, tcu::RGBA::red());
}
}
}
{
DE_ASSERT(numTargetSamples != 0);
- std::ostringstream buf;
+ std::ostringstream buf;
+ const bool isES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
+ map<string, string> args;
+ args["GLSL_VERSION_DECL"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
+ args["GLSL_EXTENSION"] = isES32 ? "" : "#extension GL_OES_sample_variables : require";
// test supports only one sample mask word
if (numTargetSamples > 32)
- throw tcu::NotSupportedError("Sample count larger than 32 is not supported.");
+ TCU_THROW(NotSupportedError, "Sample count larger than 32 is not supported.");
// output min and max sample id
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
"uniform highp uint u_bitSelector;\n"
"layout(location = 0) out mediump vec4 fragColor;\n"
"void main (void)\n"
" fragColor = vec4(float(redBits) / float(31), float(greenBits) / float(63), float(blueBits) / float(31), 1.0);\n"
"}\n";
- return buf.str();
+ return tcu::StringTemplate(buf.str()).specialize(args);
}
bool SampleMaskUniqueSetCase::verifySampleBuffers (const std::vector<tcu::Surface>& resultBuffers)
deUint16 high;
{
- int redBits = (int)deFloatRound(lowColor.getRed() / 255.0f * 31);
- int greenBits = (int)deFloatRound(lowColor.getGreen() / 255.0f * 63);
- int blueBits = (int)deFloatRound(lowColor.getBlue() / 255.0f * 31);
+ int redBits = (int)deFloatRound((float)lowColor.getRed() / 255.0f * 31);
+ int greenBits = (int)deFloatRound((float)lowColor.getGreen() / 255.0f * 63);
+ int blueBits = (int)deFloatRound((float)lowColor.getBlue() / 255.0f * 31);
low = (deUint16)(redBits | (greenBits << 5) | (blueBits << 11));
}
{
- int redBits = (int)deFloatRound(highColor.getRed() / 255.0f * 31);
- int greenBits = (int)deFloatRound(highColor.getGreen() / 255.0f * 63);
- int blueBits = (int)deFloatRound(highColor.getBlue() / 255.0f * 31);
+ int redBits = (int)deFloatRound((float)highColor.getRed() / 255.0f * 31);
+ int greenBits = (int)deFloatRound((float)highColor.getGreen() / 255.0f * 63);
+ int blueBits = (int)deFloatRound((float)highColor.getBlue() / 255.0f * 31);
high = (deUint16)(redBits | (greenBits << 5) | (blueBits << 11));
}
DE_UNREF(numTargetSamples);
std::ostringstream buf;
+ const bool isES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
+ map<string, string> args;
+ args["GLSL_VERSION_DECL"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
+ args["GLSL_EXTENSION"] = isES32 ? "" : "#extension GL_OES_sample_variables : require";
if (m_testMode == TEST_DISCARD)
{
// mask out every other coverage bit
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
"layout(location = 0) out mediump vec4 fragColor;\n"
"void main (void)\n"
"{\n"
{
// inverse every coverage bit
- buf << "#version 310 es\n"
- "#extension GL_OES_sample_variables : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${GLSL_EXTENSION}\n"
"layout(location = 0) out mediump vec4 fragColor;\n"
"uniform highp uint u_mask;\n"
"void main (void)\n"
else
DE_ASSERT(false);
- return buf.str();
+ return tcu::StringTemplate(buf.str()).specialize(args);
}
bool SampleMaskWriteCase::verifyImage (const tcu::Surface& resultImage)