1Name 2 3 NV_geometry_shader4 4 5Name String 6 7 GL_NV_geometry_shader4 8 9Contact 10 11 Pat Brown, NVIDIA (pbrown 'at' nvidia.com) 12 Barthold Lichtenbelt, NVIDIA (blichtenbelt 'at' nvidia.com) 13 14Status 15 16 Shipping for GeForce 8 Series (November 2006) 17 18Version 19 20 Last Modified Date: 11/09/2009 21 Author revision: 17 22 23Number 24 25 338 26 27Dependencies 28 29 OpenGL 1.1 is required. 30 31 EXT_geometry_shader4 is required. 32 33 This extension is written against the EXT_geometry_shader4 and OpenGL 2.0 34 specifications. 35 36Overview 37 38 This extension builds upon the EXT_geometry_shader4 specification to 39 provide two additional capabilities: 40 41 * Support for QUADS, QUAD_STRIP, and POLYGON primitive types when 42 geometry shaders are enabled. Such primitives will be tessellated 43 into individual triangles. 44 45 * Setting the value of GEOMETRY_VERTICES_OUT_EXT will take effect 46 immediately. It is not necessary to link the program object in 47 order for this change to take effect, as is the case in the EXT 48 version of this extension. 49 50New Procedures and Functions 51 52 None 53 54New Tokens 55 56 None 57 58Additions to Chapter 2 of the OpenGL 2.0 Specification (OpenGL Operation) 59 60 Modify Section 2.15.2 Program Objects, p. 73 61 62 Change the language below the LinkProgram command on p. 74 as follows: 63 64 ... Linking can fail for a variety of reasons as specified in the OpenGL 65 Shading Language Specification. Linking will also fail if one or more of 66 the shader objects, attached to <program> are not compiled successfully, 67 or if more active uniform or active sampler variables are used in 68 <program> than allowed (see sections 2.15.3 and 2.16.3). Linking will also 69 fail if the program object contains objects to form a geometry shader (see 70 section 2.16), but no objects to form a vertex shader. If LinkProgram 71 failed, ... 72 73 Modify Section 2.16.1, Geometry shader Input Primitives, of the 74 EXT_geometry_shader4 specification as follows: 75 76 Triangles (TRIANGLES) 77 78 Geometry shaders that operate on triangles are valid for the TRIANGLES, 79 TRIANGLE_STRIP, TRIANGLE_FAN, QUADS, QUAD_STRIP, and POLYGON primitive 80 types. 81 82 When used with a geometry shader that operates on triangles, QUADS, 83 QUAD_STRIP, and POLYGON primitives are decomposed into triangles in an 84 unspecified, implementation-dependent manner. This decomposition satisfies 85 three properties: 86 87 1. the collection of triangles fully covers the area of the original 88 primitive, 89 2. no two triangles in the decomposition overlap, and 90 3. the orientation of each triangle is consistent with the orientation 91 of the original primitive. 92 93 For such primitives, the shader is executed once for each triangle in the 94 decomposition. 95 96 There are three vertices available for each program invocation. The first, 97 second and third vertices refer to attributes of the first, second and 98 third vertex of the triangle, respectively. ... 99 100 Modify Section 2.16.4, Geometry Shader Execution Environment, of the 101 EXT_geometry_shader4 specification as follows: 102 103 Geometry shader inputs 104 105 (modify the spec language for primitive ID, describing its interaction 106 with QUADS, QUAD_STRIP, and POLYGON topologies) The built-in special 107 variable gl_PrimitiveIDIn is not an array and has no vertex shader 108 equivalent. It is filled with the number of primitives processed since the 109 last time Begin was called (directly or indirectly via vertex array 110 functions). The first primitive generated after a Begin is numbered zero, 111 and the primitive ID counter is incremented after every individual point, 112 line, or polygon primitive is processed. For polygons drawn in point or 113 line mode, the primitive ID counter is incremented only once, even though 114 multiple points or lines may be drawn. For QUADS and QUAD_STRIP 115 primitives that are decomposed into triangles, the primitive ID is 116 incremented after each complete quad is processed. For POLYGON 117 primitives, the primitive ID counter is undefined. Restarting a primitive 118 topology using the primitive restart index has no effect on the primitive 119 ID counter. 120 121 Geometry Shader outputs 122 123 (modify the vertex output limit language to allow changes to take effect 124 immediately) A geometry shader is limited in the number of vertices it may 125 emit per invocation. The maximum number of vertices a geometry shader can 126 possibly emit needs to be set as a parameter of the program object that 127 contains the geometry shader. To do so, call ProgramParameteriEXT with 128 <pname> set to GEOMETRY_VERTICES_OUT_EXT and <value> set to the maximum 129 number of vertices the geometry shader will emit in one invocation. 130 Setting this limit will take effect immediately. If a geometry shader, in 131 one invocation, emits more vertices than the value 132 GEOMETRY_VERTICES_OUT_EXT, these emits may have no effect. 133 134 (modify the error checking language for values that are too large) There 135 are two implementation-dependent limits on the value of 136 GEOMETRY_VERTICES_OUT_EXT. First, the error INVALID_VALUE will be 137 generated by ProgramParameteriEXT if the number of vertices specified 138 exceeds the value of MAX_GEOMETRY_OUTPUT_VERTICES_EXT. Second, the 139 product of the total number of vertices and the sum of all components of 140 all active varying variables may not exceed the value of 141 MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT. If <program> has already been 142 successfully linked, the error INVALID_VALUE will be generated by 143 ProgramParameteriEXT if the specified value causes this limit to be 144 exceeded. Additionally, LinkProgram will fail if it determines that the 145 total component limit would be violated. 146 147Additions to Chapter 3 of the OpenGL 2.0 Specification (Rasterization) 148 149 None 150 151Additions to Chapter 4 of the OpenGL 2.0 Specification (Per-Fragment 152Operations and the Frame Buffer) 153 154 None 155 156Additions to Chapter 5 of the OpenGL 2.0 Specification (Special Functions) 157 158 None 159 160Additions to Chapter 6 of the OpenGL 2.0 Specification (State and State 161Requests) 162 163 None 164 165Additions to Appendix A of the OpenGL 2.0 Specification (Invariance) 166 167 None 168 169Additions to the AGL/GLX/WGL Specifications 170 171 None 172 173Interactions with NV_transform_feedback 174 175 If GL_NV_transform_feedback is not supported, the function 176 GetActiveVaryingNV() needs to be added to this extension. This function 177 can be used to count the number of varying components output by a geometry 178 shader, and from that data the maximum value for GEOMETRY_VERTICES_OUT_EXT 179 computed by the application. 180 181GLX protocol 182 183 None required 184 185Errors 186 187 The error INVALID_OPERATION is generated if Begin, or any command that 188 implicitly calls Begin, is called when a geometry shader is active and: 189 190 * the input primitive type of the current geometry shader is POINTS 191 and <mode> is not POINTS, 192 193 * the input primitive type of the current geometry shader is LINES and 194 <mode> is not LINES, LINE_STRIP, or LINE_LOOP, 195 196 * the input primitive type of the current geometry shader is TRIANGLES 197 and <mode> is not TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN, QUADS, 198 QUAD_STRIP, or POLYGON, 199 200 * the input primitive type of the current geometry shader is 201 LINES_ADJACENCY_EXT and <mode> is not LINES_ADJACENCY_EXT or 202 LINE_STRIP_ADJACENCY_EXT, or 203 204 * the input primitive type of the current geometry shader is 205 TRIANGLES_ADJACENCY_EXT and <mode> is not TRIANGLES_ADJACENCY_EXT or 206 TRIANGLE_STRIP_ADJACENCY_EXT. 207 208 * GEOMETRY_VERTICES_OUT_EXT is zero for the currently active program 209 object. 210 211New State 212 213 None 214 215Issues 216 217 1. Why is there a GL_NV_geometry_shader4 and a GL_EXT_geometry_shader4 218 extension? 219 220 RESOLVED: NVIDIA initially wrote the geometry shader extension, and 221 worked with other vendors on a common extension. Most of the 222 functionality of the original specification was retained, but a few 223 functional changes were made, resulting in the GL_EXT_geometry_shader4 224 specification. 225 226 Some of the functionality removed in this process may be useful to 227 developers, so we chose to provide an NVIDIA extension to expose this 228 extra functionality. 229 230 2. Should it be possible to change the limit on the number of vertices 231 emitted by a geometry shader after the program object, containing the 232 shader, is linked? 233 234 RESOLVED: Yes. Applications may want to tweak a piece of data that 235 affects the number of vertices emitted, but wouldn't otherwise require 236 re-linking the entire program object. One simple example might be a 237 "circular point sprite" shader, that reads a single point, and draws a 238 circle centered at that point with <N> vertices, where <N> is provided 239 as a uniform. An application could change the value <N> at run time, 240 which would require a change in the vertex limit. Another example might 241 be a geometry shader that does some fancy subdivision, where the 242 relevant parameter might be a limit on how far the primitive is 243 subdivided. This limit can be changed using the function 244 ProgramParameteriEXT with <pname> set to GEOMETRY_VERTICES_OUT_EXT. 245 246 3. How are QUADS, QUAD_STRIP, and POLYGON primitives decomposed into 247 triangles in the initial implementation? 248 249 RESOLVED: The specification leaves the decomposition undefined, subject 250 to a small number of rules. Assume that four vertices are specified in 251 the order V0, V1, V2, V3. 252 253 For QUADS primitives, the quad V0->V1->V2->V3 is decomposed into the 254 triangles V0->V1->V2, and V0->V2->V3. The provoking vertex of the quad 255 (V3) is only found in the second triangle. If it's necessary to flat 256 shade over an entire quad, take the attributes from V0, which will be 257 the first vertex for both triangles in the decomposition. 258 259 For QUAD_STRIP primitives, the quad V0->V1->V3->V2 is decomposed into 260 the triangles V0->V1->V3 and V2->V0->V3. This has the property of 261 leaving the provoking vertex for the polygon (V3) as the third vertex 262 for each triangle of the decomposition. 263 264 For POLYGON primitives, the polygon V0->V1->V2->V3 is decomposed into 265 the triangles V1->V2->V0 and V2->V3->V0. This has the property of 266 leaving the provoking vertex for the polygon (V0) as the third vertex 267 for each triangle of the decomposition. 268 269 The triangulation described here is not guaranteed to be used on all 270 implementations of this extension, and subsequent implementations may 271 use a more natural decomposition for QUAD_STRIP and POLYGON primitives. 272 (For example, the triangulation of 4-vertex polygons might match that 273 used for QUADS.) 274 275 4. Should this extension maintain the link error when GEOMETRY_VERTICES_OUT 276 is zero at link time stipulated by EXT/ARB_geometry_shader? 277 278 RESOLVED: No. While a link error is helpful to indicate the problem 279 earlier and with additional information, the way this extension is meant 280 to be used is more consistent with allowing the vertices out to remain 281 unspecified until render time rather than demanding a potentially bogus 282 value for it just to satisfy the linker. 283 284 285Revision History 286 287 288 Rev. Date Author Changes 289 ---- ---------- -------- ------------------------------------------- 290 17 10/09/2009 groth Added explicit language excluding error for 291 linking with zero GEOMETRY_VERTICES_OUT. 292 16 01/10/2007 pbrown Initial public revision. 293