From c611ca59373ed08331cf92246375c0751a268072 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jarkko=20P=C3=B6yry?= Date: Tue, 9 Jun 2015 19:08:33 -0700 Subject: [PATCH] Add negative tests for explicit TCS-TES varying arrays. Bug: 21737242 Change-Id: I27cd6defd9185698f4861e69f894e7bb669088b0 --- android/cts/master/src/gles31-new-tests.txt | 5 + .../tessellation_negative_user_defined_io.test | 184 +++++++++++++++++++++ modules/glshared/glsShaderLibraryCase.cpp | 49 ++++-- scripts/build_android_mustpass.py | 1 + 4 files changed, 227 insertions(+), 12 deletions(-) create mode 100644 android/cts/master/src/gles31-new-tests.txt diff --git a/android/cts/master/src/gles31-new-tests.txt b/android/cts/master/src/gles31-new-tests.txt new file mode 100644 index 0000000..85003ca --- /dev/null +++ b/android/cts/master/src/gles31-new-tests.txt @@ -0,0 +1,5 @@ +# Feature Request 21737242 +dEQP-GLES31.functional.tessellation.user_defined_io.negative.per_vertex_incorrect_control_explicit_output_array_size_1 +dEQP-GLES31.functional.tessellation.user_defined_io.negative.per_vertex_incorrect_control_explicit_output_array_size_2 +dEQP-GLES31.functional.tessellation.user_defined_io.negative.per_vertex_incorrect_control_explicit_output_array_size_3 +dEQP-GLES31.functional.tessellation.user_defined_io.negative.per_vertex_incorrect_eval_explicit_input_array_size diff --git a/data/gles31/shaders/tessellation_negative_user_defined_io.test b/data/gles31/shaders/tessellation_negative_user_defined_io.test index 36bd5e7..32ae315 100644 --- a/data/gles31/shaders/tessellation_negative_user_defined_io.test +++ b/data/gles31/shaders/tessellation_negative_user_defined_io.test @@ -114,3 +114,187 @@ case per_patch_structs_containing_arrays } "" end + +case per_vertex_incorrect_control_explicit_output_array_size_1 + version 310 es + desc "Incorrectly sized tessellation control output array" + expect compile_or_link_fail + require extension { "GL_OES_tessellation_shader" | "GL_EXT_tessellation_shader" } in { tessellation_control, tessellation_evaluation } + vertex "" + #version 310 es + ${VERTEX_DECLARATIONS} + void main() + { + ${VERTEX_OUTPUT} + } + "" + tessellation_control "" + #version 310 es + ${TESSELLATION_CONTROL_DECLARATIONS} + out highp float varyingArray[3]; // size is not equal to gl_MaxPatchVertices + void main() + { + varyingArray[gl_InvocationID] = gl_in[0].gl_Position[gl_InvocationID]; + ${TESSELLATION_CONTROL_OUTPUT} + } + "" + tessellation_evaluation "" + #version 310 es + ${TESSELLATION_EVALUATION_DECLARATIONS} + in highp float varyingArray[gl_MaxPatchVertices]; // size is correct + out mediump float te_out; + void main() + { + te_out = varyingArray[0] * gl_TessCoord.x + varyingArray[1] * gl_TessCoord.y + varyingArray[2]; + ${TESSELLATION_EVALUATION_OUTPUT} + } + "" + fragment "" + #version 310 es + precision mediump float; + ${FRAGMENT_DECLARATIONS} + in mediump float te_out; + void main() + { + ${FRAG_COLOR} = vec4(te_out); + } + "" +end + +case per_vertex_incorrect_control_explicit_output_array_size_2 + version 310 es + desc "Incorrectly sized tessellation control output array" + expect compile_or_link_fail + require extension { "GL_OES_tessellation_shader" | "GL_EXT_tessellation_shader" } in { tessellation_control, tessellation_evaluation } + vertex "" + #version 310 es + ${VERTEX_DECLARATIONS} + void main() + { + ${VERTEX_OUTPUT} + } + "" + tessellation_control "" + #version 310 es + ${TESSELLATION_CONTROL_DECLARATIONS} + out highp float varyingArray[gl_MaxPatchVertices]; // size does not match layout declaration + void main() + { + varyingArray[gl_InvocationID] = gl_in[0].gl_Position[gl_InvocationID]; + ${TESSELLATION_CONTROL_OUTPUT} + } + "" + tessellation_evaluation "" + #version 310 es + ${TESSELLATION_EVALUATION_DECLARATIONS} + in highp float varyingArray[gl_MaxPatchVertices]; // size is correct + out mediump float te_out; + void main() + { + te_out = varyingArray[0] * gl_TessCoord.x + varyingArray[1] * gl_TessCoord.y + varyingArray[2]; + ${TESSELLATION_EVALUATION_OUTPUT} + } + "" + fragment "" + #version 310 es + precision mediump float; + ${FRAGMENT_DECLARATIONS} + in mediump float te_out; + void main() + { + ${FRAG_COLOR} = vec4(te_out); + } + "" +end + +case per_vertex_incorrect_control_explicit_output_array_size_3 + version 310 es + desc "Incorrectly sized tessellation control output array" + expect compile_or_link_fail + require extension { "GL_OES_tessellation_shader" | "GL_EXT_tessellation_shader" } in { tessellation_control, tessellation_evaluation } + vertex "" + #version 310 es + ${VERTEX_DECLARATIONS} + void main() + { + ${VERTEX_OUTPUT} + } + "" + tessellation_control "" + #version 310 es + ${TESSELLATION_CONTROL_DECLARATIONS} + out highp float varyingArray[${GL_MAX_PATCH_VERTICES}]; // size does not match layout declaration + void main() + { + varyingArray[gl_InvocationID] = gl_in[0].gl_Position[gl_InvocationID]; + ${TESSELLATION_CONTROL_OUTPUT} + } + "" + tessellation_evaluation "" + #version 310 es + ${TESSELLATION_EVALUATION_DECLARATIONS} + in highp float varyingArray[gl_MaxPatchVertices]; // size is correct + out mediump float te_out; + void main() + { + te_out = varyingArray[0] * gl_TessCoord.x + varyingArray[1] * gl_TessCoord.y + varyingArray[2]; + ${TESSELLATION_EVALUATION_OUTPUT} + } + "" + fragment "" + #version 310 es + precision mediump float; + ${FRAGMENT_DECLARATIONS} + in mediump float te_out; + void main() + { + ${FRAG_COLOR} = vec4(te_out); + } + "" +end + +case per_vertex_incorrect_eval_explicit_input_array_size + version 310 es + desc "Incorrectly sized tessellation control output array" + expect compile_or_link_fail + require extension { "GL_OES_tessellation_shader" | "GL_EXT_tessellation_shader" } in { tessellation_control, tessellation_evaluation } + vertex "" + #version 310 es + ${VERTEX_DECLARATIONS} + void main() + { + ${VERTEX_OUTPUT} + } + "" + tessellation_control "" + #version 310 es + ${TESSELLATION_CONTROL_DECLARATIONS} + out highp float varyingArray[]; + void main() + { + varyingArray[gl_InvocationID] = gl_in[0].gl_Position[gl_InvocationID]; + ${TESSELLATION_CONTROL_OUTPUT} + } + "" + tessellation_evaluation "" + #version 310 es + ${TESSELLATION_EVALUATION_DECLARATIONS} + in highp float varyingArray[3]; // size is not equal to gl_MaxPatchVertices + out mediump float te_out; + void main() + { + te_out = varyingArray[0] * gl_TessCoord.x + varyingArray[1] * gl_TessCoord.y + varyingArray[2]; + ${TESSELLATION_EVALUATION_OUTPUT} + } + "" + fragment "" + #version 310 es + precision mediump float; + ${FRAGMENT_DECLARATIONS} + in mediump float te_out; + void main() + { + ${FRAG_COLOR} = vec4(te_out); + } + "" +end diff --git a/modules/glshared/glsShaderLibraryCase.cpp b/modules/glshared/glsShaderLibraryCase.cpp index 7a4e366..a37bb47 100644 --- a/modules/glshared/glsShaderLibraryCase.cpp +++ b/modules/glshared/glsShaderLibraryCase.cpp @@ -85,6 +85,17 @@ static inline bool supportsFragmentHighp (glu::GLSLVersion version) return version != glu::GLSL_VERSION_100_ES; } +static int queryGLInt (const glu::RenderContext& renderCtx, deUint32 pname) +{ + const glw::Functions& gl = renderCtx.getFunctions(); + glw::GLint value = 0; + + gl.getIntegerv(pname, &value); + GLU_EXPECT_NO_ERROR(gl.getError(), ("query " + de::toString(glu::getGettableStateStr(pname))).c_str()); + + return value; +} + ShaderCase::ValueBlock::ValueBlock (void) : arrayLength(0) { @@ -1493,7 +1504,7 @@ string ShaderCase::specializeFragmentShader (const char* src, const ValueBlock& return withExt; } -static map generateVertexSpecialization (glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock) +static map generateVertexSpecialization (const glu::RenderContext& renderCtx, glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock) { const bool usesInout = usesShaderInoutQualifiers(targetVersion); const char* vtxIn = usesInout ? "in" : "attribute"; @@ -1501,6 +1512,8 @@ static map generateVertexSpecialization (glu::GLSLVersion target ostringstream setup; map params; + DE_UNREF(renderCtx); + decl << vtxIn << " highp vec4 dEQP_Position;\n"; for (int ndx = 0; ndx < (int)valueBlock.values.size(); ndx++) @@ -1534,7 +1547,7 @@ static map generateVertexSpecialization (glu::GLSLVersion target return params; } -static map generateFragmentSpecialization (glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock) +static map generateFragmentSpecialization (const glu::RenderContext& renderCtx, glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock) { const bool usesInout = usesShaderInoutQualifiers(targetVersion); const bool customColorOut = usesInout; @@ -1543,6 +1556,8 @@ static map generateFragmentSpecialization (glu::GLSLVersion targ ostringstream output; map params; + DE_UNREF(renderCtx); + genCompareFunctions(decl, valueBlock, false); genCompareOp(output, fragColor, valueBlock, "", DE_NULL); @@ -1573,11 +1588,12 @@ static map generateFragmentSpecialization (glu::GLSLVersion targ return params; } -static map generateGeometrySpecialization (glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock) +static map generateGeometrySpecialization (const glu::RenderContext& renderCtx, glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock) { ostringstream decl; map params; + DE_UNREF(renderCtx); DE_UNREF(targetVersion); decl << "layout (triangles) in;\n"; @@ -1601,7 +1617,7 @@ static map generateGeometrySpecialization (glu::GLSLVersion targ return params; } -static map generateTessControlSpecialization (glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock) +static map generateTessControlSpecialization (const glu::RenderContext& renderCtx, glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock) { ostringstream decl; ostringstream output; @@ -1635,10 +1651,11 @@ static map generateTessControlSpecialization (glu::GLSLVersion t params.insert(pair("TESSELLATION_CONTROL_DECLARATIONS", decl.str())); params.insert(pair("TESSELLATION_CONTROL_OUTPUT", output.str())); + params.insert(pair("GL_MAX_PATCH_VERTICES", de::toString(queryGLInt(renderCtx, GL_MAX_PATCH_VERTICES)))); return params; } -static map generateTessEvalSpecialization (glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock) +static map generateTessEvalSpecialization (const glu::RenderContext& renderCtx, glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock) { ostringstream decl; ostringstream output; @@ -1666,14 +1683,22 @@ static map generateTessEvalSpecialization (glu::GLSLVersion targ params.insert(pair("TESSELLATION_EVALUATION_DECLARATIONS", decl.str())); params.insert(pair("TESSELLATION_EVALUATION_OUTPUT", output.str())); + params.insert(pair("GL_MAX_PATCH_VERTICES", de::toString(queryGLInt(renderCtx, GL_MAX_PATCH_VERTICES)))); return params; } -static void specializeShaders (glu::ProgramSources& dst, glu::ShaderType shaderType, const std::vector& sources, const ShaderCase::ValueBlock& valueBlock, glu::GLSLVersion targetVersion, const std::vector& requirements, std::map (*specializationGenerator)(glu::GLSLVersion, const ShaderCase::ValueBlock&)) +static void specializeShaders (const glu::RenderContext& renderCtx, + glu::ProgramSources& dst, + glu::ShaderType shaderType, + const std::vector& sources, + const ShaderCase::ValueBlock& valueBlock, + glu::GLSLVersion targetVersion, + const std::vector& requirements, + std::map (*specializationGenerator)(const glu::RenderContext&, glu::GLSLVersion, const ShaderCase::ValueBlock&)) { if (!sources.empty()) { - const std::map specializationParams = specializationGenerator(targetVersion, valueBlock); + const std::map specializationParams = specializationGenerator(renderCtx, targetVersion, valueBlock); for (int ndx = 0; ndx < (int)sources.size(); ++ndx) { @@ -1688,27 +1713,27 @@ static void specializeShaders (glu::ProgramSources& dst, glu::ShaderType shaderT void ShaderCase::specializeVertexShaders (glu::ProgramSources& dst, const std::vector& sources, const ValueBlock& valueBlock, const std::vector& requirements) const { - specializeShaders(dst, glu::SHADERTYPE_VERTEX, sources, valueBlock, m_targetVersion, requirements, generateVertexSpecialization); + specializeShaders(m_renderCtx, dst, glu::SHADERTYPE_VERTEX, sources, valueBlock, m_targetVersion, requirements, generateVertexSpecialization); } void ShaderCase::specializeFragmentShaders (glu::ProgramSources& dst, const std::vector& sources, const ValueBlock& valueBlock, const std::vector& requirements) const { - specializeShaders(dst, glu::SHADERTYPE_FRAGMENT, sources, valueBlock, m_targetVersion, requirements, generateFragmentSpecialization); + specializeShaders(m_renderCtx, dst, glu::SHADERTYPE_FRAGMENT, sources, valueBlock, m_targetVersion, requirements, generateFragmentSpecialization); } void ShaderCase::specializeGeometryShaders (glu::ProgramSources& dst, const std::vector& sources, const ValueBlock& valueBlock, const std::vector& requirements) const { - specializeShaders(dst, glu::SHADERTYPE_GEOMETRY, sources, valueBlock, m_targetVersion, requirements, generateGeometrySpecialization); + specializeShaders(m_renderCtx, dst, glu::SHADERTYPE_GEOMETRY, sources, valueBlock, m_targetVersion, requirements, generateGeometrySpecialization); } void ShaderCase::specializeTessControlShaders (glu::ProgramSources& dst, const std::vector& sources, const ValueBlock& valueBlock, const std::vector& requirements) const { - specializeShaders(dst, glu::SHADERTYPE_TESSELLATION_CONTROL, sources, valueBlock, m_targetVersion, requirements, generateTessControlSpecialization); + specializeShaders(m_renderCtx, dst, glu::SHADERTYPE_TESSELLATION_CONTROL, sources, valueBlock, m_targetVersion, requirements, generateTessControlSpecialization); } void ShaderCase::specializeTessEvalShaders (glu::ProgramSources& dst, const std::vector& sources, const ValueBlock& valueBlock, const std::vector& requirements) const { - specializeShaders(dst, glu::SHADERTYPE_TESSELLATION_EVALUATION, sources, valueBlock, m_targetVersion, requirements, generateTessEvalSpecialization); + specializeShaders(m_renderCtx, dst, glu::SHADERTYPE_TESSELLATION_EVALUATION, sources, valueBlock, m_targetVersion, requirements, generateTessEvalSpecialization); } void ShaderCase::dumpValues (const ValueBlock& valueBlock, int arrayNdx) diff --git a/scripts/build_android_mustpass.py b/scripts/build_android_mustpass.py index 8f987f7..d81362b 100644 --- a/scripts/build_android_mustpass.py +++ b/scripts/build_android_mustpass.py @@ -488,6 +488,7 @@ MASTER_GLES31_COMMON_FILTERS = [ exclude("gles31-hw-issues.txt"), exclude("gles31-test-issues.txt"), exclude("gles31-spec-issues.txt"), + exclude("gles31-new-tests.txt"), ] MASTER_GLES31_PKG = Package(module = GLES31_MODULE, configurations = [ # Master -- 2.7.4