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 GL_ARB_sparse_texture2 extension is available for GLSL
70 class ShaderExtensionTestCase : public deqp::TestCase
74 ShaderExtensionTestCase(deqp::Context& context);
76 tcu::TestNode::IterateResult iterate();
82 /** Test verifies if values returned by GetInternalFormat* query matches Standard Virtual Page Sizes for <pname>:
83 * - VIRTUAL_PAGE_SIZE_X_ARB,
84 * - VIRTUAL_PAGE_SIZE_Y_ARB,
85 * - VIRTUAL_PAGE_SIZE_Z_ARB.
87 class StandardPageSizesTestCase : public deqp::TestCase
91 StandardPageSizesTestCase(deqp::Context& context);
94 tcu::TestNode::IterateResult iterate();
98 std::vector<GLint> mSupportedTargets;
99 std::map<GLint, PageSizeStruct> mStandardVirtualPageSizesTable;
101 /* Private members */
104 /** Test verifies glTexStorage* functionality added by ARB_sparse_texture2 extension
106 class SparseTexture2AllocationTestCase : public SparseTextureAllocationTestCase
110 SparseTexture2AllocationTestCase(deqp::Context& context);
113 virtual tcu::TestNode::IterateResult iterate();
116 /* Private methods */
119 /** Test verifies glTexPageCommitmentARB functionality added by ARB_sparse_texture2 extension
121 class SparseTexture2CommitmentTestCase : public SparseTextureCommitmentTestCase
125 SparseTexture2CommitmentTestCase(deqp::Context& context);
127 SparseTexture2CommitmentTestCase(deqp::Context& context, const char* name, const char* description);
130 virtual tcu::TestNode::IterateResult iterate();
133 /* Protected members */
137 std::string pointType;
138 std::string pointDef;
139 std::string outputType;
140 std::string inputType;
141 std::string returnType;
142 std::string resultExpected;
143 std::string resultDefault;
145 std::string sampleDef;
148 /* Protected methods */
149 TokenStrings createShaderTokens(GLint target, GLint format, GLint sample, const std::string outputBase = "image",
150 const std::string inputBase = "image");
152 virtual bool caseAllowed(GLint target, GLint format);
154 virtual bool sparseAllocateTexture(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint levels);
155 virtual bool allocateTexture(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint levels);
156 virtual bool writeDataToTexture(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
157 virtual bool verifyTextureData(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
160 /** Test verifies if access to uncommitted regions of sparse texture works as expected
162 class UncommittedRegionsAccessTestCase : public SparseTexture2CommitmentTestCase
166 UncommittedRegionsAccessTestCase(deqp::Context& context);
169 virtual tcu::TestNode::IterateResult iterate();
172 /* Private members */
174 GLuint mRenderbuffer;
176 /* Private methods */
177 bool readsAllowed(GLint target, GLint format, bool shaderOnly = false);
178 bool atomicAllowed(GLint target, GLint format);
179 bool depthStencilAllowed(GLint target, GLint format);
181 bool UncommittedReads(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
182 bool UncommittedAtomicOperations(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
183 bool UncommittedDepthStencil(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
185 void prepareDepthStencilFramebuffer(const Functions& gl, GLint width, GLint height);
186 void cleanupDepthStencilFramebuffer(const Functions& gl);
187 bool verifyTextureDataExtended(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level,
188 bool shaderOnly = false);
189 bool verifyAtomicOperations(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
190 bool verifyStencilTest(const Functions& gl, ShaderProgram& program, GLint width, GLint height,
191 GLint widthCommitted);
192 bool verifyDepthTest(const Functions& gl, ShaderProgram& program, GLint width, GLint height, GLint widthCommitted);
193 bool verifyDepthBoundsTest(const Functions& gl, ShaderProgram& program, GLint width, GLint height,
194 GLint widthCommitted);
197 /** Test verifies if sparse texture lookup functions for GLSL works as expected
199 class SparseTexture2LookupTestCase : public SparseTexture2CommitmentTestCase
203 SparseTexture2LookupTestCase(deqp::Context& context);
206 tcu::TestNode::IterateResult iterate();
213 std::string arguments;
215 std::set<GLint> allowedTargets;
221 FunctionToken(std::string fname, std::string fargs) : name(fname), arguments(fargs)
226 struct TokenStringsExt : public TokenStrings
228 std::string formatDef;
231 std::string coordType;
232 std::string coordDef;
233 std::string cubeMapCoordDef;
235 std::string offsetDim;
236 std::string componentDef;
237 std::string offsetArrayDef;
238 std::string pointCoord;
241 /* Private members */
242 std::vector<FunctionToken> mFunctions;
244 /* Private methods */
245 TokenStringsExt createLookupShaderTokens(GLint target, GLint format, GLint level, GLint sample,
246 FunctionToken& funcToken);
248 virtual bool caseAllowed(GLint target, GLint format);
249 virtual bool funcAllowed(GLint target, GLint format, FunctionToken& funcToken);
251 virtual bool writeDataToTexture(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
253 virtual void setupDepthMode(const Functions& gl, GLint target, GLuint& texture);
254 virtual bool verifyLookupTextureData(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level,
255 FunctionToken& funcToken);
258 /** Test group which encapsulates all sparse texture conformance tests */
259 class SparseTexture2Tests : public deqp::TestCaseGroup
263 SparseTexture2Tests(deqp::Context& context);
268 SparseTexture2Tests(const SparseTexture2Tests& other);
269 SparseTexture2Tests& operator=(const SparseTexture2Tests& other);
272 } /* glcts namespace */
274 #endif // _GL4CSPARSETEXTURE2TESTS_HPP