1 #ifndef _GL4CTEXTUREFILTERMINMAXTESTS_HPP 2 #define _GL4CTEXTUREFILTERMINMAXTESTS_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 gl4cTextureFilterMinmaxTests.hpp 29 * \brief Conformance tests for the ARB_texture_filter_minmax functionality. 30 */ /*-------------------------------------------------------------------*/ 31 32 #include "deUniquePtr.hpp" 33 #include "glcTestCase.hpp" 34 #include "gluTexture.hpp" 35 #include "glwDefs.hpp" 36 #include "glwEnums.hpp" 37 #include "tcuDefs.hpp" 38 39 #include <string> 40 #include <vector> 41 42 namespace gl4cts 43 { 44 class TextureFilterMinmaxUtils 45 { 46 public: 47 enum TextureTestFlag 48 { 49 MINMAX = (1u << 0), 50 EXCLUDE_3D = (1u << 2), 51 EXCLUDE_CUBE = (1u << 3) 52 }; 53 54 struct SupportedTextureDataType 55 { 56 57 glw::GLenum m_format; 58 glw::GLenum m_type; 59 int m_testFlags; 60 SupportedTextureDataTypegl4cts::TextureFilterMinmaxUtils::SupportedTextureDataType61 SupportedTextureDataType(glw::GLenum format, glw::GLenum type, int testFlags = MINMAX) 62 : m_format(format) 63 , m_type(type) 64 , m_testFlags(testFlags) 65 { 66 } 67 hasFlaggl4cts::TextureFilterMinmaxUtils::SupportedTextureDataType68 inline bool hasFlag(TextureTestFlag flag) const 69 { 70 return (m_testFlags & flag) != 0; 71 } 72 }; 73 74 struct ReductionModeParam 75 { 76 glw::GLint m_reductionMode; 77 bool m_queryTestOnly; 78 ReductionModeParamgl4cts::TextureFilterMinmaxUtils::ReductionModeParam79 ReductionModeParam(glw::GLint reductionMode, bool queryTestOnly) 80 : m_reductionMode(reductionMode) 81 , m_queryTestOnly(queryTestOnly) 82 { 83 } 84 }; 85 86 class SupportedTextureType 87 { 88 protected: 89 glw::GLenum m_type; 90 tcu::IVec3 m_size; 91 std::string m_vertexShader; 92 std::string m_fragmentShader; 93 94 void replaceAll(std::string &str, const std::string &from, const std::string &to); 95 96 void renderQuad(const glu::RenderContext &context, glw::GLint reductionMode); 97 98 virtual glw::GLuint getTextureGL() = 0; 99 100 virtual std::vector<float> getTexCoords() = 0; 101 102 public: 103 SupportedTextureType(glw::GLenum type, const std::string &shaderTexcoordType, 104 const std::string &shaderSamplerType); ~SupportedTextureType()105 virtual ~SupportedTextureType() 106 { 107 } 108 getType() const109 inline glw::GLenum getType() const 110 { 111 return m_type; 112 } 113 114 virtual void generate(const glu::RenderContext &context, tcu::IVec3 size, glw::GLenum format, glw::GLenum type, 115 bool generateMipmaps = false) = 0; 116 117 void renderToFBO(const glu::RenderContext &context, glw::GLuint resultTextureId, tcu::IVec2 size, 118 glw::GLint reductionMode); 119 }; 120 121 class Texture1D : public SupportedTextureType 122 { 123 protected: 124 de::MovePtr<glu::Texture1D> m_texture; 125 126 glw::GLuint getTextureGL(); 127 std::vector<float> getTexCoords(); 128 129 public: 130 Texture1D(); 131 132 void generate(const glu::RenderContext &context, tcu::IVec3 size, glw::GLenum format, glw::GLenum type, 133 bool generateMipmaps = false); 134 }; 135 136 class Texture1DArray : public SupportedTextureType 137 { 138 protected: 139 de::MovePtr<glu::Texture1DArray> m_texture; 140 141 glw::GLuint getTextureGL(); 142 std::vector<float> getTexCoords(); 143 144 public: 145 Texture1DArray(); 146 147 void generate(const glu::RenderContext &context, tcu::IVec3 size, glw::GLenum format, glw::GLenum type, 148 bool generateMipmaps = false); 149 }; 150 151 class Texture2D : public SupportedTextureType 152 { 153 protected: 154 de::MovePtr<glu::Texture2D> m_texture; 155 156 glw::GLuint getTextureGL(); 157 std::vector<float> getTexCoords(); 158 159 public: 160 Texture2D(); 161 162 void generate(const glu::RenderContext &context, tcu::IVec3 size, glw::GLenum format, glw::GLenum type, 163 bool generateMipmaps = false); 164 }; 165 166 class Texture2DArray : public SupportedTextureType 167 { 168 protected: 169 de::MovePtr<glu::Texture2DArray> m_texture; 170 171 glw::GLuint getTextureGL(); 172 std::vector<float> getTexCoords(); 173 174 public: 175 Texture2DArray(); 176 177 void generate(const glu::RenderContext &context, tcu::IVec3 size, glw::GLenum format, glw::GLenum type, 178 bool generateMipmaps = false); 179 }; 180 181 class Texture3D : public SupportedTextureType 182 { 183 protected: 184 de::MovePtr<glu::Texture3D> m_texture; 185 186 glw::GLuint getTextureGL(); 187 std::vector<float> getTexCoords(); 188 189 public: 190 Texture3D(); 191 192 void generate(const glu::RenderContext &context, tcu::IVec3 size, glw::GLenum format, glw::GLenum type, 193 bool generateMipmaps = false); 194 }; 195 196 class TextureCube : public SupportedTextureType 197 { 198 protected: 199 de::MovePtr<glu::TextureCube> m_texture; 200 201 glw::GLuint getTextureGL(); 202 std::vector<float> getTexCoords(); 203 204 public: 205 TextureCube(); 206 207 void generate(const glu::RenderContext &context, tcu::IVec3 size, glw::GLenum format, glw::GLenum type, 208 bool generateMipmaps = false); 209 }; 210 211 /* Public methods */ 212 TextureFilterMinmaxUtils(); 213 ~TextureFilterMinmaxUtils(); 214 215 std::vector<glw::GLuint> getDataFromTexture(const glu::RenderContext &context, glw::GLuint textureId, 216 tcu::IVec2 textureSize, glw::GLenum format, glw::GLenum type); 217 218 glw::GLuint calcPixelSumValue(const glu::RenderContext &context, glw::GLuint textureId, tcu::IVec2 textureSize, 219 glw::GLenum format, glw::GLenum type); 220 getReductionModeParams()221 inline const std::vector<ReductionModeParam> &getReductionModeParams() 222 { 223 return m_reductionModeParams; 224 } 225 getSupportedTextureDataTypes()226 inline const std::vector<SupportedTextureDataType> &getSupportedTextureDataTypes() 227 { 228 return m_supportedTextureDataTypes; 229 } 230 getSupportedTextureTypes()231 inline const std::vector<SupportedTextureType *> &getSupportedTextureTypes() 232 { 233 return m_supportedTextureTypes; 234 } 235 236 typedef std::vector<ReductionModeParam>::const_iterator ReductionModeParamIter; 237 typedef std::vector<SupportedTextureDataType>::const_iterator SupportedTextureDataTypeIter; 238 typedef std::vector<SupportedTextureType *>::const_iterator SupportedTextureTypeIter; 239 240 private: 241 /* Private members */ 242 std::vector<ReductionModeParam> m_reductionModeParams; 243 std::vector<SupportedTextureDataType> m_supportedTextureDataTypes; 244 std::vector<SupportedTextureType *> m_supportedTextureTypes; 245 }; 246 247 /** Test verifies default values and manual setting of reduction mode queries 248 **/ 249 class TextureFilterMinmaxParameterQueriesTestCase : public deqp::TestCase 250 { 251 public: 252 /* Public methods */ 253 TextureFilterMinmaxParameterQueriesTestCase(deqp::Context &context); 254 255 tcu::TestNode::IterateResult iterate(); 256 257 private: 258 /* Private methods */ 259 void testReductionModeQueriesDefaultValues(const glw::Functions &gl); 260 void testReductionModeQueries(const glw::Functions &gl, glw::GLint pname); 261 262 /* Private members */ 263 TextureFilterMinmaxUtils m_utils; 264 }; 265 266 /** Base class for rendering based filtering tests 267 **/ 268 class TextureFilterMinmaxFilteringTestCaseBase : public deqp::TestCase 269 { 270 public: 271 /* Public methods */ 272 TextureFilterMinmaxFilteringTestCaseBase(deqp::Context &context, const char *name, const char *description, 273 float renderScale, bool mipmapping); 274 275 tcu::TestNode::IterateResult iterate(); 276 277 protected: 278 /* Protected members */ 279 TextureFilterMinmaxUtils m_utils; 280 float m_renderScale; 281 bool m_mipmapping; 282 }; 283 284 /** Test verifies results of minification filtering for different reduction modes, targets, texture formats 285 **/ 286 class TextureFilterMinmaxMinificationFilteringTestCase : public TextureFilterMinmaxFilteringTestCaseBase 287 { 288 public: 289 /* Public methods */ 290 TextureFilterMinmaxMinificationFilteringTestCase(deqp::Context &context); 291 }; 292 293 /** Test verifies results of magnification filtering for different reduction modes, targets, texture formats 294 **/ 295 class TextureFilterMinmaxMagnificationFilteringTestCase : public TextureFilterMinmaxFilteringTestCaseBase 296 { 297 public: 298 /* Public methods */ 299 TextureFilterMinmaxMagnificationFilteringTestCase(deqp::Context &context); 300 }; 301 302 /** Test verifies results of minification filtering for different reduction modes, targets, texture formats 303 with mipmapping enabled 304 **/ 305 class TextureFilterMinmaxMipmapMinificationFilteringTestCase : public TextureFilterMinmaxFilteringTestCaseBase 306 { 307 public: 308 /* Public methods */ 309 TextureFilterMinmaxMipmapMinificationFilteringTestCase(deqp::Context &context); 310 }; 311 312 /** Test verifies results of calling GetInternalFormat to verify support for specific texture types 313 **/ 314 class TextureFilterMinmaxSupportTestCase : public deqp::TestCase 315 { 316 public: 317 /* Public methods */ 318 TextureFilterMinmaxSupportTestCase(deqp::Context &context); 319 320 tcu::TestNode::IterateResult iterate(); 321 322 private: 323 /* Private members */ 324 TextureFilterMinmaxUtils m_utils; 325 }; 326 327 /** Test group which encapsulates all texture filter minmax conformance tests */ 328 class TextureFilterMinmax : public deqp::TestCaseGroup 329 { 330 public: 331 /* Public methods */ 332 TextureFilterMinmax(deqp::Context &context); 333 334 void init(); 335 336 private: 337 TextureFilterMinmax(const TextureFilterMinmax &other); 338 TextureFilterMinmax &operator=(const TextureFilterMinmax &other); 339 }; 340 341 } // namespace gl4cts 342 343 #endif // _GL4CTEXTUREFILTERMINMAXTESTS_HPP 344