15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci ARB_viewport_array 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_ARB_viewport_array 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContributors 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Graham Sellers, AMD 125bd8deadSopenharmony_ci Mark Young, AMD 135bd8deadSopenharmony_ci Nick Haemel, AMD 145bd8deadSopenharmony_ci Bill Licea-Kane, AMD 155bd8deadSopenharmony_ci Jeff Bolz, NVIDIA 165bd8deadSopenharmony_ci Daniel Koch, TransGaming 175bd8deadSopenharmony_ci Pat Brown, NVIDIA 185bd8deadSopenharmony_ci Bruce Merry, ARM 195bd8deadSopenharmony_ci Ian Stewart, NVIDIA 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ciContact 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ci Graham Sellers, AMD (graham.sellers 'at' amd.com) 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ciNotice 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ci Copyright (c) 2010-2013 The Khronos Group Inc. Copyright terms at 285bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 295bd8deadSopenharmony_ci 305bd8deadSopenharmony_ciSpecification Update Policy 315bd8deadSopenharmony_ci 325bd8deadSopenharmony_ci Khronos-approved extension specifications are updated in response to 335bd8deadSopenharmony_ci issues and bugs prioritized by the Khronos OpenGL Working Group. For 345bd8deadSopenharmony_ci extensions which have been promoted to a core Specification, fixes will 355bd8deadSopenharmony_ci first appear in the latest version of that core Specification, and will 365bd8deadSopenharmony_ci eventually be backported to the extension document. This policy is 375bd8deadSopenharmony_ci described in more detail at 385bd8deadSopenharmony_ci https://www.khronos.org/registry/OpenGL/docs/update_policy.php 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ciStatus 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ci Complete. Approved by the ARB on June 9, 2010. 435bd8deadSopenharmony_ci Approved by the Khronos Board of Promoters on July 23, 2010. 445bd8deadSopenharmony_ci 455bd8deadSopenharmony_ciVersion 465bd8deadSopenharmony_ci 475bd8deadSopenharmony_ci Last Modified Date: 06/25/2012 485bd8deadSopenharmony_ci Author Revision: 18 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ciNumber 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci ARB Extension #100 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ciDependencies 555bd8deadSopenharmony_ci 565bd8deadSopenharmony_ci OpenGL 1.0 is required. 575bd8deadSopenharmony_ci 585bd8deadSopenharmony_ci OpenGL 3.2 or the EXT_geometry_shader4 or ARB_geometry_shader4 extensions 595bd8deadSopenharmony_ci are required. 605bd8deadSopenharmony_ci 615bd8deadSopenharmony_ci This extension is written against the OpenGL 3.2 (Compatibility) 625bd8deadSopenharmony_ci Specification. 635bd8deadSopenharmony_ci 645bd8deadSopenharmony_ci This extension is written against the OpenGL Shading Language Specification 655bd8deadSopenharmony_ci version 1.50.09. 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ciOverview 685bd8deadSopenharmony_ci 695bd8deadSopenharmony_ci OpenGL is modeled on a pipeline of operations. The final stage in this 705bd8deadSopenharmony_ci pipeline before rasterization is the viewport transformation. This stage 715bd8deadSopenharmony_ci transforms vertices from view space into window coordinates and allows the 725bd8deadSopenharmony_ci application to specify a rectangular region of screen space into which 735bd8deadSopenharmony_ci OpenGL should draw primitives. Unextended OpenGL implementations provide a 745bd8deadSopenharmony_ci single viewport per context. In order to draw primitives into multiple 755bd8deadSopenharmony_ci viewports, the OpenGL viewport may be changed between several draw calls. 765bd8deadSopenharmony_ci With the advent of Geometry Shaders, it has become possible for an 775bd8deadSopenharmony_ci application to amplify geometry and produce multiple output primitives 785bd8deadSopenharmony_ci for each primitive input to the Geometry Shader. It is possible to direct 795bd8deadSopenharmony_ci these primitives to render into a selected render target. However, all 805bd8deadSopenharmony_ci render targets share the same, global OpenGL viewport. 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci This extension enhances OpenGL by providing a mechanism to expose multiple 835bd8deadSopenharmony_ci viewports. Each viewport is specified as a rectangle. The destination 845bd8deadSopenharmony_ci viewport may be selected per-primitive by the geometry shader. This allows 855bd8deadSopenharmony_ci the Geometry Shader to produce different versions of primitives destined 865bd8deadSopenharmony_ci for separate viewport rectangles on the same surface. Additionally, when 875bd8deadSopenharmony_ci combined with multiple framebuffer attachments, it allows a different 885bd8deadSopenharmony_ci viewport rectangle to be selected for each. This extension also exposes a 895bd8deadSopenharmony_ci separate scissor rectangle for each viewport. Finally, the viewport bounds 905bd8deadSopenharmony_ci are now floating point quantities allowing fractional pixel offsets to be 915bd8deadSopenharmony_ci applied during the viewport transform. 925bd8deadSopenharmony_ci 935bd8deadSopenharmony_ciIP Status 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ci No known IP claims. 965bd8deadSopenharmony_ci 975bd8deadSopenharmony_ciNew Procedures and Functions 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ci void ViewportArrayv(uint first, sizei count, const float * v); 1005bd8deadSopenharmony_ci void ViewportIndexedf(uint index, float x, float y, float w, float h); 1015bd8deadSopenharmony_ci void ViewportIndexedfv(uint index, const float * v); 1025bd8deadSopenharmony_ci void ScissorArrayv(uint first, sizei count, const int * v); 1035bd8deadSopenharmony_ci void ScissorIndexed(uint index, int left, int bottom, sizei width, sizei height); 1045bd8deadSopenharmony_ci void ScissorIndexedv(uint index, const int * v); 1055bd8deadSopenharmony_ci void DepthRangeArrayv(uint first, sizei count, const clampd * v); 1065bd8deadSopenharmony_ci void DepthRangeIndexed(uint index, clampd n, clampd f); 1075bd8deadSopenharmony_ci void GetFloati_v(enum target, uint index, float *data); 1085bd8deadSopenharmony_ci void GetDoublei_v(enum target, uint index, double *data); 1095bd8deadSopenharmony_ci 1105bd8deadSopenharmony_ci void GetIntegerIndexedvEXT(enum target, uint index, int * v); 1115bd8deadSopenharmony_ci void EnableIndexedEXT(enum target, uint index); 1125bd8deadSopenharmony_ci void DisableIndexedEXT(enum target, uint index); 1135bd8deadSopenharmony_ci boolean IsEnabledIndexedEXT(enum target, uint index); 1145bd8deadSopenharmony_ci 1155bd8deadSopenharmony_ci Note that GetIntegerIndexedvEXT, EnableIndexedEXT, DisableIndexedEXT and 1165bd8deadSopenharmony_ci IsEnabledIndexedEXT are introduced by other OpenGL extensions such as 1175bd8deadSopenharmony_ci EXT_draw_buffers2. If this extension is implemented against an earlier 1185bd8deadSopenharmony_ci version of OpenGL that does not support GetIntegeri_v and so on, the 1195bd8deadSopenharmony_ci 'Indexed' versions of these functions may be used in their place. 1205bd8deadSopenharmony_ci 1215bd8deadSopenharmony_ciNew Tokens 1225bd8deadSopenharmony_ci 1235bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, 1245bd8deadSopenharmony_ci GetDoublev and GetInteger64v: 1255bd8deadSopenharmony_ci 1265bd8deadSopenharmony_ci MAX_VIEWPORTS 0x825B 1275bd8deadSopenharmony_ci VIEWPORT_SUBPIXEL_BITS 0x825C 1285bd8deadSopenharmony_ci VIEWPORT_BOUNDS_RANGE 0x825D 1295bd8deadSopenharmony_ci LAYER_PROVOKING_VERTEX 0x825E 1305bd8deadSopenharmony_ci VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F 1315bd8deadSopenharmony_ci 1325bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetIntegeri_v: 1335bd8deadSopenharmony_ci 1345bd8deadSopenharmony_ci SCISSOR_BOX 0x0C10 1355bd8deadSopenharmony_ci 1365bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetFloati_v: 1375bd8deadSopenharmony_ci 1385bd8deadSopenharmony_ci VIEWPORT 0x0BA2 1395bd8deadSopenharmony_ci 1405bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetDoublei_v: 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci DEPTH_RANGE 0x0B70 1435bd8deadSopenharmony_ci 1445bd8deadSopenharmony_ci Accepted by the <pname> parameter of Enablei, Disablei, and IsEnabledi: 1455bd8deadSopenharmony_ci 1465bd8deadSopenharmony_ci SCISSOR_TEST 0x0C11 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ci Returned in the <data> parameter from a Get query with a <pname> of 1495bd8deadSopenharmony_ci LAYER_PROVOKING_VERTEX or VIEWPORT_INDEX_PROVOKING_VERTEX: 1505bd8deadSopenharmony_ci 1515bd8deadSopenharmony_ci FIRST_VERTEX_CONVENTION 0x8E4D 1525bd8deadSopenharmony_ci LAST_VERTEX_CONVENTION 0x8E4E 1535bd8deadSopenharmony_ci PROVOKING_VERTEX 0x8E4F 1545bd8deadSopenharmony_ci UNDEFINED_VERTEX 0x8260 1555bd8deadSopenharmony_ci 1565bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 3.2 (Compatibility) Specification (OpenGL 1575bd8deadSopenharmony_ciOperation) 1585bd8deadSopenharmony_ci 1595bd8deadSopenharmony_ci Modifications to Section 2.15.4, Geometry Shader Execution Environment 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci Add a paragraph after the description of gl_Layer, page 124. 1625bd8deadSopenharmony_ci 1635bd8deadSopenharmony_ci The built-in special variable gl_ViewportIndex is used to direct 1645bd8deadSopenharmony_ci rendering to one of several viewports and is discussed in the section 1655bd8deadSopenharmony_ci entitled "Layer and Viewport Selection", below. 1665bd8deadSopenharmony_ci 1675bd8deadSopenharmony_ci Rename the the "Layered Rendering" subsection to "Layer and Viewport 1685bd8deadSopenharmony_ci Selection" and append the following: 1695bd8deadSopenharmony_ci 1705bd8deadSopenharmony_ci Geometry shaders may also select the destination viewport for each 1715bd8deadSopenharmony_ci output primitive. The destination viewport for a primitive may be 1725bd8deadSopenharmony_ci selected in the geometry shader by writing to the built-in output 1735bd8deadSopenharmony_ci variable gl_ViewportIndex. This functionality allows a geometry 1745bd8deadSopenharmony_ci shader to direct its output to a different viewport for each 1755bd8deadSopenharmony_ci primitive, or to draw multiple versions of a primitive into several 1765bd8deadSopenharmony_ci different viewports. 1775bd8deadSopenharmony_ci 1785bd8deadSopenharmony_ci The specific vertex of a primitive that is used to select the 1795bd8deadSopenharmony_ci rendering layer or viewport index is implementation-dependent and 1805bd8deadSopenharmony_ci thus portable applications will assign the same layer and viewport 1815bd8deadSopenharmony_ci index for all vertices in a primitive. The vertex conventions 1825bd8deadSopenharmony_ci followed for gl_Layer and gl_ViewportIndex may be determined by 1835bd8deadSopenharmony_ci calling GetIntegerv with the symbolic constants 1845bd8deadSopenharmony_ci LAYER_PROVOKING_VERTEX and VIEWPORT_INDEX_PROVOKING_VERTEX, 1855bd8deadSopenharmony_ci respectively. For either value, if the value returned is 1865bd8deadSopenharmony_ci PROVOKING_VERTEX, then vertex selection follows the convention 1875bd8deadSopenharmony_ci specified by ProvokingVertex (see section 2.21). If the value 1885bd8deadSopenharmony_ci returned is FIRST_VERTEX_CONVENTION, selection is always taken from 1895bd8deadSopenharmony_ci the first vertex of a primitive. If the value returned is 1905bd8deadSopenharmony_ci LAST_VERTEX_CONVENTION, the selection is always taken from the last 1915bd8deadSopenharmony_ci vertex of a primitive. If the value returned is UNDEFINED_VERTEX, 1925bd8deadSopenharmony_ci the selection is not guaranteed to be taken from any specific vertex 1935bd8deadSopenharmony_ci in the primitive. The vertex considered the provoking vertex for 1945bd8deadSopenharmony_ci particular primitive types is given in Table 2.15. 1955bd8deadSopenharmony_ci 1965bd8deadSopenharmony_ci Modify section 2.16.1 "Controlling the Viewport", page 126. 1975bd8deadSopenharmony_ci 1985bd8deadSopenharmony_ci Change the first paragraph of section 2.16.1 to read 1995bd8deadSopenharmony_ci 2005bd8deadSopenharmony_ci The viewport transformation is determined by the selected viewport's 2015bd8deadSopenharmony_ci width and height in pixels, p_x and p_y, respectively, and its 2025bd8deadSopenharmony_ci center (o_x,o_y) (also in pixels) ... 2035bd8deadSopenharmony_ci 2045bd8deadSopenharmony_ci { leave equations intact } 2055bd8deadSopenharmony_ci 2065bd8deadSopenharmony_ci Multiple viewports are available and are numbered zero through the 2075bd8deadSopenharmony_ci value of MAX_VIEWPORTS minus one. If a geometry shader is active and 2085bd8deadSopenharmony_ci writes to gl_ViewportIndex, the viewport transformation uses the 2095bd8deadSopenharmony_ci viewport corresponding to the value assigned to gl_ViewportIndex 2105bd8deadSopenharmony_ci taken from an implementation-dependent primitive vertex. If the 2115bd8deadSopenharmony_ci value of the viewport index is outside the range zero to the value 2125bd8deadSopenharmony_ci of MAX_VIEWPORTS minus one, the results of the viewport 2135bd8deadSopenharmony_ci transformation are undefined. If no geometry shader is active, or if 2145bd8deadSopenharmony_ci the active geometry shader does not write to gl_ViewportIndex, the 2155bd8deadSopenharmony_ci viewport numbered zero is used by the viewport transformation. 2165bd8deadSopenharmony_ci 2175bd8deadSopenharmony_ci A single vertex may be used in more than one individual primitive, in 2185bd8deadSopenharmony_ci primitives such as TRIANGLE_STRIP. In this case, the viewport 2195bd8deadSopenharmony_ci transformation is applied separately for each primitive. 2205bd8deadSopenharmony_ci 2215bd8deadSopenharmony_ci The factor and offset applied to Z_d for each viewport encoded by n 2225bd8deadSopenharmony_ci and f are set using 2235bd8deadSopenharmony_ci 2245bd8deadSopenharmony_ci void DepthRangeArrayv(uint first, sizei count, const clampd * v); 2255bd8deadSopenharmony_ci void DepthRangeIndexed(uint index, clampd n, clampd f); 2265bd8deadSopenharmony_ci void DepthRange(clampd n, clampd f); 2275bd8deadSopenharmony_ci 2285bd8deadSopenharmony_ci DepthRangeArrayv is used to specify the depth range for multiple 2295bd8deadSopenharmony_ci viewports simultaneously. <first> specifies the index of the first 2305bd8deadSopenharmony_ci viewport to modify and <count> specifies the number of viewports. If 2315bd8deadSopenharmony_ci (<first> + <count>) is greater than the value of MAX_VIEWPORTS then 2325bd8deadSopenharmony_ci an INVALID_VALUE error will be generated. Viewports whose indices 2335bd8deadSopenharmony_ci lie outside the range [<first>, <first> + <count>) are not modified. 2345bd8deadSopenharmony_ci The <v> parameter contains the address of an array of clampd types 2355bd8deadSopenharmony_ci specifying near (n) and far (f) for each viewport in that order. 2365bd8deadSopenharmony_ci 2375bd8deadSopenharmony_ci DepthRangeIndexed specifies the depth range for a single viewport 2385bd8deadSopenharmony_ci and is equivalent (assuming no errors are generated) to: 2395bd8deadSopenharmony_ci 2405bd8deadSopenharmony_ci clampd v[] = { n, f }; 2415bd8deadSopenharmony_ci DepthRangeArrayv(index, 1, v); 2425bd8deadSopenharmony_ci 2435bd8deadSopenharmony_ci DepthRange sets the depth range for all viewports to the same values 2445bd8deadSopenharmony_ci and is equivalent (assuming no errors are generated) to: 2455bd8deadSopenharmony_ci 2465bd8deadSopenharmony_ci for (uint i = 0; i < MAX_VIEWPORTS; i++) 2475bd8deadSopenharmony_ci DepthRangeIndexed(i, n, f); 2485bd8deadSopenharmony_ci 2495bd8deadSopenharmony_ci Z_w is represented as either ... 2505bd8deadSopenharmony_ci 2515bd8deadSopenharmony_ci Replace the end of section 2.16.1, starting from "Viewport transformation 2525bd8deadSopenharmony_ci parameters are specified using..." 2535bd8deadSopenharmony_ci 2545bd8deadSopenharmony_ci Viewport transformation parameters are specified using 2555bd8deadSopenharmony_ci 2565bd8deadSopenharmony_ci void ViewportArrayv(uint first, sizei count, const float * v); 2575bd8deadSopenharmony_ci void Viewport(int x, int y, sizei w, sizei h); 2585bd8deadSopenharmony_ci void ViewportIndexedf(uint index, float x, float y, float w, float h); 2595bd8deadSopenharmony_ci void ViewportIndexedfv(uint index, const float * v); 2605bd8deadSopenharmony_ci 2615bd8deadSopenharmony_ci ViewportArrayv specifies parameters for multiple viewports 2625bd8deadSopenharmony_ci simultaneously. <first> specifies the index of the first viewport to 2635bd8deadSopenharmony_ci modify and <count> specifies the number of viewports. If (<first> + 2645bd8deadSopenharmony_ci <count>) is greater than the value of MAX_VIEWPORTS then an 2655bd8deadSopenharmony_ci INVALID_VALUE error will be generated. Viewports whose indices lie 2665bd8deadSopenharmony_ci outside the range [<first>, <first> + <count>) are not modified. 2675bd8deadSopenharmony_ci <v> contains the address of an array of floating point values 2685bd8deadSopenharmony_ci specifying the left (x), bottom (y), width (w) and height (h) of 2695bd8deadSopenharmony_ci each viewport, in that order. <x> and <y> give the location of the 2705bd8deadSopenharmony_ci viewport's lower left corner and <w> and <h> give the viewport's 2715bd8deadSopenharmony_ci width and height, respectively. 2725bd8deadSopenharmony_ci 2735bd8deadSopenharmony_ci ViewportIndexedf and ViewportIndexedfv specify parameters for a 2745bd8deadSopenharmony_ci single viewport and are equivalent (assuming no errors are 2755bd8deadSopenharmony_ci generated) to: 2765bd8deadSopenharmony_ci 2775bd8deadSopenharmony_ci float v[4] = { x, y, w, h }; 2785bd8deadSopenharmony_ci ViewportArrayv(index, 1, v); 2795bd8deadSopenharmony_ci 2805bd8deadSopenharmony_ci and 2815bd8deadSopenharmony_ci 2825bd8deadSopenharmony_ci ViewportArrayv(index, 1, v); 2835bd8deadSopenharmony_ci 2845bd8deadSopenharmony_ci respectively. 2855bd8deadSopenharmony_ci 2865bd8deadSopenharmony_ci Viewport sets the parameters for all viewports to the same values 2875bd8deadSopenharmony_ci and is equivalent (assuming no errors are generated) to: 2885bd8deadSopenharmony_ci 2895bd8deadSopenharmony_ci for (uint i = 0; i < MAX_VIEWPORTS; i++) 2905bd8deadSopenharmony_ci ViewportIndexedf(i, 1, (float)x, (float)y, (float)w, (float)h); 2915bd8deadSopenharmony_ci 2925bd8deadSopenharmony_ci The viewport parameters shown in the above equations are found from these 2935bd8deadSopenharmony_ci values as 2945bd8deadSopenharmony_ci 2955bd8deadSopenharmony_ci o_x = x + w /2, 2965bd8deadSopenharmony_ci o_y = y + h / 2, 2975bd8deadSopenharmony_ci p_x = w, 2985bd8deadSopenharmony_ci p = h. 2995bd8deadSopenharmony_ci 3005bd8deadSopenharmony_ci The location of the viewport's bottom-left corner, given by (x,y), are 3015bd8deadSopenharmony_ci clamped to be within the implementation-dependent viewport bounds range. 3025bd8deadSopenharmony_ci The viewport bounds range [min, max] tuple may be determined by 3035bd8deadSopenharmony_ci calling GetFloatv with the symbolic constant VIEWPORT_BOUNDS_RANGE 3045bd8deadSopenharmony_ci (see section 6.1). 3055bd8deadSopenharmony_ci 3065bd8deadSopenharmony_ci Viewport width and height are clamped to implementation-dependent maximums 3075bd8deadSopenharmony_ci when specified. The maximum width and height may be found by calling 3085bd8deadSopenharmony_ci GetFloatv with the symbolic constant MAX_VIEWPORT_DIMS. The maximum 3095bd8deadSopenharmony_ci viewport dimensions must be greater than or equal to the larger of 3105bd8deadSopenharmony_ci the visible dimensions of the display being rendered to (if a 3115bd8deadSopenharmony_ci display exists), and the largest renderbuffer image which can be 3125bd8deadSopenharmony_ci successfully created and attached to a framebuffer object (see 3135bd8deadSopenharmony_ci chapter 4). INVALID_VALUE is generated if either w or h is negative. 3145bd8deadSopenharmony_ci 3155bd8deadSopenharmony_ci The state required to implement the viewport transformations is four 3165bd8deadSopenharmony_ci floating-point values and two clamped floating-point values for each 3175bd8deadSopenharmony_ci viewport. In the initial state, w and h for each viewport are set to 3185bd8deadSopenharmony_ci the width and height, respectively, of the window into which the GL 3195bd8deadSopenharmony_ci is to do its rendering. If the default framebuffer is bound but no 3205bd8deadSopenharmony_ci default framebuffer is associated with the GL context (see chapter 3215bd8deadSopenharmony_ci 4), then w and h are initially set to zero. o_x and o_y are set to 3225bd8deadSopenharmony_ci w/2 and h/2, respectively. n and f are set to 0.0 and 1.0, 3235bd8deadSopenharmony_ci respectively. 3245bd8deadSopenharmony_ci 3255bd8deadSopenharmony_ci The precision with which the GL interprets the floating point viewport 3265bd8deadSopenharmony_ci bounds is implementation-dependent and may be determined by querying the 3275bd8deadSopenharmony_ci implementation-defined constant VIEWPORT_SUBPIXEL_BITS. 3285bd8deadSopenharmony_ci 3295bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 3.2 (Compatibility) Specification 3305bd8deadSopenharmony_ci(Rasterization) 3315bd8deadSopenharmony_ci 3325bd8deadSopenharmony_ci None. 3335bd8deadSopenharmony_ci 3345bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 3.2 (Compatibility) Specification (Per- 3355bd8deadSopenharmony_ciFragment Operations and the Framebuffer) 3365bd8deadSopenharmony_ci 3375bd8deadSopenharmony_ci Replace section 4.1.2 "Scissor Test", page 284. 3385bd8deadSopenharmony_ci 3395bd8deadSopenharmony_ci The scissor test determines if (xw, yw) lies within the scissor rectangle 3405bd8deadSopenharmony_ci defined by four values for each viewport. These values are set with 3415bd8deadSopenharmony_ci 3425bd8deadSopenharmony_ci void ScissorArrayv(uint first, sizei count, const int * v); 3435bd8deadSopenharmony_ci void ScissorIndexed(uint index, int left, int bottom, sizei width, sizei height); 3445bd8deadSopenharmony_ci void ScissorIndexedv(uint index, int * v); 3455bd8deadSopenharmony_ci void Scissor(int left, int bottom, sizei width, sizei height); 3465bd8deadSopenharmony_ci 3475bd8deadSopenharmony_ci ScissorArrayv defines a set of scissor rectangles that are each 3485bd8deadSopenharmony_ci applied to the corresponding viewport (see section 2.16.1 3495bd8deadSopenharmony_ci "Controlling the Viewport"). <first> specifies the index of the 3505bd8deadSopenharmony_ci first scissor rectangle to modify, and <count> specifies the number 3515bd8deadSopenharmony_ci of scissor rectangles. If (<first> + <count>) is greater than the 3525bd8deadSopenharmony_ci value of MAX_VIEWPORTS, then an INVALID_VALUE error is generated. 3535bd8deadSopenharmony_ci <v> contains the address of an array of integers containing the 3545bd8deadSopenharmony_ci left, bottom, width and height of the scissor rectangles, in that 3555bd8deadSopenharmony_ci order. 3565bd8deadSopenharmony_ci 3575bd8deadSopenharmony_ci If left <= x_w < left + width and bottom <= y_w < bottom + height 3585bd8deadSopenharmony_ci for the selected scissor rectangle, then the scissor test passes. 3595bd8deadSopenharmony_ci Otherwise, the test fails and the fragment is discarded. For points, 3605bd8deadSopenharmony_ci lines, and polygons, the scissor rectangle for a primitive is 3615bd8deadSopenharmony_ci selected in the same manner as the viewport (see section 2.16.1). 3625bd8deadSopenharmony_ci For pixel rectangles and bitmaps, the scissor rectangle numbered 3635bd8deadSopenharmony_ci zero is used for the scissor test. 3645bd8deadSopenharmony_ci 3655bd8deadSopenharmony_ci The scissor test is enabled or disabled for all viewports using 3665bd8deadSopenharmony_ci Enable or Disable with the symbolic constant SCISSOR_TEST. The test 3675bd8deadSopenharmony_ci is enabled or disabled for a specific viewport using Enablei or 3685bd8deadSopenharmony_ci Disablei with the constant SCISSOR_TEST and the index of the 3695bd8deadSopenharmony_ci selected viewport. When disabled, it is as if the scissor test 3705bd8deadSopenharmony_ci always passes. The value of the scissor test enable for viewport <i> 3715bd8deadSopenharmony_ci can be queried by calling IsEnabledi with <target> SCISSOR_TEST and 3725bd8deadSopenharmony_ci <index> <i>. The value of the scissor test enable for viewport zero 3735bd8deadSopenharmony_ci may also be queried by calling IsEnabled with the same symbolic 3745bd8deadSopenharmony_ci constant, but no <index> parameter. If either width or height is 3755bd8deadSopenharmony_ci less than zero for any scissor rectangle, then an INVALID_VALUE 3765bd8deadSopenharmony_ci error is generated. If the viewport index specified to Enablei, 3775bd8deadSopenharmony_ci Disablei or IsEnabledi is greater or equal to the value of 3785bd8deadSopenharmony_ci MAX_VIEWPORTS, then an INVALID_VALUE error is generated. 3795bd8deadSopenharmony_ci 3805bd8deadSopenharmony_ci The state required consists of four integer values per viewport, and 3815bd8deadSopenharmony_ci a bit indicating whether the test is enabled or disabled for each 3825bd8deadSopenharmony_ci viewport. In the initial state, left = bottom = 0, and width and 3835bd8deadSopenharmony_ci height are determined by the size of the window into which the GL is 3845bd8deadSopenharmony_ci to do its rendering for all viewports. If the default framebuffer is 3855bd8deadSopenharmony_ci bound but no default framebuffer is associated with the GL context 3865bd8deadSopenharmony_ci (see chapter 4), then with and height are initially set to zero. 3875bd8deadSopenharmony_ci Initially, the scissor test is disabled for all viewports. 3885bd8deadSopenharmony_ci 3895bd8deadSopenharmony_ci ScissorIndexed and ScissorIndexedv specify the scissor rectangle for 3905bd8deadSopenharmony_ci a single viewport and are equivalent (assuming no errors are 3915bd8deadSopenharmony_ci generated) to: 3925bd8deadSopenharmony_ci 3935bd8deadSopenharmony_ci int v[] = { left, bottom, width, height }; 3945bd8deadSopenharmony_ci ScissorArrayv(index, 1, v); 3955bd8deadSopenharmony_ci 3965bd8deadSopenharmony_ci and 3975bd8deadSopenharmony_ci 3985bd8deadSopenharmony_ci ScissorArrayv(index, 1, v); 3995bd8deadSopenharmony_ci 4005bd8deadSopenharmony_ci respectively. 4015bd8deadSopenharmony_ci 4025bd8deadSopenharmony_ci Scissor sets the scissor rectangle for all viewports to the same 4035bd8deadSopenharmony_ci values and is equivalent (assuming no errors are generated) to: 4045bd8deadSopenharmony_ci 4055bd8deadSopenharmony_ci for (uint i = 0; i < MAX_VIEWPORTS; i++) { 4065bd8deadSopenharmony_ci ScissorIndexed(i, left, bottom, width, height); 4075bd8deadSopenharmony_ci } 4085bd8deadSopenharmony_ci 4095bd8deadSopenharmony_ci Calling Enable or Disable with the symbolic constant SCISSOR_TEST is 4105bd8deadSopenharmony_ci equivalent, assuming no errors, to: 4115bd8deadSopenharmony_ci 4125bd8deadSopenharmony_ci for (uint i = 0; i < MAX_VIEWPORTS; i++) { 4135bd8deadSopenharmony_ci Enablei(SCISSOR_TEST, i); 4145bd8deadSopenharmony_ci /* or */ 4155bd8deadSopenharmony_ci Disablei(SCISSOR_TEST, i); 4165bd8deadSopenharmony_ci } 4175bd8deadSopenharmony_ci 4185bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 3.2 (Compatibility) Specification (Special 4195bd8deadSopenharmony_ciFunctions) 4205bd8deadSopenharmony_ci 4215bd8deadSopenharmony_ci None. 4225bd8deadSopenharmony_ci 4235bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 3.2 (Compatibility) Specification (State 4245bd8deadSopenharmony_ciand State Requests) 4255bd8deadSopenharmony_ci 4265bd8deadSopenharmony_ci Modifications to Section 6.1.1 Simple Queries 4275bd8deadSopenharmony_ci 4285bd8deadSopenharmony_ci Add to the list of indexed query functions: 4295bd8deadSopenharmony_ci 4305bd8deadSopenharmony_ci void GetFloati_v(enum target, uint index, float *data); 4315bd8deadSopenharmony_ci void GetDoublei_v(enum target, uint index, float *data); 4325bd8deadSopenharmony_ci 4335bd8deadSopenharmony_ciAdditions to the OpenGL Shading Language Version 1.50.09 Specification 4345bd8deadSopenharmony_ci 4355bd8deadSopenharmony_ci Add a new Section 3.3.x, GL_ARB_viewport_array Extension (p. 13) 4365bd8deadSopenharmony_ci 4375bd8deadSopenharmony_ci 3.3.x GL_ARB_viewport_array Extension 4385bd8deadSopenharmony_ci 4395bd8deadSopenharmony_ci To use the GL_ARB_viewport_array extension in a shader it must be 4405bd8deadSopenharmony_ci enabled using the #extension directive. 4415bd8deadSopenharmony_ci 4425bd8deadSopenharmony_ci The shading language preprocessor #define GL_ARB_viewport_array will 4435bd8deadSopenharmony_ci be defined to 1 if the GL_ARB_viewport_array extension is supported. 4445bd8deadSopenharmony_ci 4455bd8deadSopenharmony_ci Additions to Section 7.1 "Vertex and Geometry Shader Special Variables" 4465bd8deadSopenharmony_ci 4475bd8deadSopenharmony_ci Add a paragraph after the paragraph describing gl_Layer, starting "The 4485bd8deadSopenharmony_ci built-in output variable gl_Layer is available only in the geometry 4495bd8deadSopenharmony_ci language, and provides the number of the layer of textures attached to a 4505bd8deadSopenharmony_ci FBO to direct rendering to.": 4515bd8deadSopenharmony_ci 4525bd8deadSopenharmony_ci The built-in output variable gl_ViewportIndex is available only in the 4535bd8deadSopenharmony_ci geometry language, and provides the index of the viewport to which the 4545bd8deadSopenharmony_ci next primitive emitted from the geometry shader should be drawn. Primitives 4555bd8deadSopenharmony_ci generated by the geometry shader will undergo viewport transformation and 4565bd8deadSopenharmony_ci scissor testing using the viewport transformation and scissor rectangle 4575bd8deadSopenharmony_ci selected by the value of gl_ViewportIndex. The viewport index used will 4585bd8deadSopenharmony_ci come from one of the vertices in the primitive being shaded. Which vertex 4595bd8deadSopenharmony_ci the viewport index comes from is implementation-dependent, so it is best to 4605bd8deadSopenharmony_ci use the same viewport index for all vertices of the primitive. If a geometry 4615bd8deadSopenharmony_ci shader does not assign a value to gl_ViewportIndex, viewport transform 4625bd8deadSopenharmony_ci and scissor rectangle zero will be used. If a geometry shader assigns a 4635bd8deadSopenharmony_ci value to gl_ViewportIndex and there is a path through the shader that 4645bd8deadSopenharmony_ci does not set gl_ViewportIndex, then the value of gl_ViewportIndex is 4655bd8deadSopenharmony_ci undefined for executions of the shader that take that path. See section 4665bd8deadSopenharmony_ci 2.15.4, under "Geometry Shader Outputs" for more information. 4675bd8deadSopenharmony_ci 4685bd8deadSopenharmony_ci Add to the list of geometry shader built-in variables on p. 69: 4695bd8deadSopenharmony_ci 4705bd8deadSopenharmony_ci out int gl_ViewportIndex; // may be written to 4715bd8deadSopenharmony_ci 4725bd8deadSopenharmony_ci Modify the description of EmitVertex() in Section 8.10, "Geometry Shader 4735bd8deadSopenharmony_ci Functions", page 104: 4745bd8deadSopenharmony_ci 4755bd8deadSopenharmony_ci The function EmitVertex() specifies that a vertex is completed. A vertex 4765bd8deadSopenharmony_ci is added to the current output primitive using the current values of the 4775bd8deadSopenharmony_ci geometry shader's output variables, including gl_PointSize, gl_ClipDistance, 4785bd8deadSopenharmony_ci gl_Layer, gl_Position, gl_PrimitiveID and gl_ViewportIndex. The values 4795bd8deadSopenharmony_ci of all these... 4805bd8deadSopenharmony_ci 4815bd8deadSopenharmony_ci Add to the list of built in constants available to geometry shaders in 4825bd8deadSopenharmony_ci Section 7.4: 4835bd8deadSopenharmony_ci 4845bd8deadSopenharmony_ci const int gl_MaxViewports = 16; 4855bd8deadSopenharmony_ci 4865bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 4875bd8deadSopenharmony_ci 4885bd8deadSopenharmony_ci None. 4895bd8deadSopenharmony_ci 4905bd8deadSopenharmony_ciGLX Protocol 4915bd8deadSopenharmony_ci 4925bd8deadSopenharmony_ci TBD. 4935bd8deadSopenharmony_ci 4945bd8deadSopenharmony_ciErrors 4955bd8deadSopenharmony_ci 4965bd8deadSopenharmony_ci INVALID_VALUE is generated by ViewportArrayv if <first> + <count> is 4975bd8deadSopenharmony_ci greater than or equal to the value of MAX_VIEWPORTS, or if any 4985bd8deadSopenharmony_ci viewport's width or height is less than 0. 4995bd8deadSopenharmony_ci 5005bd8deadSopenharmony_ci INVALID_VALUE is generated by ScissorArrayv if <first> + <count> is 5015bd8deadSopenharmony_ci greater than or equal to the value of MAX_VIEWPORTS, or if any 5025bd8deadSopenharmony_ci scissor rectangle's width or height is less than zero. 5035bd8deadSopenharmony_ci 5045bd8deadSopenharmony_ci INVALID_VALUE is generated by DepthRangeArrayv if <first> + <count> is 5055bd8deadSopenharmony_ci greater than or equal to the vaue of MAX_VIEWPORTS. 5065bd8deadSopenharmony_ci 5075bd8deadSopenharmony_ci INVALID_VALUE is generated by Enablei, Disablei and IsEnabledi if 5085bd8deadSopenharmony_ci <index> is greater than or equal to the value of MAX_VIEWPORTS. 5095bd8deadSopenharmony_ci 5105bd8deadSopenharmony_ciNew State 5115bd8deadSopenharmony_ci 5125bd8deadSopenharmony_ci Table 6.13 (p. 405) 5135bd8deadSopenharmony_ci 5145bd8deadSopenharmony_ci Get Value Type Get Command Initial Value Description Sec Attribute 5155bd8deadSopenharmony_ci ------------------------ ---------------- ------------ ------------- ------------------------ ----- --------- 5165bd8deadSopenharmony_ci VIEWPORT 16* x 4 x R GetFloati_v See 2.11.1 Viewport origin & extent 2.11.1 viewport 5175bd8deadSopenharmony_ci DEPTH_RANGE 16* x 2 x R[0,1] GetDoublei_v See 2.16.1 Depth range near & far 2.16.1 viewport 5185bd8deadSopenharmony_ci 5195bd8deadSopenharmony_ciNOTE: The changes are that VIEWPORT and DEPTH_RANGE are extended to 5205bd8deadSopenharmony_ciaccommodate 16* copies and now consist of floating-point and 5215bd8deadSopenharmony_cidouble-precision values, respectively. 5225bd8deadSopenharmony_ci 5235bd8deadSopenharmony_ci Table 6.26 (p. 418) 5245bd8deadSopenharmony_ci 5255bd8deadSopenharmony_ci Get Value Type Get Command Initial Value Description Sec Attribute 5265bd8deadSopenharmony_ci ------------------------ ---------- ------------- ------------- ------------------- ----- --------- 5275bd8deadSopenharmony_ci SCISSOR_TEST 16* x B IsEnabledi FALSE Scissoring enabled 4.1.2 scissor/enable 5285bd8deadSopenharmony_ci SCISSOR_BOX 16* x 4 x Z GetIntegeri_v See 4.1.2 Scissor box 4.1.2 scissor 5295bd8deadSopenharmony_ci 5305bd8deadSopenharmony_ciNOTE: The only change is that SCISSOR_TEST and SCISSOR_BOX are extended 5315bd8deadSopenharmony_cito accommodate 16* copies. 5325bd8deadSopenharmony_ci 5335bd8deadSopenharmony_ciNew Implementation Dependent State 5345bd8deadSopenharmony_ci 5355bd8deadSopenharmony_ci Get Value Type Get Command Minimum Value Description Sec. 5365bd8deadSopenharmony_ci --------- ---- ----------- ------------- ------------------- ----- 5375bd8deadSopenharmony_ci MAX_VIEWPORT_DIMS (NOTE 1) 2 x Z+ GetFloatv See 2.16.1 Maximum viewport dimensions 2.16.1 5385bd8deadSopenharmony_ci MAX_VIEWPORTS Z+ GetIntegerv 16 Maximum number of 2.16.1 5395bd8deadSopenharmony_ci active viewports 5405bd8deadSopenharmony_ci VIEWPORT_SUBPIXEL_BITS Z+ GetIntegerv 0 Number of bits of sub-pixel 2.16.1 5415bd8deadSopenharmony_ci precision for viewport bounds 5425bd8deadSopenharmony_ci VIEWPORT_BOUNDS_RANGE 2 x R GetFloatv (NOTE 2) Viewport bounds range [min,max] 2.16.1 5435bd8deadSopenharmony_ci LAYER_PROVOKING_VERTEX Z_4 GetIntegerv -- (NOTE 3) vertex convention followed by 2.15.4 5445bd8deadSopenharmony_ci the gl_Layer GLSL variable 5455bd8deadSopenharmony_ci VIEWPORT_INDEX_PROVOKING_VERTEX Z_4 GetIntegerv -- (NOTE 3) vertex convention followed by 2.15.4 5465bd8deadSopenharmony_ci the gl_ViewportIndex GLSL 5475bd8deadSopenharmony_ci variable 5485bd8deadSopenharmony_ci 5495bd8deadSopenharmony_ciNOTE 1: The recommended get command is changed from GetIntegerv to GetFloatv. 5505bd8deadSopenharmony_ciNOTE 2: range for viewport bounds: 5515bd8deadSopenharmony_ci * On GL3-capable hardware the VIEWPORT_BOUNDS_RANGE should be at least 5525bd8deadSopenharmony_ci [-16384, 16383]. 5535bd8deadSopenharmony_ci * On GL4-capable hardware the VIEWPORT_BOUNDS_RANGE should be at least 5545bd8deadSopenharmony_ci [-32768, 32767]. 5555bd8deadSopenharmony_ciNOTE 3: Valid values are: FIRST_VERTEX_CONVENTION, 5565bd8deadSopenharmony_ciLAST_VERTEX_CONVENTION, PROVOKING_VERTEX, UNDEFINED_VERTEX. 5575bd8deadSopenharmony_ci 5585bd8deadSopenharmony_ciInteractions with NV_depth_buffer_float 5595bd8deadSopenharmony_ci 5605bd8deadSopenharmony_ci If NV_depth_buffer_float is supported, add the following commands: 5615bd8deadSopenharmony_ci 5625bd8deadSopenharmony_ci void DepthRangeArraydvNV(uint first, sizei count, const double * v); 5635bd8deadSopenharmony_ci void DepthRangeIndexeddNV(uint index, double n, double f); 5645bd8deadSopenharmony_ci 5655bd8deadSopenharmony_ci These functions are equivalent to the corresponding DepthRange* 5665bd8deadSopenharmony_ci functions, except the the parameters are clamped to [0, 1] when using 5675bd8deadSopenharmony_ci DepthRange*, but not when using DepthRange*dNV. When <n> and <f> are 5685bd8deadSopenharmony_ci applied to <z_d>, they are clamped to the range appropriate given the 5695bd8deadSopenharmony_ci depth buffer's representation. 5705bd8deadSopenharmony_ci 5715bd8deadSopenharmony_ciInteractions with ARB_provoking_vertex, EXT_provoking_vertex, and OpenGL 3.2 or later 5725bd8deadSopenharmony_ci 5735bd8deadSopenharmony_ci If none of ARB_provoking_vertex, EXT_provoking_vertex or OpenGL 3.2 5745bd8deadSopenharmony_ci or later are supported, ignore all references to ProvokingVertex and 5755bd8deadSopenharmony_ci PROVOKING_VERTEX. This extension will continue to require support 5765bd8deadSopenharmony_ci for the LAYER_PROVOKING_VERTEX and VIEWPORT_INDEX_PROVOKING_VERTEX 5775bd8deadSopenharmony_ci queries, but only FIRST_VERTEX_CONVENTION, LAST_VERTEX_CONVENTION, 5785bd8deadSopenharmony_ci or UNDEFINED_VERTEX will be enumerated. 5795bd8deadSopenharmony_ci 5805bd8deadSopenharmony_ciDependencies on compatibitliy profile contexts 5815bd8deadSopenharmony_ci 5825bd8deadSopenharmony_ci Pixel rectangle primitives and bitmaps are available only in 5835bd8deadSopenharmony_ci compatibility profile contexts. In the core profile, references to 5845bd8deadSopenharmony_ci pixel rectangles and bitmaps are removed from the description of 5855bd8deadSopenharmony_ci scissor rectangles in section 4.1.2. 5865bd8deadSopenharmony_ci 5875bd8deadSopenharmony_ciInteractions with NV_geometry_program4 5885bd8deadSopenharmony_ci 5895bd8deadSopenharmony_ci If NV_geometry_program4 is supported and the "ARB_viewport_array" program 5905bd8deadSopenharmony_ci option is specified, geometry result variable "result.viewport" can be 5915bd8deadSopenharmony_ci used to specify the viewport array index to use for primitive viewport 5925bd8deadSopenharmony_ci transformations and scissoring. 5935bd8deadSopenharmony_ci 5945bd8deadSopenharmony_ci (add the following rule to the NV_geometry_program4 grammar) 5955bd8deadSopenharmony_ci 5965bd8deadSopenharmony_ci <resultBasic> ::= ... 5975bd8deadSopenharmony_ci | <resPrefix> "viewport" 5985bd8deadSopenharmony_ci 5995bd8deadSopenharmony_ci (add the following to Table X.3, Geometry Program Result Variable Bindings) 6005bd8deadSopenharmony_ci 6015bd8deadSopenharmony_ci Binding Components Description 6025bd8deadSopenharmony_ci ----------------------------- ---------- ---------------------------- 6035bd8deadSopenharmony_ci result.viewport (v,*,*,*) viewport array index 6045bd8deadSopenharmony_ci 6055bd8deadSopenharmony_ci (add the following to Section 2.X.2, Program Grammar) 6065bd8deadSopenharmony_ci 6075bd8deadSopenharmony_ci If a result variable binding matches "result.viewport", updates to the "x" 6085bd8deadSopenharmony_ci component of the result variable provide a single integer that serves as a 6095bd8deadSopenharmony_ci viewport index specifier for viewport arrays. The index must be written as 6105bd8deadSopenharmony_ci an integer value; writing a floating-point value will produce undefined 6115bd8deadSopenharmony_ci results. If a value outside the range [0, MAX_VIEWPORTS-1] is given, the 6125bd8deadSopenharmony_ci behavior is to proceed as if viewport index 0 was selected. If the 6135bd8deadSopenharmony_ci "ARB_viewport_array" program option is not specified, the "result.viewport" 6145bd8deadSopenharmony_ci binding is unavailable. 6155bd8deadSopenharmony_ci 6165bd8deadSopenharmony_ci (add the following to Section 2.X.6.Y, Geometry Program Options) 6175bd8deadSopenharmony_ci 6185bd8deadSopenharmony_ci + Viewport Array (ARB_viewport_array) 6195bd8deadSopenharmony_ci 6205bd8deadSopenharmony_ci If a geometry program specifies the "ARB_viewport_array" option, the 6215bd8deadSopenharmony_ci result binding "result.viewport" will be available to specify the viewport 6225bd8deadSopenharmony_ci index to use for primitive viewport transformations and scissoring as 6235bd8deadSopenharmony_ci described in section 2.X.2. 6245bd8deadSopenharmony_ci 6255bd8deadSopenharmony_ciIssues 6265bd8deadSopenharmony_ci 6275bd8deadSopenharmony_ci 1) The name glViewportArray infers dynamic behavior and that the GL 6285bd8deadSopenharmony_ci may use values that present in the array at draw time. Would it be 6295bd8deadSopenharmony_ci more consistent to call this glViewportiv or glViewportv? 6305bd8deadSopenharmony_ci 6315bd8deadSopenharmony_ci UNRESOLVED: For now, we'll leave it as glViewportArray. 6325bd8deadSopenharmony_ci 6335bd8deadSopenharmony_ci 2) Should we provide a mechanism to write gl_ViewportIndex in the vertex 6345bd8deadSopenharmony_ci shader? This would allow an application to assign gl_ViewportIndex 6355bd8deadSopenharmony_ci based on the value of a uniform, or from data read through an attribute, 6365bd8deadSopenharmony_ci for example. 6375bd8deadSopenharmony_ci 6385bd8deadSopenharmony_ci RESOLVED: No. While it may be possible, there is no compelling use case, 6395bd8deadSopenharmony_ci and gl_Layer whose precedent we follow here, is not writable in the 6405bd8deadSopenharmony_ci vertex shader. 6415bd8deadSopenharmony_ci 6425bd8deadSopenharmony_ci 3) Does legacy glViewport update just the first viewport, or all of them? 6435bd8deadSopenharmony_ci 6445bd8deadSopenharmony_ci RESOLVED: glViewport is equivalent to calling glViewportArray with 6455bd8deadSopenharmony_ci an array containing a single viewport once for each supported viewport. 6465bd8deadSopenharmony_ci It therefore defines all viewports in a single call. This is also true 6475bd8deadSopenharmony_ci for the legacy glScissor, glDepthRange, glEnable and glDisable functions. 6485bd8deadSopenharmony_ci 6495bd8deadSopenharmony_ci 4) When EXT_provoking_vertex is supported, is the provoking vertex convention 6505bd8deadSopenharmony_ci honored when selecting which vertex the gl_ViewportIndex property is to use? 6515bd8deadSopenharmony_ci 6525bd8deadSopenharmony_ci RESOLVED: It is desirable that the provoking vertex convention 6535bd8deadSopenharmony_ci should be honored when selecting the vertex which gl_ViewportIndex is 6545bd8deadSopenharmony_ci obtained from (and similarly for gl_Layer). Other APIs require that these 6555bd8deadSopenharmony_ci properties should be taken from the "leading vertex", and this for 6565bd8deadSopenharmony_ci maximum content portability, it is desireable to be able to configure the 6575bd8deadSopenharmony_ci pipeline in the same way. However, there exists hardware which would 6585bd8deadSopenharmony_ci otherwise be able to support these features which does not have the 6595bd8deadSopenharmony_ci capability to configure which vertex this is selected from (even though 6605bd8deadSopenharmony_ci it may be doing so in a content-portable way). The 6615bd8deadSopenharmony_ci LAYER_PROVOKING_VERTEX and VIEWPORT_INDEX_PROVOKING_VERTEX 6625bd8deadSopenharmony_ci queries have been added to allow applications to determine if the 6635bd8deadSopenharmony_ci provoking vertex convention is being followed, and if not, which 6645bd8deadSopenharmony_ci convention is being used (if any). Note that applications which are 6655bd8deadSopenharmony_ci creating new content are advised that writing the same 6665bd8deadSopenharmony_ci gl_ViewportIndex and gl_Layer to all the vertices of a primitive is 6675bd8deadSopenharmony_ci the only portable solution. 6685bd8deadSopenharmony_ci 6695bd8deadSopenharmony_ci 5) Why glViewportIndex rather than glEnablei, and so on? 6705bd8deadSopenharmony_ci 6715bd8deadSopenharmony_ci DISCUSSION: This extension follows the precedent of extensions such as 6725bd8deadSopenharmony_ci EXT_draw_buffers2, which introduced glEnableIndexed. These 'indexed' 6735bd8deadSopenharmony_ci functions since have been promoted to core OpenGL as glEnablei. If 6745bd8deadSopenharmony_ci this extension is used on an implementation supporting the glEnablei style 6755bd8deadSopenharmony_ci indexed functions, those may be used instead of, or in conjunction with 6765bd8deadSopenharmony_ci the glXXXXIndexed style indexed functions. 6775bd8deadSopenharmony_ci 6785bd8deadSopenharmony_ci 6) What happens if the viewport bounds lie on exact half-pixel coordinates? 6795bd8deadSopenharmony_ci For example, on a multi-sample surface, which samples should be considered 6805bd8deadSopenharmony_ci 'inside' the viewport? 6815bd8deadSopenharmony_ci 6825bd8deadSopenharmony_ci DISCUSSION: The viewport transformation includes clipping. Assuming this 6835bd8deadSopenharmony_ci clipping has similar precision to the viewport transform itself, then 6845bd8deadSopenharmony_ci the resulting clipped primitives should cut through partial pixels, 6855bd8deadSopenharmony_ci lighting only some of the samples within the pixel. 6865bd8deadSopenharmony_ci 6875bd8deadSopenharmony_ci FEEDBACK FROM PAT: 6885bd8deadSopenharmony_ci 6895bd8deadSopenharmony_ciThis discussion is technically incorrect -- the viewport 6905bd8deadSopenharmony_citransformation technically does *NOT* include any clipping. However, for 6915bd8deadSopenharmony_cigeometric primitives, the viewport transformation is applied to vertices 6925bd8deadSopenharmony_cipost-clipping (despite the fact that it precedes clipping in the spec), so 6935bd8deadSopenharmony_cithere is some clipping in the vicinity of the viewport transformation. 6945bd8deadSopenharmony_ci 6955bd8deadSopenharmony_ci"Guardband clipping" is an alternate implementation, producing nearly 6965bd8deadSopenharmony_ciequivalent results to those specified by OpenGL. When using guardband 6975bd8deadSopenharmony_ciclipping, primitives are not clipped tightly to the view volume in X/Y: 6985bd8deadSopenharmony_ci 6995bd8deadSopenharmony_ci -w <= x <= w 7005bd8deadSopenharmony_ci -w <= y <= w 7015bd8deadSopenharmony_ci 7025bd8deadSopenharmony_ciInstead, looser (or no) clipping is applied, for example: 7035bd8deadSopenharmony_ci 7045bd8deadSopenharmony_ci -8w <= x <= 8w 7055bd8deadSopenharmony_ci -8w <= y <= 8w 7065bd8deadSopenharmony_ci 7075bd8deadSopenharmony_ciSince primitives are clipped far less aggressively, something has to be done 7085bd8deadSopenharmony_cito produce results similar to those with aggressive clipping. To do this, 7095bd8deadSopenharmony_cisuch implementations will enable per-pixel scissoring to the viewport 7105bd8deadSopenharmony_cirectangle. 7115bd8deadSopenharmony_ci 7125bd8deadSopenharmony_ciThere are several areas of difference that implementations using guardband 7135bd8deadSopenharmony_ciclipping need to deal with (or ignore): 7145bd8deadSopenharmony_ci 7155bd8deadSopenharmony_ci* line- and point-mode polygons: The OpenGL spec says that lines should be 7165bd8deadSopenharmony_ci drawn along the edges of polygons clipped to the frustum. If you don't clip 7175bd8deadSopenharmony_ci tightly, you can't draw those edges. (NOTE: The behavior specified by 7185bd8deadSopenharmony_ci OpenGL ends up being somewhat shitty. Let's say you have a line-mode 7195bd8deadSopenharmony_ci primitive clipped by both the left and right side of the frustum, which 7205bd8deadSopenharmony_ci implies that you should have vertical edges on the left and right side of 7215bd8deadSopenharmony_ci the viewport. With integer viewport coordinates, both edges will be exactly 7225bd8deadSopenharmony_ci between pixel centers. In practice, implementations' tiebreaking rules will 7235bd8deadSopenharmony_ci have either the left or right edge light up pixels outside the viewport. If 7245bd8deadSopenharmony_ci the viewport is the full window, this means that one of those lines won't be 7255bd8deadSopenharmony_ci visible. 7265bd8deadSopenharmony_ci 7275bd8deadSopenharmony_ci* wide points and lines: According to the OpenGL spec, line or point 7285bd8deadSopenharmony_ci primitives on or near the edge of the viewport should technically extend 7295bd8deadSopenharmony_ci outside the viewport. For example, a four-pixel point on the left edge of 7305bd8deadSopenharmony_ci the viewport should light up eight pixels (2x4) outside the left edge of the 7315bd8deadSopenharmony_ci viewport. The scissoring used for guardband clipping will discard those 7325bd8deadSopenharmony_ci pixels. In my opinion, the scissored results are preferable to those called 7335bd8deadSopenharmony_ci for by the spec. Of course, with the OpenGL spec behavior, there are no 7345bd8deadSopenharmony_ci visible artifacts if: (a) the viewport covers the entire window or (b) the 7355bd8deadSopenharmony_ci application scissors manually itself. 7365bd8deadSopenharmony_ci 7375bd8deadSopenharmony_ciFractional viewports make things more complicated, particularly if the 7385bd8deadSopenharmony_ciimplementation doesn't scissor at a per-sample granularity. In this case, 7395bd8deadSopenharmony_citight view volume clipping will result in primitives that are fully contained 7405bd8deadSopenharmony_ciwithin the fractional viewport (to the limits of clipping math, at least). 7415bd8deadSopenharmony_ciGuardband clipping will have primitives that extend beyond the viewport and 7425bd8deadSopenharmony_ciprobably cover full pixels at the boundary of the viewport. (This discussion 7435bd8deadSopenharmony_ciassumes that a guardband implementation with fractional viewports extends its 7445bd8deadSopenharmony_civiewport clip to pass on pixels containing any fraction of the floating-point 7455bd8deadSopenharmony_civiewport.) 7465bd8deadSopenharmony_ci 7475bd8deadSopenharmony_ciDirect3D 11 specifies that rasterization along the one-pixel edges of 7485bd8deadSopenharmony_cifractional viewports to be undefined. If implementations want defined 7495bd8deadSopenharmony_cibehavior with fractional viewports, they can program a slightly wider viewport 7505bd8deadSopenharmony_ciand scissor away the pixels along the edge of the expanded viewport. 7515bd8deadSopenharmony_ci 7525bd8deadSopenharmony_ciMy recommendation is as follows: 7535bd8deadSopenharmony_ci 7545bd8deadSopenharmony_ci(1) Edit the clipping section of the spec to explicitly permit implementations 7555bd8deadSopenharmony_cito clip to larger view volume extents in (x,y) and instead scissor to the 7565bd8deadSopenharmony_civiewport rectangle. Note that this scissor rectangle needs to either be 7575bd8deadSopenharmony_ciseparate from the API-level scissor rectangle, or intersected with it. This 7585bd8deadSopenharmony_ciscissoring would always have to be enabled, regardless of the SCISSOR enabled. 7595bd8deadSopenharmony_ci 7605bd8deadSopenharmony_ci(2) Edit the viewport section of the spec to briefly discuss the implications 7615bd8deadSopenharmony_ciof fractional viewports on the newly permitted scissoring. 7625bd8deadSopenharmony_ci 7635bd8deadSopenharmony_ci 7) What is the VIEWPORT_SUBPIXEL_BITS implementation defined value for? 7645bd8deadSopenharmony_ci 7655bd8deadSopenharmony_ci This allows an application to query the precision of the viewport 7665bd8deadSopenharmony_ci transform. More specifically, if VIEWPORT_SUBPIXEL_BITS is zero, then 7675bd8deadSopenharmony_ci this indicates that the viewport bounds are likely implemented using 7685bd8deadSopenharmony_ci integers in hardware. If there are more bits (such as fixed point) then 7695bd8deadSopenharmony_ci this value will be non-zero. If the implementation truely has floating 7705bd8deadSopenharmony_ci point viewport bounds, it may report a sufficiently high value to 7715bd8deadSopenharmony_ci indicate this. 7725bd8deadSopenharmony_ci 7735bd8deadSopenharmony_ci 8) What happened to glGetIntegerv(GL_VIEWPORT, v)? 7745bd8deadSopenharmony_ci 7755bd8deadSopenharmony_ci It still works. You can query floating point state with an integer query. 7765bd8deadSopenharmony_ci You'll get a rounded version of the state. You can also query indexed 7775bd8deadSopenharmony_ci state with a non-indexed query - you'll get the state for index 0. Thus 7785bd8deadSopenharmony_ci glGetIntegerv(GL_VIEWPORT, v) is the same as 7795bd8deadSopenharmony_ci glGetIntegeri_v(GL_VIEWPORT, 0, v), which is legal. 7805bd8deadSopenharmony_ci 7815bd8deadSopenharmony_ciRevision History 7825bd8deadSopenharmony_ci 7835bd8deadSopenharmony_ci Rev. Date Author Changes 7845bd8deadSopenharmony_ci ---- -------- -------- ----------------------------------------- 7855bd8deadSopenharmony_ci 18 06/25/2012 Jon Leech Fixed GetIntegerIndexedivEXT -> 7865bd8deadSopenharmony_ci GetIntegerIndexedvEXT typo (Bug 6694). 7875bd8deadSopenharmony_ci 17 07/25/2010 Jon Leech Fix typo in ViewportArrayv pseudocode 7885bd8deadSopenharmony_ci (Bug 6682). 7895bd8deadSopenharmony_ci 16 07/19/2010 Jon Leech Add GetDoublei_v entry point and change 7905bd8deadSopenharmony_ci state for DEPTH_RANGE to be indexed and 7915bd8deadSopenharmony_ci queryable with this command (Bug 6495). 7925bd8deadSopenharmony_ci Reflow a few paragraphs and sync 7935bd8deadSopenharmony_ci language with 4.1 API spec. 7945bd8deadSopenharmony_ci 15 06/16/2010 istewart Add interaction with NV_geometry_program4. 7955bd8deadSopenharmony_ci 14 05/26/2010 Jon Leech Fix minor typos, remove tabs, make language 7965bd8deadSopenharmony_ci more consistent with GL core spec in 7975bd8deadSopenharmony_ci some places, and reflow paragraphs 7985bd8deadSopenharmony_ci following changes. 7995bd8deadSopenharmony_ci 13 05/18/2010 gsellers Rename to ARB_viewport_array. 8005bd8deadSopenharmony_ci ARBify. Remove suffixes for Core 4.1. 8015bd8deadSopenharmony_ci 12 05/17/2010 gsellers Error is not generated for viewport bounds 8025bd8deadSopenharmony_ci outside VIEWPORT_BOUNDS_RANGE. 8035bd8deadSopenharmony_ci Incoporate feedback from pbrown. 8045bd8deadSopenharmony_ci 11 05/11/2010 gsellers Incorporate feedback from bmerry. 8055bd8deadSopenharmony_ci 10 05/10/2010 dgkoch allow UNDEFINED_VERTEX_EXT for compatibility 8065bd8deadSopenharmony_ci 9 05/10/2010 dgkoch add VIEWPORT_BOUNDS_RANGE and clarify the 8075bd8deadSopenharmony_ci valid values for the viewport location. 8085bd8deadSopenharmony_ci added queries to determing layer and viewport 8095bd8deadSopenharmony_ci index provoking vertex convention. 8105bd8deadSopenharmony_ci updated issue 4. 8115bd8deadSopenharmony_ci 8 05/06/2010 gsellers Remove error if viewport > MAX_VIEWPORT_DIMS. 8125bd8deadSopenharmony_ci Fix typo in definition of glScissorIndexedv. 8135bd8deadSopenharmony_ci Update description of ViewportArrayv to accept 8145bd8deadSopenharmony_ci an array of floats, rather than an array of 8155bd8deadSopenharmony_ci integers. 8165bd8deadSopenharmony_ci 7 04/29/2010 gsellers Updates and clarifications. 8175bd8deadSopenharmony_ci 6 04/15/2010 gsellers Add interaction with NV_depth_range. 8185bd8deadSopenharmony_ci Change viewport bounds to floating point values. 8195bd8deadSopenharmony_ci Add viewport subpixel precision query. 8205bd8deadSopenharmony_ci Chage function names to ...Indexed. 8215bd8deadSopenharmony_ci Add issues 6 and 7. 8225bd8deadSopenharmony_ci 5 01/07/2010 gsellers Change from AMD to EXT 8235bd8deadSopenharmony_ci Change function prototypes 8245bd8deadSopenharmony_ci Add glViewporti{_v}. 8255bd8deadSopenharmony_ci Add glScissorArray, glScissori{_v}. 8265bd8deadSopenharmony_ci Add glDepthRangeArrayv, glDepthRangei. 8275bd8deadSopenharmony_ci 4 07/16/2009 gsellers Document EXT_provoking_vertex interaction. 8285bd8deadSopenharmony_ci Change 'leading vertex' to 'provoking vertex'. 8295bd8deadSopenharmony_ci Clarify interaction with glViewport. 8305bd8deadSopenharmony_ci Add multiple scissor rectangles. 8315bd8deadSopenharmony_ci 3 07/14/2009 gsellers Updates from nickh and wwlk 8325bd8deadSopenharmony_ci 2 07/08/2009 gsellers Updates from myoung 8335bd8deadSopenharmony_ci 1 07/06/2009 gsellers Initial draft 834