1 #ifndef _GL4CSPARSETEXTURE2TESTS_HPP
2 #define _GL4CSPARSETEXTURE2TESTS_HPP
3 /*-------------------------------------------------------------------------
4 * OpenGL Conformance Test Suite
5 * -----------------------------
7 * Copyright (c) 2016 The Khronos Group Inc.
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
24 */ /*-------------------------------------------------------------------*/
28 * \file gl4cSparseTexture2Tests.hpp
29 * \brief Conformance tests for the GL_ARB_sparse_texture2 functionality.
30 */ /*-------------------------------------------------------------------*/
32 #include "glcTestCase.hpp"
33 #include "glwDefs.hpp"
34 #include "glwEnums.hpp"
35 #include "tcuDefs.hpp"
40 #include "gl4cSparseTextureTests.hpp"
41 #include "gluDrawUtil.hpp"
42 #include "gluShaderProgram.hpp"
43 #include "gluTextureUtil.hpp"
44 #include "tcuTextureUtil.hpp"
58 PageSizeStruct() : xSize(0), ySize(0), zSize(0)
61 PageSizeStruct(GLint x, GLint y, GLint z) : xSize(x), ySize(y), zSize(z)
66 typedef std::pair<GLint, PageSizeStruct> PageSizePair;
68 /** Test verifies if extension is available for GLSL
70 class ShaderExtensionTestCase : public deqp::TestCase
74 ShaderExtensionTestCase(deqp::Context& context, const std::string extension);
76 tcu::TestNode::IterateResult iterate();
80 std::string mExtension;
83 /** Test verifies if values returned by GetInternalFormat* query matches Standard Virtual Page Sizes for <pname>:
84 * - VIRTUAL_PAGE_SIZE_X_ARB,
85 * - VIRTUAL_PAGE_SIZE_Y_ARB,
86 * - VIRTUAL_PAGE_SIZE_Z_ARB.
88 class StandardPageSizesTestCase : public deqp::TestCase
92 StandardPageSizesTestCase(deqp::Context& context);
95 tcu::TestNode::IterateResult iterate();
99 std::vector<GLint> mSupportedTargets;
100 std::map<GLint, PageSizeStruct> mStandardVirtualPageSizesTable;
102 /* Private members */
105 /** Test verifies glTexStorage* functionality added by ARB_sparse_texture2 extension
107 class SparseTexture2AllocationTestCase : public SparseTextureAllocationTestCase
111 SparseTexture2AllocationTestCase(deqp::Context& context);
114 virtual tcu::TestNode::IterateResult iterate();
117 /* Private methods */
120 /** Test verifies glTexPageCommitmentARB functionality added by ARB_sparse_texture2 extension
122 class SparseTexture2CommitmentTestCase : public SparseTextureCommitmentTestCase
126 SparseTexture2CommitmentTestCase(deqp::Context& context);
128 SparseTexture2CommitmentTestCase(deqp::Context& context, const char* name, const char* description);
131 virtual tcu::TestNode::IterateResult iterate();
134 /* Protected members */
138 std::string pointType;
139 std::string pointDef;
140 std::string outputType;
141 std::string inputType;
142 std::string returnType;
143 std::string resultExpected;
144 std::string resultDefault;
146 std::string sampleDef;
149 /* Protected methods */
150 TokenStrings createShaderTokens(GLint target, GLint format, GLint sample, const std::string outputBase = "image",
151 const std::string inputBase = "image");
153 virtual bool caseAllowed(GLint target, GLint format);
155 virtual bool sparseAllocateTexture(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint levels);
156 virtual bool allocateTexture(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint levels);
157 virtual bool writeDataToTexture(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
158 virtual bool verifyTextureData(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
161 /** Test verifies if access to uncommitted regions of sparse texture works as expected
163 class UncommittedRegionsAccessTestCase : public SparseTexture2CommitmentTestCase
167 UncommittedRegionsAccessTestCase(deqp::Context& context);
170 virtual tcu::TestNode::IterateResult iterate();
173 /* Private members */
175 GLuint mRenderbuffer;
177 /* Private methods */
178 bool readsAllowed(GLint target, GLint format, bool shaderOnly = false);
179 bool atomicAllowed(GLint target, GLint format);
180 bool depthStencilAllowed(GLint target, GLint format);
182 bool UncommittedReads(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
183 bool UncommittedAtomicOperations(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
184 bool UncommittedDepthStencil(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
186 void prepareDepthStencilFramebuffer(const Functions& gl, GLint width, GLint height);
187 void cleanupDepthStencilFramebuffer(const Functions& gl);
188 bool verifyTextureDataExtended(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level,
189 bool shaderOnly = false);
190 bool verifyAtomicOperations(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
191 bool verifyStencilTest(const Functions& gl, ShaderProgram& program, GLint width, GLint height,
192 GLint widthCommitted);
193 bool verifyDepthTest(const Functions& gl, ShaderProgram& program, GLint width, GLint height, GLint widthCommitted);
194 bool verifyDepthBoundsTest(const Functions& gl, ShaderProgram& program, GLint width, GLint height,
195 GLint widthCommitted);
198 /** Test verifies if sparse texture lookup functions for GLSL works as expected
200 class SparseTexture2LookupTestCase : public SparseTexture2CommitmentTestCase
204 SparseTexture2LookupTestCase(deqp::Context& context);
206 SparseTexture2LookupTestCase(deqp::Context& context, const char* name, const char* description);
209 tcu::TestNode::IterateResult iterate();
212 /* Protected types */
216 std::string arguments;
218 std::set<GLint> allowedTargets;
224 FunctionToken(std::string fname, std::string fargs) : name(fname), arguments(fargs)
229 struct TokenStringsExt : public TokenStrings
231 std::string formatDef;
235 std::string coordType;
236 std::string iCoordType;
237 std::string coordDef;
238 std::string cubeMapCoordDef;
240 std::string offsetDim;
241 std::string offsetType;
242 std::string nOffsetType;
243 std::string componentDef;
244 std::string offsetArrayDef;
245 std::string pointCoord;
248 /* Protected members */
249 std::vector<FunctionToken> mFunctions;
251 /* Protected methods */
252 TokenStringsExt createLookupShaderTokens(GLint target, GLint format, GLint level, GLint sample,
253 FunctionToken& funcToken);
255 virtual bool caseAllowed(GLint target, GLint format);
256 virtual bool funcAllowed(GLint target, GLint format, FunctionToken& funcToken);
258 virtual bool writeDataToTexture(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
260 virtual void setupDepthMode(const Functions& gl, GLint target, GLuint& texture);
261 virtual bool verifyLookupTextureData(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level,
262 FunctionToken& funcToken);
265 /** Test group which encapsulates all sparse texture conformance tests */
266 class SparseTexture2Tests : public deqp::TestCaseGroup
270 SparseTexture2Tests(deqp::Context& context);
275 SparseTexture2Tests(const SparseTexture2Tests& other);
276 SparseTexture2Tests& operator=(const SparseTexture2Tests& other);
279 void replaceToken(const GLchar* token, const GLchar* text, std::string& string);
281 } /* glcts namespace */
283 #endif // _GL4CSPARSETEXTURE2TESTS_HPP