1 #ifndef _ESEXTCGEOMETRYSHADERLAYEREDRENDERING_HPP 2 #define _ESEXTCGEOMETRYSHADERLAYEREDRENDERING_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 #include "../esextcTestCaseBase.hpp" 27 28 namespace glcts 29 { 30 /** Implementation of "Group 7" from CTS_EXT_geometry_shader. Description follows: 31 * 32 * 1. Make sure that layered rendering works correctly for cube-map texture 33 * color attachments. 34 * 35 * Category: API; 36 * Functional Test. 37 * 38 * Initialize cube-map texture object, assuming that cube-map face textures 39 * should have a resolution of 64x64 and use GL_RGBA8 internal format. 40 * 41 * Use glFramebufferTextureEXT() to attach base level of cube-map texture to 42 * color attachment 0. 43 * 44 * Vertex shader can be boilerplate. 45 * 46 * Geometry shader should take point primitives on input and output triangle 47 * strips. The shader will not emit more than 6 faces*16 vertices. 48 * 49 * Consider a triangle strip consisting of the following vertices: 50 * 51 * 1) ( 1, 1, 0, 1) 52 * 2) ( 1, -1, 0, 1) 53 * 3) (-1, 1, 0, 1) 54 * 4) (-1, -1, 0, 1) 55 * 56 * which is a "full-screen" quad in screen coordinates space. Remembering 57 * that each quad should be separated with EndPrimitive() call, quad 58 * primitives should be emitted to all six layers. Remember to set gl_Layer 59 * to corresponding layer ID for each of the vertices. 60 * 61 * Fragment shader should set result variable to: 62 * 63 * 1) (1, 0, 0, 0) if gl_Layer == 0 (+X face) 64 * 2) (0, 1, 0, 0) if gl_Layer == 1 (-X face) 65 * 3) (0, 0, 1, 0) if gl_Layer == 2 (+Y face) 66 * 4) (0, 0, 0, 1) if gl_Layer == 3 (-Y face) 67 * 5) (1, 1, 0, 0) if gl_Layer == 4(+Z face) 68 * 6) (1, 0, 1, 0) if gl_Layer == 5(-Z face) 69 * 70 * The test should then read cube-map texture data and verify that all 71 * texels of each cube map face texture are set to correct values. 72 * 73 * 74 * 2. Make sure that layered rendering works correctly for a set of 3D texture 75 * color attachments. 76 * 77 * Category: API; 78 * Functional test. 79 * 80 * Modify test case 7.1, so that: 81 * 82 * - the test uses a 64x64x64 3D texture instead of a cube-map texture; 83 * - the test attaches 4 first levels of the texture instead of cube-map 84 * texture faces to consequent color attachments; 85 * - the test only writes to 4 layers instead of 6. 86 * 87 * The change of number of layers we write to is related to a minimum 88 * maximum of color attachments implementations must expose to be 89 * GLES3.0-compliant. 90 * 91 * 92 * 3. Make sure that layered rendering works correctly for a set of 2D array 93 * texture color attachments. 94 * 95 * Category: API; 96 * Functional Test. 97 * 98 * Modify test case 7.2, so that the test uses a 64x64x64 2D array texture 99 * instead of a 3D texture; 100 * 101 * 102 * 4. Make sure that layered rendering works correctly for a set of multisample 103 * 2D array texture color attachments. 104 * 105 * Category: API; 106 * Dependency on OES_texture_storage_multisample_2d_array; 107 * Functional Test. 108 * 109 * Modify test case 7.2, so that the test uses a 64x64x64 multisample 2D 110 * array texture instead of a 3D texture; 111 **/ 112 class GeometryShaderLayeredRendering : public TestCaseBase 113 { 114 public: 115 /* Public methods */ 116 GeometryShaderLayeredRendering(Context& context, const ExtParameters& extParams, const char* name, 117 const char* description); 118 ~GeometryShaderLayeredRendering(void)119 virtual ~GeometryShaderLayeredRendering(void) 120 { 121 } 122 123 void deinit(void); 124 IterateResult iterate(void); 125 126 private: 127 /* Private type definitions */ 128 /** Describes type of the test iteration being considered */ 129 typedef enum { 130 LAYERED_RENDERING_TEST_ITERATION_2D_ARRAY, 131 LAYERED_RENDERING_TEST_ITERATION_2D_MULTISAMPLE_ARRAY, 132 LAYERED_RENDERING_TEST_ITERATION_3D, 133 LAYERED_RENDERING_TEST_ITERATION_CUBEMAP, 134 135 /* Always last */ 136 LAYERED_RENDERING_TEST_ITERATION_LAST 137 } _layered_rendering_test_iteration; 138 139 /** Holds data necessary to perform a single iteration of a single layered rendering test iteration */ 140 typedef struct 141 { 142 glw::GLuint fbo_id; 143 glw::GLuint fs_id; 144 glw::GLuint gs_id; 145 glw::GLuint po_id; 146 glw::GLuint to_id; 147 glw::GLuint vs_id; 148 149 const char** fs_parts; 150 const char** gs_parts; 151 const char** vs_parts; 152 unsigned int n_fs_parts; 153 unsigned int n_gs_parts; 154 unsigned int n_vs_parts; 155 156 _layered_rendering_test_iteration iteration; 157 unsigned int n_layers; 158 } _layered_rendering_test; 159 160 /* Private functions */ 161 bool buildProgramForLRTest(_layered_rendering_test* test); 162 163 /* Private variables */ 164 static const unsigned char m_layered_rendering_expected_layer_data[6 * 4]; 165 static const char* m_layered_rendering_fs_code; 166 static const char* m_layered_rendering_gs_code_preamble; 167 static const char* m_layered_rendering_gs_code_2d_array; 168 static const char* m_layered_rendering_gs_code_2d_marray; 169 static const char* m_layered_rendering_gs_code_3d; 170 static const char* m_layered_rendering_gs_code_cm; 171 static const char* m_layered_rendering_gs_code_main; 172 static const char* m_layered_rendering_vs_code; 173 174 glw::GLuint m_vao_id; 175 176 /* Holds pointers to test instances that are to be executed */ 177 _layered_rendering_test m_tests[LAYERED_RENDERING_TEST_ITERATION_LAST]; 178 }; 179 180 } // namespace glcts 181 182 #endif // _ESEXTCGEOMETRYSHADERLAYEREDRENDERING_HPP 183