1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 2e5c31af7Sopenharmony_ci * drawElements Quality Program OpenGL ES 3.1 Module 3e5c31af7Sopenharmony_ci * ------------------------------------------------- 4e5c31af7Sopenharmony_ci * 5e5c31af7Sopenharmony_ci * Copyright 2015 The Android Open Source Project 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 10e5c31af7Sopenharmony_ci * 11e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 17e5c31af7Sopenharmony_ci * limitations under the License. 18e5c31af7Sopenharmony_ci * 19e5c31af7Sopenharmony_ci *//*! 20e5c31af7Sopenharmony_ci * \file 21e5c31af7Sopenharmony_ci * \brief Program State Query tests. 22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "es31fProgramStateQueryTests.hpp" 25e5c31af7Sopenharmony_ci#include "es31fInfoLogQueryShared.hpp" 26e5c31af7Sopenharmony_ci#include "glsStateQueryUtil.hpp" 27e5c31af7Sopenharmony_ci#include "gluRenderContext.hpp" 28e5c31af7Sopenharmony_ci#include "gluCallLogWrapper.hpp" 29e5c31af7Sopenharmony_ci#include "gluContextInfo.hpp" 30e5c31af7Sopenharmony_ci#include "gluObjectWrapper.hpp" 31e5c31af7Sopenharmony_ci#include "gluShaderProgram.hpp" 32e5c31af7Sopenharmony_ci#include "glwFunctions.hpp" 33e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 34e5c31af7Sopenharmony_ci#include "tcuStringTemplate.hpp" 35e5c31af7Sopenharmony_ci 36e5c31af7Sopenharmony_cinamespace deqp 37e5c31af7Sopenharmony_ci{ 38e5c31af7Sopenharmony_ci 39e5c31af7Sopenharmony_ciusing std::string; 40e5c31af7Sopenharmony_ciusing std::map; 41e5c31af7Sopenharmony_ci 42e5c31af7Sopenharmony_cinamespace gles31 43e5c31af7Sopenharmony_ci{ 44e5c31af7Sopenharmony_cinamespace Functional 45e5c31af7Sopenharmony_ci{ 46e5c31af7Sopenharmony_cinamespace 47e5c31af7Sopenharmony_ci{ 48e5c31af7Sopenharmony_ci 49e5c31af7Sopenharmony_ciusing namespace gls::StateQueryUtil; 50e5c31af7Sopenharmony_ci 51e5c31af7Sopenharmony_cistatic const char* getVerifierSuffix (QueryType type) 52e5c31af7Sopenharmony_ci{ 53e5c31af7Sopenharmony_ci switch (type) 54e5c31af7Sopenharmony_ci { 55e5c31af7Sopenharmony_ci case QUERY_PROGRAM_INTEGER_VEC3: 56e5c31af7Sopenharmony_ci case QUERY_PROGRAM_INTEGER: 57e5c31af7Sopenharmony_ci return "get_programiv"; 58e5c31af7Sopenharmony_ci 59e5c31af7Sopenharmony_ci default: 60e5c31af7Sopenharmony_ci DE_ASSERT(DE_FALSE); 61e5c31af7Sopenharmony_ci return DE_NULL; 62e5c31af7Sopenharmony_ci } 63e5c31af7Sopenharmony_ci} 64e5c31af7Sopenharmony_ci 65e5c31af7Sopenharmony_cistatic bool checkSupport(Context& ctx) 66e5c31af7Sopenharmony_ci{ 67e5c31af7Sopenharmony_ci auto ctxType = ctx.getRenderContext().getType(); 68e5c31af7Sopenharmony_ci return contextSupports(ctxType, glu::ApiType::es(3, 2)) || 69e5c31af7Sopenharmony_ci contextSupports(ctxType, glu::ApiType::core(4, 5)); 70e5c31af7Sopenharmony_ci} 71e5c31af7Sopenharmony_ci 72e5c31af7Sopenharmony_cistatic std::string specializeShader(Context& context, const char* code) 73e5c31af7Sopenharmony_ci{ 74e5c31af7Sopenharmony_ci auto ctxType = context.getRenderContext().getType(); 75e5c31af7Sopenharmony_ci const glu::GLSLVersion glslVersion = glu::getContextTypeGLSLVersion(ctxType); 76e5c31af7Sopenharmony_ci const bool isES32orGL45 = checkSupport(context); 77e5c31af7Sopenharmony_ci const bool isES = isContextTypeES(ctxType); 78e5c31af7Sopenharmony_ci 79e5c31af7Sopenharmony_ci std::map<std::string, std::string> specializationMap = 80e5c31af7Sopenharmony_ci { 81e5c31af7Sopenharmony_ci { "GLSL_VERSION_DECL", glu::getGLSLVersionDeclaration(glslVersion) }, 82e5c31af7Sopenharmony_ci { "GEOMETRY_SHADER_REQUIRE", (isES32orGL45 ? "" : "#extension GL_EXT_geometry_shader : require") }, 83e5c31af7Sopenharmony_ci { "TESSELLATION_SHADER_REQUIRE", (isES32orGL45 ? "" : "#extension GL_EXT_tessellation_shader : require") }, 84e5c31af7Sopenharmony_ci { "GL_POSITION_REDECL", (isES ? "" : "out gl_PerVertex { vec4 gl_Position;};")} 85e5c31af7Sopenharmony_ci }; 86e5c31af7Sopenharmony_ci 87e5c31af7Sopenharmony_ci return tcu::StringTemplate(code).specialize(specializationMap); 88e5c31af7Sopenharmony_ci} 89e5c31af7Sopenharmony_ci 90e5c31af7Sopenharmony_ci 91e5c31af7Sopenharmony_ciclass GeometryShaderCase : public TestCase 92e5c31af7Sopenharmony_ci{ 93e5c31af7Sopenharmony_cipublic: 94e5c31af7Sopenharmony_ci GeometryShaderCase (Context& context, QueryType verifier, const char* name, const char* desc); 95e5c31af7Sopenharmony_ci IterateResult iterate (void); 96e5c31af7Sopenharmony_ci 97e5c31af7Sopenharmony_ciprivate: 98e5c31af7Sopenharmony_ci const QueryType m_verifier; 99e5c31af7Sopenharmony_ci}; 100e5c31af7Sopenharmony_ci 101e5c31af7Sopenharmony_ciGeometryShaderCase::GeometryShaderCase (Context& context, QueryType verifier, const char* name, const char* desc) 102e5c31af7Sopenharmony_ci : TestCase (context, name, desc) 103e5c31af7Sopenharmony_ci , m_verifier (verifier) 104e5c31af7Sopenharmony_ci{ 105e5c31af7Sopenharmony_ci} 106e5c31af7Sopenharmony_ci 107e5c31af7Sopenharmony_ciGeometryShaderCase::IterateResult GeometryShaderCase::iterate (void) 108e5c31af7Sopenharmony_ci{ 109e5c31af7Sopenharmony_ci const bool isES32orGL45 = checkSupport(m_context); 110e5c31af7Sopenharmony_ci 111e5c31af7Sopenharmony_ci if (!isES32orGL45 && !m_context.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) 112e5c31af7Sopenharmony_ci TCU_THROW(NotSupportedError, "Geometry shader tests require GL_EXT_geometry_shader extension or an OpenGL ES 3.2 or higher context."); 113e5c31af7Sopenharmony_ci 114e5c31af7Sopenharmony_ci 115e5c31af7Sopenharmony_ci static const char* const s_vtxFragTemplate = "${GLSL_VERSION_DECL}\n" 116e5c31af7Sopenharmony_ci "void main()\n" 117e5c31af7Sopenharmony_ci "{\n" 118e5c31af7Sopenharmony_ci "}\n"; 119e5c31af7Sopenharmony_ci 120e5c31af7Sopenharmony_ci static const char* const s_geometryTemplate1 = "${GLSL_VERSION_DECL}\n" 121e5c31af7Sopenharmony_ci "${GEOMETRY_SHADER_REQUIRE}\n" 122e5c31af7Sopenharmony_ci "layout(triangles) in;" 123e5c31af7Sopenharmony_ci "layout(triangle_strip, max_vertices = 3) out;\n" 124e5c31af7Sopenharmony_ci "void main()\n" 125e5c31af7Sopenharmony_ci "{\n" 126e5c31af7Sopenharmony_ci " EndPrimitive();\n" 127e5c31af7Sopenharmony_ci "}\n"; 128e5c31af7Sopenharmony_ci 129e5c31af7Sopenharmony_ci static const char* const s_geometryTemplate2 = "${GLSL_VERSION_DECL}\n" 130e5c31af7Sopenharmony_ci "${GEOMETRY_SHADER_REQUIRE}\n" 131e5c31af7Sopenharmony_ci "layout(points) in;" 132e5c31af7Sopenharmony_ci "layout(line_strip, max_vertices = 5) out;\n" 133e5c31af7Sopenharmony_ci "void main()\n" 134e5c31af7Sopenharmony_ci "{\n" 135e5c31af7Sopenharmony_ci " EndPrimitive();\n" 136e5c31af7Sopenharmony_ci "}\n"; 137e5c31af7Sopenharmony_ci 138e5c31af7Sopenharmony_ci static const char* const s_geometryTemplate3 = "${GLSL_VERSION_DECL}\n" 139e5c31af7Sopenharmony_ci "${GEOMETRY_SHADER_REQUIRE}\n" 140e5c31af7Sopenharmony_ci "layout(points) in;" 141e5c31af7Sopenharmony_ci "layout(points, max_vertices = 50) out;\n" 142e5c31af7Sopenharmony_ci "void main()\n" 143e5c31af7Sopenharmony_ci "{\n" 144e5c31af7Sopenharmony_ci " EndPrimitive();\n" 145e5c31af7Sopenharmony_ci "}\n"; 146e5c31af7Sopenharmony_ci 147e5c31af7Sopenharmony_ci glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog()); 148e5c31af7Sopenharmony_ci tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: "); 149e5c31af7Sopenharmony_ci 150e5c31af7Sopenharmony_ci gl.enableLogging(true); 151e5c31af7Sopenharmony_ci 152e5c31af7Sopenharmony_ci { 153e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "Layout", "triangles in, triangle strip out, 3 vertices"); 154e5c31af7Sopenharmony_ci glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources() 155e5c31af7Sopenharmony_ci << glu::VertexSource(specializeShader(m_context, s_vtxFragTemplate)) 156e5c31af7Sopenharmony_ci << glu::FragmentSource(specializeShader(m_context, s_vtxFragTemplate)) 157e5c31af7Sopenharmony_ci << glu::GeometrySource(specializeShader(m_context, s_geometryTemplate1))); 158e5c31af7Sopenharmony_ci 159e5c31af7Sopenharmony_ci TCU_CHECK_MSG(program.isOk(), "Compile failed"); 160e5c31af7Sopenharmony_ci 161e5c31af7Sopenharmony_ci m_testCtx.getLog() << program; 162e5c31af7Sopenharmony_ci 163e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_VERTICES_OUT, 3, m_verifier); 164e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_INPUT_TYPE, GL_TRIANGLES, m_verifier); 165e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_OUTPUT_TYPE, GL_TRIANGLE_STRIP, m_verifier); 166e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_SHADER_INVOCATIONS, 1, m_verifier); 167e5c31af7Sopenharmony_ci } 168e5c31af7Sopenharmony_ci 169e5c31af7Sopenharmony_ci { 170e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "Layout", "points in, line strip out, 5 vertices"); 171e5c31af7Sopenharmony_ci glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources() 172e5c31af7Sopenharmony_ci << glu::VertexSource(specializeShader(m_context, s_vtxFragTemplate)) 173e5c31af7Sopenharmony_ci << glu::FragmentSource(specializeShader(m_context, s_vtxFragTemplate)) 174e5c31af7Sopenharmony_ci << glu::GeometrySource(specializeShader(m_context, s_geometryTemplate2))); 175e5c31af7Sopenharmony_ci 176e5c31af7Sopenharmony_ci TCU_CHECK_MSG(program.isOk(), "Compile failed"); 177e5c31af7Sopenharmony_ci 178e5c31af7Sopenharmony_ci m_testCtx.getLog() << program; 179e5c31af7Sopenharmony_ci 180e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_VERTICES_OUT, 5, m_verifier); 181e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_INPUT_TYPE, GL_POINTS, m_verifier); 182e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_OUTPUT_TYPE, GL_LINE_STRIP, m_verifier); 183e5c31af7Sopenharmony_ci } 184e5c31af7Sopenharmony_ci 185e5c31af7Sopenharmony_ci { 186e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "Layout", "points in, points out, 50 vertices"); 187e5c31af7Sopenharmony_ci glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources() 188e5c31af7Sopenharmony_ci << glu::VertexSource(specializeShader(m_context, s_vtxFragTemplate)) 189e5c31af7Sopenharmony_ci << glu::FragmentSource(specializeShader(m_context, s_vtxFragTemplate)) 190e5c31af7Sopenharmony_ci << glu::GeometrySource(specializeShader(m_context, s_geometryTemplate3))); 191e5c31af7Sopenharmony_ci 192e5c31af7Sopenharmony_ci TCU_CHECK_MSG(program.isOk(), "Compile failed"); 193e5c31af7Sopenharmony_ci 194e5c31af7Sopenharmony_ci m_testCtx.getLog() << program; 195e5c31af7Sopenharmony_ci 196e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_VERTICES_OUT, 50, m_verifier); 197e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_INPUT_TYPE, GL_POINTS, m_verifier); 198e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_OUTPUT_TYPE, GL_POINTS, m_verifier); 199e5c31af7Sopenharmony_ci } 200e5c31af7Sopenharmony_ci 201e5c31af7Sopenharmony_ci result.setTestContextResult(m_testCtx); 202e5c31af7Sopenharmony_ci return STOP; 203e5c31af7Sopenharmony_ci} 204e5c31af7Sopenharmony_ci 205e5c31af7Sopenharmony_ciclass TessellationShaderCase : public TestCase 206e5c31af7Sopenharmony_ci{ 207e5c31af7Sopenharmony_cipublic: 208e5c31af7Sopenharmony_ci TessellationShaderCase (Context& context, QueryType verifier, const char* name, const char* desc); 209e5c31af7Sopenharmony_ci IterateResult iterate (void); 210e5c31af7Sopenharmony_ci 211e5c31af7Sopenharmony_ciprivate: 212e5c31af7Sopenharmony_ci const QueryType m_verifier; 213e5c31af7Sopenharmony_ci}; 214e5c31af7Sopenharmony_ci 215e5c31af7Sopenharmony_ciTessellationShaderCase::TessellationShaderCase (Context& context, QueryType verifier, const char* name, const char* desc) 216e5c31af7Sopenharmony_ci : TestCase (context, name, desc) 217e5c31af7Sopenharmony_ci , m_verifier (verifier) 218e5c31af7Sopenharmony_ci{ 219e5c31af7Sopenharmony_ci} 220e5c31af7Sopenharmony_ci 221e5c31af7Sopenharmony_ciTessellationShaderCase::IterateResult TessellationShaderCase::iterate (void) 222e5c31af7Sopenharmony_ci{ 223e5c31af7Sopenharmony_ci const bool isES32orGL45 = checkSupport(m_context); 224e5c31af7Sopenharmony_ci 225e5c31af7Sopenharmony_ci if (!isES32orGL45 && !m_context.getContextInfo().isExtensionSupported("GL_EXT_tessellation_shader")) 226e5c31af7Sopenharmony_ci TCU_THROW(NotSupportedError, "Tessellation shader tests require GL_EXT_tessellation_shader extension or an OpenGL ES 3.2 or higher context."); 227e5c31af7Sopenharmony_ci 228e5c31af7Sopenharmony_ci 229e5c31af7Sopenharmony_ci static const char* const s_vtxFragTemplate = "${GLSL_VERSION_DECL}\n" 230e5c31af7Sopenharmony_ci "void main()\n" 231e5c31af7Sopenharmony_ci "{\n" 232e5c31af7Sopenharmony_ci "}\n"; 233e5c31af7Sopenharmony_ci 234e5c31af7Sopenharmony_ci static const char* const s_tessCtrlTemplate1 = "${GLSL_VERSION_DECL}\n" 235e5c31af7Sopenharmony_ci "${TESSELLATION_SHADER_REQUIRE}\n" 236e5c31af7Sopenharmony_ci "layout(vertices = 3) out;\n" 237e5c31af7Sopenharmony_ci "void main()\n" 238e5c31af7Sopenharmony_ci "{\n" 239e5c31af7Sopenharmony_ci "}\n"; 240e5c31af7Sopenharmony_ci 241e5c31af7Sopenharmony_ci static const char* const s_tessEvalTemplate1 = "${GLSL_VERSION_DECL}\n" 242e5c31af7Sopenharmony_ci "${TESSELLATION_SHADER_REQUIRE}\n" 243e5c31af7Sopenharmony_ci "layout(triangles, equal_spacing, cw) in;\n" 244e5c31af7Sopenharmony_ci "void main()\n" 245e5c31af7Sopenharmony_ci "{\n" 246e5c31af7Sopenharmony_ci "}\n"; 247e5c31af7Sopenharmony_ci 248e5c31af7Sopenharmony_ci static const char* const s_tessCtrlTemplate2 = "${GLSL_VERSION_DECL}\n" 249e5c31af7Sopenharmony_ci "${TESSELLATION_SHADER_REQUIRE}\n" 250e5c31af7Sopenharmony_ci "layout(vertices = 5) out;\n" 251e5c31af7Sopenharmony_ci "void main()\n" 252e5c31af7Sopenharmony_ci "{\n" 253e5c31af7Sopenharmony_ci "}\n"; 254e5c31af7Sopenharmony_ci 255e5c31af7Sopenharmony_ci static const char* const s_tessEvalTemplate2 = "${GLSL_VERSION_DECL}\n" 256e5c31af7Sopenharmony_ci "${TESSELLATION_SHADER_REQUIRE}\n" 257e5c31af7Sopenharmony_ci "layout(quads, fractional_even_spacing, ccw) in;\n" 258e5c31af7Sopenharmony_ci "void main()\n" 259e5c31af7Sopenharmony_ci "{\n" 260e5c31af7Sopenharmony_ci "}\n"; 261e5c31af7Sopenharmony_ci 262e5c31af7Sopenharmony_ci static const char* const s_tessEvalTemplate3 = "${GLSL_VERSION_DECL}\n" 263e5c31af7Sopenharmony_ci "${TESSELLATION_SHADER_REQUIRE}\n" 264e5c31af7Sopenharmony_ci "layout(isolines, fractional_odd_spacing, ccw, point_mode) in;\n" 265e5c31af7Sopenharmony_ci "void main()\n" 266e5c31af7Sopenharmony_ci "{\n" 267e5c31af7Sopenharmony_ci "}\n"; 268e5c31af7Sopenharmony_ci 269e5c31af7Sopenharmony_ci glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog()); 270e5c31af7Sopenharmony_ci tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: "); 271e5c31af7Sopenharmony_ci 272e5c31af7Sopenharmony_ci gl.enableLogging(true); 273e5c31af7Sopenharmony_ci 274e5c31af7Sopenharmony_ci { 275e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "Query State", "3 vertices, triangles, equal_spacing, cw"); 276e5c31af7Sopenharmony_ci glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources() 277e5c31af7Sopenharmony_ci << glu::VertexSource(specializeShader(m_context, s_vtxFragTemplate)) 278e5c31af7Sopenharmony_ci << glu::FragmentSource(specializeShader(m_context, s_vtxFragTemplate)) 279e5c31af7Sopenharmony_ci << glu::TessellationControlSource(specializeShader(m_context, s_tessCtrlTemplate1)) 280e5c31af7Sopenharmony_ci << glu::TessellationEvaluationSource(specializeShader(m_context, s_tessEvalTemplate1))); 281e5c31af7Sopenharmony_ci 282e5c31af7Sopenharmony_ci TCU_CHECK_MSG(program.isOk(), "Compile failed"); 283e5c31af7Sopenharmony_ci 284e5c31af7Sopenharmony_ci m_testCtx.getLog() << program; 285e5c31af7Sopenharmony_ci 286e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_CONTROL_OUTPUT_VERTICES, 3, m_verifier); 287e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_MODE, GL_TRIANGLES, m_verifier); 288e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_SPACING, GL_EQUAL, m_verifier); 289e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_VERTEX_ORDER, GL_CW, m_verifier); 290e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_POINT_MODE, GL_FALSE, m_verifier); 291e5c31af7Sopenharmony_ci } 292e5c31af7Sopenharmony_ci 293e5c31af7Sopenharmony_ci { 294e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "Query State", "5 vertices, quads, fractional_even_spacing, ccw"); 295e5c31af7Sopenharmony_ci glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources() 296e5c31af7Sopenharmony_ci << glu::VertexSource(specializeShader(m_context, s_vtxFragTemplate)) 297e5c31af7Sopenharmony_ci << glu::FragmentSource(specializeShader(m_context, s_vtxFragTemplate)) 298e5c31af7Sopenharmony_ci << glu::TessellationControlSource(specializeShader(m_context, s_tessCtrlTemplate2)) 299e5c31af7Sopenharmony_ci << glu::TessellationEvaluationSource(specializeShader(m_context, s_tessEvalTemplate2))); 300e5c31af7Sopenharmony_ci 301e5c31af7Sopenharmony_ci TCU_CHECK_MSG(program.isOk(), "Compile failed"); 302e5c31af7Sopenharmony_ci 303e5c31af7Sopenharmony_ci m_testCtx.getLog() << program; 304e5c31af7Sopenharmony_ci 305e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_CONTROL_OUTPUT_VERTICES, 5, m_verifier); 306e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_MODE, GL_QUADS, m_verifier); 307e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_SPACING, GL_FRACTIONAL_EVEN, m_verifier); 308e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_VERTEX_ORDER, GL_CCW, m_verifier); 309e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_POINT_MODE, GL_FALSE, m_verifier); 310e5c31af7Sopenharmony_ci } 311e5c31af7Sopenharmony_ci 312e5c31af7Sopenharmony_ci { 313e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "Query State", "5 vertices, isolines, fractional_odd_spacing, ccw, point_mode"); 314e5c31af7Sopenharmony_ci glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources() 315e5c31af7Sopenharmony_ci << glu::VertexSource(specializeShader(m_context, s_vtxFragTemplate)) 316e5c31af7Sopenharmony_ci << glu::FragmentSource(specializeShader(m_context, s_vtxFragTemplate)) 317e5c31af7Sopenharmony_ci << glu::TessellationControlSource(specializeShader(m_context, s_tessCtrlTemplate2)) 318e5c31af7Sopenharmony_ci << glu::TessellationEvaluationSource(specializeShader(m_context, s_tessEvalTemplate3))); 319e5c31af7Sopenharmony_ci 320e5c31af7Sopenharmony_ci TCU_CHECK_MSG(program.isOk(), "Compile failed"); 321e5c31af7Sopenharmony_ci 322e5c31af7Sopenharmony_ci m_testCtx.getLog() << program; 323e5c31af7Sopenharmony_ci 324e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_CONTROL_OUTPUT_VERTICES, 5, m_verifier); 325e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_MODE, GL_ISOLINES, m_verifier); 326e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_SPACING, GL_FRACTIONAL_ODD, m_verifier); 327e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_VERTEX_ORDER, GL_CCW, m_verifier); 328e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_POINT_MODE, GL_TRUE, m_verifier); 329e5c31af7Sopenharmony_ci } 330e5c31af7Sopenharmony_ci 331e5c31af7Sopenharmony_ci result.setTestContextResult(m_testCtx); 332e5c31af7Sopenharmony_ci return STOP; 333e5c31af7Sopenharmony_ci} 334e5c31af7Sopenharmony_ci 335e5c31af7Sopenharmony_ciclass ProgramSeparableCase : public TestCase 336e5c31af7Sopenharmony_ci{ 337e5c31af7Sopenharmony_cipublic: 338e5c31af7Sopenharmony_ci ProgramSeparableCase (Context& context, QueryType verifier, const char* name, const char* desc); 339e5c31af7Sopenharmony_ci IterateResult iterate (void); 340e5c31af7Sopenharmony_ci 341e5c31af7Sopenharmony_ciprivate: 342e5c31af7Sopenharmony_ci const QueryType m_verifier; 343e5c31af7Sopenharmony_ci}; 344e5c31af7Sopenharmony_ci 345e5c31af7Sopenharmony_ciProgramSeparableCase::ProgramSeparableCase (Context& context, QueryType verifier, const char* name, const char* desc) 346e5c31af7Sopenharmony_ci : TestCase (context, name, desc) 347e5c31af7Sopenharmony_ci , m_verifier (verifier) 348e5c31af7Sopenharmony_ci{ 349e5c31af7Sopenharmony_ci} 350e5c31af7Sopenharmony_ci 351e5c31af7Sopenharmony_ciProgramSeparableCase::IterateResult ProgramSeparableCase::iterate (void) 352e5c31af7Sopenharmony_ci{ 353e5c31af7Sopenharmony_ci const string vtxTemplate = "${GLSL_VERSION_DECL}\n" 354e5c31af7Sopenharmony_ci "out highp vec4 v_color;\n" 355e5c31af7Sopenharmony_ci // NOTE that core profile requires the gl_PerVertex block to be redeclared 356e5c31af7Sopenharmony_ci // in case a separable program is enabled. 357e5c31af7Sopenharmony_ci "${GL_POSITION_REDECL}\n" 358e5c31af7Sopenharmony_ci "void main()\n" 359e5c31af7Sopenharmony_ci "{\n" 360e5c31af7Sopenharmony_ci " gl_Position = vec4(float(gl_VertexID) * 0.5, float(gl_VertexID+1) * 0.5, 0.0, 1.0);\n" 361e5c31af7Sopenharmony_ci " v_color = vec4(float(gl_VertexID), 1.0, 0.0, 1.0);\n" 362e5c31af7Sopenharmony_ci "}\n"; 363e5c31af7Sopenharmony_ci const string fragTemplate = "${GLSL_VERSION_DECL}\n" 364e5c31af7Sopenharmony_ci "in highp vec4 v_color;\n" 365e5c31af7Sopenharmony_ci "layout(location=0) out highp vec4 o_color;\n" 366e5c31af7Sopenharmony_ci "void main()\n" 367e5c31af7Sopenharmony_ci "{\n" 368e5c31af7Sopenharmony_ci " o_color = v_color;\n" 369e5c31af7Sopenharmony_ci "}\n"; 370e5c31af7Sopenharmony_ci 371e5c31af7Sopenharmony_ci glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog()); 372e5c31af7Sopenharmony_ci tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: "); 373e5c31af7Sopenharmony_ci glu::Shader vtxShader (m_context.getRenderContext(), glu::SHADERTYPE_VERTEX); 374e5c31af7Sopenharmony_ci glu::Shader frgShader (m_context.getRenderContext(), glu::SHADERTYPE_FRAGMENT); 375e5c31af7Sopenharmony_ci 376e5c31af7Sopenharmony_ci const std::string vStr = specializeShader(m_context, vtxTemplate.c_str()); 377e5c31af7Sopenharmony_ci const std::string fStr = specializeShader(m_context, fragTemplate.c_str()); 378e5c31af7Sopenharmony_ci const char* const vtxSourcePtr = vStr.c_str(); 379e5c31af7Sopenharmony_ci const char* const fragSourcePtr = fStr.c_str(); 380e5c31af7Sopenharmony_ci 381e5c31af7Sopenharmony_ci vtxShader.setSources(1, &vtxSourcePtr, DE_NULL); 382e5c31af7Sopenharmony_ci frgShader.setSources(1, &fragSourcePtr, DE_NULL); 383e5c31af7Sopenharmony_ci 384e5c31af7Sopenharmony_ci vtxShader.compile(); 385e5c31af7Sopenharmony_ci frgShader.compile(); 386e5c31af7Sopenharmony_ci 387e5c31af7Sopenharmony_ci { 388e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section(m_testCtx.getLog(), "VtxShader", "Vertex shader"); 389e5c31af7Sopenharmony_ci m_testCtx.getLog() << vtxShader; 390e5c31af7Sopenharmony_ci } 391e5c31af7Sopenharmony_ci 392e5c31af7Sopenharmony_ci { 393e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section(m_testCtx.getLog(), "FrgShader", "Fragment shader"); 394e5c31af7Sopenharmony_ci m_testCtx.getLog() << frgShader; 395e5c31af7Sopenharmony_ci } 396e5c31af7Sopenharmony_ci 397e5c31af7Sopenharmony_ci TCU_CHECK_MSG(vtxShader.getCompileStatus() && frgShader.getCompileStatus(), "failed to build shaders"); 398e5c31af7Sopenharmony_ci 399e5c31af7Sopenharmony_ci gl.enableLogging(true); 400e5c31af7Sopenharmony_ci 401e5c31af7Sopenharmony_ci { 402e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "Initial", "Initial"); 403e5c31af7Sopenharmony_ci glu::Program program (m_context.getRenderContext()); 404e5c31af7Sopenharmony_ci 405e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_PROGRAM_SEPARABLE, 0, m_verifier); 406e5c31af7Sopenharmony_ci } 407e5c31af7Sopenharmony_ci 408e5c31af7Sopenharmony_ci { 409e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "SetFalse", "SetFalse"); 410e5c31af7Sopenharmony_ci glu::Program program (m_context.getRenderContext()); 411e5c31af7Sopenharmony_ci int linkStatus = 0; 412e5c31af7Sopenharmony_ci 413e5c31af7Sopenharmony_ci gl.glAttachShader(program.getProgram(), vtxShader.getShader()); 414e5c31af7Sopenharmony_ci gl.glAttachShader(program.getProgram(), frgShader.getShader()); 415e5c31af7Sopenharmony_ci gl.glProgramParameteri(program.getProgram(), GL_PROGRAM_SEPARABLE, GL_FALSE); 416e5c31af7Sopenharmony_ci gl.glLinkProgram(program.getProgram()); 417e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.glGetError(), "setup program"); 418e5c31af7Sopenharmony_ci 419e5c31af7Sopenharmony_ci gl.glGetProgramiv(program.getProgram(), GL_LINK_STATUS, &linkStatus); 420e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.glGetError(), "query link status"); 421e5c31af7Sopenharmony_ci 422e5c31af7Sopenharmony_ci gl.glDetachShader(program.getProgram(), vtxShader.getShader()); 423e5c31af7Sopenharmony_ci gl.glDetachShader(program.getProgram(), frgShader.getShader()); 424e5c31af7Sopenharmony_ci 425e5c31af7Sopenharmony_ci TCU_CHECK_MSG(linkStatus == GL_TRUE, "failed to link program"); 426e5c31af7Sopenharmony_ci 427e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_PROGRAM_SEPARABLE, 0, m_verifier); 428e5c31af7Sopenharmony_ci } 429e5c31af7Sopenharmony_ci 430e5c31af7Sopenharmony_ci { 431e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "SetTrue", "SetTrue"); 432e5c31af7Sopenharmony_ci glu::Program program (m_context.getRenderContext()); 433e5c31af7Sopenharmony_ci int linkStatus = 0; 434e5c31af7Sopenharmony_ci 435e5c31af7Sopenharmony_ci gl.glAttachShader(program.getProgram(), vtxShader.getShader()); 436e5c31af7Sopenharmony_ci gl.glAttachShader(program.getProgram(), frgShader.getShader()); 437e5c31af7Sopenharmony_ci gl.glProgramParameteri(program.getProgram(), GL_PROGRAM_SEPARABLE, GL_TRUE); 438e5c31af7Sopenharmony_ci gl.glLinkProgram(program.getProgram()); 439e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.glGetError(), "setup program"); 440e5c31af7Sopenharmony_ci 441e5c31af7Sopenharmony_ci gl.glGetProgramiv(program.getProgram(), GL_LINK_STATUS, &linkStatus); 442e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.glGetError(), "query link status"); 443e5c31af7Sopenharmony_ci 444e5c31af7Sopenharmony_ci gl.glDetachShader(program.getProgram(), vtxShader.getShader()); 445e5c31af7Sopenharmony_ci gl.glDetachShader(program.getProgram(), frgShader.getShader()); 446e5c31af7Sopenharmony_ci 447e5c31af7Sopenharmony_ci TCU_CHECK_MSG(linkStatus == GL_TRUE, "failed to link program"); 448e5c31af7Sopenharmony_ci 449e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_PROGRAM_SEPARABLE, GL_TRUE, m_verifier); 450e5c31af7Sopenharmony_ci } 451e5c31af7Sopenharmony_ci 452e5c31af7Sopenharmony_ci result.setTestContextResult(m_testCtx); 453e5c31af7Sopenharmony_ci return STOP; 454e5c31af7Sopenharmony_ci} 455e5c31af7Sopenharmony_ci 456e5c31af7Sopenharmony_ciclass ComputeWorkGroupSizeCase : public TestCase 457e5c31af7Sopenharmony_ci{ 458e5c31af7Sopenharmony_cipublic: 459e5c31af7Sopenharmony_ci ComputeWorkGroupSizeCase (Context& context, QueryType verifier, const char* name, const char* desc); 460e5c31af7Sopenharmony_ci IterateResult iterate (void); 461e5c31af7Sopenharmony_ci 462e5c31af7Sopenharmony_ciprivate: 463e5c31af7Sopenharmony_ci const QueryType m_verifier; 464e5c31af7Sopenharmony_ci}; 465e5c31af7Sopenharmony_ci 466e5c31af7Sopenharmony_ciComputeWorkGroupSizeCase::ComputeWorkGroupSizeCase (Context& context, QueryType verifier, const char* name, const char* desc) 467e5c31af7Sopenharmony_ci : TestCase (context, name, desc) 468e5c31af7Sopenharmony_ci , m_verifier (verifier) 469e5c31af7Sopenharmony_ci{ 470e5c31af7Sopenharmony_ci} 471e5c31af7Sopenharmony_ci 472e5c31af7Sopenharmony_ciComputeWorkGroupSizeCase::IterateResult ComputeWorkGroupSizeCase::iterate (void) 473e5c31af7Sopenharmony_ci{ 474e5c31af7Sopenharmony_ci static const char* const s_computeTemplate1D = "${GLSL_VERSION_DECL}\n" 475e5c31af7Sopenharmony_ci "layout (local_size_x = 3) in;\n" 476e5c31af7Sopenharmony_ci "layout(binding = 0) buffer Output\n" 477e5c31af7Sopenharmony_ci "{\n" 478e5c31af7Sopenharmony_ci " highp float val;\n" 479e5c31af7Sopenharmony_ci "} sb_out;\n" 480e5c31af7Sopenharmony_ci "\n" 481e5c31af7Sopenharmony_ci "void main (void)\n" 482e5c31af7Sopenharmony_ci "{\n" 483e5c31af7Sopenharmony_ci " sb_out.val = 1.0;\n" 484e5c31af7Sopenharmony_ci "}\n"; 485e5c31af7Sopenharmony_ci static const char* const s_computeTemplate2D = "${GLSL_VERSION_DECL}\n" 486e5c31af7Sopenharmony_ci "layout (local_size_x = 3, local_size_y = 2) in;\n" 487e5c31af7Sopenharmony_ci "layout(binding = 0) buffer Output\n" 488e5c31af7Sopenharmony_ci "{\n" 489e5c31af7Sopenharmony_ci " highp float val;\n" 490e5c31af7Sopenharmony_ci "} sb_out;\n" 491e5c31af7Sopenharmony_ci "\n" 492e5c31af7Sopenharmony_ci "void main (void)\n" 493e5c31af7Sopenharmony_ci "{\n" 494e5c31af7Sopenharmony_ci " sb_out.val = 1.0;\n" 495e5c31af7Sopenharmony_ci "}\n"; 496e5c31af7Sopenharmony_ci static const char* const s_computeTemplate3D = "${GLSL_VERSION_DECL}\n" 497e5c31af7Sopenharmony_ci "layout (local_size_x = 3, local_size_y = 2, local_size_z = 4) in;\n" 498e5c31af7Sopenharmony_ci "layout(binding = 0) buffer Output\n" 499e5c31af7Sopenharmony_ci "{\n" 500e5c31af7Sopenharmony_ci " highp float val;\n" 501e5c31af7Sopenharmony_ci "} sb_out;\n" 502e5c31af7Sopenharmony_ci "\n" 503e5c31af7Sopenharmony_ci "void main (void)\n" 504e5c31af7Sopenharmony_ci "{\n" 505e5c31af7Sopenharmony_ci " sb_out.val = 1.0;\n" 506e5c31af7Sopenharmony_ci "}\n"; 507e5c31af7Sopenharmony_ci 508e5c31af7Sopenharmony_ci glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog()); 509e5c31af7Sopenharmony_ci tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: "); 510e5c31af7Sopenharmony_ci 511e5c31af7Sopenharmony_ci gl.enableLogging(true); 512e5c31af7Sopenharmony_ci 513e5c31af7Sopenharmony_ci { 514e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "OneDimensional", "1D"); 515e5c31af7Sopenharmony_ci glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources() << glu::ComputeSource(specializeShader(m_context, s_computeTemplate1D))); 516e5c31af7Sopenharmony_ci 517e5c31af7Sopenharmony_ci m_testCtx.getLog() << program; 518e5c31af7Sopenharmony_ci 519e5c31af7Sopenharmony_ci TCU_CHECK_MSG(program.isOk(), "failed to build program"); 520e5c31af7Sopenharmony_ci 521e5c31af7Sopenharmony_ci verifyStateProgramIntegerVec3(result, gl, program.getProgram(), GL_COMPUTE_WORK_GROUP_SIZE, tcu::IVec3(3, 1, 1), m_verifier); 522e5c31af7Sopenharmony_ci } 523e5c31af7Sopenharmony_ci 524e5c31af7Sopenharmony_ci { 525e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "TwoDimensional", "2D"); 526e5c31af7Sopenharmony_ci glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources() << glu::ComputeSource(specializeShader(m_context, s_computeTemplate2D))); 527e5c31af7Sopenharmony_ci 528e5c31af7Sopenharmony_ci m_testCtx.getLog() << program; 529e5c31af7Sopenharmony_ci 530e5c31af7Sopenharmony_ci TCU_CHECK_MSG(program.isOk(), "failed to build program"); 531e5c31af7Sopenharmony_ci 532e5c31af7Sopenharmony_ci verifyStateProgramIntegerVec3(result, gl, program.getProgram(), GL_COMPUTE_WORK_GROUP_SIZE, tcu::IVec3(3, 2, 1), m_verifier); 533e5c31af7Sopenharmony_ci } 534e5c31af7Sopenharmony_ci 535e5c31af7Sopenharmony_ci { 536e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "TreeDimensional", "3D"); 537e5c31af7Sopenharmony_ci glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources() << glu::ComputeSource(specializeShader(m_context, s_computeTemplate3D))); 538e5c31af7Sopenharmony_ci 539e5c31af7Sopenharmony_ci m_testCtx.getLog() << program; 540e5c31af7Sopenharmony_ci 541e5c31af7Sopenharmony_ci TCU_CHECK_MSG(program.isOk(), "failed to build program"); 542e5c31af7Sopenharmony_ci 543e5c31af7Sopenharmony_ci verifyStateProgramIntegerVec3(result, gl, program.getProgram(), GL_COMPUTE_WORK_GROUP_SIZE, tcu::IVec3(3, 2, 4), m_verifier); 544e5c31af7Sopenharmony_ci } 545e5c31af7Sopenharmony_ci 546e5c31af7Sopenharmony_ci result.setTestContextResult(m_testCtx); 547e5c31af7Sopenharmony_ci return STOP; 548e5c31af7Sopenharmony_ci} 549e5c31af7Sopenharmony_ci 550e5c31af7Sopenharmony_ciclass ActiveAtomicCounterBuffersCase : public TestCase 551e5c31af7Sopenharmony_ci{ 552e5c31af7Sopenharmony_cipublic: 553e5c31af7Sopenharmony_ci ActiveAtomicCounterBuffersCase (Context& context, QueryType verifier, const char* name, const char* desc); 554e5c31af7Sopenharmony_ci IterateResult iterate (void); 555e5c31af7Sopenharmony_ci 556e5c31af7Sopenharmony_ciprivate: 557e5c31af7Sopenharmony_ci const QueryType m_verifier; 558e5c31af7Sopenharmony_ci}; 559e5c31af7Sopenharmony_ci 560e5c31af7Sopenharmony_ciActiveAtomicCounterBuffersCase::ActiveAtomicCounterBuffersCase (Context& context, QueryType verifier, const char* name, const char* desc) 561e5c31af7Sopenharmony_ci : TestCase (context, name, desc) 562e5c31af7Sopenharmony_ci , m_verifier (verifier) 563e5c31af7Sopenharmony_ci{ 564e5c31af7Sopenharmony_ci} 565e5c31af7Sopenharmony_ci 566e5c31af7Sopenharmony_ciActiveAtomicCounterBuffersCase::IterateResult ActiveAtomicCounterBuffersCase::iterate (void) 567e5c31af7Sopenharmony_ci{ 568e5c31af7Sopenharmony_ci static const char* const s_computeTemplate0 = "${GLSL_VERSION_DECL}\n" 569e5c31af7Sopenharmony_ci "layout (local_size_x = 3) in;\n" 570e5c31af7Sopenharmony_ci "layout(binding = 0) buffer Output\n" 571e5c31af7Sopenharmony_ci "{\n" 572e5c31af7Sopenharmony_ci " highp float val;\n" 573e5c31af7Sopenharmony_ci "} sb_out;\n" 574e5c31af7Sopenharmony_ci "\n" 575e5c31af7Sopenharmony_ci "void main (void)\n" 576e5c31af7Sopenharmony_ci "{\n" 577e5c31af7Sopenharmony_ci " sb_out.val = 1.0;\n" 578e5c31af7Sopenharmony_ci "}\n"; 579e5c31af7Sopenharmony_ci static const char* const s_computeTemplate1 = "${GLSL_VERSION_DECL}\n" 580e5c31af7Sopenharmony_ci "layout (local_size_x = 3) in;\n" 581e5c31af7Sopenharmony_ci "layout(binding = 0) uniform highp atomic_uint u_counters[2];\n" 582e5c31af7Sopenharmony_ci "layout(binding = 0) buffer Output\n" 583e5c31af7Sopenharmony_ci "{\n" 584e5c31af7Sopenharmony_ci " highp float val;\n" 585e5c31af7Sopenharmony_ci "} sb_out;\n" 586e5c31af7Sopenharmony_ci "\n" 587e5c31af7Sopenharmony_ci "void main (void)\n" 588e5c31af7Sopenharmony_ci "{\n" 589e5c31af7Sopenharmony_ci " sb_out.val = float(atomicCounterIncrement(u_counters[0])) + float(atomicCounterIncrement(u_counters[1]));\n" 590e5c31af7Sopenharmony_ci "}\n"; 591e5c31af7Sopenharmony_ci 592e5c31af7Sopenharmony_ci glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog()); 593e5c31af7Sopenharmony_ci tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: "); 594e5c31af7Sopenharmony_ci 595e5c31af7Sopenharmony_ci gl.enableLogging(true); 596e5c31af7Sopenharmony_ci 597e5c31af7Sopenharmony_ci { 598e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "Initial", "Initial"); 599e5c31af7Sopenharmony_ci glu::Program program (m_context.getRenderContext()); 600e5c31af7Sopenharmony_ci 601e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_ACTIVE_ATOMIC_COUNTER_BUFFERS, 0, m_verifier); 602e5c31af7Sopenharmony_ci } 603e5c31af7Sopenharmony_ci 604e5c31af7Sopenharmony_ci { 605e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "NoBuffers", "No buffers"); 606e5c31af7Sopenharmony_ci glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources() << glu::ComputeSource(specializeShader(m_context, s_computeTemplate0))); 607e5c31af7Sopenharmony_ci 608e5c31af7Sopenharmony_ci m_testCtx.getLog() << program; 609e5c31af7Sopenharmony_ci 610e5c31af7Sopenharmony_ci TCU_CHECK_MSG(program.isOk(), "failed to build program"); 611e5c31af7Sopenharmony_ci 612e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_ACTIVE_ATOMIC_COUNTER_BUFFERS, 0, m_verifier); 613e5c31af7Sopenharmony_ci } 614e5c31af7Sopenharmony_ci 615e5c31af7Sopenharmony_ci { 616e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section (m_testCtx.getLog(), "OneBuffer", "One buffer"); 617e5c31af7Sopenharmony_ci glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources() << glu::ComputeSource(specializeShader(m_context, s_computeTemplate1))); 618e5c31af7Sopenharmony_ci 619e5c31af7Sopenharmony_ci m_testCtx.getLog() << program; 620e5c31af7Sopenharmony_ci 621e5c31af7Sopenharmony_ci TCU_CHECK_MSG(program.isOk(), "failed to build program"); 622e5c31af7Sopenharmony_ci 623e5c31af7Sopenharmony_ci verifyStateProgramInteger(result, gl, program.getProgram(), GL_ACTIVE_ATOMIC_COUNTER_BUFFERS, 1, m_verifier); 624e5c31af7Sopenharmony_ci } 625e5c31af7Sopenharmony_ci 626e5c31af7Sopenharmony_ci result.setTestContextResult(m_testCtx); 627e5c31af7Sopenharmony_ci return STOP; 628e5c31af7Sopenharmony_ci} 629e5c31af7Sopenharmony_ci 630e5c31af7Sopenharmony_ciclass ProgramLogCase : public TestCase 631e5c31af7Sopenharmony_ci{ 632e5c31af7Sopenharmony_cipublic: 633e5c31af7Sopenharmony_ci enum BuildErrorType 634e5c31af7Sopenharmony_ci { 635e5c31af7Sopenharmony_ci BUILDERROR_VERTEX_FRAGMENT = 0, 636e5c31af7Sopenharmony_ci BUILDERROR_COMPUTE, 637e5c31af7Sopenharmony_ci BUILDERROR_GEOMETRY, 638e5c31af7Sopenharmony_ci BUILDERROR_TESSELLATION, 639e5c31af7Sopenharmony_ci }; 640e5c31af7Sopenharmony_ci 641e5c31af7Sopenharmony_ci ProgramLogCase (Context& ctx, const char* name, const char* desc, BuildErrorType errorType); 642e5c31af7Sopenharmony_ci 643e5c31af7Sopenharmony_ciprivate: 644e5c31af7Sopenharmony_ci void init (void); 645e5c31af7Sopenharmony_ci IterateResult iterate (void); 646e5c31af7Sopenharmony_ci glu::ProgramSources getProgramSources (void) const; 647e5c31af7Sopenharmony_ci 648e5c31af7Sopenharmony_ci const BuildErrorType m_buildErrorType; 649e5c31af7Sopenharmony_ci}; 650e5c31af7Sopenharmony_ci 651e5c31af7Sopenharmony_ciProgramLogCase::ProgramLogCase (Context& ctx, const char* name, const char* desc, BuildErrorType errorType) 652e5c31af7Sopenharmony_ci : TestCase (ctx, name, desc) 653e5c31af7Sopenharmony_ci , m_buildErrorType (errorType) 654e5c31af7Sopenharmony_ci{ 655e5c31af7Sopenharmony_ci} 656e5c31af7Sopenharmony_ci 657e5c31af7Sopenharmony_civoid ProgramLogCase::init (void) 658e5c31af7Sopenharmony_ci{ 659e5c31af7Sopenharmony_ci const bool supportsES32orGL45 = checkSupport(m_context); 660e5c31af7Sopenharmony_ci 661e5c31af7Sopenharmony_ci switch (m_buildErrorType) 662e5c31af7Sopenharmony_ci { 663e5c31af7Sopenharmony_ci case BUILDERROR_VERTEX_FRAGMENT: 664e5c31af7Sopenharmony_ci case BUILDERROR_COMPUTE: 665e5c31af7Sopenharmony_ci break; 666e5c31af7Sopenharmony_ci 667e5c31af7Sopenharmony_ci case BUILDERROR_GEOMETRY: 668e5c31af7Sopenharmony_ci if (!supportsES32orGL45 && !m_context.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) 669e5c31af7Sopenharmony_ci TCU_THROW(NotSupportedError, "Test requires GL_EXT_geometry_shader extension"); 670e5c31af7Sopenharmony_ci break; 671e5c31af7Sopenharmony_ci 672e5c31af7Sopenharmony_ci case BUILDERROR_TESSELLATION: 673e5c31af7Sopenharmony_ci if (!supportsES32orGL45 && !m_context.getContextInfo().isExtensionSupported("GL_EXT_tessellation_shader")) 674e5c31af7Sopenharmony_ci TCU_THROW(NotSupportedError, "Test requires GL_EXT_tessellation_shader extension"); 675e5c31af7Sopenharmony_ci break; 676e5c31af7Sopenharmony_ci 677e5c31af7Sopenharmony_ci default: 678e5c31af7Sopenharmony_ci DE_ASSERT(false); 679e5c31af7Sopenharmony_ci break; 680e5c31af7Sopenharmony_ci } 681e5c31af7Sopenharmony_ci} 682e5c31af7Sopenharmony_ci 683e5c31af7Sopenharmony_ciProgramLogCase::IterateResult ProgramLogCase::iterate (void) 684e5c31af7Sopenharmony_ci{ 685e5c31af7Sopenharmony_ci using gls::StateQueryUtil::StateQueryMemoryWriteGuard; 686e5c31af7Sopenharmony_ci 687e5c31af7Sopenharmony_ci tcu::ResultCollector result (m_testCtx.getLog()); 688e5c31af7Sopenharmony_ci glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog()); 689e5c31af7Sopenharmony_ci glu::ShaderProgram program (m_context.getRenderContext(), getProgramSources()); 690e5c31af7Sopenharmony_ci StateQueryMemoryWriteGuard<glw::GLint> logLen; 691e5c31af7Sopenharmony_ci 692e5c31af7Sopenharmony_ci gl.enableLogging(true); 693e5c31af7Sopenharmony_ci 694e5c31af7Sopenharmony_ci m_testCtx.getLog() << tcu::TestLog::Message << "Trying to link a broken program." << tcu::TestLog::EndMessage; 695e5c31af7Sopenharmony_ci 696e5c31af7Sopenharmony_ci gl.glGetProgramiv(program.getProgram(), GL_INFO_LOG_LENGTH, &logLen); 697e5c31af7Sopenharmony_ci logLen.verifyValidity(result); 698e5c31af7Sopenharmony_ci 699e5c31af7Sopenharmony_ci if (logLen.verifyValidity(result)) 700e5c31af7Sopenharmony_ci verifyInfoLogQuery(result, gl, logLen, program.getProgram(), &glu::CallLogWrapper::glGetProgramInfoLog, "glGetProgramInfoLog"); 701e5c31af7Sopenharmony_ci 702e5c31af7Sopenharmony_ci result.setTestContextResult(m_testCtx); 703e5c31af7Sopenharmony_ci return STOP; 704e5c31af7Sopenharmony_ci} 705e5c31af7Sopenharmony_ci 706e5c31af7Sopenharmony_ciglu::ProgramSources ProgramLogCase::getProgramSources (void) const 707e5c31af7Sopenharmony_ci{ 708e5c31af7Sopenharmony_ci const char* const vertexTemplate1 = "${GLSL_VERSION_DECL}\n" 709e5c31af7Sopenharmony_ci "in highp vec4 a_pos;\n" 710e5c31af7Sopenharmony_ci "uniform highp vec4 u_uniform;\n" 711e5c31af7Sopenharmony_ci "void main()\n" 712e5c31af7Sopenharmony_ci "{\n" 713e5c31af7Sopenharmony_ci " gl_Position = a_pos + u_uniform;\n" 714e5c31af7Sopenharmony_ci "}\n"; 715e5c31af7Sopenharmony_ci const char* const vertexTemplate2 = "${GLSL_VERSION_DECL}\n" 716e5c31af7Sopenharmony_ci "in highp vec4 a_pos;\n" 717e5c31af7Sopenharmony_ci "void main()\n" 718e5c31af7Sopenharmony_ci "{\n" 719e5c31af7Sopenharmony_ci " gl_Position = a_pos;\n" 720e5c31af7Sopenharmony_ci "}\n"; 721e5c31af7Sopenharmony_ci const char* const fragmentTemplate1 = "${GLSL_VERSION_DECL}\n" 722e5c31af7Sopenharmony_ci "in highp vec4 v_missingVar;\n" 723e5c31af7Sopenharmony_ci "uniform highp int u_uniform;\n" 724e5c31af7Sopenharmony_ci "layout(location = 0) out mediump vec4 fragColor;\n" 725e5c31af7Sopenharmony_ci "void main()\n" 726e5c31af7Sopenharmony_ci "{\n" 727e5c31af7Sopenharmony_ci " fragColor = v_missingVar + vec4(float(u_uniform));\n" 728e5c31af7Sopenharmony_ci "}\n"; 729e5c31af7Sopenharmony_ci 730e5c31af7Sopenharmony_ci const char* const fragmentTemplate2 = "${GLSL_VERSION_DECL}\n" 731e5c31af7Sopenharmony_ci "layout(location = 0) out mediump vec4 fragColor;\n" 732e5c31af7Sopenharmony_ci "void main()\n" 733e5c31af7Sopenharmony_ci "{\n" 734e5c31af7Sopenharmony_ci " fragColor = vec4(1.0);\n" 735e5c31af7Sopenharmony_ci "}\n"; 736e5c31af7Sopenharmony_ci const char* const computeTemplate1 = "${GLSL_VERSION_DECL}\n" 737e5c31af7Sopenharmony_ci "layout (binding = 0) buffer IOBuffer { highp float buf_var; };\n" 738e5c31af7Sopenharmony_ci "uniform highp vec4 u_uniform;\n" 739e5c31af7Sopenharmony_ci "void main()\n" 740e5c31af7Sopenharmony_ci "{\n" 741e5c31af7Sopenharmony_ci " buf_var = u_uniform.x;\n" 742e5c31af7Sopenharmony_ci "}\n"; 743e5c31af7Sopenharmony_ci const char* const geometryTemplate1 = "${GLSL_VERSION_DECL}\n" 744e5c31af7Sopenharmony_ci "${GEOMETRY_SHADER_REQUIRE}\n" 745e5c31af7Sopenharmony_ci "layout(triangles) in;\n" 746e5c31af7Sopenharmony_ci "layout(max_vertices=1, points) out;\n" 747e5c31af7Sopenharmony_ci "in highp vec4 v_missingVar[];\n" 748e5c31af7Sopenharmony_ci "uniform highp int u_uniform;\n" 749e5c31af7Sopenharmony_ci "void main()\n" 750e5c31af7Sopenharmony_ci "{\n" 751e5c31af7Sopenharmony_ci " gl_Position = gl_in[0].gl_Position + v_missingVar[2] + vec4(float(u_uniform));\n" 752e5c31af7Sopenharmony_ci " EmitVertex();\n" 753e5c31af7Sopenharmony_ci "}\n"; 754e5c31af7Sopenharmony_ci const char* const tessCtrlTemplate1 = "${GLSL_VERSION_DECL}\n" 755e5c31af7Sopenharmony_ci "${TESSELLATION_SHADER_REQUIRE}\n" 756e5c31af7Sopenharmony_ci "layout(vertices=2) out;" 757e5c31af7Sopenharmony_ci "patch out highp vec2 vp_var;\n" 758e5c31af7Sopenharmony_ci "void main()\n" 759e5c31af7Sopenharmony_ci "{\n" 760e5c31af7Sopenharmony_ci " gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position\n" 761e5c31af7Sopenharmony_ci " gl_TessLevelOuter[0] = 0.8;\n" 762e5c31af7Sopenharmony_ci " gl_TessLevelOuter[1] = 0.8;\n" 763e5c31af7Sopenharmony_ci " if (gl_InvocationID == 0)\n" 764e5c31af7Sopenharmony_ci " vp_var = gl_in[gl_InvocationID].gl_Position.xy;\n" 765e5c31af7Sopenharmony_ci "}\n"; 766e5c31af7Sopenharmony_ci const char* const tessEvalTemplate1 = "${GLSL_VERSION_DECL}\n" 767e5c31af7Sopenharmony_ci "${TESSELLATION_SHADER_REQUIRE}\n" 768e5c31af7Sopenharmony_ci "layout(isolines) in;" 769e5c31af7Sopenharmony_ci "in highp float vp_var[];\n" 770e5c31af7Sopenharmony_ci "void main()\n" 771e5c31af7Sopenharmony_ci "{\n" 772e5c31af7Sopenharmony_ci " gl_Position = gl_in[gl_InvocationID].gl_Position + vec4(vp_var[1]);\n" 773e5c31af7Sopenharmony_ci "}\n"; 774e5c31af7Sopenharmony_ci 775e5c31af7Sopenharmony_ci switch (m_buildErrorType) 776e5c31af7Sopenharmony_ci { 777e5c31af7Sopenharmony_ci case BUILDERROR_VERTEX_FRAGMENT: 778e5c31af7Sopenharmony_ci return glu::ProgramSources() 779e5c31af7Sopenharmony_ci << glu::VertexSource(specializeShader(m_context, vertexTemplate1)) 780e5c31af7Sopenharmony_ci << glu::FragmentSource(specializeShader(m_context, fragmentTemplate1)); 781e5c31af7Sopenharmony_ci 782e5c31af7Sopenharmony_ci case BUILDERROR_COMPUTE: 783e5c31af7Sopenharmony_ci return glu::ProgramSources() 784e5c31af7Sopenharmony_ci << glu::ComputeSource(specializeShader(m_context, computeTemplate1)); 785e5c31af7Sopenharmony_ci 786e5c31af7Sopenharmony_ci case BUILDERROR_GEOMETRY: 787e5c31af7Sopenharmony_ci return glu::ProgramSources() 788e5c31af7Sopenharmony_ci << glu::VertexSource(specializeShader(m_context, vertexTemplate1)) 789e5c31af7Sopenharmony_ci << glu::GeometrySource(specializeShader(m_context, geometryTemplate1)) 790e5c31af7Sopenharmony_ci << glu::FragmentSource(specializeShader(m_context, fragmentTemplate2)); 791e5c31af7Sopenharmony_ci 792e5c31af7Sopenharmony_ci case BUILDERROR_TESSELLATION: 793e5c31af7Sopenharmony_ci return glu::ProgramSources() 794e5c31af7Sopenharmony_ci << glu::VertexSource(specializeShader(m_context, vertexTemplate2)) 795e5c31af7Sopenharmony_ci << glu::TessellationControlSource(specializeShader(m_context, tessCtrlTemplate1)) 796e5c31af7Sopenharmony_ci << glu::TessellationEvaluationSource(specializeShader(m_context, tessEvalTemplate1)) 797e5c31af7Sopenharmony_ci << glu::FragmentSource(specializeShader(m_context, fragmentTemplate2)); 798e5c31af7Sopenharmony_ci 799e5c31af7Sopenharmony_ci default: 800e5c31af7Sopenharmony_ci DE_ASSERT(false); 801e5c31af7Sopenharmony_ci return glu::ProgramSources(); 802e5c31af7Sopenharmony_ci } 803e5c31af7Sopenharmony_ci} 804e5c31af7Sopenharmony_ci 805e5c31af7Sopenharmony_ci} // anonymous 806e5c31af7Sopenharmony_ci 807e5c31af7Sopenharmony_ciProgramStateQueryTests::ProgramStateQueryTests (Context& context) 808e5c31af7Sopenharmony_ci : TestCaseGroup(context, "program", "Program State Query tests") 809e5c31af7Sopenharmony_ci{ 810e5c31af7Sopenharmony_ci} 811e5c31af7Sopenharmony_ci 812e5c31af7Sopenharmony_ciProgramStateQueryTests::~ProgramStateQueryTests (void) 813e5c31af7Sopenharmony_ci{ 814e5c31af7Sopenharmony_ci} 815e5c31af7Sopenharmony_ci 816e5c31af7Sopenharmony_civoid ProgramStateQueryTests::init (void) 817e5c31af7Sopenharmony_ci{ 818e5c31af7Sopenharmony_ci static const QueryType intVerifiers[] = 819e5c31af7Sopenharmony_ci { 820e5c31af7Sopenharmony_ci QUERY_PROGRAM_INTEGER, 821e5c31af7Sopenharmony_ci }; 822e5c31af7Sopenharmony_ci static const QueryType intVec3Verifiers[] = 823e5c31af7Sopenharmony_ci { 824e5c31af7Sopenharmony_ci QUERY_PROGRAM_INTEGER_VEC3, 825e5c31af7Sopenharmony_ci }; 826e5c31af7Sopenharmony_ci 827e5c31af7Sopenharmony_ci#define FOR_EACH_INT_VERIFIER(X) \ 828e5c31af7Sopenharmony_ci do { \ 829e5c31af7Sopenharmony_ci for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(intVerifiers); ++verifierNdx) \ 830e5c31af7Sopenharmony_ci { \ 831e5c31af7Sopenharmony_ci const char* verifierSuffix = getVerifierSuffix(intVerifiers[verifierNdx]); \ 832e5c31af7Sopenharmony_ci const QueryType verifier = intVerifiers[verifierNdx]; \ 833e5c31af7Sopenharmony_ci this->addChild(X); \ 834e5c31af7Sopenharmony_ci } \ 835e5c31af7Sopenharmony_ci } while (0) 836e5c31af7Sopenharmony_ci 837e5c31af7Sopenharmony_ci#define FOR_EACH_VEC_VERIFIER(X) \ 838e5c31af7Sopenharmony_ci do { \ 839e5c31af7Sopenharmony_ci for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(intVec3Verifiers); ++verifierNdx) \ 840e5c31af7Sopenharmony_ci { \ 841e5c31af7Sopenharmony_ci const char* verifierSuffix = getVerifierSuffix(intVec3Verifiers[verifierNdx]); \ 842e5c31af7Sopenharmony_ci const QueryType verifier = intVec3Verifiers[verifierNdx]; \ 843e5c31af7Sopenharmony_ci this->addChild(X); \ 844e5c31af7Sopenharmony_ci } \ 845e5c31af7Sopenharmony_ci } while (0) 846e5c31af7Sopenharmony_ci 847e5c31af7Sopenharmony_ci FOR_EACH_INT_VERIFIER(new ProgramSeparableCase (m_context, verifier, (std::string("program_separable_") + verifierSuffix).c_str(), "Test PROGRAM_SEPARABLE")); 848e5c31af7Sopenharmony_ci FOR_EACH_VEC_VERIFIER(new ComputeWorkGroupSizeCase (m_context, verifier, (std::string("compute_work_group_size_") + verifierSuffix).c_str(), "Test COMPUTE_WORK_GROUP_SIZE")); 849e5c31af7Sopenharmony_ci FOR_EACH_INT_VERIFIER(new ActiveAtomicCounterBuffersCase (m_context, verifier, (std::string("active_atomic_counter_buffers_") + verifierSuffix).c_str(), "Test ACTIVE_ATOMIC_COUNTER_BUFFERS")); 850e5c31af7Sopenharmony_ci FOR_EACH_INT_VERIFIER(new GeometryShaderCase (m_context, verifier, (std::string("geometry_shader_state_") + verifierSuffix).c_str(), "Test Geometry Shader State")); 851e5c31af7Sopenharmony_ci FOR_EACH_INT_VERIFIER(new TessellationShaderCase (m_context, verifier, (std::string("tesselation_shader_state_") + verifierSuffix).c_str(), "Test Tesselation Shader State")); 852e5c31af7Sopenharmony_ci 853e5c31af7Sopenharmony_ci#undef FOR_EACH_INT_VERIFIER 854e5c31af7Sopenharmony_ci#undef FOR_EACH_VEC_VERIFIER 855e5c31af7Sopenharmony_ci 856e5c31af7Sopenharmony_ci // program info log tests 857e5c31af7Sopenharmony_ci // \note, there exists similar tests in gles3 module. However, the gles31 could use a different 858e5c31af7Sopenharmony_ci // shader compiler with different INFO_LOG bugs. 859e5c31af7Sopenharmony_ci { 860e5c31af7Sopenharmony_ci static const struct 861e5c31af7Sopenharmony_ci { 862e5c31af7Sopenharmony_ci const char* caseName; 863e5c31af7Sopenharmony_ci ProgramLogCase::BuildErrorType caseType; 864e5c31af7Sopenharmony_ci } shaderTypes[] = 865e5c31af7Sopenharmony_ci { 866e5c31af7Sopenharmony_ci { "info_log_vertex_fragment_link_fail", ProgramLogCase::BUILDERROR_VERTEX_FRAGMENT }, 867e5c31af7Sopenharmony_ci { "info_log_compute_link_fail", ProgramLogCase::BUILDERROR_COMPUTE }, 868e5c31af7Sopenharmony_ci { "info_log_geometry_link_fail", ProgramLogCase::BUILDERROR_GEOMETRY }, 869e5c31af7Sopenharmony_ci { "info_log_tessellation_link_fail", ProgramLogCase::BUILDERROR_TESSELLATION }, 870e5c31af7Sopenharmony_ci }; 871e5c31af7Sopenharmony_ci 872e5c31af7Sopenharmony_ci for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(shaderTypes); ++ndx) 873e5c31af7Sopenharmony_ci addChild(new ProgramLogCase(m_context, shaderTypes[ndx].caseName, "", shaderTypes[ndx].caseType)); 874e5c31af7Sopenharmony_ci } 875e5c31af7Sopenharmony_ci} 876e5c31af7Sopenharmony_ci 877e5c31af7Sopenharmony_ci} // Functional 878e5c31af7Sopenharmony_ci} // gles31 879e5c31af7Sopenharmony_ci} // deqp 880