1 #ifndef _GL4CSPARSETEXTURETESTS_HPP
2 #define _GL4CSPARSETEXTURETESTS_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 gl4cSparseTextureTests.hpp
29 * \brief Conformance tests for the GL_ARB_sparse_texture functionality.
30 */ /*-------------------------------------------------------------------*/
31 #include "glcTestCase.hpp"
32 #include "glwDefs.hpp"
33 #include "glwEnums.hpp"
34 #include "tcuDefs.hpp"
37 #include "gluTextureUtil.hpp"
38 #include "tcuTextureUtil.hpp"
42 class SparseTextureUtils
45 static bool verifyQueryError(tcu::TestContext& testCtx, const char* funcName, glw::GLint target, glw::GLint pname,
46 glw::GLint error, glw::GLint expectedError);
48 static bool verifyError(tcu::TestContext& testCtx, const char* funcName, glw::GLint error,
49 glw::GLint expectedError);
51 static glw::GLint getTargetDepth(glw::GLint target);
53 static void getTexturePageSizes(const glw::Functions& gl, glw::GLint target, glw::GLint format,
54 glw::GLint& pageSizeX, glw::GLint& pageSizeY, glw::GLint& pageSizeZ);
57 /** Represents texture static helper
62 /* Public static routines */
64 static void Bind(const glw::Functions& gl, glw::GLuint id, glw::GLenum target);
66 static void Generate(const glw::Functions& gl, glw::GLuint& out_id);
68 static void Delete(const glw::Functions& gl, glw::GLuint& id);
70 static void Storage(const glw::Functions& gl, glw::GLenum target, glw::GLsizei levels, glw::GLenum internal_format,
71 glw::GLuint width, glw::GLuint height, glw::GLuint depth);
73 static void SubImage(const glw::Functions& gl, glw::GLenum target, glw::GLint level, glw::GLint x, glw::GLint y,
74 glw::GLint z, glw::GLsizei width, glw::GLsizei height, glw::GLsizei depth, glw::GLenum format,
75 glw::GLenum type, const glw::GLvoid* pixels);
80 /* Public constants */
81 static const glw::GLuint m_invalid_id;
84 /** Test verifies TexParameter{if}{v}, TexParameterI{u}v, GetTexParameter{if}v
85 * and GetTexParameterIi{u}v queries for <pname>:
86 * - TEXTURE_SPARSE_ARB,
87 * - VIRTUAL_PAGE_SIZE_INDEX_ARB.
88 * Test verifies also GetTexParameter{if}v and GetTexParameterIi{u}v queries for <pname>:
89 * - NUM_SPARSE_LEVELS_ARB
91 class TextureParameterQueriesTestCase : public deqp::TestCase
95 TextureParameterQueriesTestCase(deqp::Context& context);
98 tcu::TestNode::IterateResult iterate();
101 /* Private members */
102 std::vector<glw::GLint> mSupportedTargets;
103 std::vector<glw::GLint> mNotSupportedTargets;
105 /* Private methods */
106 bool testTextureSparseARB(const glw::Functions& gl, glw::GLint target, glw::GLint expectedError = GL_NO_ERROR);
107 bool testVirtualPageSizeIndexARB(const glw::Functions& gl, glw::GLint target,
108 glw::GLint expectedError = GL_NO_ERROR);
109 bool testNumSparseLevelsARB(const glw::Functions& gl, glw::GLint target);
111 bool checkGetTexParameter(const glw::Functions& gl, glw::GLint target, glw::GLint pname, glw::GLint expected);
114 /** Test verifies GetInternalformativ query for formats from Table 8.12 and <pname>:
115 * - NUM_VIRTUAL_PAGE_SIZES_ARB,
116 * - VIRTUAL_PAGE_SIZE_X_ARB,
117 * - VIRTUAL_PAGE_SIZE_Y_ARB,
118 * - VIRTUAL_PAGE_SIZE_Z_ARB.
120 class InternalFormatQueriesTestCase : public deqp::TestCase
124 InternalFormatQueriesTestCase(deqp::Context& context);
127 tcu::TestNode::IterateResult iterate();
130 /* Private methods */
131 std::vector<glw::GLint> mSupportedTargets;
132 std::vector<glw::GLint> mSupportedInternalFormats;
134 /* Private members */
137 /** Test verifies GetIntegerv, GetFloatv, GetDoublev, GetInteger64v,
138 * and GetBooleanv queries for <pname>:
139 * - MAX_SPARSE_TEXTURE_SIZE_ARB,
140 * - MAX_SPARSE_3D_TEXTURE_SIZE_ARB,
141 * - MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB,
142 * - SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB.
144 class SimpleQueriesTestCase : public deqp::TestCase
148 SimpleQueriesTestCase(deqp::Context& context);
150 tcu::TestNode::IterateResult iterate();
153 /* Private methods */
154 /* Private members */
155 void testSipmleQueries(const glw::Functions& gl, glw::GLint pname);
158 /** Test verifies glTexStorage* functionality added by ARB_sparse_texture extension
160 class SparseTextureAllocationTestCase : public deqp::TestCase
164 SparseTextureAllocationTestCase(deqp::Context& context);
166 SparseTextureAllocationTestCase(deqp::Context& context, const char* name, const char* description);
169 virtual tcu::TestNode::IterateResult iterate();
172 /* Protected methods */
173 std::vector<glw::GLint> mSupportedTargets;
174 std::vector<glw::GLint> mFullArrayTargets;
175 std::vector<glw::GLint> mSupportedInternalFormats;
177 /* Protected members */
178 void positiveTesting(const glw::Functions& gl, glw::GLint target, glw::GLint format);
179 bool verifyTexParameterErrors(const glw::Functions& gl, glw::GLint target, glw::GLint format);
180 bool verifyTexStorageVirtualPageSizeIndexError(const glw::Functions& gl, glw::GLint target, glw::GLint format);
181 bool verifyTexStorageFullArrayCubeMipmapsError(const glw::Functions& gl, glw::GLint target, glw::GLint format);
182 bool verifyTexStorageInvalidValueErrors(const glw::Functions& gl, glw::GLint target, glw::GLint format);
185 /** Test verifies glTexPageCommitmentARB functionality added by ARB_sparse_texture extension
187 class SparseTextureCommitmentTestCase : public deqp::TestCase
191 SparseTextureCommitmentTestCase(deqp::Context& context);
193 SparseTextureCommitmentTestCase(deqp::Context& context, const char* name, const char* description);
196 virtual tcu::TestNode::IterateResult iterate();
199 /* Protected members */
200 std::vector<glw::GLint> mSupportedTargets;
201 std::vector<glw::GLint> mSupportedInternalFormats;
203 glw::GLint mWidthStored;
204 glw::GLint mHeightStored;
205 glw::GLint mDepthStored;
206 tcu::TextureFormat mTextureFormatStored;
208 /* Protected methods */
209 void texPageCommitment(const glw::Functions& gl, glw::GLint target, glw::GLint format, glw::GLuint& texture,
210 glw::GLint level, glw::GLint xOffset, glw::GLint yOffset, glw::GLint zOffset,
211 glw::GLint width, glw::GLint height, glw::GLint depth, glw::GLboolean committ);
213 bool prepareTexture(const glw::Functions& gl, glw::GLint target, glw::GLint format, glw::GLuint& texture);
214 bool sparseAllocateTexture(const glw::Functions& gl, glw::GLint target, glw::GLint format, glw::GLuint& texture);
215 bool allocateTexture(const glw::Functions& gl, glw::GLint target, glw::GLint format, glw::GLuint& texture);
216 bool writeDataToTexture(const glw::Functions& gl, glw::GLint target, glw::GLint format, glw::GLuint& texture);
217 bool verifyTextureData(const glw::Functions& gl, glw::GLint target, glw::GLint format, glw::GLuint& texture);
218 bool commitTexturePage(const glw::Functions& gl, glw::GLint target, glw::GLint format, glw::GLuint& texture);
220 bool verifyInvalidOperationErrors(const glw::Functions& gl, glw::GLint target, glw::GLint format,
221 glw::GLuint& texture);
222 bool verifyInvalidValueErrors(const glw::Functions& gl, glw::GLint target, glw::GLint format, glw::GLuint& texture);
225 /** Test verifies glTexturePageCommitmentEXT functionality added by ARB_sparse_texture extension
227 class SparseDSATextureCommitmentTestCase : public SparseTextureCommitmentTestCase
231 SparseDSATextureCommitmentTestCase(deqp::Context& context);
233 virtual tcu::TestNode::IterateResult iterate();
236 /* Private methods */
237 virtual void texPageCommitment(const glw::Functions& gl, glw::GLint target, glw::GLint format, glw::GLuint& texture,
238 glw::GLint level, glw::GLint xOffset, glw::GLint yOffset, glw::GLint zOffset,
239 glw::GLint width, glw::GLint height, glw::GLint depth, glw::GLboolean committ);
242 /** Test group which encapsulates all sparse texture conformance tests */
243 class SparseTextureTests : public deqp::TestCaseGroup
247 SparseTextureTests(deqp::Context& context);
252 SparseTextureTests(const SparseTextureTests& other);
253 SparseTextureTests& operator=(const SparseTextureTests& other);
256 } /* glcts namespace */
258 #endif // _GL4CSPARSETEXTURETESTS_HPP