0c3a6a54797279344c4a46e36c974631bef4a46f
[platform/upstream/VK-GL-CTS.git] / external / openglcts / modules / gl / gl4cSparseTextureTests.hpp
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 #include "glcTestCase.hpp"
32 #include "glwDefs.hpp"
33 #include "glwEnums.hpp"
34 #include "tcuDefs.hpp"
35 #include <vector>
36
37 #include "gluTextureUtil.hpp"
38 #include "tcuTextureUtil.hpp"
39
40 namespace gl4cts
41 {
42 class SparseTextureUtils
43 {
44 public:
45         static bool verifyQueryError(tcu::TestContext& testCtx, const char* funcName, glw::GLint target, glw::GLint pname,
46                                                                  glw::GLint error, glw::GLint expectedError);
47
48         static bool verifyError(tcu::TestContext& testCtx, const char* funcName, glw::GLint error,
49                                                         glw::GLint expectedError);
50
51         static glw::GLint getTargetDepth(glw::GLint target);
52
53         static void getTexturePageSizes(const glw::Functions& gl, glw::GLint target, glw::GLint format,
54                                                                         glw::GLint& pageSizeX, glw::GLint& pageSizeY, glw::GLint& pageSizeZ);
55 };
56
57 /** Represents texture static helper
58  **/
59 class Texture
60 {
61 public:
62         /* Public static routines */
63         /* Functionality */
64         static void Bind(const glw::Functions& gl, glw::GLuint id, glw::GLenum target);
65
66         static void Generate(const glw::Functions& gl, glw::GLuint& out_id);
67
68         static void Delete(const glw::Functions& gl, glw::GLuint& id);
69
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);
72
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);
76
77         /* Public fields */
78         glw::GLuint m_id;
79
80         /* Public constants */
81         static const glw::GLuint m_invalid_id;
82 };
83
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
90  **/
91 class TextureParameterQueriesTestCase : public deqp::TestCase
92 {
93 public:
94         /* Public methods */
95         TextureParameterQueriesTestCase(deqp::Context& context);
96
97         void                                             init();
98         tcu::TestNode::IterateResult iterate();
99
100 private:
101         /* Private members */
102         std::vector<glw::GLint> mSupportedTargets;
103         std::vector<glw::GLint> mNotSupportedTargets;
104
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);
110
111         bool checkGetTexParameter(const glw::Functions& gl, glw::GLint target, glw::GLint pname, glw::GLint expected);
112 };
113
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.
119  **/
120 class InternalFormatQueriesTestCase : public deqp::TestCase
121 {
122 public:
123         /* Public methods */
124         InternalFormatQueriesTestCase(deqp::Context& context);
125
126         void                                             init();
127         tcu::TestNode::IterateResult iterate();
128
129 private:
130         /* Private methods */
131         std::vector<glw::GLint> mSupportedTargets;
132         std::vector<glw::GLint> mSupportedInternalFormats;
133
134         /* Private members */
135 };
136
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.
143  **/
144 class SimpleQueriesTestCase : public deqp::TestCase
145 {
146 public:
147         /* Public methods */
148         SimpleQueriesTestCase(deqp::Context& context);
149
150         tcu::TestNode::IterateResult iterate();
151
152 private:
153         /* Private methods */
154         /* Private members */
155         void testSipmleQueries(const glw::Functions& gl, glw::GLint pname);
156 };
157
158 /** Test verifies glTexStorage* functionality added by ARB_sparse_texture extension
159  **/
160 class SparseTextureAllocationTestCase : public deqp::TestCase
161 {
162 public:
163         /* Public methods */
164         SparseTextureAllocationTestCase(deqp::Context& context);
165
166         SparseTextureAllocationTestCase(deqp::Context& context, const char* name, const char* description);
167
168         virtual void                                             init();
169         virtual tcu::TestNode::IterateResult iterate();
170
171 protected:
172         /* Protected methods */
173         std::vector<glw::GLint> mSupportedTargets;
174         std::vector<glw::GLint> mFullArrayTargets;
175         std::vector<glw::GLint> mSupportedInternalFormats;
176
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);
183 };
184
185 /** Test verifies glTexPageCommitmentARB functionality added by ARB_sparse_texture extension
186  **/
187 class SparseTextureCommitmentTestCase : public deqp::TestCase
188 {
189 public:
190         /* Public methods */
191         SparseTextureCommitmentTestCase(deqp::Context& context);
192
193         SparseTextureCommitmentTestCase(deqp::Context& context, const char* name, const char* description);
194
195         virtual void                                             init();
196         virtual tcu::TestNode::IterateResult iterate();
197
198 protected:
199         /* Protected members */
200         std::vector<glw::GLint> mSupportedTargets;
201         std::vector<glw::GLint> mSupportedInternalFormats;
202
203         glw::GLint                 mWidthStored;
204         glw::GLint                 mHeightStored;
205         glw::GLint                 mDepthStored;
206         tcu::TextureFormat mTextureFormatStored;
207
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);
212
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);
219
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);
223 };
224
225 /** Test verifies glTexturePageCommitmentEXT functionality added by ARB_sparse_texture extension
226  **/
227 class SparseDSATextureCommitmentTestCase : public SparseTextureCommitmentTestCase
228 {
229 public:
230         /* Public methods */
231         SparseDSATextureCommitmentTestCase(deqp::Context& context);
232
233         virtual tcu::TestNode::IterateResult iterate();
234
235 private:
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);
240 };
241
242 /** Test group which encapsulates all sparse texture conformance tests */
243 class SparseTextureTests : public deqp::TestCaseGroup
244 {
245 public:
246         /* Public methods */
247         SparseTextureTests(deqp::Context& context);
248
249         void init();
250
251 private:
252         SparseTextureTests(const SparseTextureTests& other);
253         SparseTextureTests& operator=(const SparseTextureTests& other);
254 };
255
256 } /* glcts namespace */
257
258 #endif // _GL4CSPARSETEXTURETESTS_HPP