15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    OES_primitive_bounding_box
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_OES_primitive_bounding box
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Jesse Hall (jessehall 'at' google.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciContributors
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Alex Chalfin, ARM
165bd8deadSopenharmony_ci    Jan-Harald Fredriksen, ARM
175bd8deadSopenharmony_ci    Dan Stoza, Google
185bd8deadSopenharmony_ci    Cass Everitt, NVIDIA
195bd8deadSopenharmony_ci    Daniel Koch, NVIDIA
205bd8deadSopenharmony_ci    Jeff Bolz, NVIDIA
215bd8deadSopenharmony_ci    Pat Brown, NVIDIA
225bd8deadSopenharmony_ci    Bill Licea-Kane, Qualcomm
235bd8deadSopenharmony_ci    Maurice Ribble, Qualcomm
245bd8deadSopenharmony_ci    Vineet Goel, Qualcomm
255bd8deadSopenharmony_ci
265bd8deadSopenharmony_ciNotice
275bd8deadSopenharmony_ci
285bd8deadSopenharmony_ci    Copyright (c) 2014-2018 The Khronos Group Inc. Copyright terms at
295bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ciSpecification Update Policy
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ci    Khronos-approved extension specifications are updated in response to
345bd8deadSopenharmony_ci    issues and bugs prioritized by the Khronos OpenGL ES Working Group. For
355bd8deadSopenharmony_ci    extensions which have been promoted to a core Specification, fixes will
365bd8deadSopenharmony_ci    first appear in the latest version of that core Specification, and will
375bd8deadSopenharmony_ci    eventually be backported to the extension document. This policy is
385bd8deadSopenharmony_ci    described in more detail at
395bd8deadSopenharmony_ci        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
405bd8deadSopenharmony_ci
415bd8deadSopenharmony_ciStatus
425bd8deadSopenharmony_ci
435bd8deadSopenharmony_ci    Approved by the OpenGL ES Working Group
445bd8deadSopenharmony_ci    Ratified by the Khronos Board of Promoters on November 7, 2014
455bd8deadSopenharmony_ci
465bd8deadSopenharmony_ciVersion
475bd8deadSopenharmony_ci
485bd8deadSopenharmony_ci    Last Modified Date: February 13, 2018
495bd8deadSopenharmony_ci    Revision: 3
505bd8deadSopenharmony_ci
515bd8deadSopenharmony_ciNumber
525bd8deadSopenharmony_ci
535bd8deadSopenharmony_ci    OpenGL ES Extension #212
545bd8deadSopenharmony_ci
555bd8deadSopenharmony_ciDependencies
565bd8deadSopenharmony_ci
575bd8deadSopenharmony_ci    OpenGL ES 3.1 and OpenGL ES Shading Language 3.10 are required.
585bd8deadSopenharmony_ci
595bd8deadSopenharmony_ci    This specification is written against the OpenGL ES 3.1 (March 17,
605bd8deadSopenharmony_ci    2014) and OpenGL ES 3.10 Shading Language (March 17, 2014)
615bd8deadSopenharmony_ci    Specifications.
625bd8deadSopenharmony_ci
635bd8deadSopenharmony_ci    This extension interacts with the OpenGL ES 3.20 Shading Language.
645bd8deadSopenharmony_ci
655bd8deadSopenharmony_ci    This extension interacts with EXT_tessellation_shader and
665bd8deadSopenharmony_ci    OES_tessellation_shader.
675bd8deadSopenharmony_ci
685bd8deadSopenharmony_ci    OES_geometry_shader and EXT_geometry_shader trivially affect the
695bd8deadSopenharmony_ci    definition of this extension.
705bd8deadSopenharmony_ci
715bd8deadSopenharmony_ciOverview
725bd8deadSopenharmony_ci
735bd8deadSopenharmony_ci    On tile-based architectures, transformed primitives are generally written
745bd8deadSopenharmony_ci    out to memory before rasterization, and then read back from memory for each
755bd8deadSopenharmony_ci    tile they intersect. When geometry expands during transformation due to
765bd8deadSopenharmony_ci    tessellation or one-to-many geometry shaders, the external bandwidth
775bd8deadSopenharmony_ci    required grows proportionally. This extension provides a way for
785bd8deadSopenharmony_ci    implementations to know which tiles incoming geometry will intersect before
795bd8deadSopenharmony_ci    fully transforming (and expanding) the geometry. This allows them to only
805bd8deadSopenharmony_ci    store the unexpanded geometry in memory, and perform expansion on-chip for
815bd8deadSopenharmony_ci    each intersected tile.
825bd8deadSopenharmony_ci
835bd8deadSopenharmony_ci    New state is added to hold an axis-aligned bounding box which is assumed to
845bd8deadSopenharmony_ci    contain any geometry submitted. An implementation is allowed to ignore any
855bd8deadSopenharmony_ci    portions of primitives outside the bounding box; thus if a primitive extends
865bd8deadSopenharmony_ci    outside of a tile into a neighboring tile that the bounding box didn't
875bd8deadSopenharmony_ci    intersect, the implementation is not required to render those portions. The
885bd8deadSopenharmony_ci    tessellation control shader is optionally able to specify a per-patch
895bd8deadSopenharmony_ci    bounding box that overrides the bounding box state for primitives generated
905bd8deadSopenharmony_ci    from that patch, in order to provide tighter bounds.
915bd8deadSopenharmony_ci
925bd8deadSopenharmony_ci    The typical usage is that an application will have an object-space bounding
935bd8deadSopenharmony_ci    volume for a primitive or group of primitives, either calculated at runtime
945bd8deadSopenharmony_ci    or provided with the mesh by the authoring tool or content pipeline. It will
955bd8deadSopenharmony_ci    transform this volume to clip space, compute an axis-aligned bounding box
965bd8deadSopenharmony_ci    that contains the transformed bounding volume, and provide that at either
975bd8deadSopenharmony_ci    per-patch or per-draw granularity.
985bd8deadSopenharmony_ci
995bd8deadSopenharmony_ciIP Status
1005bd8deadSopenharmony_ci
1015bd8deadSopenharmony_ci    No known IP claims.
1025bd8deadSopenharmony_ci
1035bd8deadSopenharmony_ciNew Procedures and Functions
1045bd8deadSopenharmony_ci
1055bd8deadSopenharmony_ci    void PrimitiveBoundingBoxOES(float minX, float minY, float minZ, float minW,
1065bd8deadSopenharmony_ci                                 float maxX, float maxY, float maxZ, float maxW);
1075bd8deadSopenharmony_ci
1085bd8deadSopenharmony_ciNew Tokens
1095bd8deadSopenharmony_ci
1105bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetBooleanv, GetFloatv, GetIntegerv,
1115bd8deadSopenharmony_ci    and GetInteger64v:
1125bd8deadSopenharmony_ci
1135bd8deadSopenharmony_ci        PRIMITIVE_BOUNDING_BOX_OES                          0x92BE
1145bd8deadSopenharmony_ci
1155bd8deadSopenharmony_ciAdditions to the OpenGL ES 3.1 Specification
1165bd8deadSopenharmony_ci
1175bd8deadSopenharmony_ci    Modify section 11.1ts.1.2.3, "Tessellation Control Shader Outputs", as added
1185bd8deadSopenharmony_ci    by OES_tessellation_shader or EXT_tessellation_shader:
1195bd8deadSopenharmony_ci
1205bd8deadSopenharmony_ci    In the second paragraph, add gl_BoundingBoxOES[] to the list of built-in
1215bd8deadSopenharmony_ci    per-patch output arrays:
1225bd8deadSopenharmony_ci
1235bd8deadSopenharmony_ci    Tessellation shaders additionally have three built-in per-patch output
1245bd8deadSopenharmony_ci    arrays, gl_TessLevelOuter[], gl_TessLevelInner[], and gl_BoundingBoxOES[].
1255bd8deadSopenharmony_ci    These arrays ... as discussed in the following section. gl_BoundingBoxOES[]
1265bd8deadSopenharmony_ci    is an array of two vec4 values that should be used instead of the value of
1275bd8deadSopenharmony_ci    PRIMITIVE_BOUNDING_BOX_OES as the primitive bounding box (see Section
1285bd8deadSopenharmony_ci    13.1pbb) for primitives generated from the output patch.
1295bd8deadSopenharmony_ci
1305bd8deadSopenharmony_ci    Modify the sixth paragraph of the section to state that gl_BoundingBoxOES[]
1315bd8deadSopenharmony_ci    counts against the per-patch limit:
1325bd8deadSopenharmony_ci
1335bd8deadSopenharmony_ci    ... The built-in outputs gl_TessLevelOuter[] and gl_TessLevelInner[] are not
1345bd8deadSopenharmony_ci    counted against the per-patch limit. The built-in output
1355bd8deadSopenharmony_ci    gl_BoundingBoxOES[], if statically assigned by the shader, is counted
1365bd8deadSopenharmony_ci    against the per-patch limit. The total number of components...
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci
1395bd8deadSopenharmony_ci    Modify section 11.1ts.3.3, "Tessellation Evaluation Shader Inputs", as added
1405bd8deadSopenharmony_ci    by OES_tessellation_shader or EXT_tessellation_shader:
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ci    Insert a new paragraph after the list of special input variables in
1435bd8deadSopenharmony_ci    paragraph 2:
1445bd8deadSopenharmony_ci
1455bd8deadSopenharmony_ci    The special tessellation control shader output gl_BoundingBoxOES[] is
1465bd8deadSopenharmony_ci    consumed by the tessellation primitive generator, and is not available as an
1475bd8deadSopenharmony_ci    input to the tessellation evaluation shader.
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ci
1505bd8deadSopenharmony_ci    Add new section 13.1pbb following section 13.1, "Discarding Primitives
1515bd8deadSopenharmony_ci    Before Rasterization" on p. 288:
1525bd8deadSopenharmony_ci
1535bd8deadSopenharmony_ci    13.1pbb, Primitive Bounding Box
1545bd8deadSopenharmony_ci
1555bd8deadSopenharmony_ci    Implementations may be able to optimize performance if the application
1565bd8deadSopenharmony_ci    provides bounds of primitives that will be generated by the tessellation
1575bd8deadSopenharmony_ci    primitive generator or the geometry shader prior to executing those stages.
1585bd8deadSopenharmony_ci    If the provided bounds are incorrect and primitives extend beyond them, the
1595bd8deadSopenharmony_ci    rasterizer may or may not generate fragments for the portions of primitives
1605bd8deadSopenharmony_ci    outside the bounds.
1615bd8deadSopenharmony_ci
1625bd8deadSopenharmony_ci    The primitive bounding box is specified using
1635bd8deadSopenharmony_ci
1645bd8deadSopenharmony_ci        void PrimitiveBoundingBoxOES(float minX, float minY, float minZ, float minW,
1655bd8deadSopenharmony_ci                                     float maxX, float maxY, float maxZ, float maxW);
1665bd8deadSopenharmony_ci
1675bd8deadSopenharmony_ci    where <minX>, <minY>, <minZ>, and <minW> specify the minimum clip space
1685bd8deadSopenharmony_ci    coordinate of the bounding box and <maxX>, <maxY>, <maxZ>, and <maxW>
1695bd8deadSopenharmony_ci    specify the maximum coordinate.
1705bd8deadSopenharmony_ci
1715bd8deadSopenharmony_ci    If tessellation is active, each invocation of the tessellation control
1725bd8deadSopenharmony_ci    shader may re-specify the bounding box by writing to the built-in
1735bd8deadSopenharmony_ci    gl_BoundingBoxOES[] variable. If the shader statically assigns a value to
1745bd8deadSopenharmony_ci    any part of this variable, then gl_BoundingBoxOES[0] is used instead of
1755bd8deadSopenharmony_ci    <minX>, <minY>, <minZ>, <minW>, and gl_BoundingBoxOES[1] is used instead of
1765bd8deadSopenharmony_ci    <maxX>, <maxY>, <maxZ>, <maxW>.  If the shader contains a static assignment
1775bd8deadSopenharmony_ci    to gl_BoundingBoxOES[] and there is an execution path through the shader
1785bd8deadSopenharmony_ci    that does not write all components of gl_BoundingBoxOES[], the value of
1795bd8deadSopenharmony_ci    unwritten components and corresponding bounding box coordinates is undefined
1805bd8deadSopenharmony_ci    for executions of the shader that take that path.
1815bd8deadSopenharmony_ci
1825bd8deadSopenharmony_ci    If the tessellation control shader re-specifies the bounding box, the re-
1835bd8deadSopenharmony_ci    specified value is used for primitives generated from the output patch by
1845bd8deadSopenharmony_ci    the primitive generator, any primitives emitted by the geometry shader
1855bd8deadSopenharmony_ci    invocations for those generated primitives, and any primitives further
1865bd8deadSopenharmony_ci    introduced during clipping.
1875bd8deadSopenharmony_ci
1885bd8deadSopenharmony_ci    The bounding box in clip space is composed of 16 vertices formed by all
1895bd8deadSopenharmony_ci    combinations of the minimum and maximum values for each dimension. This
1905bd8deadSopenharmony_ci    bounding box is clipped against w_c > 0, and projected to three dimensions
1915bd8deadSopenharmony_ci    by dividing x_c, y_c, and z_c by w_c for each vertex. The viewport transform
1925bd8deadSopenharmony_ci    is then applied to each vertex to produce a three-dimensional bounding
1935bd8deadSopenharmony_ci    volume in window coordinates.
1945bd8deadSopenharmony_ci
1955bd8deadSopenharmony_ci    The window space bounding volume is expanded in the X and Y dimensions to
1965bd8deadSopenharmony_ci    accomodate the rasterization rules for the primitive type, and to fall on
1975bd8deadSopenharmony_ci    fragment boundaries:
1985bd8deadSopenharmony_ci        min_wc' = floor(min_wc - size/2.0)
1995bd8deadSopenharmony_ci        max_wc' = ceil(max_wc + size/2.0)
2005bd8deadSopenharmony_ci    where the min_wc rule is used for x and y window coordinates of bounding
2015bd8deadSopenharmony_ci    volume vertices formed from minX and minY respectively, and the max_wc rule
2025bd8deadSopenharmony_ci    is used for x and y window coordinates of bounding volume vertices formed
2035bd8deadSopenharmony_ci    from maxX and maxY respectively. For point primitives, size is the per-
2045bd8deadSopenharmony_ci    primitive point size after clamping to the implementation-defined maximum
2055bd8deadSopenharmony_ci    point size as described in section 13.3. For line primitives, size is the
2065bd8deadSopenharmony_ci    line width, after rounding and clamping as described in section 13.4.2.1.
2075bd8deadSopenharmony_ci    For triangle primitives, size is zero.
2085bd8deadSopenharmony_ci
2095bd8deadSopenharmony_ci    During rasterization, the rasterizer will generate fragments with
2105bd8deadSopenharmony_ci    window coordinates inside the windows space bounding volume, but may or may
2115bd8deadSopenharmony_ci    not generate fragments with window coordinates outside the bounding volume.
2125bd8deadSopenharmony_ci
2135bd8deadSopenharmony_ci
2145bd8deadSopenharmony_ciDependencies on OES_tessellation_shader and EXT_tessellation_shader
2155bd8deadSopenharmony_ci
2165bd8deadSopenharmony_ci    If OES_tessellation_shader, EXT_tessellation_shader or equivalent
2175bd8deadSopenharmony_ci    functionality is not supported, ignore all references to the
2185bd8deadSopenharmony_ci    gl_BoundingBoxOES[] built-in per-patch variable in tessellation control and
2195bd8deadSopenharmony_ci    evaluation shaders, and remove references to the tessellation primitive
2205bd8deadSopenharmony_ci    generator.
2215bd8deadSopenharmony_ci
2225bd8deadSopenharmony_ciDependencies on OES_geometry_shader and EXT_geometry_shader
2235bd8deadSopenharmony_ci
2245bd8deadSopenharmony_ci    If OES_geometry_shader, EXT_geometry_shader or equivalent functionality is
2255bd8deadSopenharmony_ci    not supported, remove all references to geometry shaders.
2265bd8deadSopenharmony_ci    OES_tessellation_shader requires OES_geometry_shader, if OES_geometry_shader
2275bd8deadSopenharmony_ci    is not supported there is probably no benefit to supporting this extension.
2285bd8deadSopenharmony_ci
2295bd8deadSopenharmony_ciNew State
2305bd8deadSopenharmony_ci
2315bd8deadSopenharmony_ci    Add to state values in Table 6.5, Transformation State:
2325bd8deadSopenharmony_ci
2335bd8deadSopenharmony_ci                                                  Default
2345bd8deadSopenharmony_ci    Get Value                  Type  Get Command  Value        Description       Sec.
2355bd8deadSopenharmony_ci    -------------------------- ----  -----------  ------------ ----------------- --------
2365bd8deadSopenharmony_ci    PRIMITIVE_BOUNDING_BOX_OES 8xR   GetFloatv    -1,-1,-1, 1, Default primitive 13.1pbb
2375bd8deadSopenharmony_ci                                                   1, 1, 1, 1  bounding box
2385bd8deadSopenharmony_ci
2395bd8deadSopenharmony_ci
2405bd8deadSopenharmony_ciAdditions to the OpenGL ES Shading Language 3.10 Specification
2415bd8deadSopenharmony_ci
2425bd8deadSopenharmony_ci    Including the following line in a shader can be used to control the
2435bd8deadSopenharmony_ci    language features described in this extension:
2445bd8deadSopenharmony_ci
2455bd8deadSopenharmony_ci      #extension GL_OES_primitive_bounding_box : <behavior>
2465bd8deadSopenharmony_ci
2475bd8deadSopenharmony_ci    where <behavior> is as specified in section 3.4.
2485bd8deadSopenharmony_ci
2495bd8deadSopenharmony_ci    A new preprocessor #define is added to the OpenGL ES Shading Language:
2505bd8deadSopenharmony_ci
2515bd8deadSopenharmony_ci      #define GL_OES_primitive_bounding_box 1
2525bd8deadSopenharmony_ci
2535bd8deadSopenharmony_ci
2545bd8deadSopenharmony_ci    Modify subsection 7.1ts1 "Tessellation Control Special Variables" as added
2555bd8deadSopenharmony_ci    by OES_tessellation_shader:
2565bd8deadSopenharmony_ci
2575bd8deadSopenharmony_ci    Add a new built-in variable intrinsic declaration after the
2585bd8deadSopenharmony_ci    gl_TessLevelOuter and gl_TessLevelInner declarations:
2595bd8deadSopenharmony_ci
2605bd8deadSopenharmony_ci      patch out highp vec4 gl_BoundingBoxOES[2];
2615bd8deadSopenharmony_ci
2625bd8deadSopenharmony_ci    Add the following paragraph to subsection 7.1ts1.2 "Tessellation Control
2635bd8deadSopenharmony_ci    Output Variables" as added by OES_tessellation_shader, after the paragraph
2645bd8deadSopenharmony_ci    describing gl_TessLevelOuter and gl_TessLevelInner:
2655bd8deadSopenharmony_ci
2665bd8deadSopenharmony_ci      The values written to gl_BoundingBoxOES specify the minimum and maximum
2675bd8deadSopenharmony_ci      clip-space extents of a bounding box containing all primitives generated
2685bd8deadSopenharmony_ci      from the patch by the primitive generator, geometry shader, and clipping.
2695bd8deadSopenharmony_ci      Fragments may or may not be generated for portions of these primitives
2705bd8deadSopenharmony_ci      that extend outside the window-coordinate projection of this bounding
2715bd8deadSopenharmony_ci      box.
2725bd8deadSopenharmony_ci
2735bd8deadSopenharmony_ci
2745bd8deadSopenharmony_ciDependencies on the OpenGL ES 3.20 Shading Language Specification
2755bd8deadSopenharmony_ci
2765bd8deadSopenharmony_ci    If GL_OES_primitive_bounding_box is enabled in an OpenGL ES 3.20 shader,
2775bd8deadSopenharmony_ci    gl_BoundingBoxOES is an alias for gl_BoundingBox: the last value written
2785bd8deadSopenharmony_ci    to either variable will be used for bounding box optimizations and for
2795bd8deadSopenharmony_ci    reads from both variables.
2805bd8deadSopenharmony_ci
2815bd8deadSopenharmony_ci
2825bd8deadSopenharmony_ciIssues
2835bd8deadSopenharmony_ci
2845bd8deadSopenharmony_ci    (1) What coordinate space should the bounding box be specified in?
2855bd8deadSopenharmony_ci
2865bd8deadSopenharmony_ci    RESOLVED: The bounding box is specified in clip coordinates.
2875bd8deadSopenharmony_ci
2885bd8deadSopenharmony_ci    Using clip coordinates is consistent with vertex positions, allowing apps
2895bd8deadSopenharmony_ci    to use the same transformations. Another option was NDC, but NDC is not
2905bd8deadSopenharmony_ci    used directly by application or shader code anywhere else in the API, and
2915bd8deadSopenharmony_ci    many developers are unfamiliar with it. Using clip coordinates gives
2925bd8deadSopenharmony_ci    implementations the maximum amount of flexibility in how they implement the
2935bd8deadSopenharmony_ci    subsequent transforms and bounding box test.
2945bd8deadSopenharmony_ci
2955bd8deadSopenharmony_ci    (2) Should the bounds be 3D or 2D? The goal of optimizing tiling
2965bd8deadSopenharmony_ci    architectures only appears to need 2D.
2975bd8deadSopenharmony_ci
2985bd8deadSopenharmony_ci    RESOLVED: The bounds are 3D. Depth bounds could be useful for culling
2995bd8deadSopenharmony_ci    patches prior to primitive generation if all the generated primitives would
3005bd8deadSopenharmony_ci    fail the depth test.
3015bd8deadSopenharmony_ci
3025bd8deadSopenharmony_ci    (3) With the bounding box in clip coordinates, what happens when w <= 0?
3035bd8deadSopenharmony_ci
3045bd8deadSopenharmony_ci    RESOLVED: Clip the bounding box against the w > 0 plane.
3055bd8deadSopenharmony_ci
3065bd8deadSopenharmony_ci    This effectively pushes the front face of the bounding box forward until it
3075bd8deadSopenharmony_ci    is just in front of the camera. It is relatively simple in that no new
3085bd8deadSopenharmony_ci    vertices will be introduced and no connectivity will change.
3095bd8deadSopenharmony_ci
3105bd8deadSopenharmony_ci    Note that, as with Issue #5, since false-positives are allowed, an
3115bd8deadSopenharmony_ci    implementation may be able to avoid this clipping altogether. As an extreme
3125bd8deadSopenharmony_ci    example, if either min or max w is <= 0, the implementation could disable
3135bd8deadSopenharmony_ci    bounding box optimizations.
3145bd8deadSopenharmony_ci
3155bd8deadSopenharmony_ci    (4) What happens if a primitive extends outside the bounding box? Is
3165bd8deadSopenharmony_ci    behavior undefined for the whole primitive, or only for the portions outside
3175bd8deadSopenharmony_ci    the bounds? What restrictions can we place on the undefined behavior?
3185bd8deadSopenharmony_ci
3195bd8deadSopenharmony_ci    RESOLVED: In the interest of limiting the scope of undefined behavior as
3205bd8deadSopenharmony_ci    much as possible without requiring precise clipping or scissoring, specify
3215bd8deadSopenharmony_ci    that portions of the primitive inside the bounding box generate fragments
3225bd8deadSopenharmony_ci    normally, and that the rasterizer may or may not generate fragments for
3235bd8deadSopenharmony_ci    portions of the primitive outside the bounding box.
3245bd8deadSopenharmony_ci
3255bd8deadSopenharmony_ci    (5) What space should the bounding box test happen in, and how should it
3265bd8deadSopenharmony_ci    be specified?
3275bd8deadSopenharmony_ci
3285bd8deadSopenharmony_ci    RESOLVED: The proposed resolution to Issue #4 is that fragments outside the
3295bd8deadSopenharmony_ci    bounds may or may not be generated. That makes window space the most natural
3305bd8deadSopenharmony_ci    place to specify the test. If that issue were resolved differently,
3315bd8deadSopenharmony_ci    specifying the bounds test in NDC space might have been simpler and more
3325bd8deadSopenharmony_ci    natural.
3335bd8deadSopenharmony_ci
3345bd8deadSopenharmony_ci    In practice, implementations will probably do the test conservatively at an
3355bd8deadSopenharmony_ci    earlier stage than rasterization.  Because false-positives are allowed,
3365bd8deadSopenharmony_ci    implementations have a lot of flexibility in where and how precisely they
3375bd8deadSopenharmony_ci    perform the test, so the primary requirement for this spec is to provide
3385bd8deadSopenharmony_ci    useful and understandable guarantees about what parts of the primitive
3395bd8deadSopenharmony_ci    definitely will be rendered.
3405bd8deadSopenharmony_ci
3415bd8deadSopenharmony_ci    (6) Should the bounding box test apply even when tessellation isn't active?
3425bd8deadSopenharmony_ci
3435bd8deadSopenharmony_ci    RESOLVED: Yes. Having it apply in VS+GS+FS pipelines is useful to allow
3445bd8deadSopenharmony_ci    implementations to run the GS after binning, since like tessellation it can
3455bd8deadSopenharmony_ci    greatly magnify the amount of geometry. Unlike tessellation, because the
3465bd8deadSopenharmony_ci    expansion happens in the geometry shader, there isn't a natural way for the
3475bd8deadSopenharmony_ci    geometry shader itself to specify the bounding box for its own output
3485bd8deadSopenharmony_ci    primitives.
3495bd8deadSopenharmony_ci
3505bd8deadSopenharmony_ci    Because the bounding box is no longer a tessellation-specific feature, it
3515bd8deadSopenharmony_ci    is now a separate extension from OES_tessellation_shader.
3525bd8deadSopenharmony_ci
3535bd8deadSopenharmony_ci    (7) What should the initial value of the bounding box state be?
3545bd8deadSopenharmony_ci
3555bd8deadSopenharmony_ci    RESOLVED: The initial value is {(-1,-1,-1,1), (1,1,1,1)}. This corresponds
3565bd8deadSopenharmony_ci    to the entire view frustum, so by default the bounding box test won't reject
3575bd8deadSopenharmony_ci    any fragments that would otherwise have been drawn.
3585bd8deadSopenharmony_ci
3595bd8deadSopenharmony_ci    Another proposed option was to use positive and negative infinity values;
3605bd8deadSopenharmony_ci    that has no benefits over positive and negative one, and infinity values can
3615bd8deadSopenharmony_ci    be hard to generate in C code if an application wanted to return to the
3625bd8deadSopenharmony_ci    initial state.
3635bd8deadSopenharmony_ci
3645bd8deadSopenharmony_ci    (8) Do we really need a 16-vertex bounding volume? Do we need the vertices
3655bd8deadSopenharmony_ci    with (minZ, maxW) or (maxZ, minW)?
3665bd8deadSopenharmony_ci
3675bd8deadSopenharmony_ci    RESOLVED: Specify 16 vertices for generality.  Implementations may be able
3685bd8deadSopenharmony_ci    to avoid forming or transforming all of them explicitly.
3695bd8deadSopenharmony_ci
3705bd8deadSopenharmony_ci    With standard orthographic (w==1) or perspective projections (such as those
3715bd8deadSopenharmony_ci    produced by glFrustum) and "normal" vertices, an eight-vertex bounding
3725bd8deadSopenharmony_ci    volume is sufficient because of the restricted relationships between z_c and
3735bd8deadSopenharmony_ci    w_c.  However, OpenGL ES does not require this restricted relationship, and
3745bd8deadSopenharmony_ci    in the general case all 16 vertices are needed. It's possible that
3755bd8deadSopenharmony_ci    applications attempting to bloat the bounding box to account for
3765bd8deadSopenharmony_ci    displacement mapping, gl_FragDepth modifications, etc. may break the
3775bd8deadSopenharmony_ci    standard relationship and require all 16 vertices.
3785bd8deadSopenharmony_ci
3795bd8deadSopenharmony_ci    (9) Do we need a way to bloat the bounding volume in window space to account
3805bd8deadSopenharmony_ci    for things like point size, line width, etc.? Applying this bloat in clip
3815bd8deadSopenharmony_ci    space may be difficult or overly conservative.
3825bd8deadSopenharmony_ci
3835bd8deadSopenharmony_ci    RESOLVED: Automatically expand the bounding volume in window space by the
3845bd8deadSopenharmony_ci    point size or line width.
3855bd8deadSopenharmony_ci
3865bd8deadSopenharmony_ci    Another option considered was to add state for the application to specify a
3875bd8deadSopenharmony_ci    window-space expansion. This would impose an extra burden on the application
3885bd8deadSopenharmony_ci    to update the state to match line width or maximum point size being
3895bd8deadSopenharmony_ci    rendered, and strongly constrains implementations.
3905bd8deadSopenharmony_ci
3915bd8deadSopenharmony_ci    (10) Should the TES be able to read gl_BoundingBoxOES[]?
3925bd8deadSopenharmony_ci
3935bd8deadSopenharmony_ci    RESOLVED: No. The bounding box is consumed by the primitive generator.
3945bd8deadSopenharmony_ci
3955bd8deadSopenharmony_ci    Being able to read gl_BoundingBoxOES[] in the TES doesn't seem particularly
3965bd8deadSopenharmony_ci    useful. It raises the question of what value it gets when the TCS doesn't
3975bd8deadSopenharmony_ci    write the bounding box (undefined, or the PRIMITIVE_BOUNDING_BOX_OES
3985bd8deadSopenharmony_ci    state?), and whether the TES is required to declare it when the TCS and TES
3995bd8deadSopenharmony_ci    are in different program objects. More importantly, reading the bounding box
4005bd8deadSopenharmony_ci    in the TES may impose surprising costs on some implementations where it is
4015bd8deadSopenharmony_ci    consumed by the fixed-function primitive generation stage.
4025bd8deadSopenharmony_ci
4035bd8deadSopenharmony_ci
4045bd8deadSopenharmony_ciRevision History
4055bd8deadSopenharmony_ci
4065bd8deadSopenharmony_ci    Rev.    Date      Author    Changes
4075bd8deadSopenharmony_ci    ----  ----------  --------- -------------------------------------------------
4085bd8deadSopenharmony_ci     3    02/13/2018  jessehall Added a description of gl_BoundingBoxOES to the
4095bd8deadSopenharmony_ci                                shading language specification.
4105bd8deadSopenharmony_ci
4115bd8deadSopenharmony_ci     2    09/07/2016  jessehall Added interaction with the OpenGL ES 3.20 Shading
4125bd8deadSopenharmony_ci                                Language.
4135bd8deadSopenharmony_ci
4145bd8deadSopenharmony_ci     1    07/14/2014  dkoch     Initial OES version based on EXT.
4155bd8deadSopenharmony_ci                                No functional changes.
416