15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci NV_fill_rectangle 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_NV_fill_rectangle 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Jeff Bolz, NVIDIA Corporation (jbolz 'at' nvidia.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Jeff Bolz, NVIDIA Corporation 165bd8deadSopenharmony_ci James Helferty, NVIDIA Corporation 175bd8deadSopenharmony_ci 185bd8deadSopenharmony_ciStatus 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ci Shipping 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ciVersion 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ci Last Modified Date: March 27, 2015 255bd8deadSopenharmony_ci Revision: 2 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ciNumber 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci OpenGL Extension #466 305bd8deadSopenharmony_ci OpenGL ES Extension #232 315bd8deadSopenharmony_ci 325bd8deadSopenharmony_ciDependencies 335bd8deadSopenharmony_ci 345bd8deadSopenharmony_ci This extension is written against the OpenGL 4.3 Specification 355bd8deadSopenharmony_ci (Compatibility Profile). 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ci This extension interacts with OpenGL ES 3.1 (June 4, 2014) 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ci If implemented in OpenGL ES, NV_polygon_mode is required. 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ciOverview 425bd8deadSopenharmony_ci 435bd8deadSopenharmony_ci This extension adds a new PolygonMode setting where a triangle is 445bd8deadSopenharmony_ci rasterized by computing and filling its axis-aligned screen-space bounding 455bd8deadSopenharmony_ci box, disregarding the actual triangle edges. This can be useful for 465bd8deadSopenharmony_ci drawing a rectangle without being split into two triangles with an 475bd8deadSopenharmony_ci internal edge. It is also useful to minimize the number of primitives 485bd8deadSopenharmony_ci that need to be drawn, particularly for a user-interface. 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ciNew Procedures and Functions 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci None. 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ciNew Tokens 555bd8deadSopenharmony_ci 565bd8deadSopenharmony_ci FILL_RECTANGLE_NV 0x933C 575bd8deadSopenharmony_ci 585bd8deadSopenharmony_ciAdditions to Chapter 14 of the OpenGL 4.3 (Compatibility Profile) Specification 595bd8deadSopenharmony_ci(Fixed-Function Primitive Assembly and Rasterization) 605bd8deadSopenharmony_ci 615bd8deadSopenharmony_ci Modify Section 14.6.4 (Options Controlling Polygon Rasterization) 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ci The interpretation of polygons for rasterization is controlled using 645bd8deadSopenharmony_ci 655bd8deadSopenharmony_ci void PolygonMode(enum face, enum mode); 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ci <face> is one of FRONT, BACK, or FRONT_AND_BACK, indicating that the 685bd8deadSopenharmony_ci rasterizing method described by mode respectively replaces the rasterizing 695bd8deadSopenharmony_ci method for front-facing polygons, back-facing polygons, or both front- and 705bd8deadSopenharmony_ci back-facing polygons. <mode> is one of the symbolic constants POINT, LINE, 715bd8deadSopenharmony_ci FILL, or FILL_RECTANGLE_NV. Calling PolygonMode with POINT causes certain 725bd8deadSopenharmony_ci vertices of a polygon to be treated, for rasterization purposes, as if they 735bd8deadSopenharmony_ci had been drawn with mode POINTS. The vertices selected for this treatment 745bd8deadSopenharmony_ci are those that have been tagged as having a polygon boundary edge beginning 755bd8deadSopenharmony_ci on them (see section 10.1.17). LINE causes edges that are tagged as 765bd8deadSopenharmony_ci boundary to be rasterized as line segments. (The line stipple counter is 775bd8deadSopenharmony_ci reset at the beginning of the first rasterized edge of the polygon, but not 785bd8deadSopenharmony_ci for subsequent edges.) FILL is the default mode of polygon rasterization, 795bd8deadSopenharmony_ci corresponding to the description in sections 14.6.1, 14.6.2, and 14.6.3. 805bd8deadSopenharmony_ci Note that these modes affect only the final rasterization of polygons: in 815bd8deadSopenharmony_ci particular, a polygon's vertices are lit, and the polygon is clipped and 825bd8deadSopenharmony_ci possibly culled before these modes are applied. 835bd8deadSopenharmony_ci 845bd8deadSopenharmony_ci FILL_RECTANGLE_NV mode modifies triangle rasterization to consider a sample 855bd8deadSopenharmony_ci within the primitive if the sample location is inside the window-aligned 865bd8deadSopenharmony_ci bounding box of the triangle after projection. Note that the barycentric 875bd8deadSopenharmony_ci weights used in attribute interpolation may be outside the range [0,1] 885bd8deadSopenharmony_ci when these primitives are shaded. Special treatment is given to a sample 895bd8deadSopenharmony_ci position on the boundary edge of the bounding box. In such a case we 905bd8deadSopenharmony_ci require that if two rectangles lie on either side of a common edge (with 915bd8deadSopenharmony_ci identical endpoints) on which a sample position lies, then exactly one of 925bd8deadSopenharmony_ci the triangles results in the production of the fragment during 935bd8deadSopenharmony_ci rasterization. 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ci Polygons rendered with FILL_RECTANGLE_NV mode may be clipped by the 965bd8deadSopenharmony_ci frustum or by user clip planes, in an implementation-dependent manner. 975bd8deadSopenharmony_ci If clipping is applied, the triangle is culled rather than clipped. When 985bd8deadSopenharmony_ci quads and polygons are rendered in this mode, they will be tessellated 995bd8deadSopenharmony_ci and rasterized as independent triangles (the order of tessellation within 1005bd8deadSopenharmony_ci a primitive is undefined). 1015bd8deadSopenharmony_ci 1025bd8deadSopenharmony_ci Polygon antialiasing applies only to the FILL state of PolygonMode. Polygon 1035bd8deadSopenharmony_ci antialiasing does not apply to the FILL_RECTANGLE_NV mode. For POINT or 1045bd8deadSopenharmony_ci LINE, point antialiasing or line segment antialiasing, respectively, apply. 1055bd8deadSopenharmony_ci 1065bd8deadSopenharmony_ci An INVALID_OPERATION error is generated by Begin or any Draw command if 1075bd8deadSopenharmony_ci only one of the front and back polygon mode is FILL_RECTANGLE_NV. 1085bd8deadSopenharmony_ci 1095bd8deadSopenharmony_ci 1105bd8deadSopenharmony_ciNew Implementation Dependent State 1115bd8deadSopenharmony_ci 1125bd8deadSopenharmony_ci None. 1135bd8deadSopenharmony_ci 1145bd8deadSopenharmony_ciNew State 1155bd8deadSopenharmony_ci 1165bd8deadSopenharmony_ci None. 1175bd8deadSopenharmony_ci 1185bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 1195bd8deadSopenharmony_ci 1205bd8deadSopenharmony_ci None. 1215bd8deadSopenharmony_ci 1225bd8deadSopenharmony_ciGLX Protocol 1235bd8deadSopenharmony_ci 1245bd8deadSopenharmony_ci None. 1255bd8deadSopenharmony_ci 1265bd8deadSopenharmony_ciModifications to the OpenGL Shading Language Specification, Version 4.30 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ci None. 1295bd8deadSopenharmony_ci 1305bd8deadSopenharmony_ciErrors 1315bd8deadSopenharmony_ci 1325bd8deadSopenharmony_ci An INVALID_OPERATION error is generated by Begin or any Draw command if 1335bd8deadSopenharmony_ci only one of the front and back polygon mode is FILL_RECTANGLE_NV. 1345bd8deadSopenharmony_ci 1355bd8deadSopenharmony_ciInteractions with OpenGL 4.3 (Core Profile) and OpenGL ES 3.1 1365bd8deadSopenharmony_ci 1375bd8deadSopenharmony_ci If the OpenGL core profile or OpenGL ES is used, references to Begin, line 1385bd8deadSopenharmony_ci stipple, user clip planes, separate front and back polygon modes, polygon 1395bd8deadSopenharmony_ci primitives and quad primitives should be removed. 1405bd8deadSopenharmony_ci 1415bd8deadSopenharmony_ciInteractions with OpenGL ES 3.1 1425bd8deadSopenharmony_ci 1435bd8deadSopenharmony_ci Using this extension in OpenGL ES 3.1, the tokens from OpenGL should be 1445bd8deadSopenharmony_ci considered to refer to equivalent tokens from the NV_polygon_mode 1455bd8deadSopenharmony_ci extension, with an "_NV" suffix: POINT, LINE, FILL, POLYGON_OFFSET_POINT, 1465bd8deadSopenharmony_ci and POLYGON_OFFSET_LINE. References to PolygonMode should be considered 1475bd8deadSopenharmony_ci to refer to PolygonModeNV. References to point, line, and polygon 1485bd8deadSopenharmony_ci antialiasing should be removed. 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ciIssues 1515bd8deadSopenharmony_ci 1525bd8deadSopenharmony_ci (1) Where in the pipeline does the conversion from triangle to screen- 1535bd8deadSopenharmony_ci aligned bbox occur? 1545bd8deadSopenharmony_ci 1555bd8deadSopenharmony_ci RESOLVED: The new rasterization mode applies during rasterization, not 1565bd8deadSopenharmony_ci earlier. So transform feedback would write out the triangle as if it were 1575bd8deadSopenharmony_ci being FILLed normally, and the triangle may have started life as a 1585bd8deadSopenharmony_ci different type of primitive (e.g. point or line) before being converted to 1595bd8deadSopenharmony_ci a triangle by a geometry shader. 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci (2) What happens if such a triangle is clipped? 1625bd8deadSopenharmony_ci 1635bd8deadSopenharmony_ci RESOLVED: Clipping will cause the triangle to be discarded. 1645bd8deadSopenharmony_ci 1655bd8deadSopenharmony_ci (3) How are quads and polygons handled? Are they decomposed into triangles? 1665bd8deadSopenharmony_ci 1675bd8deadSopenharmony_ci RESOLVED: When using FILL_RECTANGLE_NV, quads and polygons are decomposed 1685bd8deadSopenharmony_ci into triangles in an implementation-dependent manner, similar to the 1695bd8deadSopenharmony_ci behavior used in transform feedback. 1705bd8deadSopenharmony_ci 1715bd8deadSopenharmony_ci (4) Do these triangles still have a facingness? 1725bd8deadSopenharmony_ci 1735bd8deadSopenharmony_ci RESOLVED: Yes. Face culling is still applied, and the orientation of such 1745bd8deadSopenharmony_ci a primitive is still observable in the fragment shader (gl_FrontFacing). 1755bd8deadSopenharmony_ci 1765bd8deadSopenharmony_ci (5) How is polygon offset applied? 1775bd8deadSopenharmony_ci 1785bd8deadSopenharmony_ci RESOLVED: Polygon offset is computed and applied normally to the fill 1795bd8deadSopenharmony_ci rectangle, using the same techniques used for triangle rasterization. 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ci If the Z values for the vertices of the fill primitive are not constant, 1825bd8deadSopenharmony_ci the slope-dependent portion of the polygon offset will be computed using 1835bd8deadSopenharmony_ci the three vertices specified. That seems reasonable, since per-pixel Z 1845bd8deadSopenharmony_ci will be interpolated using the same slopes. 1855bd8deadSopenharmony_ci 1865bd8deadSopenharmony_ci However, when using floating-point depth buffers, the meaning of the 1875bd8deadSopenharmony_ci constant portion of polygon offset will scaled according to the Z values 1885bd8deadSopenharmony_ci of the three vertices specified for the fill rectangle. Since the 1895bd8deadSopenharmony_ci interpolated Z values for the fill rectangle may fall outside the range of 1905bd8deadSopenharmony_ci Z values in the primitive, it's possible that this rescaled constant 1915bd8deadSopenharmony_ci offset is too small for portions of the fill rectangle where 1925bd8deadSopenharmony_ci "extrapolated" Z values are larger than any of the Z values of the 1935bd8deadSopenharmony_ci original triangle. This issue will require a workaround in application 1945bd8deadSopenharmony_ci code in the unlikely event that it applies. 1955bd8deadSopenharmony_ci 1965bd8deadSopenharmony_ciRevision History 1975bd8deadSopenharmony_ci 1985bd8deadSopenharmony_ci Revision 2, 2015/03/27 1995bd8deadSopenharmony_ci - Add ES interactions 2005bd8deadSopenharmony_ci 2015bd8deadSopenharmony_ci Revision 1 2025bd8deadSopenharmony_ci - Internal revisions. 203