15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    OES_viewport_array
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_OES_viewport_array
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Contributors to NV_viewport_array
125bd8deadSopenharmony_ci    Daniel Koch, NVIDIA
135bd8deadSopenharmony_ci    Jeff Leger, Qualcomm
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ciContact
165bd8deadSopenharmony_ci
175bd8deadSopenharmony_ci    Tobias Hector, Imagination Technologies (tobias.hector 'at' imgtec.com)
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ciNotice
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ci    Copyright (c) 2010-2016 The Khronos Group Inc. Copyright terms at
225bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
235bd8deadSopenharmony_ci
245bd8deadSopenharmony_ciSpecification Update Policy
255bd8deadSopenharmony_ci
265bd8deadSopenharmony_ci    Khronos-approved extension specifications are updated in response to
275bd8deadSopenharmony_ci    issues and bugs prioritized by the Khronos OpenGL ES Working Group. For
285bd8deadSopenharmony_ci    extensions which have been promoted to a core Specification, fixes will
295bd8deadSopenharmony_ci    first appear in the latest version of that core Specification, and will
305bd8deadSopenharmony_ci    eventually be backported to the extension document. This policy is
315bd8deadSopenharmony_ci    described in more detail at
325bd8deadSopenharmony_ci        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
335bd8deadSopenharmony_ci
345bd8deadSopenharmony_ciStatus
355bd8deadSopenharmony_ci
365bd8deadSopenharmony_ci    Approved by the OpenGL ES Working Group on April 20, 2016
375bd8deadSopenharmony_ci    Ratified by the Khronos Board of Promoters on July 22, 2016
385bd8deadSopenharmony_ci
395bd8deadSopenharmony_ciVersion
405bd8deadSopenharmony_ci
415bd8deadSopenharmony_ci    Last Modified Date:         2016/04/19
425bd8deadSopenharmony_ci    Author Revision:            5
435bd8deadSopenharmony_ci
445bd8deadSopenharmony_ciNumber
455bd8deadSopenharmony_ci
465bd8deadSopenharmony_ci    Open GL ES Extension #267
475bd8deadSopenharmony_ci
485bd8deadSopenharmony_ciDependencies
495bd8deadSopenharmony_ci
505bd8deadSopenharmony_ci    OpenGL ES 3.2, EXT_geometry_shader or OES_geometry_shader is required.
515bd8deadSopenharmony_ci
525bd8deadSopenharmony_ci    This extension is written against the OpenGL ES 3.2 Specification (August
535bd8deadSopenharmony_ci    10, 2015)
545bd8deadSopenharmony_ci
555bd8deadSopenharmony_ci    This extension is written against the OpenGL ES Shading Language 3.20.2
565bd8deadSopenharmony_ci    Specification (August 6, 2015)
575bd8deadSopenharmony_ci
585bd8deadSopenharmony_ci    This extension has interactions with EXT_draw_buffers_indexed, OES_draw_buffers_indexed and ES3.2
595bd8deadSopenharmony_ci
605bd8deadSopenharmony_ciOverview
615bd8deadSopenharmony_ci
625bd8deadSopenharmony_ci    OpenGL ES is modeled on a pipeline of operations. The final stage in this
635bd8deadSopenharmony_ci    pipeline before rasterization is the viewport transformation. This stage
645bd8deadSopenharmony_ci    transforms vertices from view space into window coordinates and allows the
655bd8deadSopenharmony_ci    application to specify a rectangular region of screen space into which
665bd8deadSopenharmony_ci    OpenGL ES should draw primitives. Unextended OpenGL ES implementations provide a
675bd8deadSopenharmony_ci    single viewport per context. In order to draw primitives into multiple
685bd8deadSopenharmony_ci    viewports, the OpenGL ES viewport may be changed between several draw calls.
695bd8deadSopenharmony_ci    With the advent of Geometry Shaders, it has become possible for an
705bd8deadSopenharmony_ci    application to amplify geometry and produce multiple output primitives
715bd8deadSopenharmony_ci    for each primitive input to the Geometry Shader. It is possible to direct
725bd8deadSopenharmony_ci    these primitives to render into a selected render target. However, all
735bd8deadSopenharmony_ci    render targets share the same, global OpenGL ES viewport.
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ci    This extension enhances OpenGL ES by providing a mechanism to expose multiple
765bd8deadSopenharmony_ci    viewports. Each viewport is specified as a rectangle. The destination
775bd8deadSopenharmony_ci    viewport may be selected per-primitive by the geometry shader. This allows
785bd8deadSopenharmony_ci    the Geometry Shader to produce different versions of primitives destined
795bd8deadSopenharmony_ci    for separate viewport rectangles on the same surface. Additionally, when
805bd8deadSopenharmony_ci    combined with multiple framebuffer attachments, it allows a different
815bd8deadSopenharmony_ci    viewport rectangle to be selected for each. This extension also exposes a
825bd8deadSopenharmony_ci    separate scissor rectangle for each viewport. Finally, the viewport bounds
835bd8deadSopenharmony_ci    are now floating point quantities allowing fractional pixel offsets to be
845bd8deadSopenharmony_ci    applied during the viewport transform.
855bd8deadSopenharmony_ci
865bd8deadSopenharmony_ciIP Status
875bd8deadSopenharmony_ci
885bd8deadSopenharmony_ci    No known IP claims.
895bd8deadSopenharmony_ci
905bd8deadSopenharmony_ciNew Procedures and Functions
915bd8deadSopenharmony_ci
925bd8deadSopenharmony_ci    void ViewportArrayvOES(uint first, sizei count, const float * v);
935bd8deadSopenharmony_ci    void ViewportIndexedfOES(uint index, float x, float y, float w, float h);
945bd8deadSopenharmony_ci    void ViewportIndexedfvOES(uint index, const float * v);
955bd8deadSopenharmony_ci    void ScissorArrayvOES(uint first, sizei count, const int * v);
965bd8deadSopenharmony_ci    void ScissorIndexedOES(uint index, int left, int bottom, sizei width, sizei height);
975bd8deadSopenharmony_ci    void ScissorIndexedvOES(uint index, const int * v);
985bd8deadSopenharmony_ci    void DepthRangeArrayfvOES(uint first, sizei count, const float * v);
995bd8deadSopenharmony_ci    void DepthRangeIndexedfOES(uint index, float n, float f);
1005bd8deadSopenharmony_ci    void GetFloati_vOES(enum target, uint index, float *data);
1015bd8deadSopenharmony_ci
1025bd8deadSopenharmony_ci    [[If none of OpenGL ES 3.2, EXT_draw_buffers_indexed or OES_draw_buffers_indexed are supported]]
1035bd8deadSopenharmony_ci    void EnableiOES(enum target, uint index);
1045bd8deadSopenharmony_ci    void DisableiOES(enum target, uint index);
1055bd8deadSopenharmony_ci    boolean IsEnablediOES(enum target, uint index);
1065bd8deadSopenharmony_ci
1075bd8deadSopenharmony_ciNew Tokens
1085bd8deadSopenharmony_ci
1095bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv,
1105bd8deadSopenharmony_ci    and GetInteger64v:
1115bd8deadSopenharmony_ci
1125bd8deadSopenharmony_ci        MAX_VIEWPORTS_OES                               0x825B
1135bd8deadSopenharmony_ci        VIEWPORT_SUBPIXEL_BITS_OES                      0x825C
1145bd8deadSopenharmony_ci        VIEWPORT_BOUNDS_RANGE_OES                       0x825D
1155bd8deadSopenharmony_ci        VIEWPORT_INDEX_PROVOKING_VERTEX_OES             0x825F
1165bd8deadSopenharmony_ci
1175bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetIntegeri_v:
1185bd8deadSopenharmony_ci
1195bd8deadSopenharmony_ci        SCISSOR_BOX                                     0x0C10
1205bd8deadSopenharmony_ci
1215bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetFloati_vOES:
1225bd8deadSopenharmony_ci
1235bd8deadSopenharmony_ci        VIEWPORT                                        0x0BA2
1245bd8deadSopenharmony_ci        DEPTH_RANGE                                     0x0B70
1255bd8deadSopenharmony_ci
1265bd8deadSopenharmony_ci    Accepted by the <pname> parameter of Enablei, Disablei, and IsEnabledi:
1275bd8deadSopenharmony_ci
1285bd8deadSopenharmony_ci        SCISSOR_TEST                                    0x0C11
1295bd8deadSopenharmony_ci
1305bd8deadSopenharmony_ciAdditions to Chapter 11 of the OpenGL ES 3.2 Specification (Programmable Vertex
1315bd8deadSopenharmony_ciPost-Processing)
1325bd8deadSopenharmony_ci
1335bd8deadSopenharmony_ci    Modifications to Section 11.3.4.5, Layer Selection
1345bd8deadSopenharmony_ci
1355bd8deadSopenharmony_ci    Rename the section to "Layer and Viewport Selection".
1365bd8deadSopenharmony_ci
1375bd8deadSopenharmony_ci    Add the following paragraph after the first paragraph:
1385bd8deadSopenharmony_ci
1395bd8deadSopenharmony_ci    Geometry shaders may also select the destination viewport for each
1405bd8deadSopenharmony_ci    output primitive. The destination viewport for a primitive may be
1415bd8deadSopenharmony_ci    selected in the geometry shader by writing to the built-in output
1425bd8deadSopenharmony_ci    variable gl_ViewportIndex. This functionality allows a geometry
1435bd8deadSopenharmony_ci    shader to direct its output to a different viewport for each
1445bd8deadSopenharmony_ci    primitive, or to draw multiple versions of a primitive into several
1455bd8deadSopenharmony_ci    different viewports.
1465bd8deadSopenharmony_ci
1475bd8deadSopenharmony_ci    Replace the first two sentences of the last paragraph with:
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ci    The specific vertex of a primitive that is used to select the
1505bd8deadSopenharmony_ci    rendering layer or viewport index is implementation-dependent and
1515bd8deadSopenharmony_ci    thus portable applications will assign the same layer and viewport
1525bd8deadSopenharmony_ci    index for all vertices in a primitive. The vertex conventions
1535bd8deadSopenharmony_ci    followed for gl_Layer and gl_ViewportIndex may be determined by
1545bd8deadSopenharmony_ci    calling GetIntegerv with the symbolic constants
1555bd8deadSopenharmony_ci    LAYER_PROVOKING_VERTEX and VIEWPORT_INDEX_PROVOKING_VERTEX_OES,
1565bd8deadSopenharmony_ci    respectively.
1575bd8deadSopenharmony_ci
1585bd8deadSopenharmony_ciAdditions to Chapter 12 of the OpenGL ES 3.2 Specification (Fixed-Function
1595bd8deadSopenharmony_ciVertex Post-Processing)
1605bd8deadSopenharmony_ci
1615bd8deadSopenharmony_ci    Modifications to section 12.5.1 "Controlling the Viewport"
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ci    Replace the entire section to read:
1645bd8deadSopenharmony_ci
1655bd8deadSopenharmony_ci    The viewport transformation is determined by the selected viewport's
1665bd8deadSopenharmony_ci    width and height in pixels, p_x and p_y, respectively, and its
1675bd8deadSopenharmony_ci    center (o_x,o_y) (also in pixels) ...
1685bd8deadSopenharmony_ci
1695bd8deadSopenharmony_ci        { leave equations intact }
1705bd8deadSopenharmony_ci
1715bd8deadSopenharmony_ci    Multiple viewports are available and are numbered zero through the
1725bd8deadSopenharmony_ci    value of MAX_VIEWPORTS_OES minus one. If a geometry shader is active
1735bd8deadSopenharmony_ci    and writes to gl_ViewportIndex, the viewport transformation uses the
1745bd8deadSopenharmony_ci    viewport corresponding to the value assigned to gl_ViewportIndex
1755bd8deadSopenharmony_ci    taken from an implementation-dependent primitive vertex. If the
1765bd8deadSopenharmony_ci    value of the viewport index is outside the range zero to the value
1775bd8deadSopenharmony_ci    of MAX_VIEWPORTS_OES minus one, the results of the viewport
1785bd8deadSopenharmony_ci    transformation are undefined. If no geometry shader is active, or if
1795bd8deadSopenharmony_ci    the active geometry shader does not write to gl_ViewportIndex, the
1805bd8deadSopenharmony_ci    viewport numbered zero is used by the viewport transformation.
1815bd8deadSopenharmony_ci
1825bd8deadSopenharmony_ci    A single vertex may be used in more than one individual primitive, in
1835bd8deadSopenharmony_ci    primitives such as TRIANGLE_STRIP.  In this case, the viewport
1845bd8deadSopenharmony_ci    transformation is applied separately for each primitive.
1855bd8deadSopenharmony_ci
1865bd8deadSopenharmony_ci    The factor and offset applied to Z_d for each viewport encoded by n
1875bd8deadSopenharmony_ci    and f are set using
1885bd8deadSopenharmony_ci
1895bd8deadSopenharmony_ci        void DepthRangeArrayfvOES(uint first, sizei count, const float * v);
1905bd8deadSopenharmony_ci        void DepthRangeIndexedfOES(uint index, float n, float f);
1915bd8deadSopenharmony_ci        void DepthRangef(float n, float f);
1925bd8deadSopenharmony_ci
1935bd8deadSopenharmony_ci    DepthRangeArrayfvOES is used to specify the depth range for multiple
1945bd8deadSopenharmony_ci    viewports simultaneously. <first> specifies the index of the first
1955bd8deadSopenharmony_ci    viewport to modify and <count> specifies the number of viewports.
1965bd8deadSopenharmony_ci    Viewports whose indices lie outside the range [<first>, <first> + <count>)
1975bd8deadSopenharmony_ci    are not modified. The <v> parameter contains the address of an array of
1985bd8deadSopenharmony_ci    float types specifying near (n) and far (f) for each viewport in that
1995bd8deadSopenharmony_ci    order. Values in <v> and the parameters <n> and <f> are clamped to
2005bd8deadSopenharmony_ci    the range [0, 1] when specified.
2015bd8deadSopenharmony_ci
2025bd8deadSopenharmony_ci    DepthRangeIndexedfOES specifies the depth range for a single viewport
2035bd8deadSopenharmony_ci    and is equivalent (assuming no errors are generated) to:
2045bd8deadSopenharmony_ci
2055bd8deadSopenharmony_ci        float v[] = { n, f };
2065bd8deadSopenharmony_ci        DepthRangeArrayfvOES(index, 1, v);
2075bd8deadSopenharmony_ci
2085bd8deadSopenharmony_ci    DepthRangef sets the depth range for all viewports to the same values
2095bd8deadSopenharmony_ci    and is equivalent (assuming no errors are generated) to:
2105bd8deadSopenharmony_ci
2115bd8deadSopenharmony_ci        for (uint i = 0; i < MAX_VIEWPORTS_OES; i++)
2125bd8deadSopenharmony_ci            DepthRangeIndexedfOES(i, n, f);
2135bd8deadSopenharmony_ci
2145bd8deadSopenharmony_ci    Z_w is represented as either ...
2155bd8deadSopenharmony_ci
2165bd8deadSopenharmony_ci    Errors
2175bd8deadSopenharmony_ci
2185bd8deadSopenharmony_ci        An INVALID_VALUE error is generated if the sum of <first> and <count> is
2195bd8deadSopenharmony_ci        greater than the value of MAX_VIEWPORTS_OES.
2205bd8deadSopenharmony_ci
2215bd8deadSopenharmony_ci        An INVALID_VALUE error is generated if <count> is negative.
2225bd8deadSopenharmony_ci
2235bd8deadSopenharmony_ci        An INVALID_VALUE error is generated if <index> is greater than or equal to
2245bd8deadSopenharmony_ci        the value of MAX_VIEWPORTS_OES.
2255bd8deadSopenharmony_ci
2265bd8deadSopenharmony_ci    Viewport transformation parameters are specified using
2275bd8deadSopenharmony_ci
2285bd8deadSopenharmony_ci        void ViewportArrayvOES(uint first, sizei count, const float * v);
2295bd8deadSopenharmony_ci        void Viewport(int x, int y, sizei w, sizei h);
2305bd8deadSopenharmony_ci        void ViewportIndexedfOES(uint index, float x, float y, float w, float h);
2315bd8deadSopenharmony_ci        void ViewportIndexedfvOES(uint index, const float * v);
2325bd8deadSopenharmony_ci
2335bd8deadSopenharmony_ci    ViewportArrayvOES specifies parameters for multiple viewports
2345bd8deadSopenharmony_ci    simultaneously. <first> specifies the index of the first viewport to
2355bd8deadSopenharmony_ci    modify and <count> specifies the number of viewports. Viewports whose
2365bd8deadSopenharmony_ci    indices lie outside the range [<first>, <first> + <count>) are not modified.
2375bd8deadSopenharmony_ci    <v> contains the address of an array of floating point values
2385bd8deadSopenharmony_ci    specifying the left (x), bottom (y), width (w) and height (h) of
2395bd8deadSopenharmony_ci    each viewport, in that order. <x> and <y> give the location of the
2405bd8deadSopenharmony_ci    viewport's lower left corner and <w> and <h> give the viewport's
2415bd8deadSopenharmony_ci    width and height, respectively.
2425bd8deadSopenharmony_ci
2435bd8deadSopenharmony_ci    ViewportIndexedfOES and ViewportIndexedfvOES specify parameters for a
2445bd8deadSopenharmony_ci    single viewport and are equivalent (assuming no errors are
2455bd8deadSopenharmony_ci    generated) to:
2465bd8deadSopenharmony_ci
2475bd8deadSopenharmony_ci        float v[4] = { x, y, w, h };
2485bd8deadSopenharmony_ci        ViewportArrayvOES(index, 1, v);
2495bd8deadSopenharmony_ci
2505bd8deadSopenharmony_ci    and
2515bd8deadSopenharmony_ci
2525bd8deadSopenharmony_ci        ViewportArrayvOES(index, 1, v);
2535bd8deadSopenharmony_ci
2545bd8deadSopenharmony_ci    respectively.
2555bd8deadSopenharmony_ci
2565bd8deadSopenharmony_ci    Viewport sets the parameters for all viewports to the same values
2575bd8deadSopenharmony_ci    and is equivalent (assuming no errors are generated) to:
2585bd8deadSopenharmony_ci
2595bd8deadSopenharmony_ci        for (uint i = 0; i < MAX_VIEWPORTS_OES; i++)
2605bd8deadSopenharmony_ci            ViewportIndexedfOES(i, (float)x, (float)y, (float)w, (float)h);
2615bd8deadSopenharmony_ci
2625bd8deadSopenharmony_ci    The viewport parameters shown in the above equations are found from these
2635bd8deadSopenharmony_ci    values as
2645bd8deadSopenharmony_ci
2655bd8deadSopenharmony_ci        o_x = x + w /2,
2665bd8deadSopenharmony_ci        o_y = y + h / 2,
2675bd8deadSopenharmony_ci        p_x = w,
2685bd8deadSopenharmony_ci        p_y = h.
2695bd8deadSopenharmony_ci
2705bd8deadSopenharmony_ci    The location of the viewport's bottom-left corner, given by (x,y), are
2715bd8deadSopenharmony_ci    clamped to be within the implementation-dependent viewport bounds range.
2725bd8deadSopenharmony_ci    The viewport bounds range [min, max] tuple may be determined by
2735bd8deadSopenharmony_ci    calling GetFloatv with the symbolic constant VIEWPORT_BOUNDS_RANGE_OES
2745bd8deadSopenharmony_ci    (see chapter 20).
2755bd8deadSopenharmony_ci
2765bd8deadSopenharmony_ci    Viewport width and height are clamped to implementation-dependent maximums
2775bd8deadSopenharmony_ci    when specified. The maximum width and height may be found by calling
2785bd8deadSopenharmony_ci    GetFloatv with the symbolic constant MAX_VIEWPORT_DIMS. The maximum
2795bd8deadSopenharmony_ci    viewport dimensions must be greater than or equal to the larger of
2805bd8deadSopenharmony_ci    the visible dimensions of the display being rendered to (if a
2815bd8deadSopenharmony_ci    display exists), and the largest renderbuffer image which can be
2825bd8deadSopenharmony_ci    successfully created and attached to a framebuffer object (see
2835bd8deadSopenharmony_ci    chapter 9).
2845bd8deadSopenharmony_ci
2855bd8deadSopenharmony_ci    Errors
2865bd8deadSopenharmony_ci
2875bd8deadSopenharmony_ci        An INVALID_VALUE error is generated if the sum of <first> and <count> is
2885bd8deadSopenharmony_ci        greater than the value of MAX_VIEWPORTS_OES.
2895bd8deadSopenharmony_ci
2905bd8deadSopenharmony_ci        An INVALID_VALUE error is generated if <count> is negative>.
2915bd8deadSopenharmony_ci
2925bd8deadSopenharmony_ci        An INVALID_VALUE error is generated if <index> is greater than or equal to
2935bd8deadSopenharmony_ci        the value of MAX_VIEWPORTS_OES.
2945bd8deadSopenharmony_ci
2955bd8deadSopenharmony_ci        An INVALID_VALUE error is generated if any <w> or <h> value is negative.
2965bd8deadSopenharmony_ci
2975bd8deadSopenharmony_ci    The state required to implement the viewport transformations is four
2985bd8deadSopenharmony_ci    floating-point values and two clamped floating-point values for each
2995bd8deadSopenharmony_ci    viewport. In the initial state, w and h for each viewport are set to
3005bd8deadSopenharmony_ci    the width and height, respectively, of the window into which the GL
3015bd8deadSopenharmony_ci    is to do its rendering. If the default framebuffer is bound but no
3025bd8deadSopenharmony_ci    default framebuffer is associated with the GL context (see chapter
3035bd8deadSopenharmony_ci    9), then w and h are initially set to zero. o_x and o_y are set to
3045bd8deadSopenharmony_ci    w/2 and h/2, respectively. n and f are set to 0.0 and 1.0,
3055bd8deadSopenharmony_ci    respectively.
3065bd8deadSopenharmony_ci
3075bd8deadSopenharmony_ci    The precision with which the GL interprets the floating point viewport
3085bd8deadSopenharmony_ci    bounds is implementation-dependent and may be determined by querying the
3095bd8deadSopenharmony_ci    implementation-defined constant VIEWPORT_SUBPIXEL_BITS_OES.
3105bd8deadSopenharmony_ci
3115bd8deadSopenharmony_ciAdditions to Chapter 13 of the OpenGL ES 3.2 Specification (Fixed-Function
3125bd8deadSopenharmony_ciPrimitive Assembly and Rasterization)
3135bd8deadSopenharmony_ci
3145bd8deadSopenharmony_ci    Replace section 13.8.2 "Scissor Test" with the following:
3155bd8deadSopenharmony_ci
3165bd8deadSopenharmony_ci    The scissor test determines if (x_w, y_w) lies within the scissor rectangle
3175bd8deadSopenharmony_ci    defined by four values for each viewport. These values are set with
3185bd8deadSopenharmony_ci
3195bd8deadSopenharmony_ci        void ScissorArrayvOES(uint first, sizei count, const int * v);
3205bd8deadSopenharmony_ci        void ScissorIndexedOES(uint index, int left, int bottom, sizei width, sizei height);
3215bd8deadSopenharmony_ci        void ScissorIndexedvOES(uint index, int * v);
3225bd8deadSopenharmony_ci        void Scissor(int left, int bottom, sizei width, sizei height);
3235bd8deadSopenharmony_ci
3245bd8deadSopenharmony_ci    ScissorArrayvOES defines a set of scissor rectangles that are each
3255bd8deadSopenharmony_ci    applied to the corresponding viewport (see section 12.5.1
3265bd8deadSopenharmony_ci    "Controlling the Viewport"). <first> specifies the index of the
3275bd8deadSopenharmony_ci    first scissor rectangle to modify, and <count> specifies the number
3285bd8deadSopenharmony_ci    of scissor rectangles.  <v> contains the address of an array of
3295bd8deadSopenharmony_ci    integers containing the left, bottom, width and height of the
3305bd8deadSopenharmony_ci    scissor rectangles, in that order.
3315bd8deadSopenharmony_ci
3325bd8deadSopenharmony_ci    If left <= x_w < left + width and bottom <= y_w < bottom + height
3335bd8deadSopenharmony_ci    for the selected scissor rectangle, then the scissor test passes.
3345bd8deadSopenharmony_ci    Otherwise, the test fails and the fragment is discarded. For points,
3355bd8deadSopenharmony_ci    lines, and polygons, the scissor rectangle for a primitive is
3365bd8deadSopenharmony_ci    selected in the same manner as the viewport (see section 12.5.1).
3375bd8deadSopenharmony_ci
3385bd8deadSopenharmony_ci    The scissor test is enabled or disabled for all viewports using
3395bd8deadSopenharmony_ci    Enable or Disable with the symbolic constant SCISSOR_TEST. The test
3405bd8deadSopenharmony_ci    is enabled or disabled for a specific viewport using Enablei or
3415bd8deadSopenharmony_ci    Disablei with the constant SCISSOR_TEST and the index of the
3425bd8deadSopenharmony_ci    selected viewport. When disabled, it is as if the scissor test
3435bd8deadSopenharmony_ci    always passes. The value of the scissor test enable for viewport <i>
3445bd8deadSopenharmony_ci    can be queried by calling IsEnabledi with <target> SCISSOR_TEST and
3455bd8deadSopenharmony_ci    <index> <i>. The value of the scissor test enable for viewport zero
3465bd8deadSopenharmony_ci    may also be queried by calling IsEnabled with the same <target>,
3475bd8deadSopenharmony_ci    but no <index> parameter.
3485bd8deadSopenharmony_ci
3495bd8deadSopenharmony_ci    ScissorIndexedOES and ScissorIndexedvOES specify the scissor rectangle for
3505bd8deadSopenharmony_ci    a single viewport and are equivalent (assuming no errors are
3515bd8deadSopenharmony_ci    generated) to:
3525bd8deadSopenharmony_ci
3535bd8deadSopenharmony_ci        int v[] = { left, bottom, width, height };
3545bd8deadSopenharmony_ci        ScissorArrayvOES(index, 1, v);
3555bd8deadSopenharmony_ci
3565bd8deadSopenharmony_ci    and
3575bd8deadSopenharmony_ci
3585bd8deadSopenharmony_ci        ScissorArrayvOES(index, 1, v);
3595bd8deadSopenharmony_ci
3605bd8deadSopenharmony_ci    respectively.
3615bd8deadSopenharmony_ci
3625bd8deadSopenharmony_ci    Scissor sets the scissor rectangle for all viewports to the same
3635bd8deadSopenharmony_ci    values and is equivalent (assuming no errors are generated) to:
3645bd8deadSopenharmony_ci
3655bd8deadSopenharmony_ci        for (uint i = 0; i < MAX_VIEWPORTS_OES; i++) {
3665bd8deadSopenharmony_ci            ScissorIndexedOES(i, left, bottom, width, height);
3675bd8deadSopenharmony_ci        }
3685bd8deadSopenharmony_ci
3695bd8deadSopenharmony_ci    Calling Enable or Disable with <target> SCISSOR_TEST is
3705bd8deadSopenharmony_ci    equivalent, assuming no errors, to:
3715bd8deadSopenharmony_ci
3725bd8deadSopenharmony_ci    for (uint i = 0; i < MAX_VIEWPORTS_OES; i++) {
3735bd8deadSopenharmony_ci        Enablei(SCISSOR_TEST, i);
3745bd8deadSopenharmony_ci        /* or */
3755bd8deadSopenharmony_ci        Disablei(SCISSOR_TEST, i);
3765bd8deadSopenharmony_ci    }
3775bd8deadSopenharmony_ci
3785bd8deadSopenharmony_ci    Errors
3795bd8deadSopenharmony_ci
3805bd8deadSopenharmony_ci        An INVALID_VALUE error is generated if the sum of <first> and <count> is
3815bd8deadSopenharmony_ci        greater than the value of MAX_VIEWPORTS_OES.
3825bd8deadSopenharmony_ci
3835bd8deadSopenharmony_ci        An INVALID_VALUE error is generated if <index> is greater than or equal to
3845bd8deadSopenharmony_ci        the value of MAX_VIEWPORTS_OES.
3855bd8deadSopenharmony_ci
3865bd8deadSopenharmony_ci        An INVALID_VALUE error is generated if any <width> or <height> value is
3875bd8deadSopenharmony_ci        negative.
3885bd8deadSopenharmony_ci
3895bd8deadSopenharmony_ci    The state required consists of four integer values per viewport, and
3905bd8deadSopenharmony_ci    a bit indicating whether the test is enabled or disabled for each
3915bd8deadSopenharmony_ci    viewport. In the initial state, left = bottom = 0, and width and
3925bd8deadSopenharmony_ci    height are determined by the size of the window into which the GL is
3935bd8deadSopenharmony_ci    to do its rendering for all viewports. If the default framebuffer is
3945bd8deadSopenharmony_ci    bound but no default framebuffer is associated with the GL context
3955bd8deadSopenharmony_ci    (see chapter 9), then with and height are initially set to zero.
3965bd8deadSopenharmony_ci    Initially, the scissor test is disabled for all viewports.
3975bd8deadSopenharmony_ci
3985bd8deadSopenharmony_ciAdditions to Chapter 20 of the OpenGL ES 3.2 Specification (Context State
3995bd8deadSopenharmony_ciQueries)
4005bd8deadSopenharmony_ci
4015bd8deadSopenharmony_ci    Modifications to Section 20.1 Simple Queries
4025bd8deadSopenharmony_ci
4035bd8deadSopenharmony_ci        Add to the list of indexed query functions:
4045bd8deadSopenharmony_ci
4055bd8deadSopenharmony_ci        void GetFloati_vOES(enum target, uint index, float *data);
4065bd8deadSopenharmony_ci
4075bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL ES Shading Language Specification
4085bd8deadSopenharmony_ci
4095bd8deadSopenharmony_ci    Add a new Section 3.4.x, GL_OES_viewport_array Extension
4105bd8deadSopenharmony_ci
4115bd8deadSopenharmony_ci    3.4.x GL_OES_viewport_array Extension
4125bd8deadSopenharmony_ci
4135bd8deadSopenharmony_ci    To use the GL_OES_viewport_array extension in a shader it must be
4145bd8deadSopenharmony_ci    enabled using the #extension directive.
4155bd8deadSopenharmony_ci
4165bd8deadSopenharmony_ci    The shading language preprocessor #define GL_OES_viewport_array will
4175bd8deadSopenharmony_ci    be defined to 1 if the GL_OES_viewport_array extension is supported.
4185bd8deadSopenharmony_ci
4195bd8deadSopenharmony_ciAdditions to Chapter 7 of the OpenGL ES Shading Language Specification
4205bd8deadSopenharmony_ci
4215bd8deadSopenharmony_ci    Add the following built-in to section 7.1.4, Geometry Shader Special
4225bd8deadSopenharmony_ci    Variables:
4235bd8deadSopenharmony_ci
4245bd8deadSopenharmony_ci        out highp int gl_ViewportIndex;
4255bd8deadSopenharmony_ci
4265bd8deadSopenharmony_ci    Add the following paragraph to the end of Section 7.1.4.2, Geometry Shader
4275bd8deadSopenharmony_ci    Output Variables:
4285bd8deadSopenharmony_ci
4295bd8deadSopenharmony_ci    gl_ViewportIndex provides the index of the viewport to which the next
4305bd8deadSopenharmony_ci    primitive emitted from the geometry shader should be drawn. Primitives
4315bd8deadSopenharmony_ci    generated by the geometry shader will undergo viewport transformation and
4325bd8deadSopenharmony_ci    scissor scissor testing using the viewport transformation and scissor
4335bd8deadSopenharmony_ci    rectangle selected by the value of gl_ViewportIndex.
4345bd8deadSopenharmony_ci    The viewport index used will come from one of the
4355bd8deadSopenharmony_ci    vertices in the primitive being shaded. Which vertex the viewport index
4365bd8deadSopenharmony_ci    comes from is determined as discussed in section 11.3.4.5 of the OpenGL ES
4375bd8deadSopenharmony_ci    Specification, but may be undefined, so it is best to write the same
4385bd8deadSopenharmony_ci    viewport index for all vertices of the primitive. If a geometry shader does
4395bd8deadSopenharmony_ci    not assign a value to gl_ViewportIndex, viewport transform and scissor
4405bd8deadSopenharmony_ci    rectangle zero will be used. If a geometry shader statically assigns a value to
4415bd8deadSopenharmony_ci    gl_ViewportIndex and there is a path through the shader that does not set
4425bd8deadSopenharmony_ci    gl_ViewportIndex, then the value of gl_ViewportIndex is undefined for
4435bd8deadSopenharmony_ci    executions of the shader that take that path. See section 11.3.4.5 "Layer
4445bd8deadSopenharmony_ci    and Viewport Selection" of the OpenGL ES Specification for more information.
4455bd8deadSopenharmony_ci
4465bd8deadSopenharmony_ci    Add the following build-in to section 7.1.5 "Fragment Shader Special
4475bd8deadSopenharmony_ci    Variables:
4485bd8deadSopenharmony_ci
4495bd8deadSopenharmony_ci        in highp int gl_ViewportIndex;
4505bd8deadSopenharmony_ci
4515bd8deadSopenharmony_ci    Add the following paragraph to the end of section 7.1.5 "Fragment Shader
4525bd8deadSopenharmony_ci    Special Variables:
4535bd8deadSopenharmony_ci
4545bd8deadSopenharmony_ci    The input variable gl_ViewportIndex will have the same value that was
4555bd8deadSopenharmony_ci    written to the output variable gl_ViewportIndex in the geometry stage. If
4565bd8deadSopenharmony_ci    the geometry stage does not dynamically assign to gl_ViewportIndex, the
4575bd8deadSopenharmony_ci    value of gl_ViewportIndex in the fragment shader will be undefined. If the
4585bd8deadSopenharmony_ci    geometry stage makes no static assignment to gl_ViewportIndex, the value
4595bd8deadSopenharmony_ci    in the fragment stage is undefined. Otherwise, the fragment stage will read
4605bd8deadSopenharmony_ci    the same value written by the geometry stage, even if that value is out of
4615bd8deadSopenharmony_ci    range. If a fragment shader contains a static access to gl_ViewportIndex,
4625bd8deadSopenharmony_ci    it will count against the implementation defined limit for the maximum
4635bd8deadSopenharmony_ci    number of inputs to the fragment stage.
4645bd8deadSopenharmony_ci
4655bd8deadSopenharmony_ci    Add the following built-in to section 7.2 "Built-In Constants":
4665bd8deadSopenharmony_ci
4675bd8deadSopenharmony_ci        const highp int gl_MaxViewports = 16;
4685bd8deadSopenharmony_ci
4695bd8deadSopenharmony_ciErrors
4705bd8deadSopenharmony_ci
4715bd8deadSopenharmony_ci    INVALID_VALUE is generated by ViewportArrayvOES if <first> + <count> is
4725bd8deadSopenharmony_ci    greater than or equal to the value of MAX_VIEWPORTS_OES, or if any
4735bd8deadSopenharmony_ci    viewport's width or height is less than 0.
4745bd8deadSopenharmony_ci
4755bd8deadSopenharmony_ci    INVALID_VALUE is generated by ScissorArrayvOES if <first> + <count> is
4765bd8deadSopenharmony_ci    greater than or equal to the value of MAX_VIEWPORTS_OES, or if any
4775bd8deadSopenharmony_ci    scissor rectangle's width or height is less than zero.
4785bd8deadSopenharmony_ci
4795bd8deadSopenharmony_ci    INVALID_VALUE is generated by DepthRangeArrayfvOES if <first> + <count> is
4805bd8deadSopenharmony_ci    greater than or equal to the vaue of MAX_VIEWPORTS_OES.
4815bd8deadSopenharmony_ci
4825bd8deadSopenharmony_ci    An INVALID_VALUE error is generated by Enablei, Disablei and IsEnabledi if
4835bd8deadSopenharmony_ci    <target> is SCISSOR_TEST and <index> is greater than or equal to the value
4845bd8deadSopenharmony_ci    of MAX_VIEWPORTS_OES
4855bd8deadSopenharmony_ci
4865bd8deadSopenharmony_ciNew State
4875bd8deadSopenharmony_ci
4885bd8deadSopenharmony_ci    Table 21.6:
4895bd8deadSopenharmony_ci
4905bd8deadSopenharmony_ci    Get Value                 Type             Get Command       Initial Value   Description                 Sec
4915bd8deadSopenharmony_ci    ------------------------  ---------------- --------------    -------------   ------------------------  -----
4925bd8deadSopenharmony_ci    VIEWPORT                  16* x 4 x R      GetFloati_vOES    See 12.5.1      Viewport origin & extent  12.5.1
4935bd8deadSopenharmony_ci    DEPTH_RANGE               16* x 2 x R[0,1] GetFloati_vOES    See 12.5.1      Depth range near & far    12.5.1
4945bd8deadSopenharmony_ci
4955bd8deadSopenharmony_ciNOTE: The changes are that VIEWPORT and DEPTH_RANGE are extended to
4965bd8deadSopenharmony_ciaccommodate 16* copies. Viewport now consists of floating-point values.
4975bd8deadSopenharmony_ci
4985bd8deadSopenharmony_ci    Table 21.13:
4995bd8deadSopenharmony_ci
5005bd8deadSopenharmony_ci    Get Value                 Type        Get Command           Initial Value   Description               Sec
5015bd8deadSopenharmony_ci    ------------------------  ----------  -------------         -------------   -------------------       ------
5025bd8deadSopenharmony_ci    SCISSOR_TEST              16* x B     IsEnabledi            FALSE           Scissoring enabled        13.8.2
5035bd8deadSopenharmony_ci    SCISSOR_BOX               16* x 4 x Z GetIntegeri_v         See 13.8.2      Scissor box               13.8.2
5045bd8deadSopenharmony_ci
5055bd8deadSopenharmony_ciNOTE: The only change is that SCISSOR_TEST and SCISSOR_BOX are extended
5065bd8deadSopenharmony_cito accommodate 16* copies.
5075bd8deadSopenharmony_ci
5085bd8deadSopenharmony_ciNew Implementation Dependent State
5095bd8deadSopenharmony_ci
5105bd8deadSopenharmony_ci    Get Value                            Type   Get Command     Minimum Value   Description                     Sec.
5115bd8deadSopenharmony_ci    ---------                            ----   -----------     -------------   -------------------             -----
5125bd8deadSopenharmony_ci    MAX_VIEWPORT_DIMS (NOTE 1)           2 x Z+ GetFloatv       See 12.5.1      Maximum viewport dimensions     12.5.1
5135bd8deadSopenharmony_ci    MAX_VIEWPORTS_OES                    Z+     GetIntegerv     16              Maximum number of               12.5.1
5145bd8deadSopenharmony_ci                                                                                active viewports
5155bd8deadSopenharmony_ci    VIEWPORT_SUBPIXEL_BITS_OES           Z+     GetIntegerv     0               Number of bits of sub-pixel     12.5.1
5165bd8deadSopenharmony_ci                                                                                precision for viewport bounds
5175bd8deadSopenharmony_ci    VIEWPORT_BOUNDS_RANGE_OES            2 x R  GetFloatv       [-32768, 32767] Viewport bounds range [min,max] 12.5.1
5185bd8deadSopenharmony_ci    VIEWPORT_INDEX_PROVOKING_VERTEX_OES  Z_4    GetIntegerv     -- (NOTE 2)     vertex convention followed by   12.5.1
5195bd8deadSopenharmony_ci                                                                                the gl_ViewportIndex GLSL
5205bd8deadSopenharmony_ci                                                                                variable
5215bd8deadSopenharmony_ci
5225bd8deadSopenharmony_ciNOTE 1: The recommended get command is changed from GetIntegerv to GetFloatv.
5235bd8deadSopenharmony_ciNOTE 2: Valid values are: FIRST_VERTEX_CONVENTION,
5245bd8deadSopenharmony_ciLAST_VERTEX_CONVENTION, PROVOKING_VERTEX, UNDEFINED_VERTEX.
5255bd8deadSopenharmony_ci
5265bd8deadSopenharmony_ciInteractions with EXT_draw_buffers_indexed, OES_draw_buffers_indexed and OpenGL ES 3.2
5275bd8deadSopenharmony_ci
5285bd8deadSopenharmony_ci    If EXT_draw_buffers_indexed is supported, EnableiEXT, DisableiEXT and
5295bd8deadSopenharmony_ci    IsEnablediEXT can be used in place of their core counterparts.
5305bd8deadSopenharmony_ci
5315bd8deadSopenharmony_ci    If only EXT_draw_buffers_indexed is supported, replace all mentions
5325bd8deadSopenharmony_ci    of Enablei, Disablei and IsEnabledi with their EXT suffixed counterparts.
5335bd8deadSopenharmony_ci
5345bd8deadSopenharmony_ci    If OES_draw_buffers_indexed is supported, EnableiOES, DisableiOES and
5355bd8deadSopenharmony_ci    IsEnablediOES can be used in place of their core counterparts.
5365bd8deadSopenharmony_ci
5375bd8deadSopenharmony_ci    If only OES_draw_buffers_indexed is supported, replace all mentions
5385bd8deadSopenharmony_ci    of Enablei, Disablei and IsEnabledi with their OES suffixed counterparts.
5395bd8deadSopenharmony_ci
5405bd8deadSopenharmony_ci    If none of these are supported, then the EnableiOES, DisableiOES and
5415bd8deadSopenharmony_ci    IsEnablediOES functions are added, with exactly the same specification as
5425bd8deadSopenharmony_ci    the equivalently named core functions in OpenGL ES 3.2. Replace all mentions
5435bd8deadSopenharmony_ci    of Enablei, Disablei and IsEnabledi with their OES suffixed counterparts.
5445bd8deadSopenharmony_ci
5455bd8deadSopenharmony_ciIssues
5465bd8deadSopenharmony_ci
5475bd8deadSopenharmony_ci    See issues section in ARB_viewport_array.
5485bd8deadSopenharmony_ci
5495bd8deadSopenharmony_ci    #1 What are the differences from ARB_viewport_array?
5505bd8deadSopenharmony_ci
5515bd8deadSopenharmony_ci    - OpenGL ES does not support the double datatype. The changed interfaces of
5525bd8deadSopenharmony_ci    glDepthRangeArrayfvOES and DepthRangeIndexedfOES reflect that. 'float' is
5535bd8deadSopenharmony_ci    being used instead of 'clampf', with additional constraints in the text
5545bd8deadSopenharmony_ci    that the values will get clamped.
5555bd8deadSopenharmony_ci    - The ability to access gl_ViewportIndex from the fragment shader was added
5565bd8deadSopenharmony_ci    from ARB_fragment_layer_viewport.
5575bd8deadSopenharmony_ci    - Unlike ARB_fragment_layer_viewport, the value of gl_ViewportIndex is undefined
5585bd8deadSopenharmony_ci    if it wasn't written by the geometry shader.
5595bd8deadSopenharmony_ci
5605bd8deadSopenharmony_ci
5615bd8deadSopenharmony_ciRevision History
5625bd8deadSopenharmony_ci
5635bd8deadSopenharmony_ci    Rev.    Date      Author    Changes
5645bd8deadSopenharmony_ci    ----  --------    --------  -----------------------------------------
5655bd8deadSopenharmony_ci     1    10/12/2015  thector   Initial draft
5665bd8deadSopenharmony_ci     2    23/03/2016  thector   Changed to EXT
5675bd8deadSopenharmony_ci     3    06/04/2016  thector   Made gl_ViewportIndex undefined in a fragment shader if not previously written
5685bd8deadSopenharmony_ci     4    13/04/2016  thector   Changed to OES
5695bd8deadSopenharmony_ci                                Added interactions with OES_draw_buffers_indexed
5705bd8deadSopenharmony_ci                                Allowed dependency on OES_geometry_shader as well as EXT_geometry_shader
5715bd8deadSopenharmony_ci     5    19/04/2016  dkoch     Typographical fixes.
5725bd8deadSopenharmony_ci                                Sync some additional language with GL 4.5 and GLSL 4.50.
573