15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    NV_viewport_array
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_NV_viewport_array
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Contributors to ARB_viewport_array
125bd8deadSopenharmony_ci    Mathias Heyer, NVIDIA
135bd8deadSopenharmony_ci    James Helferty, NVIDIA
145bd8deadSopenharmony_ci    Daniel Koch, NVIDIA
155bd8deadSopenharmony_ci
165bd8deadSopenharmony_ciContact
175bd8deadSopenharmony_ci
185bd8deadSopenharmony_ci    Mathias Heyer, NVIDIA (mheyer 'at' nvidia.com)
195bd8deadSopenharmony_ci
205bd8deadSopenharmony_ciNotice
215bd8deadSopenharmony_ci
225bd8deadSopenharmony_ci    Copyright (c) 2010-2014 The Khronos Group Inc. Copyright terms at
235bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ci    Portions Copyright (c) 2014 NVIDIA Corporation.
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ciStatus
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ci    Complete
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ciVersion
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ci    Last Modified Date:         10/24/2014
345bd8deadSopenharmony_ci    Author Revision:            5
355bd8deadSopenharmony_ci
365bd8deadSopenharmony_ciNumber
375bd8deadSopenharmony_ci
385bd8deadSopenharmony_ci    OpenGL ES Extension #202
395bd8deadSopenharmony_ci
405bd8deadSopenharmony_ciDependencies
415bd8deadSopenharmony_ci
425bd8deadSopenharmony_ci    This extension is written against the OpenGL ES 3.1 (March 14, 2014)
435bd8deadSopenharmony_ci    Specification.
445bd8deadSopenharmony_ci
455bd8deadSopenharmony_ci    This extension is written against the OpenGL ES Shading Language
465bd8deadSopenharmony_ci    Specification version 3.10 (March 14, 2014)
475bd8deadSopenharmony_ci
485bd8deadSopenharmony_ci    OpenGL ES 3.1 and the EXT_geometry_shader extension are required.
495bd8deadSopenharmony_ci
505bd8deadSopenharmony_ci    This extension interacts with EXT_draw_buffers_indexed.
515bd8deadSopenharmony_ci
525bd8deadSopenharmony_ciOverview
535bd8deadSopenharmony_ci
545bd8deadSopenharmony_ci    OpenGL ES is modeled on a pipeline of operations. The final stage in this
555bd8deadSopenharmony_ci    pipeline before rasterization is the viewport transformation. This stage
565bd8deadSopenharmony_ci    transforms vertices from view space into window coordinates and allows the
575bd8deadSopenharmony_ci    application to specify a rectangular region of screen space into which
585bd8deadSopenharmony_ci    OpenGL should draw primitives. Unextended OpenGL implementations provide a
595bd8deadSopenharmony_ci    single viewport per context. In order to draw primitives into multiple
605bd8deadSopenharmony_ci    viewports, the OpenGL viewport may be changed between several draw calls.
615bd8deadSopenharmony_ci    With the advent of Geometry Shaders, it has become possible for an
625bd8deadSopenharmony_ci    application to amplify geometry and produce multiple output primitives for
635bd8deadSopenharmony_ci    each primitive input to the Geometry Shader. It is possible to direct these
645bd8deadSopenharmony_ci    primitives to render into a selected render target. However, all render
655bd8deadSopenharmony_ci    targets share the same, global OpenGL viewport.
665bd8deadSopenharmony_ci
675bd8deadSopenharmony_ci    This extension enhances OpenGL by providing a mechanism to expose multiple
685bd8deadSopenharmony_ci    viewports. Each viewport is specified as a rectangle. The destination
695bd8deadSopenharmony_ci    viewport may be selected per-primitive by the geometry shader. This allows
705bd8deadSopenharmony_ci    the Geometry Shader to produce different versions of primitives destined
715bd8deadSopenharmony_ci    for separate viewport rectangles on the same surface. Additionally, when
725bd8deadSopenharmony_ci    combined with multiple framebuffer attachments, it allows a different
735bd8deadSopenharmony_ci    viewport rectangle to be selected for each. This extension also exposes a
745bd8deadSopenharmony_ci    separate scissor rectangle for each viewport. Finally, the viewport bounds
755bd8deadSopenharmony_ci    are now floating point quantities allowing fractional pixel offsets to be
765bd8deadSopenharmony_ci    applied during the viewport transform.
775bd8deadSopenharmony_ci
785bd8deadSopenharmony_ciNew Procedures and Functions
795bd8deadSopenharmony_ci
805bd8deadSopenharmony_ci    void ViewportArrayvNV(uint first, sizei count, const float * v);
815bd8deadSopenharmony_ci    void ViewportIndexedfNV(uint index, float x, float y, float w, float h);
825bd8deadSopenharmony_ci    void ViewportIndexedfvNV(uint index, const float * v);
835bd8deadSopenharmony_ci    void ScissorArrayvNV(uint first, sizei count, const int * v);
845bd8deadSopenharmony_ci    void ScissorIndexedNV(uint index, int left, int bottom, sizei width, sizei height);
855bd8deadSopenharmony_ci    void ScissorIndexedvNV(uint index, const int * v);
865bd8deadSopenharmony_ci    void DepthRangeArrayfvNV(uint first, sizei count, const float * v);
875bd8deadSopenharmony_ci    void DepthRangeIndexedfNV(uint index, float n, float f);
885bd8deadSopenharmony_ci    void GetFloati_vNV(enum target, uint index, float *data);
895bd8deadSopenharmony_ci
905bd8deadSopenharmony_ci    void EnableiNV(enum target, uint index);
915bd8deadSopenharmony_ci    void DisableiNV(enum target, uint index);
925bd8deadSopenharmony_ci    boolean IsEnablediNV(enum target, uint index);
935bd8deadSopenharmony_ci
945bd8deadSopenharmony_ciNew Tokens
955bd8deadSopenharmony_ci
965bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv,
975bd8deadSopenharmony_ci    and GetInteger64v:
985bd8deadSopenharmony_ci
995bd8deadSopenharmony_ci        MAX_VIEWPORTS_NV                                0x825B
1005bd8deadSopenharmony_ci        VIEWPORT_SUBPIXEL_BITS_NV                       0x825C
1015bd8deadSopenharmony_ci        VIEWPORT_BOUNDS_RANGE_NV                        0x825D
1025bd8deadSopenharmony_ci        VIEWPORT_INDEX_PROVOKING_VERTEX_NV              0x825F
1035bd8deadSopenharmony_ci
1045bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetIntegeri_v:
1055bd8deadSopenharmony_ci
1065bd8deadSopenharmony_ci        SCISSOR_BOX                                     0x0C10
1075bd8deadSopenharmony_ci
1085bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetFloati_vNV:
1095bd8deadSopenharmony_ci
1105bd8deadSopenharmony_ci        VIEWPORT                                        0x0BA2
1115bd8deadSopenharmony_ci        DEPTH_RANGE                                     0x0B70
1125bd8deadSopenharmony_ci
1135bd8deadSopenharmony_ci    Accepted by the <pname> parameter of EnableiNV, DisableiNV,
1145bd8deadSopenharmony_ci    and IsEnablediNV:
1155bd8deadSopenharmony_ci
1165bd8deadSopenharmony_ci        SCISSOR_TEST                                    0x0C11
1175bd8deadSopenharmony_ci
1185bd8deadSopenharmony_ciAdditions to Chapter 11 of the OpenGL ES 3.1 Specification
1195bd8deadSopenharmony_ci(Programmable Vertex Processing)
1205bd8deadSopenharmony_ci
1215bd8deadSopenharmony_ci    Modify section Section 11.1gs.4.5 Layer Selection
1225bd8deadSopenharmony_ci
1235bd8deadSopenharmony_ci    Rename the the "Layer Selection" subsection to "Layer and Viewport
1245bd8deadSopenharmony_ci    Selection".
1255bd8deadSopenharmony_ci
1265bd8deadSopenharmony_ci    After the first paragraph, insert:
1275bd8deadSopenharmony_ci
1285bd8deadSopenharmony_ci    Geometry shaders may also select the destination viewport for each
1295bd8deadSopenharmony_ci    output primitive. The destination viewport for a primitive may be
1305bd8deadSopenharmony_ci    selected in the geometry shader by writing to the built-in output
1315bd8deadSopenharmony_ci    variable gl_ViewportIndex. This functionality allows a geometry
1325bd8deadSopenharmony_ci    shader to direct its output to a different viewport for each
1335bd8deadSopenharmony_ci    primitive, or to draw multiple versions of a primitive into several
1345bd8deadSopenharmony_ci    different viewports.
1355bd8deadSopenharmony_ci
1365bd8deadSopenharmony_ci    Replace the first two sentences of the second paragraph with:
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci    The specific vertex of a primitive that is used to select the
1395bd8deadSopenharmony_ci    rendering layer or viewport index is implementation-dependent and
1405bd8deadSopenharmony_ci    thus portable applications will assign the same layer and viewport
1415bd8deadSopenharmony_ci    index for all vertices in a primitive. The vertex conventions
1425bd8deadSopenharmony_ci    followed for gl_Layer and gl_ViewportIndex may be determined by
1435bd8deadSopenharmony_ci    calling GetIntegerv with the symbolic constants
1445bd8deadSopenharmony_ci    LAYER_PROVOKING_VERTEX_EXT and VIEWPORT_INDEX_PROVOKING_VERTEX_NV,
1455bd8deadSopenharmony_ci    respectively.
1465bd8deadSopenharmony_ci
1475bd8deadSopenharmony_ci    Modify section 12.5.1 "Controlling the Viewport", page 284.
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ci    Change the first paragraph of section 12.5.1 to read
1505bd8deadSopenharmony_ci
1515bd8deadSopenharmony_ci    The viewport transformation is determined by the selected viewport's
1525bd8deadSopenharmony_ci    width and height in pixels, p_x and p_y, respectively, and its
1535bd8deadSopenharmony_ci    center (o_x,o_y) (also in pixels) ...
1545bd8deadSopenharmony_ci
1555bd8deadSopenharmony_ci        { leave equations intact }
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ci    Multiple viewports are available and are numbered zero through the
1585bd8deadSopenharmony_ci    value of MAX_VIEWPORTS_NV minus one. If a geometry shader is active
1595bd8deadSopenharmony_ci    and writes to gl_ViewportIndex, the viewport transformation uses the
1605bd8deadSopenharmony_ci    viewport corresponding to the value assigned to gl_ViewportIndex
1615bd8deadSopenharmony_ci    taken from an implementation-dependent primitive vertex. If the
1625bd8deadSopenharmony_ci    value of the viewport index is outside the range zero to the value
1635bd8deadSopenharmony_ci    of MAX_VIEWPORTS_NV minus one, the results of the viewport
1645bd8deadSopenharmony_ci    transformation are undefined. If no geometry shader is active, or if
1655bd8deadSopenharmony_ci    the active geometry shader does not write to gl_ViewportIndex, the
1665bd8deadSopenharmony_ci    viewport numbered zero is used by the viewport transformation.
1675bd8deadSopenharmony_ci
1685bd8deadSopenharmony_ci    A single vertex may be used in more than one individual primitive, in
1695bd8deadSopenharmony_ci    primitives such as TRIANGLE_STRIP.  In this case, the viewport
1705bd8deadSopenharmony_ci    transformation is applied separately for each primitive.
1715bd8deadSopenharmony_ci
1725bd8deadSopenharmony_ci    The factor and offset applied to Z_d for each viewport encoded by n
1735bd8deadSopenharmony_ci    and f are set using
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ci        void DepthRangeArrayfvNV(uint first, sizei count, const float * v);
1765bd8deadSopenharmony_ci        void DepthRangeIndexedfNV(uint index, float n, float f);
1775bd8deadSopenharmony_ci        void DepthRangef(float n, float f);
1785bd8deadSopenharmony_ci
1795bd8deadSopenharmony_ci    DepthRangeArrayfvNV is used to specify the depth range for multiple
1805bd8deadSopenharmony_ci    viewports simultaneously. <first> specifies the index of the first
1815bd8deadSopenharmony_ci    viewport to modify and <count> specifies the number of viewports. If
1825bd8deadSopenharmony_ci    (<first> + <count>) is greater than the value of MAX_VIEWPORTS_NV then
1835bd8deadSopenharmony_ci    an INVALID_VALUE error will be generated. Viewports whose indices
1845bd8deadSopenharmony_ci    lie outside the range [<first>, <first> + <count>) are not modified.
1855bd8deadSopenharmony_ci    The <v> parameter contains the address of an array of float types
1865bd8deadSopenharmony_ci    specifying near (n) and far (f) for each viewport in that order.
1875bd8deadSopenharmony_ci    (n) and (f) of each viewport will be clamped to [0.0, 1.0].
1885bd8deadSopenharmony_ci
1895bd8deadSopenharmony_ci    DepthRangeIndexedfNV specifies the depth range for a single viewport
1905bd8deadSopenharmony_ci    and is equivalent (assuming no errors are generated) to:
1915bd8deadSopenharmony_ci
1925bd8deadSopenharmony_ci        float v[] = { n, f };
1935bd8deadSopenharmony_ci        DepthRangeArrayfvNV(index, 1, v);
1945bd8deadSopenharmony_ci
1955bd8deadSopenharmony_ci    DepthRangef sets the depth range for all viewports to the same values
1965bd8deadSopenharmony_ci    and is equivalent (assuming no errors are generated) to:
1975bd8deadSopenharmony_ci
1985bd8deadSopenharmony_ci        for (uint i = 0; i < MAX_VIEWPORTS_NV; i++)
1995bd8deadSopenharmony_ci            DepthRangeIndexedfNV(i, n, f);
2005bd8deadSopenharmony_ci
2015bd8deadSopenharmony_ci    Z_w is represented as either ...
2025bd8deadSopenharmony_ci
2035bd8deadSopenharmony_ci    Replace the end of section 12.5.1, starting from "Viewport transformation
2045bd8deadSopenharmony_ci    parameters are specified using..."
2055bd8deadSopenharmony_ci
2065bd8deadSopenharmony_ci    Viewport transformation parameters are specified using
2075bd8deadSopenharmony_ci
2085bd8deadSopenharmony_ci        void ViewportArrayvNV(uint first, sizei count, const float * v);
2095bd8deadSopenharmony_ci        void Viewport(int x, int y, sizei w, sizei h);
2105bd8deadSopenharmony_ci        void ViewportIndexedfNV(uint index, float x, float y, float w, float h);
2115bd8deadSopenharmony_ci        void ViewportIndexedfvNV(uint index, const float * v);
2125bd8deadSopenharmony_ci
2135bd8deadSopenharmony_ci    ViewportArrayvNV specifies parameters for multiple viewports
2145bd8deadSopenharmony_ci    simultaneously. <first> specifies the index of the first viewport to
2155bd8deadSopenharmony_ci    modify and <count> specifies the number of viewports. If (<first> +
2165bd8deadSopenharmony_ci    <count>) is greater than the value of MAX_VIEWPORTS_NV then an
2175bd8deadSopenharmony_ci    INVALID_VALUE error will be generated. Viewports whose indices lie
2185bd8deadSopenharmony_ci    outside the range [<first>, <first> + <count>) are not modified.
2195bd8deadSopenharmony_ci    <v> contains the address of an array of floating point values
2205bd8deadSopenharmony_ci    specifying the left (x), bottom (y), width (w) and height (h) of
2215bd8deadSopenharmony_ci    each viewport, in that order. <x> and <y> give the location of the
2225bd8deadSopenharmony_ci    viewport's lower left corner and <w> and <h> give the viewport's
2235bd8deadSopenharmony_ci    width and height, respectively.
2245bd8deadSopenharmony_ci
2255bd8deadSopenharmony_ci    ViewportIndexedfNV and ViewportIndexedfvNV specify parameters for a
2265bd8deadSopenharmony_ci    single viewport and are equivalent (assuming no errors are
2275bd8deadSopenharmony_ci    generated) to:
2285bd8deadSopenharmony_ci
2295bd8deadSopenharmony_ci        float v[4] = { x, y, w, h };
2305bd8deadSopenharmony_ci        ViewportArrayvNV(index, 1, v);
2315bd8deadSopenharmony_ci
2325bd8deadSopenharmony_ci    and
2335bd8deadSopenharmony_ci
2345bd8deadSopenharmony_ci        ViewportArrayvNV(index, 1, v);
2355bd8deadSopenharmony_ci
2365bd8deadSopenharmony_ci    respectively.
2375bd8deadSopenharmony_ci
2385bd8deadSopenharmony_ci    Viewport sets the parameters for all viewports to the same values
2395bd8deadSopenharmony_ci    and is equivalent (assuming no errors are generated) to:
2405bd8deadSopenharmony_ci
2415bd8deadSopenharmony_ci        for (uint i = 0; i < MAX_VIEWPORTS_NV; i++)
2425bd8deadSopenharmony_ci            ViewportIndexedfNV(i, (float)x, (float)y, (float)w, (float)h);
2435bd8deadSopenharmony_ci
2445bd8deadSopenharmony_ci    The viewport parameters shown in the above equations are found from these
2455bd8deadSopenharmony_ci    values as
2465bd8deadSopenharmony_ci
2475bd8deadSopenharmony_ci        o_x = x + w /2,
2485bd8deadSopenharmony_ci        o_y = y + h / 2,
2495bd8deadSopenharmony_ci        p_x = w,
2505bd8deadSopenharmony_ci        p_y = h.
2515bd8deadSopenharmony_ci
2525bd8deadSopenharmony_ci    The location of the viewport's bottom-left corner, given by (x,y), are
2535bd8deadSopenharmony_ci    clamped to be within the implementation-dependent viewport bounds range.
2545bd8deadSopenharmony_ci    The viewport bounds range [min, max] tuple may be determined by
2555bd8deadSopenharmony_ci    calling GetFloatv with the symbolic constant VIEWPORT_BOUNDS_RANGE_NV
2565bd8deadSopenharmony_ci    (see chapter 20).
2575bd8deadSopenharmony_ci
2585bd8deadSopenharmony_ci    Viewport width and height are clamped to implementation-dependent maximums
2595bd8deadSopenharmony_ci    when specified. The maximum width and height may be found by calling
2605bd8deadSopenharmony_ci    GetFloatv with the symbolic constant MAX_VIEWPORT_DIMS. The maximum
2615bd8deadSopenharmony_ci    viewport dimensions must be greater than or equal to the larger of
2625bd8deadSopenharmony_ci    the visible dimensions of the display being rendered to (if a
2635bd8deadSopenharmony_ci    display exists), and the largest renderbuffer image which can be
2645bd8deadSopenharmony_ci    successfully created and attached to a framebuffer object (see
2655bd8deadSopenharmony_ci    chapter 9). INVALID_VALUE is generated if either w or h is negative.
2665bd8deadSopenharmony_ci
2675bd8deadSopenharmony_ci    The state required to implement the viewport transformations is four
2685bd8deadSopenharmony_ci    floating-point values and two clamped floating-point values for each
2695bd8deadSopenharmony_ci    viewport. In the initial state, w and h for each viewport are set to
2705bd8deadSopenharmony_ci    the width and height, respectively, of the window into which the GL
2715bd8deadSopenharmony_ci    is to do its rendering. If the default framebuffer is bound but no
2725bd8deadSopenharmony_ci    default framebuffer is associated with the GL context (see chapter
2735bd8deadSopenharmony_ci    9), then w and h are initially set to zero. o_x and o_y are set to
2745bd8deadSopenharmony_ci    w/2 and h/2, respectively. n and f are set to 0.0 and 1.0,
2755bd8deadSopenharmony_ci    respectively.
2765bd8deadSopenharmony_ci
2775bd8deadSopenharmony_ci    The precision with which the GL interprets the floating point viewport
2785bd8deadSopenharmony_ci    bounds is implementation-dependent and may be determined by querying the
2795bd8deadSopenharmony_ci    implementation-defined constant VIEWPORT_SUBPIXEL_BITS_NV.
2805bd8deadSopenharmony_ci
2815bd8deadSopenharmony_ciAdditions to Chapter 15 of the OpenGL ES 3.1 Specification (Writing
2825bd8deadSopenharmony_ciFragments and Samples to the Framebuffer)
2835bd8deadSopenharmony_ci
2845bd8deadSopenharmony_ci    Replace section 15.1.2 "Scissor Test", page 309.
2855bd8deadSopenharmony_ci
2865bd8deadSopenharmony_ci    The scissor test determines if (xw, yw) lies within the scissor rectangle
2875bd8deadSopenharmony_ci    defined by four values for each viewport. These values are set with
2885bd8deadSopenharmony_ci
2895bd8deadSopenharmony_ci        void ScissorArrayvNV(uint first, sizei count, const int * v);
2905bd8deadSopenharmony_ci        void ScissorIndexedNV(uint index, int left, int bottom, sizei width, sizei height);
2915bd8deadSopenharmony_ci        void ScissorIndexedvNV(uint index, int * v);
2925bd8deadSopenharmony_ci        void Scissor(int left, int bottom, sizei width, sizei height);
2935bd8deadSopenharmony_ci
2945bd8deadSopenharmony_ci    ScissorArrayvNV defines a set of scissor rectangles that are each
2955bd8deadSopenharmony_ci    applied to the corresponding viewport (see section 12.5.1
2965bd8deadSopenharmony_ci    "Controlling the Viewport"). <first> specifies the index of the
2975bd8deadSopenharmony_ci    first scissor rectangle to modify, and <count> specifies the number
2985bd8deadSopenharmony_ci    of scissor rectangles. If (<first> + <count>) is greater than the
2995bd8deadSopenharmony_ci    value of MAX_VIEWPORTS_NV, then an INVALID_VALUE error is generated.
3005bd8deadSopenharmony_ci    <v> contains the address of an array of integers containing the
3015bd8deadSopenharmony_ci    left, bottom, width and height of the scissor rectangles, in that
3025bd8deadSopenharmony_ci    order.
3035bd8deadSopenharmony_ci
3045bd8deadSopenharmony_ci    If left <= x_w < left + width and bottom <= y_w < bottom + height
3055bd8deadSopenharmony_ci    for the selected scissor rectangle, then the scissor test passes.
3065bd8deadSopenharmony_ci    Otherwise, the test fails and the fragment is discarded. For points,
3075bd8deadSopenharmony_ci    lines, and polygons, the scissor rectangle for a primitive is
3085bd8deadSopenharmony_ci    selected in the same manner as the viewport (see section 12.5.1).
3095bd8deadSopenharmony_ci
3105bd8deadSopenharmony_ci    The scissor test is enabled or disabled for all viewports using
3115bd8deadSopenharmony_ci    Enable or Disable with the symbolic constant SCISSOR_TEST. The test
3125bd8deadSopenharmony_ci    is enabled or disabled for a specific viewport using EnableiNV or
3135bd8deadSopenharmony_ci    DisableiNV with the constant SCISSOR_TEST and the index of the
3145bd8deadSopenharmony_ci    selected viewport. When disabled, it is as if the scissor test
3155bd8deadSopenharmony_ci    always passes. The value of the scissor test enable for viewport <i>
3165bd8deadSopenharmony_ci    can be queried by calling IsEnablediNV with <target> SCISSOR_TEST and
3175bd8deadSopenharmony_ci    <index> <i>. The value of the scissor test enable for viewport zero
3185bd8deadSopenharmony_ci    may also be queried by calling IsEnabled with the same symbolic
3195bd8deadSopenharmony_ci    constant, but no <index> parameter. If either width or height is
3205bd8deadSopenharmony_ci    less than zero for any scissor rectangle, then an INVALID_VALUE
3215bd8deadSopenharmony_ci    error is generated. If the viewport index specified to EnableiNV,
3225bd8deadSopenharmony_ci    DisableiNV or IsEnablediNV is greater or equal to the value of
3235bd8deadSopenharmony_ci    MAX_VIEWPORTS_NV, then an INVALID_VALUE error is generated.
3245bd8deadSopenharmony_ci
3255bd8deadSopenharmony_ci    The state required consists of four integer values per viewport, and
3265bd8deadSopenharmony_ci    a bit indicating whether the test is enabled or disabled for each
3275bd8deadSopenharmony_ci    viewport. In the initial state, left = bottom = 0, and width and
3285bd8deadSopenharmony_ci    height are determined by the size of the window into which the GL is
3295bd8deadSopenharmony_ci    to do its rendering for all viewports. If the default framebuffer is
3305bd8deadSopenharmony_ci    bound but no default framebuffer is associated with the GL context
3315bd8deadSopenharmony_ci    (see chapter 9), then with and height are initially set to zero.
3325bd8deadSopenharmony_ci    Initially, the scissor test is disabled for all viewports.
3335bd8deadSopenharmony_ci
3345bd8deadSopenharmony_ci    ScissorIndexedNV and ScissorIndexedvNV specify the scissor rectangle for
3355bd8deadSopenharmony_ci    a single viewport and are equivalent (assuming no errors are
3365bd8deadSopenharmony_ci    generated) to:
3375bd8deadSopenharmony_ci
3385bd8deadSopenharmony_ci        int v[] = { left, bottom, width, height };
3395bd8deadSopenharmony_ci        ScissorArrayvNV(index, 1, v);
3405bd8deadSopenharmony_ci
3415bd8deadSopenharmony_ci    and
3425bd8deadSopenharmony_ci
3435bd8deadSopenharmony_ci        ScissorArrayvNV(index, 1, v);
3445bd8deadSopenharmony_ci
3455bd8deadSopenharmony_ci    respectively.
3465bd8deadSopenharmony_ci
3475bd8deadSopenharmony_ci    Scissor sets the scissor rectangle for all viewports to the same
3485bd8deadSopenharmony_ci    values and is equivalent (assuming no errors are generated) to:
3495bd8deadSopenharmony_ci
3505bd8deadSopenharmony_ci        for (uint i = 0; i < MAX_VIEWPORTS_NV; i++) {
3515bd8deadSopenharmony_ci            ScissorIndexedNV(i, left, bottom, width, height);
3525bd8deadSopenharmony_ci        }
3535bd8deadSopenharmony_ci
3545bd8deadSopenharmony_ci    Calling Enable or Disable with the symbolic constant SCISSOR_TEST is
3555bd8deadSopenharmony_ci    equivalent, assuming no errors, to:
3565bd8deadSopenharmony_ci
3575bd8deadSopenharmony_ci    for (uint i = 0; i < MAX_VIEWPORTS_NV; i++) {
3585bd8deadSopenharmony_ci        EnableiNV(SCISSOR_TEST, i);
3595bd8deadSopenharmony_ci        /* or */
3605bd8deadSopenharmony_ci        DisableiNV(SCISSOR_TEST, i);
3615bd8deadSopenharmony_ci    }
3625bd8deadSopenharmony_ci
3635bd8deadSopenharmony_ciAdditions to Chapter 19 of the OpenGL ES 3.1 Specification (Context State
3645bd8deadSopenharmony_ciQueries)
3655bd8deadSopenharmony_ci
3665bd8deadSopenharmony_ci    Modifications to Section 19.1 Simple Queries
3675bd8deadSopenharmony_ci
3685bd8deadSopenharmony_ci        Add to the list of indexed query functions:
3695bd8deadSopenharmony_ci
3705bd8deadSopenharmony_ci        void GetFloati_vNV(enum target, uint index, float *data);
3715bd8deadSopenharmony_ci
3725bd8deadSopenharmony_ciAdditions to the OpenGL ES Shading Language Version 3.10 Specification
3735bd8deadSopenharmony_ci
3745bd8deadSopenharmony_ci    Add a new Section 3.4.x, GL_NV_viewport_array Extension (p. 13)
3755bd8deadSopenharmony_ci
3765bd8deadSopenharmony_ci    3.4.x GL_NV_viewport_array Extension
3775bd8deadSopenharmony_ci
3785bd8deadSopenharmony_ci    To use the GL_NV_viewport_array extension in a shader it must be
3795bd8deadSopenharmony_ci    enabled using the #extension directive.
3805bd8deadSopenharmony_ci
3815bd8deadSopenharmony_ci    The shading language preprocessor #define GL_NV_viewport_array will
3825bd8deadSopenharmony_ci    be defined to 1 if the GL_NV_viewport_array extension is supported.
3835bd8deadSopenharmony_ci
3845bd8deadSopenharmony_ci    Modify Section 7.1.1gs, "Geometry Shader Special Variables"
3855bd8deadSopenharmony_ci
3865bd8deadSopenharmony_ci    Add to the list of geometry shader built-in variables:
3875bd8deadSopenharmony_ci
3885bd8deadSopenharmony_ci        out highp int gl_ViewportIndex;    // may be written to
3895bd8deadSopenharmony_ci
3905bd8deadSopenharmony_ci
3915bd8deadSopenharmony_ci    Additions to Section 7.1.1gs.2, "Geometry Shader Output Variables"
3925bd8deadSopenharmony_ci
3935bd8deadSopenharmony_ci    Add a paragraph after the paragraph describing gl_Layer, starting
3945bd8deadSopenharmony_ci    "gl_Layer is used to select a specific layer (or face and layer of a
3955bd8deadSopenharmony_ci    cube map) of a multi-layer framebuffer attachment.":
3965bd8deadSopenharmony_ci
3975bd8deadSopenharmony_ci    The built-in variable gl_ViewportIndex is available as an output variable
3985bd8deadSopenharmony_ci    in the geometry shader and an input variable in the fragment shader. In the
3995bd8deadSopenharmony_ci    geometry shader it provides the index of the viewport to which the next
4005bd8deadSopenharmony_ci    primitive emitted from the geometry shader should be drawn. Primitives
4015bd8deadSopenharmony_ci    generated by the geometry shader will undergo viewport transformation and
4025bd8deadSopenharmony_ci    scissor testing using the viewport transformation and scissor rectangle
4035bd8deadSopenharmony_ci    selected by the value of gl_ViewportIndex. The viewport index used will
4045bd8deadSopenharmony_ci    come from one of the vertices in the primitive being shaded. Which vertex
4055bd8deadSopenharmony_ci    the viewport index comes from is implementation-dependent, so it is best to
4065bd8deadSopenharmony_ci    use the same viewport index for all vertices of the primitive. If a
4075bd8deadSopenharmony_ci    geometry shader does not assign a value to gl_ViewportIndex, viewport
4085bd8deadSopenharmony_ci    transform and scissor rectangle zero will be used. If a geometry shader
4095bd8deadSopenharmony_ci    assigns a value to gl_ViewportIndex and there is a path through the shader
4105bd8deadSopenharmony_ci    that does not set gl_ViewportIndex, then the value of gl_ViewportIndex is
4115bd8deadSopenharmony_ci    undefined for executions of the shader that take that path. See section
4125bd8deadSopenharmony_ci    11.1gs.4 "Geometry Shader Outputs" of the OpenGL ES Specification for more
4135bd8deadSopenharmony_ci    information.
4145bd8deadSopenharmony_ci
4155bd8deadSopenharmony_ci    Modify section 7.1.2 "Fragment Shader Special Variables", as modified by
4165bd8deadSopenharmony_ci    EXT_geometry_shader:
4175bd8deadSopenharmony_ci
4185bd8deadSopenharmony_ci    Add to the list of built-in variables:
4195bd8deadSopenharmony_ci
4205bd8deadSopenharmony_ci        in highp int gl_ViewportIndex;
4215bd8deadSopenharmony_ci
4225bd8deadSopenharmony_ci    Add description of the variable:
4235bd8deadSopenharmony_ci
4245bd8deadSopenharmony_ci    The input variable gl_ViewportIndex will have the same value that was
4255bd8deadSopenharmony_ci    written to the output variable gl_ViewportIndex in the geometry stage. If
4265bd8deadSopenharmony_ci    the geometry stage does not dynamically assign to gl_ViewportIndex, the
4275bd8deadSopenharmony_ci    value of gl_ViewportIndex in the fragment shader will be undefined. If the
4285bd8deadSopenharmony_ci    geometry stage makes no static assignment to gl_ViewportIndex, the fragment
4295bd8deadSopenharmony_ci    stage will read zero. Otherwise, the fragment stage will read the same
4305bd8deadSopenharmony_ci    value written by the geometry stage, even if that value is out of range. If
4315bd8deadSopenharmony_ci    a fragment shader contains a static access to gl_ViewportIndex, it will
4325bd8deadSopenharmony_ci    count against the implementation defined limit for the maximum number of
4335bd8deadSopenharmony_ci    inputs to the fragment stage.
4345bd8deadSopenharmony_ci
4355bd8deadSopenharmony_ci    Add to Section 7.2 "Built-In Constants", as modified by
4365bd8deadSopenharmony_ci    EXT_geometry_shader, to the list of built-in constants matching the
4375bd8deadSopenharmony_ci    corresponding API implementation-dependent limits:
4385bd8deadSopenharmony_ci
4395bd8deadSopenharmony_ci        const highp int gl_MaxViewports = 16;
4405bd8deadSopenharmony_ci
4415bd8deadSopenharmony_ciErrors
4425bd8deadSopenharmony_ci
4435bd8deadSopenharmony_ci    INVALID_VALUE is generated by ViewportArrayvNV if <first> + <count> is
4445bd8deadSopenharmony_ci    greater than or equal to the value of MAX_VIEWPORTS_NV, or if any
4455bd8deadSopenharmony_ci    viewport's width or height is less than 0.
4465bd8deadSopenharmony_ci
4475bd8deadSopenharmony_ci    INVALID_VALUE is generated by ScissorArrayvNV if <first> + <count> is
4485bd8deadSopenharmony_ci    greater than or equal to the value of MAX_VIEWPORTS_NV, or if any
4495bd8deadSopenharmony_ci    scissor rectangle's width or height is less than zero.
4505bd8deadSopenharmony_ci
4515bd8deadSopenharmony_ci    INVALID_VALUE is generated by DepthRangeArrayfvNV if <first> + <count> is
4525bd8deadSopenharmony_ci    greater than or equal to the vaue of MAX_VIEWPORTS_NV.
4535bd8deadSopenharmony_ci
4545bd8deadSopenharmony_ci    INVALID_VALUE is generated by EnableiNV, DisableiNV and IsEnablediNV if
4555bd8deadSopenharmony_ci    <index> is greater than or equal to the value of MAX_VIEWPORTS_NV.
4565bd8deadSopenharmony_ci
4575bd8deadSopenharmony_ciNew State
4585bd8deadSopenharmony_ci
4595bd8deadSopenharmony_ci    Table 20.5 (p. 356)
4605bd8deadSopenharmony_ci
4615bd8deadSopenharmony_ci    Get Value                 Type             Get Command       Initial Value   Description                 Sec
4625bd8deadSopenharmony_ci    ------------------------  ---------------- ------------      -------------   --------------------------  -----
4635bd8deadSopenharmony_ci    VIEWPORT                  16* x 4 x R      GetFloati_vNV       See 2.11.1      Viewport origin & extent  12.5.1
4645bd8deadSopenharmony_ci    DEPTH_RANGE               16* x 2 x R[0,1] GetFloati_vNV       See 2.16.1      Depth range near & far    12.5.1
4655bd8deadSopenharmony_ci
4665bd8deadSopenharmony_ciNOTE: The changes are that VIEWPORT and DEPTH_RANGE are extended to
4675bd8deadSopenharmony_ciaccommodate 16* copies and now consist of floating-point and
4685bd8deadSopenharmony_cidouble-precision values, respectively.
4695bd8deadSopenharmony_ci
4705bd8deadSopenharmony_ci    Table 20.12 (p. 363)
4715bd8deadSopenharmony_ci
4725bd8deadSopenharmony_ci    Get Value                 Type        Get Command           Initial Value   Description               Sec
4735bd8deadSopenharmony_ci    ------------------------  ----------  -------------         -------------   -------------------       ------
4745bd8deadSopenharmony_ci    SCISSOR_TEST              16* x B     IsEnablediNV          FALSE           Scissoring enabled        15.1.2
4755bd8deadSopenharmony_ci    SCISSOR_BOX               16* x 4 x Z GetIntegeri_v         See 4.1.2       Scissor box               15.1.2
4765bd8deadSopenharmony_ci
4775bd8deadSopenharmony_ciNOTE: The only change is that SCISSOR_TEST and SCISSOR_BOX are extended
4785bd8deadSopenharmony_cito accommodate 16* copies.
4795bd8deadSopenharmony_ci
4805bd8deadSopenharmony_ciNew Implementation Dependent State
4815bd8deadSopenharmony_ci
4825bd8deadSopenharmony_ci    Get Value                          Type   Get Command     Minimum Value   Description                     Sec.
4835bd8deadSopenharmony_ci    ---------                          ----   -----------     -------------   -------------------             -----
4845bd8deadSopenharmony_ci    MAX_VIEWPORT_DIMS    (NOTE 1)      2 x Z+ GetFloatv       See 2.16.1      Maximum viewport dimensions     12.5.1
4855bd8deadSopenharmony_ci    MAX_VIEWPORTS_NV                   Z+     GetIntegerv     16              Maximum number of               12.5.1
4865bd8deadSopenharmony_ci                                                                              active viewports
4875bd8deadSopenharmony_ci    VIEWPORT_SUBPIXEL_BITS_NV          Z+     GetIntegerv     0               Number of bits of sub-pixel     12.5.1
4885bd8deadSopenharmony_ci                                                                              precision for viewport bounds
4895bd8deadSopenharmony_ci    VIEWPORT_BOUNDS_RANGE_NV           2 x R  GetFloatv       (NOTE 2)        Viewport bounds range [min,max] 12.5.1
4905bd8deadSopenharmony_ci    LAYER_PROVOKING_VERTEX_NV          Z_4    GetIntegerv     -- (NOTE 3)     vertex convention followed by   12.5.1
4915bd8deadSopenharmony_ci                                                                              the gl_Layer GLSL variable
4925bd8deadSopenharmony_ci    VIEWPORT_INDEX_PROVOKING_VERTEX_NV Z_4    GetIntegerv     -- (NOTE 3)     vertex convention followed by   12.5.1
4935bd8deadSopenharmony_ci                                                                              the gl_ViewportIndex GLSL
4945bd8deadSopenharmony_ci                                                                              variable
4955bd8deadSopenharmony_ci
4965bd8deadSopenharmony_ciNOTE 1: The recommended get command is changed from GetIntegerv to GetFloatv.
4975bd8deadSopenharmony_ciNOTE 2: range for viewport bounds:
4985bd8deadSopenharmony_ci  * On ES3.1-capable hardware the VIEWPORT_BOUNDS_RANGE_NV should be at least
4995bd8deadSopenharmony_ci    [-32768, 32767].
5005bd8deadSopenharmony_ciNOTE 3: Valid values are: FIRST_VERTEX_CONVENTION_NV,
5015bd8deadSopenharmony_ciLAST_VERTEX_CONVENTION_NV, UNDEFINED_VERTEX_NV.
5025bd8deadSopenharmony_ci
5035bd8deadSopenharmony_ci
5045bd8deadSopenharmony_ciInteractions with EXT_draw_buffers_indexed
5055bd8deadSopenharmony_ci
5065bd8deadSopenharmony_ci    If EXT_draw_buffers_indexed is supported, EnableiNV, DisableiNV and
5075bd8deadSopenharmony_ci    IsEnablediNV alias EnableiEXT, DisableiEXT and IsEnablediEXT, respectively.
5085bd8deadSopenharmony_ci
5095bd8deadSopenharmony_ci
5105bd8deadSopenharmony_ciIssues
5115bd8deadSopenharmony_ci
5125bd8deadSopenharmony_ci    See issues section in ARB_viewport_array.
5135bd8deadSopenharmony_ci
5145bd8deadSopenharmony_ci    #1 What are the differences from ARB_viewport_array?
5155bd8deadSopenharmony_ci
5165bd8deadSopenharmony_ci    - OpenGL ES does not support the double datatype. The changed interfaces of
5175bd8deadSopenharmony_ci    glDepthRangeArrayfvNV and DepthRangeIndexedfNV reflect that. 'float' is
5185bd8deadSopenharmony_ci    being used instead of 'clampf', with additional constraints in the text
5195bd8deadSopenharmony_ci    that the values will get clamped.
5205bd8deadSopenharmony_ci    - The ability to access gl_ViewportIndex from the fragment shader was added
5215bd8deadSopenharmony_ci    from ARB_fragment_layer_viewport.
5225bd8deadSopenharmony_ci
5235bd8deadSopenharmony_ci
5245bd8deadSopenharmony_ciRevision History
5255bd8deadSopenharmony_ci
5265bd8deadSopenharmony_ci    Rev.    Date      Author    Changes
5275bd8deadSopenharmony_ci    ----  --------    --------  -----------------------------------------
5285bd8deadSopenharmony_ci     1    06/18/2014  mheyer    Based on ARB_viewport_array, stripped for ES3.1
5295bd8deadSopenharmony_ci                                - replaced clampd with float for glDepthRangef
5305bd8deadSopenharmony_ci                                - instead of EnableIndexed and DisableIndexed, use
5315bd8deadSopenharmony_ci                                  Enablei and Disablei
5325bd8deadSopenharmony_ci                                - PROVOKING_VERTEX_NV removed
5335bd8deadSopenharmony_ci     2    07/24/2014  mheyer    Minor edits.
5345bd8deadSopenharmony_ci     3    08/10/2014  mheyer    Edit for consistency.
5355bd8deadSopenharmony_ci     4    09/04/2014  jhelferty Add viewport part of ARB_fragment_layer_viewport
5365bd8deadSopenharmony_ci                                as was done with layer in EXT_geometry_shader
5375bd8deadSopenharmony_ci     5    10/24/2014  dkoch     Cleanup for publishing.
538