1 #ifndef _ESEXTCGEOMETRYSHADERPRIMITIVEQUERIES_HPP 2 #define _ESEXTCGEOMETRYSHADERPRIMITIVEQUERIES_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 #include "glwEnums.hpp" 28 29 namespace glcts 30 { 31 /** Implementation of "Group 13" from from CTS_EXT_geometry_shader. Description follows: 32 * 33 * 1. Make sure that values reported for 34 * GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN primitive query are correct if 35 * a geometry stage is active in program object used for a draw call. 36 * 37 * Category: API. 38 * 39 * Iterate through geometry shaders using all valid output primitive types. 40 * They should emit a few primitives for each output primitive type (make 41 * sure the vertices emitted are all in screen-space and that depth test 42 * is disabled). Vertex and fragment shaders are irrelevant, but they should 43 * be valid. 44 * 45 * The test should make a few draw calls using each of the program objects, 46 * with the primitive query active. After doing a round of draw calls, the 47 * counter should be checked and verified. 48 * 49 * 50 * 2. Make sure that GL_PRIMITIVES_GENERATED_EXT and 51 * GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN primitive queries are assigned 52 * different values if a buffer object bound to a TF binding point has an 53 * insufficient size to hold all primitives generated in geometry shader 54 * stage. 55 * 56 * Category: API; 57 * Functional Test. 58 * 59 * Test should generate a buffer object and set up a storage that can hold 60 * up to 4 vec4s. 61 * 62 * It should then create a program object and boilerplate fragment & vertex 63 * shader objects. It should also create a geometry shader that: 64 * 65 * * Takes points on input; 66 * * Outputs triangles (a maximum of 3 vertices); 67 * * Defines an output vec4 variable test_variable; 68 * * For each emitted vertex, it should set test_variable to 69 * (1.0, 2.0, 3.0, 4.0); 70 * 71 * All the shader objects should now be attached to the program object and 72 * compiled. Transform feedback should be configured for the program object, 73 * so that values stored in test_variable should be stored in the buffer 74 * object described at the beginning. 75 * 76 * Test should then generate and bind a vertex array object. 77 * 78 * Test should also generate two query objects: 79 * 80 * - Query object A of type GL_PRIMITIVES_GENERATED_EXT; 81 * - Query object B of type GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN; 82 * 83 * Both of these query objects should be then started. 84 * 85 * At this point, the test should activate the program object, start 86 * transform feedback, and draw 8 points. 87 * 88 * Test succeeds if values stored in query objects are both not equal 89 * to 0 and different from each other.*/ 90 91 class GeometryShaderPrimitiveQueries : public TestCaseBase 92 { 93 public: 94 /* Public methods */ 95 virtual void deinit(void); 96 virtual IterateResult iterate(void); 97 98 protected: 99 /* Protected methods */ 100 GeometryShaderPrimitiveQueries(Context& context, const ExtParameters& extParams, const char* name, 101 const char* description); 102 ~GeometryShaderPrimitiveQueries(void)103 virtual ~GeometryShaderPrimitiveQueries(void) 104 { 105 } 106 107 /* Protected abstract methods */ 108 virtual glw::GLint getAmountOfEmittedVertices() = 0; 109 virtual const char* getGeometryShaderCode() = 0; 110 virtual glw::GLenum getTFMode() = 0; 111 112 private: 113 /* Private methods */ 114 void readPrimitiveQueryValues(glw::GLint bufferId, glw::GLuint* nPrimitivesGenerated, 115 glw::GLuint* nPrimitivesWritten); 116 117 /* Private variables */ 118 static const char* m_fs_code; 119 static const char* m_vs_code; 120 121 const glw::GLint m_n_texture_components; 122 glw::GLuint m_bo_large_id; 123 glw::GLuint m_bo_small_id; 124 glw::GLuint m_fs_id; 125 glw::GLuint m_gs_id; 126 glw::GLuint m_po_id; 127 glw::GLuint m_qo_primitives_generated_id; 128 glw::GLuint m_qo_tf_primitives_written_id; 129 glw::GLuint m_vao_id; 130 glw::GLuint m_vs_id; 131 }; 132 133 /** 134 * The tests uses points as output primitive type for a geometry shader 135 */ 136 class GeometryShaderPrimitiveQueriesPoints : public GeometryShaderPrimitiveQueries 137 { 138 public: 139 /* Public methods */ 140 GeometryShaderPrimitiveQueriesPoints(Context& context, const ExtParameters& extParams, const char* name, 141 const char* description); 142 ~GeometryShaderPrimitiveQueriesPoints(void)143 virtual ~GeometryShaderPrimitiveQueriesPoints(void) 144 { 145 } 146 147 protected: 148 /* Protected methods */ 149 glw::GLint getAmountOfEmittedVertices(); 150 const char* getGeometryShaderCode(); 151 glw::GLenum getTFMode(); 152 153 private: 154 /* Private variables */ 155 static const char* m_gs_code; 156 }; 157 158 /** 159 * Test uses lines as output primitive type for a geometry shader 160 */ 161 class GeometryShaderPrimitiveQueriesLines : public GeometryShaderPrimitiveQueries 162 { 163 public: 164 /* Public methods */ 165 GeometryShaderPrimitiveQueriesLines(Context& context, const ExtParameters& extParams, const char* name, 166 const char* description); 167 ~GeometryShaderPrimitiveQueriesLines(void)168 virtual ~GeometryShaderPrimitiveQueriesLines(void) 169 { 170 } 171 172 protected: 173 /* Protected methods */ 174 glw::GLint getAmountOfEmittedVertices(); 175 const char* getGeometryShaderCode(); 176 glw::GLenum getTFMode(); 177 178 private: 179 /* Private variables */ 180 static const char* m_gs_code; 181 }; 182 183 /** 184 * Test uses triangles as output primitive type for a geometry shader 185 */ 186 class GeometryShaderPrimitiveQueriesTriangles : public GeometryShaderPrimitiveQueries 187 { 188 public: 189 /* Public methods */ 190 GeometryShaderPrimitiveQueriesTriangles(Context& context, const ExtParameters& extParams, const char* name, 191 const char* description); 192 ~GeometryShaderPrimitiveQueriesTriangles(void)193 virtual ~GeometryShaderPrimitiveQueriesTriangles(void) 194 { 195 } 196 197 protected: 198 /* Protected methods */ 199 glw::GLint getAmountOfEmittedVertices(); 200 const char* getGeometryShaderCode(); 201 glw::GLenum getTFMode(); 202 203 private: 204 /* Private variables */ 205 static const char* m_gs_code; 206 }; 207 208 } // namespace glcts 209 210 #endif // _ESEXTCGEOMETRYSHADERPRIMITIVEQUERIES_HPP 211