1 #ifndef _ESEXTCGEOMETRYSHADERLAYEREDFBO_HPP 2 #define _ESEXTCGEOMETRYSHADERLAYEREDFBO_HPP 3 /*------------------------------------------------------------------------- 4 * OpenGL Conformance Test Suite 5 * ----------------------------- 6 * 7 * Copyright (c) 2015-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 #include "../esextcTestCaseBase.hpp" 27 28 namespace glcts 29 { 30 /** Class which implements methods shared by more than one conformance test related to 31 * layered framebuffers. 32 */ 33 class GeometryShaderLayeredFBOShared 34 { 35 public: 36 static bool checkFBOCompleteness(tcu::TestContext& test_context, const glw::Functions& gl, glw::GLenum fbo_id, 37 glw::GLenum expected_completeness_status); 38 39 static void deinitFBOs(const glw::Functions& gl, const glw::GLuint* fbo_ids); 40 41 static void deinitTOs(const glw::Functions& gl, const glw::GLuint* to_ids); 42 43 static void initFBOs(const glw::Functions& gl, glw::glFramebufferTextureFunc pGLFramebufferTexture, 44 const glw::GLuint* to_ids, glw::GLuint* out_fbo_ids); 45 46 static void initTOs(const glw::Functions& gl, glw::glTexStorage3DMultisampleFunc pGLTexStorage3DMultisample, 47 glw::GLuint* out_to_ids); 48 49 static const unsigned int n_shared_fbo_ids; 50 static const unsigned int n_shared_to_ids; 51 static const glw::GLuint shared_to_depth; 52 static const glw::GLuint shared_to_height; 53 static const glw::GLuint shared_to_width; 54 }; 55 56 /** Implementation of Test 21.1 from CTS_EXT_geometry_shader. Description follows: 57 * 58 * Reassure GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT framebuffer 59 * incompleteness status is reported for framebuffer objects, for which some 60 * of the attachments are layered and some aren't. 61 * 62 * Category: API; 63 * Dependency with OES_texture_storage_multisample_2d_array. 64 * 65 * 1. Create four framebuffer objects (A, B, C, D) and set up: 66 * 67 * - an immutable 2D texture object A (using any color-renderable 68 * internalformat); 69 * - an immutable 2D texture object A' (using any depth-renderable 70 * internalformat); 71 * - an immutable 2D array texture object B (using any color-renderable 72 * internalformat); 73 * - an immutable 3D texture object C (using any color-renderable 74 * internalformat); 75 * - an immutable cube-map texture object D (using any color-renderable 76 * internalformat); 77 * - an immutable multisample 2D texture object E (using any 78 * color-renderable internalformat and any number of samples > 1) 79 * - an immutable multisample 2D array texture object F (using any 80 * color-renderable internalformat and any number of samples > 1) 81 * 82 * Resolution of all textures should be set to 4x4 (for each face, layer, 83 * slice, etc.). Use depth of 4 if appropriate. 84 * 85 * 2.Set up a layered FBO A using glFramebufferTextureEXT() calls, so that: 86 * 87 * - base mip-map of texture object A is bound to its color attachment 0; 88 * - level 0 of texture object B is bound to color attachment 2; 89 * - level 0 of texture object A' is bound to its depth attachment; 90 * - draw buffers are set to use color attachments 0 and 2. 91 * 92 * 3. Set up a layered FBO B using glFramebufferTextureEXT() calls, so that: 93 * 94 * - level 0 of texture object C is bound to color attachment 0; 95 * - mip-map at level 0 of texture object A is bound to color attachment 1; 96 * - layer 3 of the cube-map texture object is bound to color attachment 2; 97 * - draw buffers are set to use color attachments 0, 1 and 2. 98 * 99 * 4. Set up a layered FBO C using glFramebufferTextureEXT() calls so that: 100 * 101 * - layer 5 of the cube-map texture object is bound to color attachment 0; 102 * - level 0 of texture object A' is bound to the depth attachment; 103 * - the only draw buffer used is color attachment 0. 104 * 105 * 5. Set up a layered FBO D using glFramebufferTextureEXT() calls so that: 106 * 107 * - base mip-map of multisample texture object E is bound to color 108 * attachment 0; 109 * - level 0 of texture object F is bound to color attachment 1; 110 * - draw buffers are set to use color attachments 0 and 1. 111 * 112 * 6. Make sure that, once each of these FBOs is bound, 113 * GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT FBO status is reported. 114 * 115 **/ 116 class GeometryShaderIncompleteLayeredFBOTest : public TestCaseBase 117 { 118 public: 119 /* Public methods */ 120 GeometryShaderIncompleteLayeredFBOTest(Context& context, const ExtParameters& extParams, const char* name, 121 const char* description); 122 ~GeometryShaderIncompleteLayeredFBOTest()123 virtual ~GeometryShaderIncompleteLayeredFBOTest() 124 { 125 } 126 127 void deinit(void); 128 IterateResult iterate(void); 129 130 private: 131 /* Private functions */ 132 133 /* Private variables */ 134 glw::GLuint* m_fbo_ids; 135 glw::GLuint* m_to_ids; 136 }; 137 138 /** Implementation of Test 21.2 from CTS_EXT_geometry_shader. Description follows: 139 * 140 * 2. Make sure that values reported layered FBO attachment properties are 141 * valid. 142 * 143 * Category: API. 144 * 145 * 1. Use FBO and textures as described in test case 21.1. 146 * 2. Make sure that for each of the FBO attachments, value reported for 147 * GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT is as expected. 148 * 149 **/ 150 class GeometryShaderIncompleteLayeredAttachmentsTest : public TestCaseBase 151 { 152 public: 153 /* Public methods */ 154 GeometryShaderIncompleteLayeredAttachmentsTest(Context& context, const ExtParameters& extParams, const char* name, 155 const char* description); 156 ~GeometryShaderIncompleteLayeredAttachmentsTest()157 virtual ~GeometryShaderIncompleteLayeredAttachmentsTest() 158 { 159 } 160 161 void deinit(void); 162 IterateResult iterate(void); 163 164 private: 165 /* Private functions */ 166 167 /* Private variables */ 168 glw::GLuint* m_fbo_ids; 169 glw::GLuint* m_to_ids; 170 }; 171 172 /* Implementation of "Group 26", test 1 from CTS_EXT_geometry_shader. Description follows: 173 * 174 * 1. glFramebufferTextureEXT() should not accept invalid targets. 175 * 176 * Category: API; 177 * Coverage; 178 * Negative Test. 179 * 180 * Calling glFramebufferTextureEXT() for target = GL_TEXTURE_3D should 181 * result in GL_INVALID_ENUM error. 182 * 183 */ 184 class GeometryShaderFramebufferTextureInvalidTarget : public TestCaseBase 185 { 186 public: 187 /* Public methods */ 188 GeometryShaderFramebufferTextureInvalidTarget(Context& context, const ExtParameters& extParams, const char* name, 189 const char* description); 190 ~GeometryShaderFramebufferTextureInvalidTarget()191 virtual ~GeometryShaderFramebufferTextureInvalidTarget() 192 { 193 } 194 195 virtual void deinit(); 196 virtual IterateResult iterate(); 197 198 private: 199 /* Private type definition */ 200 201 /* Private methods */ 202 203 /* Private variables */ 204 glw::GLuint m_fbo_id; 205 glw::GLuint m_to_id; 206 }; 207 208 /* Implementation of "Group 26", test 2 from CTS_EXT_geometry_shader. Description follows: 209 * 210 * 2. glFramebufferTextureEXT() should generate GL_INVALID_OPERATION error if 211 * there is no framebuffer object bound to requested framebuffer target. 212 * 213 * Category: API; 214 * Coverage; 215 * Negative Test. 216 * 217 * Try to issue glFramebufferTextureEXT() calls for GL_DRAW_FRAMEBUFFER, 218 * GL_READ_FRAMEBUFFER and GL_FRAMEBUFFER framebuffer targets, assuming the 219 * texture object these calls refer to exists. 220 * 221 * Default binding for both GL_DRAW_FRAMEBUFFER and GL_READ_FRAMEBUFFER 222 * framebuffer target is zero, so after each of these calls 223 * GL_INVALID_OPERATION error should be generated. 224 * 225 */ 226 class GeometryShaderFramebufferTextureNoFBOBoundToTarget : public TestCaseBase 227 { 228 public: 229 /* Public methods */ 230 GeometryShaderFramebufferTextureNoFBOBoundToTarget(Context& context, const ExtParameters& extParams, 231 const char* name, const char* description); 232 ~GeometryShaderFramebufferTextureNoFBOBoundToTarget()233 virtual ~GeometryShaderFramebufferTextureNoFBOBoundToTarget() 234 { 235 } 236 237 virtual void deinit(); 238 virtual IterateResult iterate(); 239 240 private: 241 /* Private type definition */ 242 243 /* Private methods */ 244 245 /* Private variables */ 246 glw::GLuint m_to_id; 247 }; 248 249 /* Implementation of "Group 26", test 3 from CTS_EXT_geometry_shader. Description follows: 250 * 251 * 3. glFramebufferTextureEXT() should generate GL_INVALID_ENUM if attachment 252 * argument is set to invalid value. 253 * 254 * Category: API; 255 * Coverage; 256 * Negative Test. 257 * 258 * Try to issue glFramebufferTextureEXT() call for GL_COLOR_ATTACHMENTi 259 * where i is equal to value reported for GL_MAX_COLOR_ATTACHMENTS. 260 * 261 */ 262 class GeometryShaderFramebufferTextureInvalidAttachment : public TestCaseBase 263 { 264 public: 265 /* Public methods */ 266 GeometryShaderFramebufferTextureInvalidAttachment(Context& context, const ExtParameters& extParams, 267 const char* name, const char* description); 268 ~GeometryShaderFramebufferTextureInvalidAttachment()269 virtual ~GeometryShaderFramebufferTextureInvalidAttachment() 270 { 271 } 272 273 virtual void deinit(); 274 virtual IterateResult iterate(); 275 276 private: 277 /* Private type definition */ 278 279 /* Private methods */ 280 281 /* Private variables */ 282 glw::GLuint m_fbo_id; 283 glw::GLuint m_to_id; 284 }; 285 286 /* Implementation of "Group 26", test 4 from CTS_EXT_geometry_shader. Description follows: 287 * 288 * 4. glFramebufferTextureEXT() should generate GL_INVALID_VALUE if texture is 289 * not the name of a texture object. 290 * 291 * Category: API; 292 * Coverage; 293 * Negative Test. 294 * 295 * Try to issue glFramebufferTextureEXT() call for non-existing texture ids 296 * 1, 10 and 100, with a FBO bound to specified FBO target. GL_INVALID_VALUE 297 * error should be reported for each attempt. 298 * 299 */ 300 class GeometryShaderFramebufferTextureInvalidValue : public TestCaseBase 301 { 302 public: 303 /* Public methods */ 304 GeometryShaderFramebufferTextureInvalidValue(Context& context, const ExtParameters& extParams, const char* name, 305 const char* description); 306 ~GeometryShaderFramebufferTextureInvalidValue()307 virtual ~GeometryShaderFramebufferTextureInvalidValue() 308 { 309 } 310 311 virtual void deinit(); 312 virtual IterateResult iterate(); 313 314 private: 315 /* Private type definition */ 316 317 /* Private methods */ 318 319 /* Private variables */ 320 glw::GLuint m_fbo_id; 321 }; 322 323 /* Implementation of "Group 26", test 5 from CTS_EXT_geometry_shader. Description follows: 324 * 325 * 5. glFramebufferTextureEXT() should generate GL_INVALID_OPERATION if level 326 * argument is an invalid texture level number. 327 * 328 * Category: API; 329 * Coverage; 330 * Negative Test. 331 * 332 * Consider a 2D texture array object A and a 3D texture array object B 333 * (each of 4x4x4 resolution), and a framebuffer object C. Base mip-map 334 * should be filled with any data, and descendant mip-maps should be 335 * generated with glGenerateMipmap() call. 336 * 337 * glFramebufferTextureEXT() should fail with GL_INVALID_OPERATION error 338 * when used for the FBO C and either of the textures and for level = 3. 339 * 340 */ 341 class GeometryShaderFramebufferTextureInvalidLevelNumber : public TestCaseBase 342 { 343 public: 344 /* Public methods */ 345 GeometryShaderFramebufferTextureInvalidLevelNumber(Context& context, const ExtParameters& extParams, 346 const char* name, const char* description); 347 ~GeometryShaderFramebufferTextureInvalidLevelNumber()348 virtual ~GeometryShaderFramebufferTextureInvalidLevelNumber() 349 { 350 } 351 352 virtual void deinit(); 353 virtual IterateResult iterate(); 354 355 private: 356 /* Private type definition */ 357 358 /* Private methods */ 359 360 /* Private variables */ 361 glw::GLuint m_fbo_id; 362 glw::GLubyte* m_texels; 363 glw::GLushort m_tex_depth; 364 glw::GLushort m_tex_height; 365 glw::GLushort m_tex_width; 366 glw::GLuint m_to_2d_array_id; 367 glw::GLuint m_to_3d_id; 368 }; 369 370 /* Implementation of "Group 26", test 6 from CTS_EXT_geometry_shader. Description follows: 371 * 372 * 6. glFramebufferTextureEXT() should generate GL_INVALID_OPERATION if texture 373 * argument refers to a buffer texture. 374 * 375 * Category: API; 376 * Coverage; 377 * Dependency on EXT_texture_buffer; 378 * Negative Test. 379 * 380 * Consider a framebuffer object A, buffer object B and a buffer texture C 381 * using buffer object B as a data source. 382 * 383 * glFramebufferTextureEXT() should fail with GL_INVALID_OPERATION error 384 * when used for the FBO A and texture argument relates to ID of buffer 385 * texture C. 386 * 387 */ 388 class GeometryShaderFramebufferTextureArgumentRefersToBufferTexture : public TestCaseBase 389 { 390 public: 391 /* Public methods */ 392 GeometryShaderFramebufferTextureArgumentRefersToBufferTexture(Context& context, const ExtParameters& extParams, 393 const char* name, const char* description); 394 ~GeometryShaderFramebufferTextureArgumentRefersToBufferTexture()395 virtual ~GeometryShaderFramebufferTextureArgumentRefersToBufferTexture() 396 { 397 } 398 399 virtual void deinit(); 400 virtual IterateResult iterate(); 401 402 private: 403 /* Private type definition */ 404 405 /* Private methods */ 406 407 /* Private variables */ 408 glw::GLuint m_bo_id; 409 glw::GLuint m_fbo_id; 410 glw::GLuint m_tbo_id; 411 glw::GLuint m_tex_height; 412 glw::GLuint m_tex_width; 413 glw::GLint* m_texels; 414 }; 415 416 } // namespace glcts 417 418 #endif // _ESEXTCGEOMETRYSHADERLAYEREDFBO_HPP 419