From: Michael Hadley Date: Tue, 14 Mar 2017 15:42:34 +0000 (+0000) Subject: Add negative OES_sample_variables tests X-Git-Tag: upstream/0.1.0~150^2~1^2~25 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d30cb292941b7ab98bf84048c72a11bed1029795;p=platform%2Fupstream%2FVK-GL-CTS.git Add negative OES_sample_variables tests New Tests: - dEQP-GLES31.functional.debug.negative_coverage.callbacks.oes_sample_variables.* - dEQP-GLES31.functional.debug.negative_coverage.log.oes_sample_variables.* - dEQP-GLES31.functional.debug.negative_coverage.get_error.oes_sample_variables.* Change-Id: I83bf9b48ca0ac7133419099b1a54ebc4d1cacf20 --- diff --git a/android/cts/master/gles31-master.txt b/android/cts/master/gles31-master.txt index 3d99919..f19e50a 100644 --- a/android/cts/master/gles31-master.txt +++ b/android/cts/master/gles31-master.txt @@ -16804,6 +16804,11 @@ dEQP-GLES31.functional.debug.negative_coverage.callbacks.tessellation.invalid_pr dEQP-GLES31.functional.debug.negative_coverage.callbacks.tessellation.get_programiv dEQP-GLES31.functional.debug.negative_coverage.callbacks.tessellation.invalid_program_queries dEQP-GLES31.functional.debug.negative_coverage.callbacks.tessellation.tessellation_control_invalid_vertex_count +dEQP-GLES31.functional.debug.negative_coverage.callbacks.oes_sample_variables.write_to_read_only_types +dEQP-GLES31.functional.debug.negative_coverage.callbacks.oes_sample_variables.access_built_in_types_inside_other_shaders +dEQP-GLES31.functional.debug.negative_coverage.callbacks.oes_sample_variables.index_outside_sample_mask_range +dEQP-GLES31.functional.debug.negative_coverage.callbacks.oes_sample_variables.access_built_in_types_without_extension +dEQP-GLES31.functional.debug.negative_coverage.callbacks.oes_sample_variables.redeclare_built_in_types dEQP-GLES31.functional.debug.negative_coverage.callbacks.compute.program_not_active dEQP-GLES31.functional.debug.negative_coverage.callbacks.compute.invalid_program_query dEQP-GLES31.functional.debug.negative_coverage.callbacks.compute.invalid_dispatch_compute_indirect @@ -17295,6 +17300,11 @@ dEQP-GLES31.functional.debug.negative_coverage.log.tessellation.invalid_program_ dEQP-GLES31.functional.debug.negative_coverage.log.tessellation.get_programiv dEQP-GLES31.functional.debug.negative_coverage.log.tessellation.invalid_program_queries dEQP-GLES31.functional.debug.negative_coverage.log.tessellation.tessellation_control_invalid_vertex_count +dEQP-GLES31.functional.debug.negative_coverage.log.oes_sample_variables.write_to_read_only_types +dEQP-GLES31.functional.debug.negative_coverage.log.oes_sample_variables.access_built_in_types_inside_other_shaders +dEQP-GLES31.functional.debug.negative_coverage.log.oes_sample_variables.index_outside_sample_mask_range +dEQP-GLES31.functional.debug.negative_coverage.log.oes_sample_variables.access_built_in_types_without_extension +dEQP-GLES31.functional.debug.negative_coverage.log.oes_sample_variables.redeclare_built_in_types dEQP-GLES31.functional.debug.negative_coverage.log.compute.program_not_active dEQP-GLES31.functional.debug.negative_coverage.log.compute.invalid_program_query dEQP-GLES31.functional.debug.negative_coverage.log.compute.invalid_dispatch_compute_indirect @@ -17784,6 +17794,11 @@ dEQP-GLES31.functional.debug.negative_coverage.get_error.tessellation.invalid_pr dEQP-GLES31.functional.debug.negative_coverage.get_error.tessellation.get_programiv dEQP-GLES31.functional.debug.negative_coverage.get_error.tessellation.invalid_program_queries dEQP-GLES31.functional.debug.negative_coverage.get_error.tessellation.tessellation_control_invalid_vertex_count +dEQP-GLES31.functional.debug.negative_coverage.get_error.oes_sample_variables.write_to_read_only_types +dEQP-GLES31.functional.debug.negative_coverage.get_error.oes_sample_variables.access_built_in_types_inside_other_shaders +dEQP-GLES31.functional.debug.negative_coverage.get_error.oes_sample_variables.index_outside_sample_mask_range +dEQP-GLES31.functional.debug.negative_coverage.get_error.oes_sample_variables.access_built_in_types_without_extension +dEQP-GLES31.functional.debug.negative_coverage.get_error.oes_sample_variables.redeclare_built_in_types dEQP-GLES31.functional.debug.negative_coverage.get_error.compute.program_not_active dEQP-GLES31.functional.debug.negative_coverage.get_error.compute.invalid_program_query dEQP-GLES31.functional.debug.negative_coverage.get_error.compute.invalid_dispatch_compute_indirect diff --git a/modules/gles31/functional/CMakeLists.txt b/modules/gles31/functional/CMakeLists.txt index bf566fd..f9f21c7 100644 --- a/modules/gles31/functional/CMakeLists.txt +++ b/modules/gles31/functional/CMakeLists.txt @@ -157,6 +157,8 @@ set(DEQP_GLES31_FUNCTIONAL_SRCS es31fNegativeShaderFunctionTests.hpp es31fNegativeShaderDirectiveTests.cpp es31fNegativeShaderDirectiveTests.hpp + es31fNegativeSampleVariablesTests.hpp + es31fNegativeSampleVariablesTests.cpp es31fNegativePreciseTests.cpp es31fNegativePreciseTests.hpp es31fNegativeAdvancedBlendEquationTests.cpp diff --git a/modules/gles31/functional/es31fDebugTests.cpp b/modules/gles31/functional/es31fDebugTests.cpp index f2e65b3..242974b 100644 --- a/modules/gles31/functional/es31fDebugTests.cpp +++ b/modules/gles31/functional/es31fDebugTests.cpp @@ -40,6 +40,7 @@ #include "es31fNegativeShaderStorageTests.hpp" #include "es31fNegativeTessellationTests.hpp" #include "es31fNegativeComputeTests.hpp" +#include "es31fNegativeSampleVariablesTests.hpp" #include "deUniquePtr.hpp" #include "deRandom.hpp" @@ -2961,6 +2962,7 @@ void DebugTests::init (void) const vector preciseFuncs = wrapCoreFunctions(NegativeTestShared::getNegativePreciseTestFunctions()); const vector advancedBlendFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeAdvancedBlendEquationTestFunctions()); const vector shaderStorageFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeShaderStorageTestFunctions()); + const vector sampleVariablesFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeSampleVariablesTestFunctions()); const vector computeFuncs = wrapCoreFunctions(NegativeTestShared::getNegativeComputeTestFunctions()); const vector externalFuncs = getUserMessageFuncs(); @@ -3070,6 +3072,7 @@ void DebugTests::init (void) host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "advanced_blend", "Negative Advanced Blend Equation Cases", advancedBlendFuncs)); host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "shader_storage", "Negative Shader Storage Cases", shaderStorageFuncs)); host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "tessellation", "Negative Tessellation Cases", tessellationFuncs)); + host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "oes_sample_variables", "Negative Sample Variables Cases", sampleVariablesFuncs)); host->addChild(createChildCases(CASETYPE_CALLBACK, m_context, "compute", "Negative Compute Cases", computeFuncs)); } @@ -3096,6 +3099,7 @@ void DebugTests::init (void) host->addChild(createChildCases(CASETYPE_LOG, m_context, "advanced_blend", "Negative Advanced Blend Equation Cases", advancedBlendFuncs)); host->addChild(createChildCases(CASETYPE_LOG, m_context, "shader_storage", "Negative Shader Storage Cases", shaderStorageFuncs)); host->addChild(createChildCases(CASETYPE_LOG, m_context, "tessellation", "Negative Tessellation Cases", tessellationFuncs)); + host->addChild(createChildCases(CASETYPE_LOG, m_context, "oes_sample_variables", "Negative Sample Variables Cases", sampleVariablesFuncs)); host->addChild(createChildCases(CASETYPE_LOG, m_context, "compute", "Negative Compute Cases", computeFuncs)); } @@ -3122,6 +3126,7 @@ void DebugTests::init (void) host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "advanced_blend", "Negative Advanced Blend Equation Cases", advancedBlendFuncs)); host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "shader_storage", "Negative Shader Storage Cases", shaderStorageFuncs)); host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "tessellation", "Negative Tessellation Cases", tessellationFuncs)); + host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "oes_sample_variables", "Negative Sample Variables Cases", sampleVariablesFuncs)); host->addChild(createChildCases(CASETYPE_GETERROR, m_context, "compute", "Negative Compute Cases", computeFuncs)); } } diff --git a/modules/gles31/functional/es31fNegativeSampleVariablesTests.cpp b/modules/gles31/functional/es31fNegativeSampleVariablesTests.cpp new file mode 100644 index 0000000..ea68a5a --- /dev/null +++ b/modules/gles31/functional/es31fNegativeSampleVariablesTests.cpp @@ -0,0 +1,359 @@ +/*------------------------------------------------------------------------- + * drawElements Quality Program OpenGL ES 3.1 Module + * ------------------------------------------------- + * + * Copyright 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *//*! + * \file + * \brief Negative Sample Variables Tests + *//*--------------------------------------------------------------------*/ + +#include "es31fNegativeSampleVariablesTests.hpp" +#include "gluShaderProgram.hpp" + +namespace deqp +{ +namespace gles31 +{ +namespace Functional +{ +namespace NegativeTestShared +{ +namespace +{ + +enum ExpectResult +{ + EXPECT_RESULT_PASS = 0, + EXPECT_RESULT_FAIL, + EXPECT_RESULT_LAST +}; + +void verifyShader (NegativeTestContext& ctx, glu::ShaderType shaderType, std::string shaderSource, ExpectResult expect) +{ + DE_ASSERT(expect >= EXPECT_RESULT_PASS && expect < EXPECT_RESULT_LAST); + + tcu::TestLog& log = ctx.getLog(); + bool testFailed = false; + const char* const source = shaderSource.c_str(); + const int length = (int) shaderSource.size(); + glu::Shader shader (ctx.getRenderContext(), shaderType); + std::string message; + + shader.setSources(1, &source, &length); + shader.compile(); + + log << shader; + + if (expect == EXPECT_RESULT_PASS) + { + testFailed = !shader.getCompileStatus(); + message = "Shader did not compile."; + } + else + { + testFailed = shader.getCompileStatus(); + message = "Shader was not expected to compile."; + } + + if (testFailed) + { + log << tcu::TestLog::Message << message << tcu::TestLog::EndMessage; + ctx.fail(message); + } +} + +std::string getVersionAndExtension (NegativeTestContext& ctx) +{ + const bool isES32 = contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)); + const glu::GLSLVersion version = isES32 ? glu::GLSL_VERSION_320_ES : glu::GLSL_VERSION_310_ES; + + std::string versionAndExtension = glu::getGLSLVersionDeclaration(version); + versionAndExtension += " \n"; + + if (!isES32) + versionAndExtension += "#extension GL_OES_sample_variables : require \n"; + + return versionAndExtension; +} + +void checkSupported (NegativeTestContext& ctx) +{ + const bool isES32 = contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)); + + if (!isES32 && !ctx.isExtensionSupported("GL_OES_sample_variables")) + TCU_THROW(NotSupportedError, "GL_OES_sample_variables is not supported."); +} + +void write_to_read_only_types (NegativeTestContext& ctx) +{ + checkSupported(ctx); + + std::ostringstream shader; + + struct testConfig + { + std::string builtInType; + std::string varyingCheck; + } testConfigs[] = + { + {"gl_SampleID", " lowp int writeValue = 1; \n gl_SampleID = writeValue; \n"}, + {"gl_SamplePosition", " mediump vec2 writeValue = vec2(1.0f, 1.0f); \n gl_SamplePosition = writeValue; \n"}, + {"gl_SampleMaskIn", " lowp int writeValue = 1; \n gl_SampleMaskIn[0] = writeValue; \n"} + }; + + for (int idx = 0; idx < DE_LENGTH_OF_ARRAY(testConfigs); idx++) + { + shader.str(""); + shader + << getVersionAndExtension(ctx) + << "layout (location = 0) out mediump vec4 fs_color; \n" + << "void main() \n" + << "{ \n" + << testConfigs[idx].varyingCheck + << " fs_color = vec4(1.0f, 0.0f, 0.0f, 1.0f); \n" + << "} \n"; + + ctx.beginSection("OES_sample_variables: trying to write to built-in read-only variable" + testConfigs[idx].builtInType); + verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, shader.str(), EXPECT_RESULT_FAIL); + ctx.endSection(); + } +} + +void access_built_in_types_inside_other_shaders (NegativeTestContext& ctx) +{ + checkSupported(ctx); + + std::ostringstream shader; + + struct testConfig + { + std::string builtInType; + std::string varyingCheck; + } testConfigs[] = + { + {"gl_SampleID", " lowp int writeValue = 1; \n gl_SampleID = writeValue; \n"}, + {"gl_SamplePosition", " mediump vec2 writeValue = vec2(1.0f, 1.0f); \n gl_SamplePosition = writeValue; \n"}, + {"gl_SampleMaskIn", " lowp int writeValue = 1; \n gl_SampleMaskIn[0] = writeValue; \n"}, + {"gl_SampleMask", " highp int readValue = gl_SampleMask[0]; \n"}, + }; + + for (int idx = 0; idx < DE_LENGTH_OF_ARRAY(testConfigs); idx++) + { + shader.str(""); + shader + << getVersionAndExtension(ctx) + << "void main () \n" + << "{ \n" + << testConfigs[idx].varyingCheck + << " gl_Position = vec4(1.0f, 0.0f, 0.0f , 1.0f); \n" + << "} \n"; + + ctx.beginSection("OES_sample_variables: trying to use fragment shader built-in sampler variable " + testConfigs[idx].builtInType + " inside vertex shader"); + verifyShader(ctx, glu::SHADERTYPE_VERTEX, shader.str(), EXPECT_RESULT_FAIL); + ctx.endSection(); + } + + for (int idx = 0; idx < DE_LENGTH_OF_ARRAY(testConfigs); idx++) + { + shader.str(""); + shader + << getVersionAndExtension(ctx) + << "layout (vertices = 3) out; \n" + << "void main () \n" + << "{ \n" + << testConfigs[idx].varyingCheck + << "} \n"; + + ctx.beginSection("OES_sample_variables: trying to use fragment shader built-in sampler variable " + testConfigs[idx].builtInType + " inside tessellation control shader"); + verifyShader(ctx, glu::SHADERTYPE_TESSELLATION_CONTROL, shader.str(), EXPECT_RESULT_FAIL); + ctx.endSection(); + } + + for (int idx = 0; idx < DE_LENGTH_OF_ARRAY(testConfigs); idx++) + { + shader.str(""); + shader + << getVersionAndExtension(ctx) + << "layout (triangles, equal_spacing, ccw) in; \n" + << "void main () \n" + << "{ \n" + << testConfigs[idx].varyingCheck + << "} \n"; + + ctx.beginSection("OES_sample_variables: trying to use fragment shader built-in sampler variable " + testConfigs[idx].builtInType + " inside tessellation evaluation shader"); + verifyShader(ctx, glu::SHADERTYPE_TESSELLATION_EVALUATION, shader.str(), EXPECT_RESULT_FAIL); + ctx.endSection(); + } + + for (int idx = 0; idx < DE_LENGTH_OF_ARRAY(testConfigs); idx++) + { + shader.str(""); + shader + << getVersionAndExtension(ctx) + << "layout (triangles) in; \n" + << "layout (triangle_strip, max_vertices = 32) out; \n" + << "void main () \n" + << "{ \n" + << testConfigs[idx].varyingCheck + << "} \n"; + + ctx.beginSection("OES_sample_variables: trying to use fragment shader built-in sampler variable " + testConfigs[idx].builtInType + " inside geometry shader"); + verifyShader(ctx, glu::SHADERTYPE_GEOMETRY, shader.str(), EXPECT_RESULT_FAIL); + ctx.endSection(); + } +} + +void index_outside_sample_mask_range (NegativeTestContext& ctx) +{ + checkSupported(ctx); + + std::ostringstream shader; + const int MAX_TYPES = 2; + const int MAX_INDEXES = 2; + + struct testConfig + { + std::string builtInType[MAX_TYPES]; + std::string invalidIndex[MAX_INDEXES]; + } testConfigs = + { + { + "gl_SampleMask", + "gl_SampleMaskIn" + }, + { + " const highp int invalidIndex = (gl_MaxSamples + 31) / 32; \n", + " const highp int invalidIndex = -1; \n" + } + }; + + for (int typeIdx = 0; typeIdx < MAX_TYPES; typeIdx++) + { + for (int invalidIdx = 0; invalidIdx < MAX_INDEXES; invalidIdx++) + { + shader.str(""); + shader + << getVersionAndExtension(ctx) + << "layout (location = 0) out mediump vec4 fs_color; \n" + << "void main() \n" + << "{ \n" + << testConfigs.invalidIndex[invalidIdx] + << " highp int invalidValue = " << testConfigs.builtInType[typeIdx] << "[invalidIndex]; \n" + << " fs_color = vec4(1.0f, 0.0f, 0.0f, 1.0f); \n" + << "} \n"; + + ctx.beginSection("OES_sample_variables: using constant integral expression outside of " + testConfigs.builtInType[typeIdx] + " bounds"); + verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, shader.str(), EXPECT_RESULT_FAIL); + ctx.endSection(); + } + } +} + +void access_built_in_types_without_extension (NegativeTestContext& ctx) +{ + checkSupported(ctx); + + std::ostringstream shader; + + struct testConfig + { + std::string builtInType; + std::string varyingCheck; + } testConfigs[] = + { + {"gl_SampleID", " lowp int writeValue = 1; \n gl_SampleID = writeValue; \n"}, + {"gl_SamplePosition", " mediump vec2 writeValue = vec2(1.0f, 1.0f); \n gl_SamplePosition = writeValue; \n"}, + {"gl_SampleMaskIn", " lowp int writeValue = 1; \n gl_SampleMaskIn[0] = writeValue; \n"}, + {"gl_SampleMask", " highp int readValue = gl_SampleMask[0]; \n"}, + }; + + for (int idx = 0; idx < DE_LENGTH_OF_ARRAY(testConfigs); idx++) + { + shader.str(""); + shader + << "#version 310 es \n" + << "layout (location = 0) out mediump vec4 fs_color; \n" + << "void main() \n" + << "{ \n" + << testConfigs[idx].varyingCheck + << " fs_color = vec4(1.0f, 0.0f, 0.0f, 1.0f); \n" + << "} \n"; + + ctx.beginSection("OES_sample_variables: accessing built-in type " + testConfigs[idx].builtInType + " in shader version 310 ES without required extension"); + verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, shader.str(), EXPECT_RESULT_FAIL); + ctx.endSection(); + } +} + +void redeclare_built_in_types (NegativeTestContext& ctx) +{ + checkSupported(ctx); + + std::ostringstream shader; + std::ostringstream testName; + + const char* const testConfigs[] = + { + "gl_SampleID", + "gl_SamplePosition", + "gl_SampleMaskIn", + "gl_SampleMask", + }; + + for (int idx = 0; idx < DE_LENGTH_OF_ARRAY(testConfigs); idx++) + { + shader.str(""); + shader + << getVersionAndExtension(ctx) + << "layout (location = 0) out mediump vec4 fs_color; \n" + << "uniform lowp int " << testConfigs[idx] << "; \n" + << "void main() \n" + << "{ \n" + << " if (" << testConfigs[idx] << " == 0) \n" + << " fs_color = vec4(1.0f, 0.0f, 0.0f, 1.0f); \n" + << " else \n" + << " fs_color = vec4(0.0f, 1.0f, 0.0f, 1.0f); \n" + << "} \n"; + + testName.str(""); + testName << "OES_sample_variables: redeclare built-in type " << testConfigs[idx]; + ctx.beginSection(testName.str()); + verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, shader.str(), EXPECT_RESULT_FAIL); + ctx.endSection(); + } +} + +} // anonymous + +std::vector getNegativeSampleVariablesTestFunctions (void) +{ + const FunctionContainer funcs[] = + { + {write_to_read_only_types, "write_to_read_only_types", "tests trying writing to read-only built-in sample variables"}, + {access_built_in_types_inside_other_shaders, "access_built_in_types_inside_other_shaders", "Tests try to access fragment shader sample variables in other shaders"}, + {index_outside_sample_mask_range, "index_outside_sample_mask_range", "tests try to index into built-in sample array types out of bounds"}, + {access_built_in_types_without_extension, "access_built_in_types_without_extension", "tests try to access built-in sample types without the correct extension using version 310 es"}, + {redeclare_built_in_types, "redeclare_built_in_types", "Tests try to redeclare built-in sample types"}, + }; + + return std::vector(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs)); +} + +} // NegativeTestShared +} // Functional +} // gles31 +} // deqp \ No newline at end of file diff --git a/modules/gles31/functional/es31fNegativeSampleVariablesTests.hpp b/modules/gles31/functional/es31fNegativeSampleVariablesTests.hpp new file mode 100644 index 0000000..e4d516f --- /dev/null +++ b/modules/gles31/functional/es31fNegativeSampleVariablesTests.hpp @@ -0,0 +1,45 @@ +#ifndef _ES31FNEGATIVESAMPLEVARIABLESTESTS_HPP +#define _ES31FNEGATIVESAMPLEVARIABLESTESTS_HPP +/*------------------------------------------------------------------------- + * drawElements Quality Program OpenGL ES 3.1 Module + * ------------------------------------------------- + * + * Copyright 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *//*! + * \file + * \brief Negative Sample Variables Tests + *//*--------------------------------------------------------------------*/ + +#include "tcuDefs.hpp" +#include "es31fNegativeTestShared.hpp" + +namespace deqp +{ +namespace gles31 +{ +namespace Functional +{ +namespace NegativeTestShared +{ + +std::vector getNegativeSampleVariablesTestFunctions (void); + +} // NegativeTestShared +} // Functional +} // gles31 +} // deqp + +#endif // _ES31FNEGATIVESAMPLEVARIABLESTESTS_HPP