1 #ifndef _GLCSHADERLIBRARYCASE_HPP
2 #define _GLCSHADERLIBRARYCASE_HPP
3 /*-------------------------------------------------------------------------
4 * OpenGL Conformance Test Suite
5 * -----------------------------
7 * Copyright (c) 2016 Google Inc.
8 * Copyright (c) 2016 The Khronos Group Inc.
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
24 * \brief Shader test case.
25 */ /*-------------------------------------------------------------------*/
27 #include "glcTestCase.hpp"
28 #include "gluDefs.hpp"
29 #include "gluRenderContext.hpp"
30 #include "gluShaderUtil.hpp"
31 #include "tcuSurface.hpp"
43 class ShaderCase : public tcu::TestCase
48 CASETYPE_COMPLETE = 0, //!< Has both shaders.
49 CASETYPE_VERTEX_ONLY, //!< Has only vertex shader.
50 CASETYPE_FRAGMENT_ONLY, //!< Has only fragment shader.
75 /* \todo [2010-03-31 petri] Replace with another vector to allow a) arrays, b) compact representation */
82 StorageType storageType;
83 std::string valueName;
84 glu::DataType dataType;
85 int arrayLength; // Number of elements in array (currently always 1).
86 std::vector<Element> elements; // Scalar values (length dataType.scalarSize * arrayLength).
91 int arrayLength; // Combined array length of each value (lengths must be same, or one).
92 std::vector<Value> values;
101 ShaderCase(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* caseName, const char* description,
102 ExpectResult expectResult, const std::vector<ValueBlock>& valueBlocks, glu::GLSLVersion targetVersion,
103 const char* vertexSource, const char* fragmentSource);
105 virtual ~ShaderCase(void);
107 CaseType getCaseType(void) const
111 const std::vector<ValueBlock>& getValueBlocks(void) const
113 return m_valueBlocks;
115 const char* getVertexSource(void) const
117 return m_vertexSource.c_str();
119 const char* getFragmentSource(void) const
121 return m_fragmentSource.c_str();
125 IterateResult iterate(void);
128 ShaderCase(const ShaderCase&); // not allowed!
129 ShaderCase& operator=(const ShaderCase&); // not allowed!
131 std::string genVertexShader(const ValueBlock& valueBlock);
132 std::string genFragmentShader(const ValueBlock& valueBlock);
133 std::string specializeVertexShader(const char* src, const ValueBlock& valueBlock);
134 std::string specializeFragmentShader(const char* src, const ValueBlock& valueBlock);
136 void specializeShaders(const char* vertexSource, const char* fragmentSource, std::string& outVertexSource,
137 std::string& outFragmentSource, const ValueBlock& valueBlock);
139 void dumpValues(const ValueBlock& valueBlock, int arrayNdx);
141 bool checkPixels(tcu::Surface& surface, int minX, int maxX, int minY, int maxY);
144 glu::RenderContext& m_renderCtx;
146 ExpectResult m_expectResult;
147 std::vector<ValueBlock> m_valueBlocks;
148 glu::GLSLVersion m_targetVersion;
149 std::string m_vertexSource;
150 std::string m_fragmentSource;
156 #endif // _GLCSHADERLIBRARYCASE_HPP