xref: /aosp_15_r20/external/deqp/external/openglcts/modules/gl/gl4cSparseTexture2Tests.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _GL4CSPARSETEXTURE2TESTS_HPP
2 #define _GL4CSPARSETEXTURE2TESTS_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  gl4cSparseTexture2Tests.hpp
29  * \brief Conformance tests for the GL_ARB_sparse_texture2 functionality.
30  */ /*-------------------------------------------------------------------*/
31 
32 #include "glcTestCase.hpp"
33 #include "glwDefs.hpp"
34 #include "glwEnums.hpp"
35 #include "tcuDefs.hpp"
36 #include <map>
37 #include <set>
38 #include <vector>
39 
40 #include "gl4cSparseTextureTests.hpp"
41 #include "gluDrawUtil.hpp"
42 #include "gluShaderProgram.hpp"
43 #include "gluTextureUtil.hpp"
44 #include "tcuTextureUtil.hpp"
45 
46 using namespace glw;
47 using namespace glu;
48 
49 namespace gl4cts
50 {
51 
52 struct PageSizeStruct
53 {
54     GLint xSize;
55     GLint ySize;
56     GLint zSize;
57 
PageSizeStructgl4cts::PageSizeStruct58     PageSizeStruct() : xSize(0), ySize(0), zSize(0)
59     {
60     }
PageSizeStructgl4cts::PageSizeStruct61     PageSizeStruct(GLint x, GLint y, GLint z) : xSize(x), ySize(y), zSize(z)
62     {
63     }
64 };
65 
66 typedef std::pair<GLint, PageSizeStruct> PageSizePair;
67 
68 /** Test verifies if extension is available for GLSL
69  **/
70 class ShaderExtensionTestCase : public deqp::TestCase
71 {
72 public:
73     /* Public methods */
74     ShaderExtensionTestCase(deqp::Context &context, const std::string extension);
75 
76     tcu::TestNode::IterateResult iterate();
77 
78 private:
79     /* Private members */
80     std::string mExtension;
81 };
82 
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.
87  **/
88 class StandardPageSizesTestCase : public deqp::TestCase
89 {
90 public:
91     /* Public methods */
92     StandardPageSizesTestCase(deqp::Context &context);
93 
94     void init();
95     tcu::TestNode::IterateResult iterate();
96 
97 private:
98     /* Private methods */
99     std::vector<GLint> mSupportedTargets;
100     std::map<GLint, PageSizeStruct> mStandardVirtualPageSizesTable;
101 
102     /* Private members */
103 };
104 
105 /** Test verifies glTexStorage* functionality added by ARB_sparse_texture2 extension
106  **/
107 class SparseTexture2AllocationTestCase : public SparseTextureAllocationTestCase
108 {
109 public:
110     /* Public methods */
111     SparseTexture2AllocationTestCase(deqp::Context &context);
112 
113     virtual void init();
114     virtual tcu::TestNode::IterateResult iterate();
115 
116 private:
117     /* Private methods */
118 };
119 
120 /** Test verifies glTexPageCommitmentARB functionality added by ARB_sparse_texture2 extension
121  **/
122 class SparseTexture2CommitmentTestCase : public SparseTextureCommitmentTestCase
123 {
124 public:
125     /* Public methods */
126     SparseTexture2CommitmentTestCase(deqp::Context &context);
127 
128     SparseTexture2CommitmentTestCase(deqp::Context &context, const char *name, const char *description);
129 
130     virtual void init();
131     virtual tcu::TestNode::IterateResult iterate();
132 
133 protected:
134     /* Protected members */
135     struct TokenStrings
136     {
137         std::string format;
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;
145         std::string epsilon;
146         std::string sampleDef;
147     };
148 
149     /* Protected methods */
150     TokenStrings createShaderTokens(GLint target, GLint verifyTarget, GLint format, GLint sample,
151                                     const std::string outputBase = "image", const std::string inputBase = "image");
152 
153     virtual bool caseAllowed(GLint target, GLint format);
154 
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);
159 };
160 
161 /** Test verifies if access to uncommitted regions of sparse texture works as expected
162  **/
163 class UncommittedRegionsAccessTestCase : public SparseTexture2CommitmentTestCase
164 {
165 public:
166     /* Public methods */
167     UncommittedRegionsAccessTestCase(deqp::Context &context);
168 
169     virtual void init();
170     virtual tcu::TestNode::IterateResult iterate();
171 
172 private:
173     /* Private members */
174     GLuint mFramebuffer;
175     GLuint mRenderbuffer;
176 
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);
181 
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);
185 
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);
196 };
197 
198 /** Test verifies if sparse texture lookup functions for GLSL works as expected
199  **/
200 class SparseTexture2LookupTestCase : public SparseTexture2CommitmentTestCase
201 {
202 public:
203     /* Public methods */
204     SparseTexture2LookupTestCase(deqp::Context &context);
205 
206     SparseTexture2LookupTestCase(deqp::Context &context, const char *name, const char *description);
207 
208     void init();
209     tcu::TestNode::IterateResult iterate();
210 
211 protected:
212     /* Protected types */
213     struct FunctionToken
214     {
215         std::string name;
216         std::string arguments;
217 
218         std::set<GLint> allowedTargets;
219 
FunctionTokengl4cts::SparseTexture2LookupTestCase::FunctionToken220         FunctionToken()
221         {
222         }
223 
FunctionTokengl4cts::SparseTexture2LookupTestCase::FunctionToken224         FunctionToken(std::string fname, std::string fargs) : name(fname), arguments(fargs)
225         {
226         }
227     };
228 
229     struct TokenStringsExt : public TokenStrings
230     {
231         std::string formatDef;
232         std::string sizeDef;
233         std::string lod;
234         std::string lodDef;
235         std::string coordType;
236         std::string iCoordType;
237         std::string coordDef;
238         std::string cubeMapCoordDef;
239         std::string refZDef;
240         std::string cubeMapArrayRefZDef;
241         std::string offsetDim;
242         std::string offsetType;
243         std::string nOffsetType;
244         std::string componentDef;
245         std::string offsetArrayDef;
246         std::string pointCoord;
247     };
248 
249     /* Protected members */
250     std::vector<FunctionToken> mFunctions;
251 
252     /* Protected methods */
253     TokenStringsExt createLookupShaderTokens(GLint target, GLint verifyTarget, GLint format, GLint level, GLint sample,
254                                              FunctionToken &funcToken);
255 
256     virtual bool caseAllowed(GLint target, GLint format);
257     virtual bool funcAllowed(GLint target, GLint format, FunctionToken &funcToken);
258 
259     virtual bool writeDataToTexture(const Functions &gl, GLint target, GLint format, GLuint &texture, GLint level);
260 
261     virtual void setupDepthMode(const Functions &gl, GLint target, GLuint &texture);
262     virtual bool verifyLookupTextureData(const Functions &gl, GLint target, GLint format, GLuint &texture, GLint level,
263                                          FunctionToken &funcToken);
264 };
265 
266 /** Test group which encapsulates all sparse texture conformance tests */
267 class SparseTexture2Tests : public deqp::TestCaseGroup
268 {
269 public:
270     /* Public methods */
271     SparseTexture2Tests(deqp::Context &context);
272 
273     void init();
274 
275 private:
276     SparseTexture2Tests(const SparseTexture2Tests &other);
277     SparseTexture2Tests &operator=(const SparseTexture2Tests &other);
278 };
279 
280 void replaceToken(const GLchar *token, const GLchar *text, std::string &string);
281 
282 } // namespace gl4cts
283 
284 #endif // _GL4CSPARSETEXTURE2TESTS_HPP
285