• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _GL4CSPARSETEXTURETESTS_HPP
2 #define _GL4CSPARSETEXTURETESTS_HPP
3 /*-------------------------------------------------------------------------
4  * OpenGL Conformance Test Suite
5  * -----------------------------
6  *
7  * Copyright (c) 2016 The Khronos Group Inc.
8  *
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
21  */ /*!
22  * \file
23  * \brief
24  */ /*-------------------------------------------------------------------*/
25 
26 /**
27  */ /*!
28  * \file  gl4cSparseTextureTests.hpp
29  * \brief Conformance tests for the GL_ARB_sparse_texture functionality.
30  */ /*-------------------------------------------------------------------*/
31 
32 #include "glcTestCase.hpp"
33 #include "glwDefs.hpp"
34 #include "glwEnums.hpp"
35 #include "tcuDefs.hpp"
36 #include <sstream>
37 #include <vector>
38 
39 #include "gluTextureUtil.hpp"
40 #include "tcuTextureUtil.hpp"
41 
42 using namespace glw;
43 using namespace glu;
44 
45 namespace gl4cts
46 {
47 
48 struct TextureState
49 {
50 	GLint			   width;
51 	GLint			   height;
52 	GLint			   depth;
53 	GLint			   levels;
54 	GLint			   samples;
55 	tcu::TextureFormat format;
56 
57 	GLint minDepth;
58 
59 	GLint pageSizeX;
60 	GLint pageSizeY;
61 	GLint pageSizeZ;
62 };
63 
64 class SparseTextureUtils
65 {
66 public:
67 	static bool verifyQueryError(std::stringstream& log, const char* funcName, GLint target, GLint pname, GLint error,
68 								 GLint expectedError);
69 
70 	static bool verifyError(std::stringstream& log, const char* funcName, GLint error, GLint expectedError);
71 
72 	static GLint getTargetDepth(GLint target);
73 
74 	static void getTexturePageSizes(const Functions& gl, GLint target, GLint format, GLint& pageSizeX, GLint& pageSizeY,
75 									GLint& pageSizeZ);
76 
77 	static void getTextureLevelSize(GLint target, TextureState& state, GLint level, GLint& width, GLint& height,
78 									GLint& depth);
79 };
80 
81 /** Represents texture static helper
82  **/
83 class Texture
84 {
85 public:
86 	/* Public static routines */
87 	/* Functionality */
88 	static void Bind(const Functions& gl, GLuint id, GLenum target);
89 
90 	static void Generate(const Functions& gl, GLuint& out_id);
91 
92 	static void Delete(const Functions& gl, GLuint& id);
93 
94 	static void Storage(const Functions& gl, GLenum target, GLsizei levels, GLenum internal_format, GLuint width,
95 						GLuint height, GLuint depth);
96 
97 	static void GetData(const Functions& gl, GLint level, GLenum target, GLenum format, GLenum type, GLvoid* out_data);
98 
99 	static void SubImage(const Functions& gl, GLenum target, GLint level, GLint x, GLint y, GLint z, GLsizei width,
100 						 GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
101 
102 	/* Public fields */
103 	GLuint m_id;
104 
105 	/* Public constants */
106 	static const GLuint m_invalid_id;
107 };
108 
109 /** Test verifies TexParameter{if}{v}, TexParameterI{u}v, GetTexParameter{if}v
110  * and GetTexParameterIi{u}v queries for <pname>:
111  *   - TEXTURE_SPARSE_ARB,
112  *   - VIRTUAL_PAGE_SIZE_INDEX_ARB.
113  * Test verifies also GetTexParameter{if}v and GetTexParameterIi{u}v queries for <pname>:
114  *   - NUM_SPARSE_LEVELS_ARB
115  **/
116 class TextureParameterQueriesTestCase : public deqp::TestCase
117 {
118 public:
119 	/* Public methods */
120 	TextureParameterQueriesTestCase(deqp::Context& context);
121 
122 	void						 init();
123 	tcu::TestNode::IterateResult iterate();
124 
125 private:
126 	/* Private members */
127 	std::stringstream mLog;
128 
129 	std::vector<GLint> mSupportedTargets;
130 	std::vector<GLint> mNotSupportedTargets;
131 
132 	/* Private methods */
133 	bool testTextureSparseARB(const Functions& gl, GLint target, GLint expectedError = GL_NO_ERROR);
134 	bool testVirtualPageSizeIndexARB(const Functions& gl, GLint target, GLint expectedError = GL_NO_ERROR);
135 	bool testNumSparseLevelsARB(const Functions& gl, GLint target);
136 
137 	bool checkGetTexParameter(const Functions& gl, GLint target, GLint pname, GLint expected);
138 };
139 
140 /** Test verifies GetInternalformativ query for formats from Table 8.12 and <pname>:
141  *   - NUM_VIRTUAL_PAGE_SIZES_ARB,
142  *   - VIRTUAL_PAGE_SIZE_X_ARB,
143  *   - VIRTUAL_PAGE_SIZE_Y_ARB,
144  *   - VIRTUAL_PAGE_SIZE_Z_ARB.
145  **/
146 class InternalFormatQueriesTestCase : public deqp::TestCase
147 {
148 public:
149 	/* Public methods */
150 	InternalFormatQueriesTestCase(deqp::Context& context);
151 
152 	void						 init();
153 	tcu::TestNode::IterateResult iterate();
154 
155 private:
156 	/* Private methods */
157 	std::stringstream mLog;
158 
159 	std::vector<GLint> mSupportedTargets;
160 	std::vector<GLint> mSupportedInternalFormats;
161 
162 	/* Private members */
163 };
164 
165 /** Test verifies GetIntegerv, GetFloatv, GetDoublev, GetInteger64v,
166  * and GetBooleanv queries for <pname>:
167  *   - MAX_SPARSE_TEXTURE_SIZE_ARB,
168  *   - MAX_SPARSE_3D_TEXTURE_SIZE_ARB,
169  *   - MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB,
170  *   - SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB.
171  **/
172 class SimpleQueriesTestCase : public deqp::TestCase
173 {
174 public:
175 	/* Public methods */
176 	SimpleQueriesTestCase(deqp::Context& context);
177 
178 	tcu::TestNode::IterateResult iterate();
179 
180 private:
181 	/* Private methods */
182 	/* Private members */
183 	void testSipmleQueries(const Functions& gl, GLint pname);
184 };
185 
186 /** Test verifies glTexStorage* functionality added by ARB_sparse_texture extension
187  **/
188 class SparseTextureAllocationTestCase : public deqp::TestCase
189 {
190 public:
191 	/* Public methods */
192 	SparseTextureAllocationTestCase(deqp::Context& context);
193 
194 	SparseTextureAllocationTestCase(deqp::Context& context, const char* name, const char* description);
195 
196 	virtual void						 init();
197 	virtual tcu::TestNode::IterateResult iterate();
198 
199 protected:
200 	/* Protected methods */
201 	std::stringstream mLog;
202 
203 	std::vector<GLint> mSupportedTargets;
204 	std::vector<GLint> mFullArrayTargets;
205 	std::vector<GLint> mSupportedInternalFormats;
206 
207 	/* Protected members */
208 	bool positiveTesting(const Functions& gl, GLint target, GLint format);
209 	bool verifyTexParameterErrors(const Functions& gl, GLint target, GLint format);
210 	bool verifyTexStorageVirtualPageSizeIndexError(const Functions& gl, GLint target, GLint format);
211 	bool verifyTexStorageFullArrayCubeMipmapsError(const Functions& gl, GLint target, GLint format);
212 	bool verifyTexStorageInvalidValueErrors(const Functions& gl, GLint target, GLint format);
213 };
214 
215 /** Test verifies glTexPageCommitmentARB functionality added by ARB_sparse_texture extension
216  **/
217 class SparseTextureCommitmentTestCase : public deqp::TestCase
218 {
219 public:
220 	/* Public methods */
221 	SparseTextureCommitmentTestCase(deqp::Context& context);
222 
223 	SparseTextureCommitmentTestCase(deqp::Context& context, const char* name, const char* description);
224 
225 	virtual void						 init();
226 	virtual tcu::TestNode::IterateResult iterate();
227 
228 protected:
229 	/* Protected members */
230 	std::stringstream mLog;
231 
232 	std::vector<GLint> mSupportedTargets;
233 	std::vector<GLint> mSupportedInternalFormats;
234 
235 	TextureState mState;
236 
237 	/* Protected methods */
238 	virtual void texPageCommitment(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level,
239 								   GLint xOffset, GLint yOffset, GLint zOffset, GLint width, GLint height, GLint depth,
240 								   GLboolean committ);
241 
242 	virtual bool caseAllowed(GLint target, GLint format);
243 
244 	virtual bool prepareTexture(const Functions& gl, GLint target, GLint format, GLuint& texture);
245 	virtual bool sparseAllocateTexture(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint levels);
246 	virtual bool allocateTexture(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint levels);
247 	virtual bool writeDataToTexture(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
248 	virtual bool verifyTextureData(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
249 	virtual bool commitTexturePage(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level);
250 
251 	virtual bool isInPageSizesRange(GLint target, GLint level);
252 	virtual bool isPageSizesMultiplication(GLint target, GLint level);
253 
254 	virtual bool verifyInvalidOperationErrors(const Functions& gl, GLint target, GLint format, GLuint& texture);
255 	virtual bool verifyInvalidValueErrors(const Functions& gl, GLint target, GLint format, GLuint& texture);
256 };
257 
258 /** Test verifies glTexturePageCommitmentEXT functionality added by ARB_sparse_texture extension
259  **/
260 class SparseDSATextureCommitmentTestCase : public SparseTextureCommitmentTestCase
261 {
262 public:
263 	/* Public methods */
264 	SparseDSATextureCommitmentTestCase(deqp::Context& context);
265 
266 	virtual tcu::TestNode::IterateResult iterate();
267 
268 private:
269 	/* Private methods */
270 	virtual void texPageCommitment(const Functions& gl, GLint target, GLint format, GLuint& texture, GLint level,
271 								   GLint xOffset, GLint yOffset, GLint zOffset, GLint width, GLint height, GLint depth,
272 								   GLboolean committ);
273 };
274 
275 /** Test group which encapsulates all sparse texture conformance tests */
276 class SparseTextureTests : public deqp::TestCaseGroup
277 {
278 public:
279 	/* Public methods */
280 	SparseTextureTests(deqp::Context& context);
281 
282 	void init();
283 
284 private:
285 	SparseTextureTests(const SparseTextureTests& other);
286 	SparseTextureTests& operator=(const SparseTextureTests& other);
287 };
288 
289 } /* glcts namespace */
290 
291 #endif // _GL4CSPARSETEXTURETESTS_HPP
292