#include "gluCallLogWrapper.hpp"
#include "tcuTestLog.hpp"
#include "tcuRenderTarget.hpp"
+#include "tcuStringTemplate.hpp"
#include "tcuSurface.hpp"
#include "tcuTextureUtil.hpp"
#include "tcuVectorUtil.hpp"
#include "deRandom.hpp"
#include "deStringUtil.hpp"
#include "deSharedPtr.hpp"
+#include "deUniquePtr.hpp"
#include "deString.h"
#include "deMath.h"
return compareTriangleSets(coordsA, coordsB, log, ConstantUnaryPredicate<const Vec3*, true>());
}
-static void checkExtensionSupport (Context& context, const char* extName)
+static void checkGPUShader5Support (Context& context)
{
- if (!context.getContextInfo().isExtensionSupported(extName))
- throw tcu::NotSupportedError(string(extName) + " not supported");
+ const bool supportsES32 = glu::contextSupports(context.getRenderContext().getType(), glu::ApiType::es(3, 2));
+ TCU_CHECK_AND_THROW(NotSupportedError, supportsES32 || context.getContextInfo().isExtensionSupported("GL_EXT_gpu_shader5"), "GL_EXT_gpu_shader5 is not supported");
}
static void checkTessellationSupport (Context& context)
{
- checkExtensionSupport(context, "GL_EXT_tessellation_shader");
+ const bool supportsES32 = glu::contextSupports(context.getRenderContext().getType(), glu::ApiType::es(3, 2));
+ TCU_CHECK_AND_THROW(NotSupportedError, supportsES32 || context.getContextInfo().isExtensionSupported("GL_EXT_tessellation_shader"), "GL_EXT_tessellation_shader is not supported");
+}
+
+static std::string specializeShader(Context& context, const char* code)
+{
+ const glu::ContextType contextType = context.getRenderContext().getType();
+ const glu::GLSLVersion glslVersion = glu::getContextTypeGLSLVersion(contextType);
+ bool supportsES32 = glu::contextSupports(contextType, glu::ApiType::es(3, 2));
+
+ std::map<std::string, std::string> specializationMap;
+
+ specializationMap["GLSL_VERSION_DECL"] = glu::getGLSLVersionDeclaration(glslVersion);
+ specializationMap["GPU_SHADER5_REQUIRE"] = supportsES32 ? "" : "#extension GL_EXT_gpu_shader5 : require";
+ specializationMap["TESSELLATION_SHADER_REQUIRE"] = supportsES32 ? "" : "#extension GL_EXT_tessellation_shader : require";
+
+ return tcu::StringTemplate(code).specialize(specializationMap);
}
// Draw primitives with shared edges and check that no cracks are visible at the shared edges.
checkTessellationSupport(m_context);
if (m_caseType == CASETYPE_PRECISE)
- checkExtensionSupport(m_context, "GL_EXT_gpu_shader5");
+ checkGPUShader5Support(m_context);
checkRenderTargetSize(m_context.getRenderTarget(), RENDER_SIZE);
- m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp vec2 in_v_position;\n"
"in highp float in_v_tessParam;\n"
"{\n"
" in_tc_position = in_v_position;\n"
" in_tc_tessParam = in_v_tessParam;\n"
- "}\n")
+ "}\n");
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
- + string(m_caseType == CASETYPE_PRECISE ? "#extension GL_EXT_gpu_shader5 : require\n" : "") +
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
+ + string(m_caseType == CASETYPE_PRECISE ? "${GPU_SHADER5_REQUIRE}\n" : "") +
"\n"
"layout (vertices = " + string(m_primitiveType == TESSPRIMITIVETYPE_TRIANGLES ? "3" : m_primitiveType == TESSPRIMITIVETYPE_QUADS ? "4" : DE_NULL) + ") out;\n"
"\n"
" gl_TessLevelOuter[2] = 1.0 + 59.0 * 0.5 * (in_tc_tessParam[3] + in_tc_tessParam[1]);\n"
" gl_TessLevelOuter[3] = 1.0 + 59.0 * 0.5 * (in_tc_tessParam[2] + in_tc_tessParam[3]);\n"
: DE_NULL) +
- "}\n")
+ "}\n");
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
- + string(m_caseType == CASETYPE_PRECISE ? "#extension GL_EXT_gpu_shader5 : require\n" : "") +
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
+ + string(m_caseType == CASETYPE_PRECISE ? "${GPU_SHADER5_REQUIRE}\n" : "") +
"\n"
+ getTessellationEvaluationInLayoutString(m_primitiveType, m_spacing) +
"\n"
" pos += float(numBits&1u)*0.04;\n"
"\n"
" gl_Position = vec4(pos, 0.0, 1.0);\n"
- "}\n")
+ "}\n");
- << glu::FragmentSource ("#version 310 es\n"
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = in_f_color;\n"
- "}\n")));
+ "}\n");
+
+ m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))));
m_testCtx.getLog() << *m_program;
if (!m_program->isOk())
checkTessellationSupport(m_context);
checkRenderTargetSize(m_context.getRenderTarget(), RENDER_SIZE);
- m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"void main (void)\n"
"{\n"
- "}\n")
+ "}\n");
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = 1) out;\n"
"\n"
" gl_TessLevelOuter[1] = u_tessLevelOuter1;\n"
" gl_TessLevelOuter[2] = u_tessLevelOuter2;\n"
" gl_TessLevelOuter[3] = u_tessLevelOuter3;\n"
- "}\n")
+ "}\n");
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(m_primitiveType, m_spacing, true) +
"\n"
"{\n"
" out_te_tessCoord = gl_TessCoord;\n"
" gl_Position = vec4(gl_TessCoord.xy*1.6 - 0.8, 0.0, 1.0);\n"
- "}\n")
+ "}\n");
- << glu::FragmentSource ("#version 310 es\n"
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = vec4(1.0);\n"
- "}\n")
+ "}\n");
+ m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))
<< glu::TransformFeedbackVarying ("out_te_tessCoord")
<< glu::TransformFeedbackMode (GL_INTERLEAVED_ATTRIBS)));
checkTessellationSupport(m_context);
checkRenderTargetSize(m_context.getRenderTarget(), RENDER_SIZE);
- m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"void main (void)\n"
"{\n"
- "}\n")
-
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = 1) out;\n"
"\n"
"{\n"
" gl_TessLevelOuter[0] = 1.0;\n"
" gl_TessLevelOuter[1] = u_tessLevelOuter1;\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(TESSPRIMITIVETYPE_ISOLINES, m_spacing, true) +
"\n"
"{\n"
" out_te_tessCoord = gl_TessCoord.x;\n"
" gl_Position = vec4(gl_TessCoord.xy*1.6 - 0.8, 0.0, 1.0);\n"
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = vec4(1.0);\n"
- "}\n")
+ "}\n");
+ m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))
<< glu::TransformFeedbackVarying ("out_te_tessCoord")
<< glu::TransformFeedbackMode (GL_INTERLEAVED_ATTRIBS)));
glu::ProgramSources sources = makeSources(m_primitiveType, m_spacing, "in_tc_position");
DE_ASSERT(sources.sources[glu::SHADERTYPE_TESSELLATION_CONTROL].empty());
- sources << glu::TessellationControlSource( "#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = " + string(m_primitiveType == TESSPRIMITIVETYPE_TRIANGLES ? "3" : "4") + ") out;\n"
"\n"
" gl_TessLevelOuter[3] = u_tessLevelOuter3;\n"
"}\n");
+ sources << glu::TessellationControlSource(specializeShader(m_context, tessellationControlTemplate.c_str()));
+
m_program = SharedPtr<const ShaderProgram>(new glu::ShaderProgram(m_context.getRenderContext(), sources));
}
protected:
void init (void)
{
- checkExtensionSupport(m_context, "GL_EXT_gpu_shader5");
+ checkGPUShader5Support(m_context);
BasicVariousTessLevelsPosAttrCase::init();
}
const glu::ProgramSources makeSources (TessPrimitiveType primitiveType, SpacingMode spacing, const char* vtxOutPosAttrName) const
{
- return glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp vec2 in_v_position;\n"
"\n"
"void main (void)\n"
"{\n"
" " + vtxOutPosAttrName + " = in_v_position;\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
- "#extension GL_EXT_gpu_shader5 : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
+ "${GPU_SHADER5_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(primitiveType, spacing) +
"\n"
" pos += 0.75 * f * fromCenter / (length(fromCenter) + 0.3);\n"
" gl_Position = vec4(pos, 0.0, 1.0);\n"
: DE_NULL) +
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"{\n"
" o_color = vec4(1.0);\n"
"}\n");
+
+ return glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()));
}
};
protected:
const glu::ProgramSources makeSources (TessPrimitiveType primitiveType, SpacingMode spacing, const char* vtxOutPosAttrName) const
{
- return glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp vec2 in_v_position;\n"
"\n"
"void main (void)\n"
"{\n"
" " + vtxOutPosAttrName + " = in_v_position;\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(primitiveType, spacing) +
"\n"
" : phase == 1 ? vec4(0.0, 1.0, 0.0, 1.0)\n"
" : vec4(0.0, 0.0, 1.0, 1.0);\n"
: DE_NULL) +
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"{\n"
" o_color = in_f_color;\n"
"}\n");
+
+ return glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()));
}
};
DE_ASSERT(primitiveType == TESSPRIMITIVETYPE_ISOLINES);
DE_UNREF(primitiveType);
- return glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp vec2 in_v_position;\n"
"\n"
"void main (void)\n"
"{\n"
" " + vtxOutPosAttrName + " = in_v_position;\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(TESSPRIMITIVETYPE_ISOLINES, spacing) +
"\n"
" in_f_color = phase == 0 ? vec4(1.0, 0.0, 0.0, 1.0)\n"
" : phase == 1 ? vec4(0.0, 1.0, 0.0, 1.0)\n"
" : vec4(0.0, 0.0, 1.0, 1.0);\n"
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"{\n"
" o_color = in_f_color;\n"
"}\n");
+
+ return glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()));
}
};
checkTessellationSupport(m_context);
checkRenderTargetSize(m_context.getRenderTarget(), RENDER_SIZE);
- m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"void main (void)\n"
"{\n"
- "}\n")
-
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = 1) out;\n"
"\n"
" gl_TessLevelOuter[1] = 5.0;\n"
" gl_TessLevelOuter[2] = 5.0;\n"
" gl_TessLevelOuter[3] = 5.0;\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(m_primitiveType, m_winding) +
"\n"
"void main (void)\n"
"{\n"
" gl_Position = vec4(gl_TessCoord.xy*2.0 - 1.0, 0.0, 1.0);\n"
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = vec4(1.0);\n"
- "}\n")));
+ "}\n");
+
+ m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))));
m_testCtx.getLog() << *m_program;
if (!m_program->isOk())
const string inSizeStr = de::toString(m_inputPatchSize);
const string outSizeStr = de::toString(m_outputPatchSize);
- m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp float in_v_attr;\n"
"\n"
"void main (void)\n"
"{\n"
" in_tc_attr = in_v_attr;\n"
- "}\n")
-
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = " + outSizeStr + ") out;\n"
"\n"
" gl_TessLevelOuter[1] = 5.0;\n"
" gl_TessLevelOuter[2] = 5.0;\n"
" gl_TessLevelOuter[3] = 5.0;\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(TESSPRIMITIVETYPE_QUADS) +
"\n"
" highp float y = gl_TessCoord.y - in_te_attr[int(round(gl_TessCoord.x*float(" + outSizeStr + "-1)))];\n"
" gl_Position = vec4(x, y, 0.0, 1.0);\n"
" in_f_color = vec4(1.0);\n"
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = in_f_color;\n"
- "}\n")));
+ "}\n");
+
+ m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))));
m_testCtx.getLog() << *m_program;
if (!m_program->isOk())
const string inSizeStr = de::toString(INPUT_PATCH_SIZE);
const string outSizeStr = de::toString(OUTPUT_PATCH_SIZE);
- m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp float in_v_attr;\n"
"\n"
"void main (void)\n"
"{\n"
" in_tc_attr = in_v_attr;\n"
- "}\n")
-
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = " + outSizeStr + ") out;\n"
"\n"
" gl_TessLevelOuter[1] = 6.0;\n"
" gl_TessLevelOuter[2] = 5.0;\n"
" gl_TessLevelOuter[3] = 4.0;\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(TESSPRIMITIVETYPE_QUADS) +
"\n"
: m_caseType == CASETYPE_TESS_LEVEL_OUTER3_TES ? "\tbool ok = abs(gl_TessLevelOuter[3] - 4.0) < 0.1f;\n"
: DE_NULL) +
" in_f_color = ok ? vec4(1.0) : vec4(vec3(0.0), 1.0);\n"
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = in_f_color;\n"
- "}\n")));
+ "}\n");
+
+ m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))));
m_testCtx.getLog() << *m_program;
if (!m_program->isOk())
const string numVertsStr = de::toString(NUM_VERTICES);
- m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp float in_v_attr;\n"
"\n"
"void main (void)\n"
"{\n"
" in_tc_attr = in_v_attr;\n"
- "}\n")
-
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = " + numVertsStr + ") out;\n"
"\n"
" gl_TessLevelOuter[1] = 32.0;\n"
" gl_TessLevelOuter[2] = 32.0;\n"
" gl_TessLevelOuter[3] = 32.0;\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(TESSPRIMITIVETYPE_QUADS) +
"\n"
" highp float y = gl_TessCoord.y - in_te_attr[int(round(gl_TessCoord.x*float(" + numVertsStr + "-1)))];\n"
" gl_Position = vec4(x, y, 0.0, 1.0);\n"
" in_f_blue = abs(in_te_patchAttr - float(" + numVertsStr + "-1));\n"
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = vec4(1.0, 0.0, in_f_blue, 1.0);\n"
- "}\n")));
+ "}\n");
+
+ m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))));
m_testCtx.getLog() << *m_program;
if (!m_program->isOk())
const string floatLit01 = de::floatToString(10.0f / (float)(constantExprCaseNdx + 10), 2);
const int programNdx = (int)m_programs.size();
- m_programs.push_back(Program(windings[windingCaseNdx],
- SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp float in_v_attr;\n"
"out highp float in_tc_attr;\n"
"void main (void)\n"
"{\n"
" in_tc_attr = in_v_attr;\n"
- "}\n")
-
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = " + de::toString(constantExprCaseNdx+1) + ") out;\n"
"\n"
" gl_TessLevelOuter[1] = in_tc_attr[3];\n"
" gl_TessLevelOuter[2] = in_tc_attr[4];\n"
" gl_TessLevelOuter[3] = in_tc_attr[5];\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(m_primitiveType, m_spacing, windings[windingCaseNdx], m_usePointMode) +
"\n"
" gl_Position = vec4(gl_TessCoord.xy*" + floatLit01 + " - in_te_positionOffset + float(gl_PrimitiveID)*0.1, 0.0, 1.0);\n"
" in_f_color = vec4(" + floatLit01 + ");\n"
" out_te_tessCoord = gl_TessCoord;\n"
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = in_f_color;\n"
- "}\n")
+ "}\n");
+ m_programs.push_back(Program(windings[windingCaseNdx],
+ SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))
<< glu::TransformFeedbackVarying ("out_te_tessCoord")
<< glu::TransformFeedbackMode (GL_INTERLEAVED_ATTRIBS)))));
const int programNdx = (int)m_programs.size();
const string floatLit01 = de::floatToString(10.0f / (float)(programNdx + 10), 2);
- m_programs.push_back(Program(winding, usePointMode,
- SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp float in_v_attr;\n"
"out highp float in_tc_attr;\n"
"void main (void)\n"
"{\n"
" in_tc_attr = in_v_attr;\n"
- "}\n")
-
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = " + de::toString(programNdx+1) + ") out;\n"
"\n"
" gl_TessLevelOuter[1] = in_tc_attr[3];\n"
" gl_TessLevelOuter[2] = in_tc_attr[4];\n"
" gl_TessLevelOuter[3] = in_tc_attr[5];\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(m_primitiveType, m_spacing, winding, usePointMode) +
"\n"
" gl_Position = vec4(gl_TessCoord.xy*" + floatLit01 + " - float(gl_PrimitiveID)*0.05, 0.0, 1.0);\n"
" in_f_color = vec4(" + floatLit01 + ");\n"
" out_te_tessCoord = gl_TessCoord;\n"
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = in_f_color;\n"
- "}\n")
+ "}\n");
+ m_programs.push_back(Program(winding, usePointMode,
+ SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))
<< glu::TransformFeedbackVarying ("out_te_tessCoord")
<< glu::TransformFeedbackMode (GL_INTERLEAVED_ATTRIBS)))));
checkTessellationSupport(m_context);
checkRenderTargetSize(m_context.getRenderTarget(), RENDER_SIZE);
- m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp float in_v_attr;\n"
"out highp float in_tc_attr;\n"
"void main (void)\n"
"{\n"
" in_tc_attr = in_v_attr;\n"
- "}\n")
-
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = 1) out;\n"
"\n"
" gl_TessLevelOuter[1] = in_tc_attr[3];\n"
" gl_TessLevelOuter[2] = in_tc_attr[4];\n"
" gl_TessLevelOuter[3] = in_tc_attr[5];\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(m_primitiveType, m_spacing, m_winding, m_usePointMode) +
"\n"
"\n"
" gl_Position = vec4(gl_TessCoord.xy, 0.0, 1.0);\n"
" in_f_color = vec4(1.0);\n"
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = in_f_color;\n"
- "}\n")
+ "}\n");
+ m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))
<< glu::TransformFeedbackVarying ("out_te_tessCoord_isMirrored")
<< glu::TransformFeedbackMode (GL_INTERLEAVED_ATTRIBS)));
checkTessellationSupport(m_context);
checkRenderTargetSize(m_context.getRenderTarget(), RENDER_SIZE);
- m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp float in_v_attr;\n"
"out highp float in_tc_attr;\n"
"void main (void)\n"
"{\n"
" in_tc_attr = in_v_attr;\n"
- "}\n")
-
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = 1) out;\n"
"\n"
" gl_TessLevelOuter[1] = in_tc_attr[3];\n"
" gl_TessLevelOuter[2] = in_tc_attr[4];\n"
" gl_TessLevelOuter[3] = in_tc_attr[5];\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(m_primitiveType, m_spacing, m_winding, m_usePointMode) +
"\n"
" out_te_tessCoord = gl_TessCoord;"
" gl_Position = vec4(gl_TessCoord.xy, 0.0, 1.0);\n"
" in_f_color = vec4(1.0);\n"
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = in_f_color;\n"
- "}\n")
+ "}\n");
+ m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))
<< glu::TransformFeedbackVarying ("out_te_tessCoord")
<< glu::TransformFeedbackMode (GL_INTERLEAVED_ATTRIBS)));
checkTessellationSupport(m_context);
checkRenderTargetSize(m_context.getRenderTarget(), RENDER_SIZE);
- m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp float in_v_attr;\n"
"out highp float in_tc_attr;\n"
"void main (void)\n"
"{\n"
" in_tc_attr = in_v_attr;\n"
- "}\n")
-
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = 1) out;\n"
"\n"
" gl_TessLevelOuter[1] = in_tc_attr[3];\n"
" gl_TessLevelOuter[2] = in_tc_attr[4];\n"
" gl_TessLevelOuter[3] = in_tc_attr[5];\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(m_primitiveType, m_spacing, m_winding, m_usePointMode) +
"\n"
" out_te_output.z = 0.0f;\n") +
" gl_Position = vec4(gl_TessCoord.xy, 0.0, 1.0);\n"
" in_f_color = vec4(1.0);\n"
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = in_f_color;\n"
- "}\n")
+ "}\n");
+ m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))
<< glu::TransformFeedbackVarying ("out_te_output")
<< glu::TransformFeedbackMode (GL_INTERLEAVED_ATTRIBS)));
checkTessellationSupport(m_context);
checkRenderTargetSize(m_context.getRenderTarget(), RENDER_SIZE);
- m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp float in_v_attr;\n"
"out highp float in_tc_attr;\n"
"void main (void)\n"
"{\n"
" in_tc_attr = in_v_attr;\n"
- "}\n")
-
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = 1) out;\n"
"\n"
" gl_TessLevelOuter[1] = in_tc_attr[3];\n"
" gl_TessLevelOuter[2] = in_tc_attr[4];\n"
" gl_TessLevelOuter[3] = in_tc_attr[5];\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(m_primitiveType, m_spacing, m_winding, m_usePointMode) +
"\n"
"{\n"
" out_te_tessCoord = gl_TessCoord;\n"
" gl_Position = vec4(gl_TessCoord.xy*in_te_positionScale + in_te_positionOffset, 0.0, 1.0);\n"
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = vec4(1.0);\n"
- "}\n")
+ "}\n");
+ m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))
<< glu::TransformFeedbackVarying ("out_te_tessCoord")
<< glu::TransformFeedbackMode (GL_INTERLEAVED_ATTRIBS)));
tesStatements += "\t}\n";
}
- m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp float in_v_attr;\n"
"out highp float in_tc_attr;\n"
"void main (void)\n"
"{\n"
" in_tc_attr = in_v_attr;\n"
- "}\n")
-
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = " + de::toString(int(NUM_OUTPUT_VERTICES)) + ") out;\n"
"\n"
" gl_TessLevelOuter[1] = in_tc_attr[3];\n"
" gl_TessLevelOuter[2] = in_tc_attr[4];\n"
" gl_TessLevelOuter[3] = in_tc_attr[5];\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(m_primitiveType) +
"\n"
" in_f_color = allOk ? vec4(0.0, 1.0, 0.0, 1.0)\n"
" : vec4(1.0, 0.0, 0.0, 1.0);\n"
" out_te_firstFailedInputIndex = firstFailedInputIndex;\n"
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = in_f_color;\n"
- "}\n")
+ "}\n");
+ m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))
<< glu::TransformFeedbackVarying ("out_te_firstFailedInputIndex")
<< glu::TransformFeedbackMode (GL_INTERLEAVED_ATTRIBS)));
const string tesIn1 = tcsToTES ? "gl_in[1].gl_Position" : "in_te_attr[1]";
const string tesIn2 = tcsToTES ? "gl_in[2].gl_Position" : "in_te_attr[2]";
- m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource ("#version 310 es\n"
+ std::string vertexShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"in highp vec4 in_v_attr;\n"
+ string(!vsToTCS ? "out highp vec4 in_tc_attr;\n" : "") +
"void main (void)\n"
"{\n"
" " + (vsToTCS ? "gl_Position" : "in_tc_attr") + " = in_v_attr;\n"
- "}\n")
-
- << glu::TessellationControlSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationControlTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
"layout (vertices = 3) out;\n"
"\n"
" gl_TessLevelOuter[1] = 5.0;\n"
" gl_TessLevelOuter[2] = 6.0;\n"
" gl_TessLevelOuter[3] = 7.0;\n"
- "}\n")
-
- << glu::TessellationEvaluationSource ("#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ "}\n");
+ std::string tessellationEvaluationTemplate ("${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"\n"
+ getTessellationEvaluationInLayoutString(TESSPRIMITIVETYPE_TRIANGLES) +
"\n"
" " + tesIn2 + ".z + " + tesIn0 + ".w,\n"
" " + tesIn1 + ".z + " + tesIn2 + ".w,\n"
" 1.0);\n"
- "}\n")
-
- << glu::FragmentSource ("#version 310 es\n"
+ "}\n");
+ std::string fragmentShaderTemplate ("${GLSL_VERSION_DECL}\n"
"\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"\n"
"void main (void)\n"
"{\n"
" o_color = in_f_color;\n"
- "}\n")));
+ "}\n");
+
+ m_program = SharedPtr<const ShaderProgram>(new ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
+ << glu::VertexSource (specializeShader(m_context, vertexShaderTemplate.c_str()))
+ << glu::TessellationControlSource (specializeShader(m_context, tessellationControlTemplate.c_str()))
+ << glu::TessellationEvaluationSource (specializeShader(m_context, tessellationEvaluationTemplate.c_str()))
+ << glu::FragmentSource (specializeShader(m_context, fragmentShaderTemplate.c_str()))));
m_testCtx.getLog() << *m_program;
if (!m_program->isOk())
std::string TessProgramQueryCase::getVertexSource (void) const
{
- return "#version 310 es\n"
+ return "${GLSL_VERSION_DECL}\n"
"void main (void)\n"
"{\n"
" gl_Position = vec4(float(gl_VertexID), float(gl_VertexID / 2), 0.0, 1.0);\n"
std::string TessProgramQueryCase::getFragmentSource (void) const
{
- return "#version 310 es\n"
+ return "${GLSL_VERSION_DECL}\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"void main (void)\n"
"{\n"
std::string TessProgramQueryCase::getTessCtrlSource (const char* globalLayouts) const
{
- return "#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ return "${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
+ std::string(globalLayouts) + ";\n"
"void main (void)\n"
"{\n"
std::string TessProgramQueryCase::getTessEvalSource (const char* globalLayouts) const
{
- return "#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ return "${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
+ std::string(globalLayouts) + ";\n"
"void main (void)\n"
"{\n"
checkTessellationSupport(m_context);
glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource(getVertexSource())
- << glu::FragmentSource(getFragmentSource())
- << glu::TessellationControlSource(getTessCtrlSource("layout(vertices=4) out"))
- << glu::TessellationEvaluationSource(getTessEvalSource("layout(triangles) in")));
+ << glu::VertexSource(specializeShader(m_context, getVertexSource().c_str()))
+ << glu::FragmentSource(specializeShader(m_context, getFragmentSource().c_str()))
+ << glu::TessellationControlSource(specializeShader(m_context, getTessCtrlSource("layout(vertices=4) out").c_str()))
+ << glu::TessellationEvaluationSource(specializeShader(m_context, getTessEvalSource("layout(triangles) in").c_str())));
m_testCtx.getLog() << program;
if (!program.isOk())
const tcu::ScopedLogSection section(m_testCtx.getLog(), "Type", s_modes[ndx].description);
glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource(getVertexSource())
- << glu::FragmentSource(getFragmentSource())
- << glu::TessellationControlSource(getTessCtrlSource("layout(vertices=6) out"))
- << glu::TessellationEvaluationSource(getTessEvalSource(s_modes[ndx].layout)));
+ << glu::VertexSource(specializeShader(m_context, getVertexSource().c_str()))
+ << glu::FragmentSource(specializeShader(m_context, getFragmentSource().c_str()))
+ << glu::TessellationControlSource(specializeShader(m_context, getTessCtrlSource("layout(vertices=6) out").c_str()))
+ << glu::TessellationEvaluationSource(specializeShader(m_context, getTessEvalSource(s_modes[ndx].layout).c_str())));
m_testCtx.getLog() << program;
if (!program.isOk())
const tcu::ScopedLogSection section(m_testCtx.getLog(), "Type", s_modes[ndx].description);
glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource(getVertexSource())
- << glu::FragmentSource(getFragmentSource())
- << glu::TessellationControlSource(getTessCtrlSource("layout(vertices=6) out"))
- << glu::TessellationEvaluationSource(getTessEvalSource(s_modes[ndx].layout)));
+ << glu::VertexSource(specializeShader(m_context, getVertexSource().c_str()))
+ << glu::FragmentSource(specializeShader(m_context, getFragmentSource().c_str()))
+ << glu::TessellationControlSource(specializeShader(m_context, getTessCtrlSource("layout(vertices=6) out").c_str()))
+ << glu::TessellationEvaluationSource(specializeShader(m_context, getTessEvalSource(s_modes[ndx].layout).c_str())));
m_testCtx.getLog() << program;
if (!program.isOk())
const tcu::ScopedLogSection section(m_testCtx.getLog(), "Type", s_modes[ndx].description);
glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource(getVertexSource())
- << glu::FragmentSource(getFragmentSource())
- << glu::TessellationControlSource(getTessCtrlSource("layout(vertices=6) out"))
- << glu::TessellationEvaluationSource(getTessEvalSource(s_modes[ndx].layout)));
+ << glu::VertexSource(specializeShader(m_context, getVertexSource().c_str()))
+ << glu::FragmentSource(specializeShader(m_context, getFragmentSource().c_str()))
+ << glu::TessellationControlSource(specializeShader(m_context, getTessCtrlSource("layout(vertices=6) out").c_str()))
+ << glu::TessellationEvaluationSource(specializeShader(m_context, getTessEvalSource(s_modes[ndx].layout).c_str())));
m_testCtx.getLog() << program;
if (!program.isOk())
const tcu::ScopedLogSection section(m_testCtx.getLog(), "Type", s_modes[ndx].description);
glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource(getVertexSource())
- << glu::FragmentSource(getFragmentSource())
- << glu::TessellationControlSource(getTessCtrlSource("layout(vertices=6) out"))
- << glu::TessellationEvaluationSource(getTessEvalSource(s_modes[ndx].layout)));
+ << glu::VertexSource(specializeShader(m_context, getVertexSource().c_str()))
+ << glu::FragmentSource(specializeShader(m_context, getFragmentSource().c_str()))
+ << glu::TessellationControlSource(specializeShader(m_context, getTessCtrlSource("layout(vertices=6) out").c_str()))
+ << glu::TessellationEvaluationSource(specializeShader(m_context, getTessEvalSource(s_modes[ndx].layout).c_str())));
m_testCtx.getLog() << program;
if (!program.isOk())
tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources()
- << glu::VertexSource(getVertexSource())
- << glu::FragmentSource(getFragmentSource())
- << glu::TessellationControlSource(getTessCtrlSource())
- << glu::TessellationEvaluationSource(getTessEvalSource()));
+ << glu::VertexSource(specializeShader(m_context, getVertexSource().c_str()))
+ << glu::FragmentSource(specializeShader(m_context, getFragmentSource().c_str()))
+ << glu::TessellationControlSource(specializeShader(m_context, getTessCtrlSource().c_str()))
+ << glu::TessellationEvaluationSource(specializeShader(m_context, getTessEvalSource().c_str())));
gl.enableLogging(true);
std::string ReferencedByTessellationQueryCase::getVertexSource (void) const
{
- return "#version 310 es\n"
+ return "${GLSL_VERSION_DECL}\n"
"void main (void)\n"
"{\n"
" gl_Position = vec4(float(gl_VertexID), float(gl_VertexID / 2), 0.0, 1.0);\n"
std::string ReferencedByTessellationQueryCase::getFragmentSource (void) const
{
- return "#version 310 es\n"
+ return "${GLSL_VERSION_DECL}\n"
"layout (location = 0) out mediump vec4 o_color;\n"
"void main (void)\n"
"{\n"
std::string ReferencedByTessellationQueryCase::getTessCtrlSource (void) const
{
std::ostringstream buf;
- buf << "#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"layout(vertices = 3) out;\n"
"uniform highp vec4 " << ((m_isCtrlCase) ? ("u_referenced") : ("u_unreferenced")) << ";\n"
"void main (void)\n"
std::string ReferencedByTessellationQueryCase::getTessEvalSource (void) const
{
std::ostringstream buf;
- buf << "#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ buf << "${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"layout(triangles) in;\n"
"uniform highp vec4 " << ((m_isCtrlCase) ? ("u_unreferenced") : ("u_referenced")) << ";\n"
"void main (void)\n"
IsPerPatchQueryCase::IterateResult IsPerPatchQueryCase::iterate (void)
{
- static const char* const s_controlSource = "#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : require\n"
+ static const char* const s_controlSource = "${GLSL_VERSION_DECL}\n"
+ "${TESSELLATION_SHADER_REQUIRE}\n"
"layout(vertices = 3) out;\n"
"patch out highp vec4 v_perPatch;\n"
"out highp vec4 v_perVertex[];\n"
tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources()
- << glu::TessellationControlSource(s_controlSource)
+ << glu::TessellationControlSource(specializeShader(m_context, s_controlSource))
<< glu::ProgramSeparable(true));
gl.enableLogging(true);
}
{
- TestCaseGroup* const negativeGroup = new TestCaseGroup(m_context, "negative", "Negative cases");
- gls::ShaderLibrary shaderLibrary (m_testCtx, m_context.getRenderContext(), m_context.getContextInfo());
- const std::vector<tcu::TestNode*> children = shaderLibrary.loadShaderFile("shaders/tessellation_negative_user_defined_io.test");
+ de::MovePtr<TestCaseGroup> negativeGroup (new TestCaseGroup(m_context, "negative", "Negative cases"));
+
+ {
+ de::MovePtr<TestCaseGroup> es31Group (new TestCaseGroup(m_context, "es31", "GLSL ES 3.1 Negative cases"));
+ gls::ShaderLibrary shaderLibrary (m_testCtx, m_context.getRenderContext(), m_context.getContextInfo());
+ const std::vector<tcu::TestNode*> children = shaderLibrary.loadShaderFile("shaders/es31/tessellation_negative_user_defined_io.test");
- userDefinedIOGroup->addChild(negativeGroup);
+ for (int i = 0; i < (int)children.size(); i++)
+ es31Group->addChild(children[i]);
+
+ negativeGroup->addChild(es31Group.release());
+ }
+
+ {
+ de::MovePtr<TestCaseGroup> es32Group (new TestCaseGroup(m_context, "es32", "GLSL ES 3.2 Negative cases"));
+ gls::ShaderLibrary shaderLibrary (m_testCtx, m_context.getRenderContext(), m_context.getContextInfo());
+ const std::vector<tcu::TestNode*> children = shaderLibrary.loadShaderFile("shaders/es32/tessellation_negative_user_defined_io.test");
+
+ for (int i = 0; i < (int)children.size(); i++)
+ es32Group->addChild(children[i]);
+
+ negativeGroup->addChild(es32Group.release());
+ }
- for (int i = 0; i < (int)children.size(); i++)
- negativeGroup->addChild(children[i]);
+ userDefinedIOGroup->addChild(negativeGroup.release());
}
}
}