xref: /aosp_15_r20/external/deqp/external/openglcts/modules/gl/gl4cShaderTextureImageSamplesTests.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _GL4CSHADERTEXTUREIMAGESAMPLESTESTS_HPP
2 #define _GL4CSHADERTEXTUREIMAGESAMPLESTESTS_HPP
3 /*-------------------------------------------------------------------------
4  * OpenGL Conformance Test Suite
5  * -----------------------------
6  *
7  * Copyright (c) 2014-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  gl4cShaderTextureImageSamples.hpp
29  * \brief Declares test classes that verify conformance of the
30  *        GL implementation with GL_ARB_shader_texture_image_samples
31  *        extension specification.
32  */ /*-------------------------------------------------------------------*/
33 
34 #include "glcTestCase.hpp"
35 #include "glwDefs.hpp"
36 
37 namespace glcts
38 {
39 /** Base test class for GL_ARB_shader_texture_image_samples conformance tests. */
40 class ShaderTextureImageSamplesTestBase : public deqp::TestCase
41 {
42 public:
43     /* Public methods */
44     ShaderTextureImageSamplesTestBase(deqp::Context &context, const char *name, const char *description);
45 
46     void deinit();
47     virtual void init();
48 
49 protected:
50     /* Protected type definitions */
51     typedef enum
52     {
53         SAMPLER_TYPE_ISAMPLER2DMS,
54         SAMPLER_TYPE_ISAMPLER2DMSARRAY,
55         SAMPLER_TYPE_SAMPLER2DMS,
56         SAMPLER_TYPE_SAMPLER2DMSARRAY,
57         SAMPLER_TYPE_USAMPLER2DMS,
58         SAMPLER_TYPE_USAMPLER2DMSARRAY,
59 
60         SAMPLER_TYPE_COUNT
61     } _sampler_type;
62 
63     typedef enum
64     {
65         TEST_TYPE_IMAGE,
66         TEST_TYPE_TEXTURE,
67 
68         TEST_TYPE_COUNT
69     } _test_type;
70 
71     /* Protected methods */
72     bool buildComputeProgram(const char *cs_body, bool should_link_po, bool should_succeed);
73 
74     void executeFunctionalTest(const _sampler_type &sampler_type, const _test_type &test_type);
75 
76 private:
77     /* Private methods */
78     void deinitProgramAndShaderObjects();
79 
80     /* Private members */
81     glw::GLint m_internalformat_n_samples_count;
82     glw::GLint *m_internalformat_n_samples_data;
83 
84     glw::GLuint m_bo_id;
85     glw::GLuint m_cs_id;
86     glw::GLuint m_po_id;
87     glw::GLuint m_to_id;
88 
89     const unsigned int m_to_depth;
90     const unsigned int m_to_height;
91     const unsigned int m_to_width;
92 };
93 
94 /** Implements the following functional tests from CTS_ARB_shader_texture_image_samples:
95  *
96  *  Basic Texture Functionality
97  *
98  *  * Create a multisample texture and use a compute shader with an SSBO
99  *    to verify the result of calling textureSamples() on that texture. The
100  *    compute shader would look like this:
101  *
102  *      buffer Result {
103  *          int samples;
104  *      }
105  *      uniform gsampler% tex;
106  *      void main() {
107  *          samples = textureSamples(tex);
108  *      }
109  *
110  *      For gsampler% the test should iterate through all the texture targets;
111  *      sampler*, isampler* and usamples* for 2DMS and 2DMSArray. For the
112  *      2SMSArray case a multisample array texture should be bound to the
113  *      texture unit.
114  *
115  *      Readback the SSBO "samples" result and verify that it matches the
116  *      <samples> parameter used to create the texture. Repeat the test for
117  *      all <samples> values supported by the implementation.
118  *
119  *  Basic Image Functionality
120  *
121  *  * Similar to the test above, but bind an image from the multisample
122  *    texture:
123  *
124  *    Create a multisample texture, bind an image from the texture and use
125  *    a compute shader with an SSBO to verify the result of calling
126  *    imageSamples() on that image. The compute shader would look like this:
127  *
128  *      buffer Result {
129  *          int samples;
130  *      }
131  *      layout(format) uniform gimage% tex;
132  *      void main() {
133  *          samples = imageSamples(tex);
134  *      }
135  *
136  *      For gimage% the test should iterate through all the image targets;
137  *      image*, iimage* and uimage* for 2DMS and 2DMSArray. For the
138  *      2SMSArray case a multisample array image should be bound to the
139  *      image unit.
140  *
141  *      Readback the SSBO "samples" result and verify that it matches the
142  *      <samples> parameter used to create the texture. Repeat the test for
143  *      all <samples> values supported by the implementation.
144  *
145  **/
146 class ShaderTextureImageSampleFunctionalTest : public ShaderTextureImageSamplesTestBase
147 {
148 public:
149     /* Public methods */
150     ShaderTextureImageSampleFunctionalTest(deqp::Context &context, const char *name);
151     void init();
152 
153     virtual tcu::TestNode::IterateResult iterate();
154 
155 private:
156     _test_type type_to_test;
157     /* Private methods */
158 };
159 
160 /** Implements the following GLSL #extension test from CTS_ARB_shader_texture_image_samples:
161  *
162  *  * Verify a shader with #extension GL_ARB_shader_texture_image_samples : enable
163  *    defines the pre-processor macro "GL_ARB_shader_texture_image_samples"
164  *    to the value "1".
165  *
166  **/
167 class ShaderTextureImageSamplesGLSLExtensionEnableTest : public ShaderTextureImageSamplesTestBase
168 {
169 public:
170     /* Public methods */
171     ShaderTextureImageSamplesGLSLExtensionEnableTest(deqp::Context &context);
172 
173     virtual tcu::TestNode::IterateResult iterate();
174 
175 private:
176     /* Private methods */
177 };
178 
179 /** Implements the following GLSL #extension test from CTS_ARB_shader_texture_image_samples:
180  *
181  *  * Verify a shader with
182  *    #extension GL_ARB_shader_texture_image_samples : require
183  *    compiles without error.
184  *
185  **/
186 class ShaderTextureImageSamplesGLSLExtensionRequireTest : public ShaderTextureImageSamplesTestBase
187 {
188 public:
189     /* Public methods */
190     ShaderTextureImageSamplesGLSLExtensionRequireTest(deqp::Context &context);
191 
192     virtual tcu::TestNode::IterateResult iterate();
193 
194 private:
195     /* Private methods */
196 };
197 
198 /** Test group which encapsulates all conformance tests for GL_ARB_shader_texture_image_samples
199  *  extension.
200  */
201 class ShaderTextureImageSamplesTests : public deqp::TestCaseGroup
202 {
203 public:
204     /* Public methods */
205     ShaderTextureImageSamplesTests(deqp::Context &context);
206 
207     void init(void);
208 
209 private:
210     ShaderTextureImageSamplesTests(const ShaderTextureImageSamplesTests &other);
211     ShaderTextureImageSamplesTests &operator=(const ShaderTextureImageSamplesTests &other);
212 };
213 
214 } // namespace glcts
215 
216 #endif // _GL4CSHADERTEXTUREIMAGESAMPLESTESTS_HPP
217