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