15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci NV_geometry_shader4 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName String 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_NV_geometry_shader4 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Pat Brown, NVIDIA (pbrown 'at' nvidia.com) 125bd8deadSopenharmony_ci Barthold Lichtenbelt, NVIDIA (blichtenbelt 'at' nvidia.com) 135bd8deadSopenharmony_ci 145bd8deadSopenharmony_ciStatus 155bd8deadSopenharmony_ci 165bd8deadSopenharmony_ci Shipping for GeForce 8 Series (November 2006) 175bd8deadSopenharmony_ci 185bd8deadSopenharmony_ciVersion 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ci Last Modified Date: 11/09/2009 215bd8deadSopenharmony_ci Author revision: 17 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ciNumber 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ci 338 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ciDependencies 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci OpenGL 1.1 is required. 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ci EXT_geometry_shader4 is required. 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci This extension is written against the EXT_geometry_shader4 and OpenGL 2.0 345bd8deadSopenharmony_ci specifications. 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ciOverview 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ci This extension builds upon the EXT_geometry_shader4 specification to 395bd8deadSopenharmony_ci provide two additional capabilities: 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ci * Support for QUADS, QUAD_STRIP, and POLYGON primitive types when 425bd8deadSopenharmony_ci geometry shaders are enabled. Such primitives will be tessellated 435bd8deadSopenharmony_ci into individual triangles. 445bd8deadSopenharmony_ci 455bd8deadSopenharmony_ci * Setting the value of GEOMETRY_VERTICES_OUT_EXT will take effect 465bd8deadSopenharmony_ci immediately. It is not necessary to link the program object in 475bd8deadSopenharmony_ci order for this change to take effect, as is the case in the EXT 485bd8deadSopenharmony_ci version of this extension. 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ciNew Procedures and Functions 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci None 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ciNew Tokens 555bd8deadSopenharmony_ci 565bd8deadSopenharmony_ci None 575bd8deadSopenharmony_ci 585bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 2.0 Specification (OpenGL Operation) 595bd8deadSopenharmony_ci 605bd8deadSopenharmony_ci Modify Section 2.15.2 Program Objects, p. 73 615bd8deadSopenharmony_ci 625bd8deadSopenharmony_ci Change the language below the LinkProgram command on p. 74 as follows: 635bd8deadSopenharmony_ci 645bd8deadSopenharmony_ci ... Linking can fail for a variety of reasons as specified in the OpenGL 655bd8deadSopenharmony_ci Shading Language Specification. Linking will also fail if one or more of 665bd8deadSopenharmony_ci the shader objects, attached to <program> are not compiled successfully, 675bd8deadSopenharmony_ci or if more active uniform or active sampler variables are used in 685bd8deadSopenharmony_ci <program> than allowed (see sections 2.15.3 and 2.16.3). Linking will also 695bd8deadSopenharmony_ci fail if the program object contains objects to form a geometry shader (see 705bd8deadSopenharmony_ci section 2.16), but no objects to form a vertex shader. If LinkProgram 715bd8deadSopenharmony_ci failed, ... 725bd8deadSopenharmony_ci 735bd8deadSopenharmony_ci Modify Section 2.16.1, Geometry shader Input Primitives, of the 745bd8deadSopenharmony_ci EXT_geometry_shader4 specification as follows: 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ci Triangles (TRIANGLES) 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ci Geometry shaders that operate on triangles are valid for the TRIANGLES, 795bd8deadSopenharmony_ci TRIANGLE_STRIP, TRIANGLE_FAN, QUADS, QUAD_STRIP, and POLYGON primitive 805bd8deadSopenharmony_ci types. 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci When used with a geometry shader that operates on triangles, QUADS, 835bd8deadSopenharmony_ci QUAD_STRIP, and POLYGON primitives are decomposed into triangles in an 845bd8deadSopenharmony_ci unspecified, implementation-dependent manner. This decomposition satisfies 855bd8deadSopenharmony_ci three properties: 865bd8deadSopenharmony_ci 875bd8deadSopenharmony_ci 1. the collection of triangles fully covers the area of the original 885bd8deadSopenharmony_ci primitive, 895bd8deadSopenharmony_ci 2. no two triangles in the decomposition overlap, and 905bd8deadSopenharmony_ci 3. the orientation of each triangle is consistent with the orientation 915bd8deadSopenharmony_ci of the original primitive. 925bd8deadSopenharmony_ci 935bd8deadSopenharmony_ci For such primitives, the shader is executed once for each triangle in the 945bd8deadSopenharmony_ci decomposition. 955bd8deadSopenharmony_ci 965bd8deadSopenharmony_ci There are three vertices available for each program invocation. The first, 975bd8deadSopenharmony_ci second and third vertices refer to attributes of the first, second and 985bd8deadSopenharmony_ci third vertex of the triangle, respectively. ... 995bd8deadSopenharmony_ci 1005bd8deadSopenharmony_ci Modify Section 2.16.4, Geometry Shader Execution Environment, of the 1015bd8deadSopenharmony_ci EXT_geometry_shader4 specification as follows: 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci Geometry shader inputs 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci (modify the spec language for primitive ID, describing its interaction 1065bd8deadSopenharmony_ci with QUADS, QUAD_STRIP, and POLYGON topologies) The built-in special 1075bd8deadSopenharmony_ci variable gl_PrimitiveIDIn is not an array and has no vertex shader 1085bd8deadSopenharmony_ci equivalent. It is filled with the number of primitives processed since the 1095bd8deadSopenharmony_ci last time Begin was called (directly or indirectly via vertex array 1105bd8deadSopenharmony_ci functions). The first primitive generated after a Begin is numbered zero, 1115bd8deadSopenharmony_ci and the primitive ID counter is incremented after every individual point, 1125bd8deadSopenharmony_ci line, or polygon primitive is processed. For polygons drawn in point or 1135bd8deadSopenharmony_ci line mode, the primitive ID counter is incremented only once, even though 1145bd8deadSopenharmony_ci multiple points or lines may be drawn. For QUADS and QUAD_STRIP 1155bd8deadSopenharmony_ci primitives that are decomposed into triangles, the primitive ID is 1165bd8deadSopenharmony_ci incremented after each complete quad is processed. For POLYGON 1175bd8deadSopenharmony_ci primitives, the primitive ID counter is undefined. Restarting a primitive 1185bd8deadSopenharmony_ci topology using the primitive restart index has no effect on the primitive 1195bd8deadSopenharmony_ci ID counter. 1205bd8deadSopenharmony_ci 1215bd8deadSopenharmony_ci Geometry Shader outputs 1225bd8deadSopenharmony_ci 1235bd8deadSopenharmony_ci (modify the vertex output limit language to allow changes to take effect 1245bd8deadSopenharmony_ci immediately) A geometry shader is limited in the number of vertices it may 1255bd8deadSopenharmony_ci emit per invocation. The maximum number of vertices a geometry shader can 1265bd8deadSopenharmony_ci possibly emit needs to be set as a parameter of the program object that 1275bd8deadSopenharmony_ci contains the geometry shader. To do so, call ProgramParameteriEXT with 1285bd8deadSopenharmony_ci <pname> set to GEOMETRY_VERTICES_OUT_EXT and <value> set to the maximum 1295bd8deadSopenharmony_ci number of vertices the geometry shader will emit in one invocation. 1305bd8deadSopenharmony_ci Setting this limit will take effect immediately. If a geometry shader, in 1315bd8deadSopenharmony_ci one invocation, emits more vertices than the value 1325bd8deadSopenharmony_ci GEOMETRY_VERTICES_OUT_EXT, these emits may have no effect. 1335bd8deadSopenharmony_ci 1345bd8deadSopenharmony_ci (modify the error checking language for values that are too large) There 1355bd8deadSopenharmony_ci are two implementation-dependent limits on the value of 1365bd8deadSopenharmony_ci GEOMETRY_VERTICES_OUT_EXT. First, the error INVALID_VALUE will be 1375bd8deadSopenharmony_ci generated by ProgramParameteriEXT if the number of vertices specified 1385bd8deadSopenharmony_ci exceeds the value of MAX_GEOMETRY_OUTPUT_VERTICES_EXT. Second, the 1395bd8deadSopenharmony_ci product of the total number of vertices and the sum of all components of 1405bd8deadSopenharmony_ci all active varying variables may not exceed the value of 1415bd8deadSopenharmony_ci MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT. If <program> has already been 1425bd8deadSopenharmony_ci successfully linked, the error INVALID_VALUE will be generated by 1435bd8deadSopenharmony_ci ProgramParameteriEXT if the specified value causes this limit to be 1445bd8deadSopenharmony_ci exceeded. Additionally, LinkProgram will fail if it determines that the 1455bd8deadSopenharmony_ci total component limit would be violated. 1465bd8deadSopenharmony_ci 1475bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 2.0 Specification (Rasterization) 1485bd8deadSopenharmony_ci 1495bd8deadSopenharmony_ci None 1505bd8deadSopenharmony_ci 1515bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 2.0 Specification (Per-Fragment 1525bd8deadSopenharmony_ciOperations and the Frame Buffer) 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci None 1555bd8deadSopenharmony_ci 1565bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 2.0 Specification (Special Functions) 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ci None 1595bd8deadSopenharmony_ci 1605bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 2.0 Specification (State and State 1615bd8deadSopenharmony_ciRequests) 1625bd8deadSopenharmony_ci 1635bd8deadSopenharmony_ci None 1645bd8deadSopenharmony_ci 1655bd8deadSopenharmony_ciAdditions to Appendix A of the OpenGL 2.0 Specification (Invariance) 1665bd8deadSopenharmony_ci 1675bd8deadSopenharmony_ci None 1685bd8deadSopenharmony_ci 1695bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 1705bd8deadSopenharmony_ci 1715bd8deadSopenharmony_ci None 1725bd8deadSopenharmony_ci 1735bd8deadSopenharmony_ciInteractions with NV_transform_feedback 1745bd8deadSopenharmony_ci 1755bd8deadSopenharmony_ci If GL_NV_transform_feedback is not supported, the function 1765bd8deadSopenharmony_ci GetActiveVaryingNV() needs to be added to this extension. This function 1775bd8deadSopenharmony_ci can be used to count the number of varying components output by a geometry 1785bd8deadSopenharmony_ci shader, and from that data the maximum value for GEOMETRY_VERTICES_OUT_EXT 1795bd8deadSopenharmony_ci computed by the application. 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ciGLX protocol 1825bd8deadSopenharmony_ci 1835bd8deadSopenharmony_ci None required 1845bd8deadSopenharmony_ci 1855bd8deadSopenharmony_ciErrors 1865bd8deadSopenharmony_ci 1875bd8deadSopenharmony_ci The error INVALID_OPERATION is generated if Begin, or any command that 1885bd8deadSopenharmony_ci implicitly calls Begin, is called when a geometry shader is active and: 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ci * the input primitive type of the current geometry shader is POINTS 1915bd8deadSopenharmony_ci and <mode> is not POINTS, 1925bd8deadSopenharmony_ci 1935bd8deadSopenharmony_ci * the input primitive type of the current geometry shader is LINES and 1945bd8deadSopenharmony_ci <mode> is not LINES, LINE_STRIP, or LINE_LOOP, 1955bd8deadSopenharmony_ci 1965bd8deadSopenharmony_ci * the input primitive type of the current geometry shader is TRIANGLES 1975bd8deadSopenharmony_ci and <mode> is not TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN, QUADS, 1985bd8deadSopenharmony_ci QUAD_STRIP, or POLYGON, 1995bd8deadSopenharmony_ci 2005bd8deadSopenharmony_ci * the input primitive type of the current geometry shader is 2015bd8deadSopenharmony_ci LINES_ADJACENCY_EXT and <mode> is not LINES_ADJACENCY_EXT or 2025bd8deadSopenharmony_ci LINE_STRIP_ADJACENCY_EXT, or 2035bd8deadSopenharmony_ci 2045bd8deadSopenharmony_ci * the input primitive type of the current geometry shader is 2055bd8deadSopenharmony_ci TRIANGLES_ADJACENCY_EXT and <mode> is not TRIANGLES_ADJACENCY_EXT or 2065bd8deadSopenharmony_ci TRIANGLE_STRIP_ADJACENCY_EXT. 2075bd8deadSopenharmony_ci 2085bd8deadSopenharmony_ci * GEOMETRY_VERTICES_OUT_EXT is zero for the currently active program 2095bd8deadSopenharmony_ci object. 2105bd8deadSopenharmony_ci 2115bd8deadSopenharmony_ciNew State 2125bd8deadSopenharmony_ci 2135bd8deadSopenharmony_ci None 2145bd8deadSopenharmony_ci 2155bd8deadSopenharmony_ciIssues 2165bd8deadSopenharmony_ci 2175bd8deadSopenharmony_ci 1. Why is there a GL_NV_geometry_shader4 and a GL_EXT_geometry_shader4 2185bd8deadSopenharmony_ci extension? 2195bd8deadSopenharmony_ci 2205bd8deadSopenharmony_ci RESOLVED: NVIDIA initially wrote the geometry shader extension, and 2215bd8deadSopenharmony_ci worked with other vendors on a common extension. Most of the 2225bd8deadSopenharmony_ci functionality of the original specification was retained, but a few 2235bd8deadSopenharmony_ci functional changes were made, resulting in the GL_EXT_geometry_shader4 2245bd8deadSopenharmony_ci specification. 2255bd8deadSopenharmony_ci 2265bd8deadSopenharmony_ci Some of the functionality removed in this process may be useful to 2275bd8deadSopenharmony_ci developers, so we chose to provide an NVIDIA extension to expose this 2285bd8deadSopenharmony_ci extra functionality. 2295bd8deadSopenharmony_ci 2305bd8deadSopenharmony_ci 2. Should it be possible to change the limit on the number of vertices 2315bd8deadSopenharmony_ci emitted by a geometry shader after the program object, containing the 2325bd8deadSopenharmony_ci shader, is linked? 2335bd8deadSopenharmony_ci 2345bd8deadSopenharmony_ci RESOLVED: Yes. Applications may want to tweak a piece of data that 2355bd8deadSopenharmony_ci affects the number of vertices emitted, but wouldn't otherwise require 2365bd8deadSopenharmony_ci re-linking the entire program object. One simple example might be a 2375bd8deadSopenharmony_ci "circular point sprite" shader, that reads a single point, and draws a 2385bd8deadSopenharmony_ci circle centered at that point with <N> vertices, where <N> is provided 2395bd8deadSopenharmony_ci as a uniform. An application could change the value <N> at run time, 2405bd8deadSopenharmony_ci which would require a change in the vertex limit. Another example might 2415bd8deadSopenharmony_ci be a geometry shader that does some fancy subdivision, where the 2425bd8deadSopenharmony_ci relevant parameter might be a limit on how far the primitive is 2435bd8deadSopenharmony_ci subdivided. This limit can be changed using the function 2445bd8deadSopenharmony_ci ProgramParameteriEXT with <pname> set to GEOMETRY_VERTICES_OUT_EXT. 2455bd8deadSopenharmony_ci 2465bd8deadSopenharmony_ci 3. How are QUADS, QUAD_STRIP, and POLYGON primitives decomposed into 2475bd8deadSopenharmony_ci triangles in the initial implementation? 2485bd8deadSopenharmony_ci 2495bd8deadSopenharmony_ci RESOLVED: The specification leaves the decomposition undefined, subject 2505bd8deadSopenharmony_ci to a small number of rules. Assume that four vertices are specified in 2515bd8deadSopenharmony_ci the order V0, V1, V2, V3. 2525bd8deadSopenharmony_ci 2535bd8deadSopenharmony_ci For QUADS primitives, the quad V0->V1->V2->V3 is decomposed into the 2545bd8deadSopenharmony_ci triangles V0->V1->V2, and V0->V2->V3. The provoking vertex of the quad 2555bd8deadSopenharmony_ci (V3) is only found in the second triangle. If it's necessary to flat 2565bd8deadSopenharmony_ci shade over an entire quad, take the attributes from V0, which will be 2575bd8deadSopenharmony_ci the first vertex for both triangles in the decomposition. 2585bd8deadSopenharmony_ci 2595bd8deadSopenharmony_ci For QUAD_STRIP primitives, the quad V0->V1->V3->V2 is decomposed into 2605bd8deadSopenharmony_ci the triangles V0->V1->V3 and V2->V0->V3. This has the property of 2615bd8deadSopenharmony_ci leaving the provoking vertex for the polygon (V3) as the third vertex 2625bd8deadSopenharmony_ci for each triangle of the decomposition. 2635bd8deadSopenharmony_ci 2645bd8deadSopenharmony_ci For POLYGON primitives, the polygon V0->V1->V2->V3 is decomposed into 2655bd8deadSopenharmony_ci the triangles V1->V2->V0 and V2->V3->V0. This has the property of 2665bd8deadSopenharmony_ci leaving the provoking vertex for the polygon (V0) as the third vertex 2675bd8deadSopenharmony_ci for each triangle of the decomposition. 2685bd8deadSopenharmony_ci 2695bd8deadSopenharmony_ci The triangulation described here is not guaranteed to be used on all 2705bd8deadSopenharmony_ci implementations of this extension, and subsequent implementations may 2715bd8deadSopenharmony_ci use a more natural decomposition for QUAD_STRIP and POLYGON primitives. 2725bd8deadSopenharmony_ci (For example, the triangulation of 4-vertex polygons might match that 2735bd8deadSopenharmony_ci used for QUADS.) 2745bd8deadSopenharmony_ci 2755bd8deadSopenharmony_ci 4. Should this extension maintain the link error when GEOMETRY_VERTICES_OUT 2765bd8deadSopenharmony_ci is zero at link time stipulated by EXT/ARB_geometry_shader? 2775bd8deadSopenharmony_ci 2785bd8deadSopenharmony_ci RESOLVED: No. While a link error is helpful to indicate the problem 2795bd8deadSopenharmony_ci earlier and with additional information, the way this extension is meant 2805bd8deadSopenharmony_ci to be used is more consistent with allowing the vertices out to remain 2815bd8deadSopenharmony_ci unspecified until render time rather than demanding a potentially bogus 2825bd8deadSopenharmony_ci value for it just to satisfy the linker. 2835bd8deadSopenharmony_ci 2845bd8deadSopenharmony_ci 2855bd8deadSopenharmony_ciRevision History 2865bd8deadSopenharmony_ci 2875bd8deadSopenharmony_ci 2885bd8deadSopenharmony_ci Rev. Date Author Changes 2895bd8deadSopenharmony_ci ---- ---------- -------- ------------------------------------------- 2905bd8deadSopenharmony_ci 17 10/09/2009 groth Added explicit language excluding error for 2915bd8deadSopenharmony_ci linking with zero GEOMETRY_VERTICES_OUT. 2925bd8deadSopenharmony_ci 16 01/10/2007 pbrown Initial public revision. 293