15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    INTEL_conservative_rasterization
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_INTEL_conservative_rasterization
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Slawomir Grajewski, Intel Corporation (slawomir.grajewski 'at' intel.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciContributors
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Petrik Clarberg, Intel Corporation
165bd8deadSopenharmony_ci    Jon Kennedy, Intel Corporation
175bd8deadSopenharmony_ci    Slawomir Cygan, Intel Corporation
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ciStatus
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ci    Draft.
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ciVersion
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ci    Last Modified Date:         11/2/2016
265bd8deadSopenharmony_ci    Intel Revision:             2
275bd8deadSopenharmony_ci
285bd8deadSopenharmony_ciNumber
295bd8deadSopenharmony_ci
305bd8deadSopenharmony_ci    OpenGL Extension #491
315bd8deadSopenharmony_ci    OpenGL ES Extension #265
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ciDependencies
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ci    This extension is written against the OpenGL 4.5 (Core Profile)
365bd8deadSopenharmony_ci    Specification (May 28, 2015)
375bd8deadSopenharmony_ci
385bd8deadSopenharmony_ci    This extension is written against Version 4.50.5 of the OpenGL Shading
395bd8deadSopenharmony_ci    Language Specification.
405bd8deadSopenharmony_ci
415bd8deadSopenharmony_ci    OpenGL 4.2 and GLSL 4.2 are required.
425bd8deadSopenharmony_ci
435bd8deadSopenharmony_ci    This extension is written against the OpenGL ES 3.2 Specification
445bd8deadSopenharmony_ci    (August 10, 2015)
455bd8deadSopenharmony_ci
465bd8deadSopenharmony_ci    This extension is written against Version 3.20.2 of the OpenGL ES Shading
475bd8deadSopenharmony_ci    Language Specification (August 6, 2015)
485bd8deadSopenharmony_ci
495bd8deadSopenharmony_ci    This extension interacts with ARB_post_depth_coverage.
505bd8deadSopenharmony_ci
515bd8deadSopenharmony_ciOverview
525bd8deadSopenharmony_ci
535bd8deadSopenharmony_ci    Regular rasterization includes fragments with at least one
545bd8deadSopenharmony_ci    sample covered by a polygon. Conservative rasterization includes all
555bd8deadSopenharmony_ci    fragments that are at least partially covered by the polygon.
565bd8deadSopenharmony_ci
575bd8deadSopenharmony_ci    In some use cases, it is also important to know if a fragment is fully
585bd8deadSopenharmony_ci    covered by a polygon, i.e. if all parts of the fragment are within the
595bd8deadSopenharmony_ci    polygon. An application may, for example, want to process fully covered
605bd8deadSopenharmony_ci    fragments different from the "edge" pixels. This extension adds an option
615bd8deadSopenharmony_ci    for the fragment shader to receive this information via gl_SampleMaskIn[].
625bd8deadSopenharmony_ci
635bd8deadSopenharmony_ci    This extension affects only polygons in FILL mode and specifically does not
645bd8deadSopenharmony_ci    imply any changes in processing of lines or points.
655bd8deadSopenharmony_ci
665bd8deadSopenharmony_ci    Conservative rasterization automatically disables polygon antialiasing
675bd8deadSopenharmony_ci    rasterization if enabled by POLYGON_SMOOTH.
685bd8deadSopenharmony_ci
695bd8deadSopenharmony_ciNew Procedures and Functions
705bd8deadSopenharmony_ci
715bd8deadSopenharmony_ci    None.
725bd8deadSopenharmony_ci
735bd8deadSopenharmony_ciNew Tokens
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ci    Accepted by the <target> parameter of Enable, Disable, IsEnabled:
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ci        CONSERVATIVE_RASTERIZATION_INTEL  0x83FE
785bd8deadSopenharmony_ci
795bd8deadSopenharmony_ciAdditions to Chapter 14.6, Polygons of the OpenGL 4.5 Specification
805bd8deadSopenharmony_ci
815bd8deadSopenharmony_ci    Modify Section 14.6.1, Basic Polygon Rasterization
825bd8deadSopenharmony_ci
835bd8deadSopenharmony_ci    (insert before the paragraph starting with "As for the data associated...")
845bd8deadSopenharmony_ci
855bd8deadSopenharmony_ci    The determination of which fragments are produced by polygon rasterization
865bd8deadSopenharmony_ci    can be modified by the conservative rasterization option (as described in
875bd8deadSopenharmony_ci    section 14.6.4).
885bd8deadSopenharmony_ci
895bd8deadSopenharmony_ci    Modify Section 14.6.3, Antialiasing
905bd8deadSopenharmony_ci
915bd8deadSopenharmony_ci    (add a new paragraph to the end of the section)
925bd8deadSopenharmony_ci
935bd8deadSopenharmony_ci    Conservative rasterization automatically disables polygon antialiasing
945bd8deadSopenharmony_ci    rasterization if enabled by POLYGON_SMOOTH.
955bd8deadSopenharmony_ci
965bd8deadSopenharmony_ci    Modify Section 14.6.4, Options Controlling Polygon Rasterization
975bd8deadSopenharmony_ci
985bd8deadSopenharmony_ci    (add a new paragraph to the end of the section)
995bd8deadSopenharmony_ci
1005bd8deadSopenharmony_ci    The determination of which fragments are produced as a result of polygon
1015bd8deadSopenharmony_ci    rasterization in FILL state can be modified by enabling the conservative
1025bd8deadSopenharmony_ci    rasterization option. Conservative rasterization is enabled or disabled
1035bd8deadSopenharmony_ci    with the generic Enable and Disable commands using the symbolic constant
1045bd8deadSopenharmony_ci    CONSERVATIVE_RASTERIZATION_INTEL. When disabled, the fragments are
1055bd8deadSopenharmony_ci    determined as described in section 14.6.1. When enabled the polygon
1065bd8deadSopenharmony_ci    rasterization produces all fragments for which any part of their squares
1075bd8deadSopenharmony_ci    are inside the polygon, after expanding the polygon by 1/512th of a pixel
1085bd8deadSopenharmony_ci    in both x and y dimensions. Polygons with an area of zero do generate
1095bd8deadSopenharmony_ci    fragments.
1105bd8deadSopenharmony_ci
1115bd8deadSopenharmony_ci    The conservative rasterization option applies only to polygons with
1125bd8deadSopenharmony_ci    PolygonMode state set to FILL. Draw requests for polygons with different
1135bd8deadSopenharmony_ci    PolygonMode setting or for other primitive types (points/lines) generate
1145bd8deadSopenharmony_ci    INVALID_OPERATION error.
1155bd8deadSopenharmony_ci
1165bd8deadSopenharmony_ci    Modify Section 14.6.6, Polygon Multisample Rasterization
1175bd8deadSopenharmony_ci
1185bd8deadSopenharmony_ci    (modify the first paragraph)
1195bd8deadSopenharmony_ci
1205bd8deadSopenharmony_ci    If MULTISAMPLE is enabled, and the value of SAMPLE_BUFFERS is one, then
1215bd8deadSopenharmony_ci    polygons are rasterized using the following algorithm, regardless of
1225bd8deadSopenharmony_ci    whether polygon antialiasing (POLYGON_SMOOTH) is enabled or disabled. When
1235bd8deadSopenharmony_ci    conservative rasterization is disabled as described in section 14.6.4,
1245bd8deadSopenharmony_ci    polygon rasterization produces a fragment for each framebuffer pixel with
1255bd8deadSopenharmony_ci    one or more sample points that satisfy the point sampling criteria
1265bd8deadSopenharmony_ci    described in section 14.6.1. When conservative rasterization is
1275bd8deadSopenharmony_ci    enabled, polygon rasterization produces exactly the same fragments as with
1285bd8deadSopenharmony_ci    MULTISAMPLE disabled and the value of SAMPLE_BUFFERS set to zero. If a
1295bd8deadSopenharmony_ci    polygon is culled, based on its orientation and the CullFace mode, then no
1305bd8deadSopenharmony_ci    fragments are produced during rasterization. When conservative
1315bd8deadSopenharmony_ci    rasterization is disabled, coverage bits that correspond to sample points
1325bd8deadSopenharmony_ci    that satisfy the point sampling criteria are 1, other coverage bits are
1335bd8deadSopenharmony_ci    0. When conservative rasterization is enabled all sample coverage bits for
1345bd8deadSopenharmony_ci    fragments produced by rasterization are 1, other coverage bits are 0.
1355bd8deadSopenharmony_ci
1365bd8deadSopenharmony_ciAdditions to Chapter 15.2.2, Shader Inputs of the OpenGL 4.5 Specification
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci    (replace the sentence starting with "Bit<n> of element<w> in the array...")
1395bd8deadSopenharmony_ci
1405bd8deadSopenharmony_ci    Bit <n> of element <w> in the array is set if and only if the sample
1415bd8deadSopenharmony_ci    numbered <32w + n> is considered covered for this fragment shader
1425bd8deadSopenharmony_ci    invocation. If the fragment shader specifies the "early_fragment_tests" and
1435bd8deadSopenharmony_ci    "post_depth_coverage" layout qualifiers, then the sample is considered
1445bd8deadSopenharmony_ci    covered if and only if the sample is covered by the primitive and the
1455bd8deadSopenharmony_ci    sample passes the early fragment tests (as described in Section 15.2.4). If
1465bd8deadSopenharmony_ci    these layout qualifiers are not specified, then the sample is considered
1475bd8deadSopenharmony_ci    covered if the sample is covered by the primitive, regardless of the result
1485bd8deadSopenharmony_ci    of the fragment tests. If the fragment shader specifies the
1495bd8deadSopenharmony_ci    "inner_coverage" layout qualifier the sample is considered covered only if
1505bd8deadSopenharmony_ci    the sample is covered by the primitive and passes the inner coverage
1515bd8deadSopenharmony_ci    test. Layout qualifier "inner_coverage" is in effect only if conservative
1525bd8deadSopenharmony_ci    is enabled and is mutually exclusive with "post_depth_coverage".
1535bd8deadSopenharmony_ci
1545bd8deadSopenharmony_ci    During the conservative rasterization process (section 14.6.4) for the
1555bd8deadSopenharmony_ci    purpose of the inner coverage test the determination is made if the
1565bd8deadSopenharmony_ci    fragment is entirely contained within the polygon. This determination is
1575bd8deadSopenharmony_ci    made by shrinking the polygon by 1/512th of pixel along the x and y
1585bd8deadSopenharmony_ci    dimensions. The result of the inner coverage test is available in
1595bd8deadSopenharmony_ci    gl_SampleMaskIn if "inner_coverage" layout qualifier is present.
1605bd8deadSopenharmony_ci
1615bd8deadSopenharmony_ci    (replace the paragraph starting with "When per-sample shading is active due
1625bd8deadSopenharmony_ci    to the use of a fragment input qualified...")
1635bd8deadSopenharmony_ci
1645bd8deadSopenharmony_ci    In the case of per-sample shading the information delivered via
1655bd8deadSopenharmony_ci    gl_SampleMaskIn depends on the conservative rasterization state and
1665bd8deadSopenharmony_ci    possibly on the layout qualifier. Regardless of the conservative
1675bd8deadSopenharmony_ci    rasterization state, samples killed due to SAMPLE_COVERAGE or SAMPLE_MASK
1685bd8deadSopenharmony_ci    are never reported in gl_SampleMaskIn regardless of the qualifier.
1695bd8deadSopenharmony_ci
1705bd8deadSopenharmony_ci    With conservative rasterization disabled, when per-sample shading is active
1715bd8deadSopenharmony_ci    due to the use of a fragment input qualified by sample or due to the use of
1725bd8deadSopenharmony_ci    the gl_SampleID or gl_SamplePosition variables, only the bit for the
1735bd8deadSopenharmony_ci    current sample is set in gl_SampleMaskIn. When state specifies multiple
1745bd8deadSopenharmony_ci    fragment shader invocations for a given fragment, the sample mask for any
1755bd8deadSopenharmony_ci    single fragment shader invocation may specify a subset of the covered
1765bd8deadSopenharmony_ci    samples for the fragment. In this case, the bit corresponding to each
1775bd8deadSopenharmony_ci    covered sample will be set in exactly one fragment shader invocation.
1785bd8deadSopenharmony_ci
1795bd8deadSopenharmony_ci    With conservative rasterization enabled, regardless of whether per-sample
1805bd8deadSopenharmony_ci    shading is active due to fragment input qualified by sample or by state,
1815bd8deadSopenharmony_ci    the meaning of the gl_SampleMaskIn depends on layout qualifier and is the
1825bd8deadSopenharmony_ci    same for both per-sample triggering conditions. Moreover as a consequence
1835bd8deadSopenharmony_ci    of rasterization rules described in section 14.6.6, when conservative
1845bd8deadSopenharmony_ci    rasterization is enabled and MULITISAMPLE is enabled and the value of
1855bd8deadSopenharmony_ci    SAMPLE_BUFFERS is one, either all samples of a given fragment are covered,
1865bd8deadSopenharmony_ci    or none.
1875bd8deadSopenharmony_ci
1885bd8deadSopenharmony_ci    * No layout qualifier present:
1895bd8deadSopenharmony_ci      The sample mask for any single fragment shader invocation specifies all
1905bd8deadSopenharmony_ci      samples covered by a conservatively rasterized fragment.
1915bd8deadSopenharmony_ci
1925bd8deadSopenharmony_ci    * Layout qualifier "inner_coverage":
1935bd8deadSopenharmony_ci      The sample mask for any single fragment shader invocation specifies all
1945bd8deadSopenharmony_ci      samples covered by a conservatively rasterized fragment that passed inner
1955bd8deadSopenharmony_ci      coverage test.
1965bd8deadSopenharmony_ci
1975bd8deadSopenharmony_ci    * Layout qualifier "post_depth_coverage":
1985bd8deadSopenharmony_ci      The sample mask for any single fragment shader invocation specifies all
1995bd8deadSopenharmony_ci      samples covered by a conservatively rasterized fragment that passed early
2005bd8deadSopenharmony_ci      depth/stencil tests if enforced by early_fragment_tests layout qualifier
2015bd8deadSopenharmony_ci      as described in section 15.2.4.
2025bd8deadSopenharmony_ci
2035bd8deadSopenharmony_ci    If MULTISAMPLE is enabled and the value of SAMPLE_BUFFERS is one, and per
2045bd8deadSopenharmony_ci    sample shading is not active, the meaning of gl_SampleMaskIn[] and its
2055bd8deadSopenharmony_ci    modifications due to layout qualifier are exactly the same as described
2065bd8deadSopenharmony_ci    above.
2075bd8deadSopenharmony_ci
2085bd8deadSopenharmony_ciAdditions to the OpenGL Shading Language Specification, version 4.50.5
2095bd8deadSopenharmony_ci
2105bd8deadSopenharmony_ci    Including the following line in a shader can be used to control the
2115bd8deadSopenharmony_ci    language features described in this extension:
2125bd8deadSopenharmony_ci
2135bd8deadSopenharmony_ci      #extension GL_INTEL_conservative_rasterization : <behavior>
2145bd8deadSopenharmony_ci
2155bd8deadSopenharmony_ci    where <behavior> is as specified in section 3.3.
2165bd8deadSopenharmony_ci
2175bd8deadSopenharmony_ci    A new preprocessor #define is added to the OpenGL Shading Language:
2185bd8deadSopenharmony_ci
2195bd8deadSopenharmony_ci      #define GL_INTEL_conservative_rasterization 1
2205bd8deadSopenharmony_ci
2215bd8deadSopenharmony_ci    Modify section 4.4.1.3, Fragment Shader Inputs
2225bd8deadSopenharmony_ci
2235bd8deadSopenharmony_ci    (replace the discussion of early_fragment_tests)
2245bd8deadSopenharmony_ci
2255bd8deadSopenharmony_ci    Fragment shaders also allow the following layout qualifiers on "in" only (not
2265bd8deadSopenharmony_ci    with variable declarations)
2275bd8deadSopenharmony_ci
2285bd8deadSopenharmony_ci        layout-qualifier-id
2295bd8deadSopenharmony_ci            early_fragment_tests
2305bd8deadSopenharmony_ci            post_depth_coverage
2315bd8deadSopenharmony_ci            inner_coverage
2325bd8deadSopenharmony_ci
2335bd8deadSopenharmony_ci    For example,
2345bd8deadSopenharmony_ci
2355bd8deadSopenharmony_ci        layout(early_fragment_tests) in;
2365bd8deadSopenharmony_ci        layout(post_depth_coverage) in;
2375bd8deadSopenharmony_ci        layout(inner_coverage) in;
2385bd8deadSopenharmony_ci
2395bd8deadSopenharmony_ci    "early_fragment_tests" requests that fragment tests be performed before
2405bd8deadSopenharmony_ci    fragment shader execution, as described in section 15.2.4 "Early Fragment
2415bd8deadSopenharmony_ci    Tests" of the OpenGL Specification. If neither this nor post_depth_coverage
2425bd8deadSopenharmony_ci    are declared, per-fragment tests will be performed after fragment shader
2435bd8deadSopenharmony_ci    execution.
2445bd8deadSopenharmony_ci
2455bd8deadSopenharmony_ci    "post_depth_coverage" requests that the built-in "gl_SampleMaskIn[]" will
2465bd8deadSopenharmony_ci    reflect the result of the early fragment tests, as described in section
2475bd8deadSopenharmony_ci    15.2.2 "Shader Inputs" of the OpenGL Specification. Use of this
2485bd8deadSopenharmony_ci    qualifier implicitly requests that fragment tests be performed before
2495bd8deadSopenharmony_ci    fragment shader execution.
2505bd8deadSopenharmony_ci
2515bd8deadSopenharmony_ci    "inner_coverage" requests that the built-in "gl_SampleMaskIn[]" will
2525bd8deadSopenharmony_ci    reflect the result of the inner coverage test as described in section
2535bd8deadSopenharmony_ci    15.2.2 "Shader Inputs" of the OpenGL Specification. It has an effect on
2545bd8deadSopenharmony_ci    "gl_SampleMaskIn[]" only if conservative rasterization is enabled.
2555bd8deadSopenharmony_ci
2565bd8deadSopenharmony_ci    "post_depth_coverage" and "inner_coverage" are mutually
2575bd8deadSopenharmony_ci    exclusive. Declaring both for fragment shader will result in compile or
2585bd8deadSopenharmony_ci    link error.
2595bd8deadSopenharmony_ci
2605bd8deadSopenharmony_ci    Only one fragment shader (compilation unit) need declare these, though
2615bd8deadSopenharmony_ci    more than one can. If at least one fragment shader declares one of these,
2625bd8deadSopenharmony_ci    then it is enabled.
2635bd8deadSopenharmony_ci
2645bd8deadSopenharmony_ciAdditions to Chapter 13.7, Polygons of the OpenGL ES 3.2 Specification
2655bd8deadSopenharmony_ci
2665bd8deadSopenharmony_ci    Modify Section 13.7.1, Basic Polygon Rasterization
2675bd8deadSopenharmony_ci
2685bd8deadSopenharmony_ci    (insert before the paragraph starting with "As for the data associated...")
2695bd8deadSopenharmony_ci
2705bd8deadSopenharmony_ci    The determination of which fragments are produced by polygon rasterization
2715bd8deadSopenharmony_ci    can be modified by the conservative rasterization option (as described in
2725bd8deadSopenharmony_ci    section 13.7.1).
2735bd8deadSopenharmony_ci
2745bd8deadSopenharmony_ci    Modify Section 13.7.1, Basic Polygon Rasterization
2755bd8deadSopenharmony_ci
2765bd8deadSopenharmony_ci    (add at the end)
2775bd8deadSopenharmony_ci
2785bd8deadSopenharmony_ci    The determination of which fragments are produced as a result of polygon
2795bd8deadSopenharmony_ci    rasterization can be modified by enabling the conservative rasterization
2805bd8deadSopenharmony_ci    option. Conservative rasterization is enabled or disabled with the generic
2815bd8deadSopenharmony_ci    Enable and Disable commands using the symbolic constant
2825bd8deadSopenharmony_ci    CONSERVATIVE_RASTERIZATION_INTEL. When disabled, the fragments are
2835bd8deadSopenharmony_ci    determined as described in this section. When enabled the polygon
2845bd8deadSopenharmony_ci    rasterization produces all fragments for which any part of their squares
2855bd8deadSopenharmony_ci    are inside the polygon, after expanding the polygon by 1/512th of pixel in
2865bd8deadSopenharmony_ci    both x and y dimensions. Polygons with an area of zero do generate
2875bd8deadSopenharmony_ci    fragments.
2885bd8deadSopenharmony_ci
2895bd8deadSopenharmony_ci    The conservative rasterization option applies only to polygons. Draw
2905bd8deadSopenharmony_ci    requests for other primitive types (points/lines) generate
2915bd8deadSopenharmony_ci    INVALID_OPERATION error.
2925bd8deadSopenharmony_ci
2935bd8deadSopenharmony_ci    Modify Section 13.7.3, Polygon Multisample Rasterization
2945bd8deadSopenharmony_ci
2955bd8deadSopenharmony_ci    (modify the first paragraph)
2965bd8deadSopenharmony_ci
2975bd8deadSopenharmony_ci    If the value of SAMPLE_BUFFERS is one, then polygons are rasterized using
2985bd8deadSopenharmony_ci    the following algorithm. When conservative rasterization is disabled,
2995bd8deadSopenharmony_ci    polygon rasterization produces a fragment for each framebuffer pixel with
3005bd8deadSopenharmony_ci    one or more sample points that satisfy the point sampling criteria
3015bd8deadSopenharmony_ci    described in section 13.7.1. If a polygon is culled, based on its
3025bd8deadSopenharmony_ci    orientation and the CullFace mode, then no fragments are produced during
3035bd8deadSopenharmony_ci    rasterization.
3045bd8deadSopenharmony_ci
3055bd8deadSopenharmony_ci    If conservative rasterization is enabled, polygon rasterization produces
3065bd8deadSopenharmony_ci    exactly the same fragments as with the value of SAMPLE_BUFFERS set to
3075bd8deadSopenharmony_ci    zero. Also, all sample coverage bits for fragments produced by
3085bd8deadSopenharmony_ci    rasterization are 1, other coverage bits are 0. If a polygon is culled,
3095bd8deadSopenharmony_ci    based on its orientation and the CullFace mode, then no fragments are
3105bd8deadSopenharmony_ci    produced during rasterization.
3115bd8deadSopenharmony_ci
3125bd8deadSopenharmony_ci
3135bd8deadSopenharmony_ciAdditions to Chapter 14.2.2, Shader Inputs of the OpenGL ES 3.2 Specification
3145bd8deadSopenharmony_ci
3155bd8deadSopenharmony_ci    (replace the sentence starting with "Bit<n> of element<w> in the array...")
3165bd8deadSopenharmony_ci
3175bd8deadSopenharmony_ci    Bit <n> of element <w> in the array is set if and only if the sample
3185bd8deadSopenharmony_ci    numbered <32w + n> is considered covered for this fragment shader
3195bd8deadSopenharmony_ci    invocation. If the fragment shader specifies the "early_fragment_tests" and
3205bd8deadSopenharmony_ci    "post_depth_coverage" layout qualifiers, then the sample is considered
3215bd8deadSopenharmony_ci    covered if and only if the sample is covered by the primitive and the
3225bd8deadSopenharmony_ci    sample passes the early fragment tests (as described in Section 15.2.4). If
3235bd8deadSopenharmony_ci    these layout qualifiers are not specified, then the sample is considered
3245bd8deadSopenharmony_ci    covered if the sample is covered by the primitive, regardless of the result
3255bd8deadSopenharmony_ci    of the fragment tests. If the fragment shader specifies the
3265bd8deadSopenharmony_ci    "inner_coverage" layout qualifier the sample is considered covered only if
3275bd8deadSopenharmony_ci    the sample is covered by the primitive and passes the inner coverage
3285bd8deadSopenharmony_ci    test. Layout qualifier "inner_coverage" is in effect only if conservative
3295bd8deadSopenharmony_ci    is enabled and is mutually exclusive with "post_depth_coverage".
3305bd8deadSopenharmony_ci
3315bd8deadSopenharmony_ci    During the conservative rasterization process (section 13.7.2) for the
3325bd8deadSopenharmony_ci    purpose of the inner coverage test the determination is made if the
3335bd8deadSopenharmony_ci    fragment is entirely contained within the polygon. This determination is
3345bd8deadSopenharmony_ci    made by shrinking the polygon by 1/512th of pixel along the x and y
3355bd8deadSopenharmony_ci    dimensions. The result of the inner coverage test is available in
3365bd8deadSopenharmony_ci    gl_SampleMaskIn if "inner_coverage" layout qualifier is present.
3375bd8deadSopenharmony_ci
3385bd8deadSopenharmony_ci    (replace the paragraph starting with "When per-sample shading is active due
3395bd8deadSopenharmony_ci    to the use of a fragment input qualified...")
3405bd8deadSopenharmony_ci
3415bd8deadSopenharmony_ci    In the case of per-sample shading the information delivered via
3425bd8deadSopenharmony_ci    gl_SampleMaskIn depends on the conservative rasterization state and
3435bd8deadSopenharmony_ci    possibly on the layout qualifier. Regardless of the conservative
3445bd8deadSopenharmony_ci    rasterization state, samples killed due to SAMPLE_COVERAGE or SAMPLE_MASK
3455bd8deadSopenharmony_ci    are never reported in gl_SampleMaskIn regardless of the qualifier.
3465bd8deadSopenharmony_ci
3475bd8deadSopenharmony_ci    With conservative rasterization disabled, when per-sample shading is active
3485bd8deadSopenharmony_ci    due to the use of a fragment input qualified by sample or due to the use of
3495bd8deadSopenharmony_ci    the gl_SampleID or gl_SamplePosition variables, only the bit for the
3505bd8deadSopenharmony_ci    current sample is set in gl_SampleMaskIn. When state specifies multiple
3515bd8deadSopenharmony_ci    fragment shader invocations for a given fragment, the sample mask for any
3525bd8deadSopenharmony_ci    single fragment shader invocation may specify a subset of the covered
3535bd8deadSopenharmony_ci    samples for the fragment. In this case, the bit corresponding to each
3545bd8deadSopenharmony_ci    covered sample will be set in exactly one fragment shader invocation.
3555bd8deadSopenharmony_ci
3565bd8deadSopenharmony_ci    With conservative rasterization enabled, regardless of whether per-sample
3575bd8deadSopenharmony_ci    shading is active due to fragment input qualified by sample or by state,
3585bd8deadSopenharmony_ci    the meaning of the gl_SampleMaskIn depends on layout qualifier and is the
3595bd8deadSopenharmony_ci    same for both per-sample triggering conditions. Moreover as a consequence
3605bd8deadSopenharmony_ci    of rasterization rules described in section 13.7.3, when conservative
3615bd8deadSopenharmony_ci    rasterization is enabled and MULITISAMPLE is enabled and the value of
3625bd8deadSopenharmony_ci    SAMPLE_BUFFERS is one, either all samples of a given fragment are covered, or
3635bd8deadSopenharmony_ci    none.
3645bd8deadSopenharmony_ci
3655bd8deadSopenharmony_ci    * No layout qualifier present:
3665bd8deadSopenharmony_ci      The sample mask for any single fragment shader invocation specifies all
3675bd8deadSopenharmony_ci      samples covered by a conservatively rasterized fragment.
3685bd8deadSopenharmony_ci
3695bd8deadSopenharmony_ci    * Layout qualifier "inner_coverage":
3705bd8deadSopenharmony_ci      The sample mask for any single fragment shader invocation specifies all
3715bd8deadSopenharmony_ci      samples covered by a conservatively rasterized fragment that passed inner
3725bd8deadSopenharmony_ci      coverage test.
3735bd8deadSopenharmony_ci
3745bd8deadSopenharmony_ci    * Layout qualifier "post_depth_coverage":
3755bd8deadSopenharmony_ci      The sample mask for any single fragment shader invocation specifies all
3765bd8deadSopenharmony_ci      samples covered by a conservatively rasterized fragment that passed early
3775bd8deadSopenharmony_ci      depth/stencil tests if enforced by early_fragment_tests layout qualifier.
3785bd8deadSopenharmony_ci
3795bd8deadSopenharmony_ci    If the value of SAMPLE_BUFFERS is one, and per sample shading is not
3805bd8deadSopenharmony_ci    active, the meaning of gl_SampleMaskIn[] and its modifications due to
3815bd8deadSopenharmony_ci    layout qualifier are exactly the same as described above.
3825bd8deadSopenharmony_ci
3835bd8deadSopenharmony_ci
3845bd8deadSopenharmony_ciAdditions to the OpenGL ES Shading Language Specification, version 3.20.2
3855bd8deadSopenharmony_ci
3865bd8deadSopenharmony_ci    Including the following line in a shader can be used to control the
3875bd8deadSopenharmony_ci    language features described in this extension:
3885bd8deadSopenharmony_ci
3895bd8deadSopenharmony_ci      #extension GL_INTEL_conservative_rasterization : <behavior>
3905bd8deadSopenharmony_ci
3915bd8deadSopenharmony_ci    where <behavior> is as specified in section 3.3.
3925bd8deadSopenharmony_ci
3935bd8deadSopenharmony_ci    A new preprocessor #define is added to the OpenGL Shading Language:
3945bd8deadSopenharmony_ci
3955bd8deadSopenharmony_ci      #define GL_INTEL_conservative_rasterization 1
3965bd8deadSopenharmony_ci
3975bd8deadSopenharmony_ci    Modify section 4.4.1.3, Fragment Shader Inputs
3985bd8deadSopenharmony_ci
3995bd8deadSopenharmony_ci    (replace the discussion of early_fragment_tests)
4005bd8deadSopenharmony_ci
4015bd8deadSopenharmony_ci    Fragment shaders also allow the following layout qualifiers on "in" only (not
4025bd8deadSopenharmony_ci    with variable declarations)
4035bd8deadSopenharmony_ci
4045bd8deadSopenharmony_ci        layout-qualifier-id
4055bd8deadSopenharmony_ci            early_fragment_tests
4065bd8deadSopenharmony_ci            post_depth_coverage
4075bd8deadSopenharmony_ci            inner_coverage
4085bd8deadSopenharmony_ci
4095bd8deadSopenharmony_ci    For example,
4105bd8deadSopenharmony_ci
4115bd8deadSopenharmony_ci        layout(early_fragment_tests) in;
4125bd8deadSopenharmony_ci        layout(post_depth_coverage) in;
4135bd8deadSopenharmony_ci        layout(inner_coverage) in;
4145bd8deadSopenharmony_ci
4155bd8deadSopenharmony_ci    "early_fragment_tests" requests that fragment tests be performed before
4165bd8deadSopenharmony_ci    fragment shader execution, as described in section 13.8 "Early Fragment
4175bd8deadSopenharmony_ci    Tests" of the OpenGL ES Specification. If neither this nor post_depth_coverage
4185bd8deadSopenharmony_ci    are declared, per-fragment tests will be performed after fragment shader
4195bd8deadSopenharmony_ci    execution.
4205bd8deadSopenharmony_ci
4215bd8deadSopenharmony_ci    "post_depth_coverage" requests that the built-in "gl_SampleMaskIn[]" will
4225bd8deadSopenharmony_ci    reflect the result of the early fragment tests, as described in section
4235bd8deadSopenharmony_ci    14.2.2 "Shader Inputs" of the OpenGL ES 3.2 Specification. Use of this
4245bd8deadSopenharmony_ci    qualifier implicitly requests that fragment tests be performed before
4255bd8deadSopenharmony_ci    fragment shader execution.
4265bd8deadSopenharmony_ci
4275bd8deadSopenharmony_ci    "inner_coverage" requests that the built-in
4285bd8deadSopenharmony_ci    "gl_SampleMaskIn[]" will reflect the result of the inner coverage test
4295bd8deadSopenharmony_ci    as described in section 14.2.2 "Shader Inputs" of the OpenGL ES 3.2
4305bd8deadSopenharmony_ci    Specification. It has an effect on "gl_SampleMaskIn[]" only if conservative
4315bd8deadSopenharmony_ci    rasterization is enabled.
4325bd8deadSopenharmony_ci
4335bd8deadSopenharmony_ci    "post_depth_coverage" and "inner_coverage" are mutually
4345bd8deadSopenharmony_ci    exclusive. Declaring both for a fragment shader will result in compile or
4355bd8deadSopenharmony_ci    link error.
4365bd8deadSopenharmony_ci
4375bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications
4385bd8deadSopenharmony_ci
4395bd8deadSopenharmony_ci    None.
4405bd8deadSopenharmony_ci
4415bd8deadSopenharmony_ciGLX Protocol
4425bd8deadSopenharmony_ci
4435bd8deadSopenharmony_ci    None.
4445bd8deadSopenharmony_ci
4455bd8deadSopenharmony_ciInteractions with ARB_post_depth_coverage
4465bd8deadSopenharmony_ci
4475bd8deadSopenharmony_ci    This extension is a fully compatible superset of ARB_post_depth_coverage
4485bd8deadSopenharmony_ci    extension. Implementations supporting INTEL_conservative_rasterization may
4495bd8deadSopenharmony_ci    or may not advertise ARB_post_depth_coverage without any changes in
4505bd8deadSopenharmony_ci    functionality.
4515bd8deadSopenharmony_ci
4525bd8deadSopenharmony_ciErrors
4535bd8deadSopenharmony_ci
4545bd8deadSopenharmony_ci    None.
4555bd8deadSopenharmony_ci
4565bd8deadSopenharmony_ciNew State in OpenGL 4.5 Core Profile
4575bd8deadSopenharmony_ci
4585bd8deadSopenharmony_ci    (add new row to the Table 23.10, Rasterization (cont.)
4595bd8deadSopenharmony_ci
4605bd8deadSopenharmony_ci                                     Initial
4615bd8deadSopenharmony_ci    Get Value      Type  Get Command  Value  Description                 Sec.
4625bd8deadSopenharmony_ci    -------------  ----  ----------- ------- -------------------------   ------
4635bd8deadSopenharmony_ci    CONSERVATIVE_  B     IsEnabled()  FALSE  Conservative Rasterization  14.6.4
4645bd8deadSopenharmony_ci    RASTERIZATION_                           setting
4655bd8deadSopenharmony_ci    INTEL
4665bd8deadSopenharmony_ci
4675bd8deadSopenharmony_ciNew State in OpenGL ES 3.2
4685bd8deadSopenharmony_ci
4695bd8deadSopenharmony_ci    (add new row to the Table 21.7, Rasterization)
4705bd8deadSopenharmony_ci
4715bd8deadSopenharmony_ci                                     Initial
4725bd8deadSopenharmony_ci    Get Value      Type  Get Command  Value  Description                 Sec.
4735bd8deadSopenharmony_ci    -------------  ----  ----------- ------- -------------------------   ------
4745bd8deadSopenharmony_ci    CONSERVATIVE_  B     IsEnabled()  FALSE  Conservative Rasterization  3.6
4755bd8deadSopenharmony_ci    RASTERIZATION_                           setting
4765bd8deadSopenharmony_ci    INTEL
4775bd8deadSopenharmony_ci
4785bd8deadSopenharmony_ciIssues
4795bd8deadSopenharmony_ci
4805bd8deadSopenharmony_ci    (1) Why in per-sample shading case, when conservative rasterization is
4815bd8deadSopenharmony_ci        disabled, each sample is reported exactly once in gl_SampleMaskIn
4825bd8deadSopenharmony_ci        across all invocations of fragment shader for given fragment, while
4835bd8deadSopenharmony_ci        when conservative rasterization is enabled, all eligible samples from
4845bd8deadSopenharmony_ci        the given fragment are reported for each fragment shader invocation for
4855bd8deadSopenharmony_ci        this fragment?
4865bd8deadSopenharmony_ci
4875bd8deadSopenharmony_ci        Resolved. The former behavior is enforced by existing OpenGL
4885bd8deadSopenharmony_ci        spec. The latter, provided by this extension, gives more information to
4895bd8deadSopenharmony_ci        the user about neighboring samples. In the extended version, the
4905bd8deadSopenharmony_ci        information about current sample can be obtained in the
4915bd8deadSopenharmony_ci        gl_SampleMaskIn[] as indicated by gl_SampleID.
4925bd8deadSopenharmony_ci
4935bd8deadSopenharmony_ci
4945bd8deadSopenharmony_ciRevision History
4955bd8deadSopenharmony_ci
4965bd8deadSopenharmony_ci    Rev.     Date       Author       Changes
4975bd8deadSopenharmony_ci    ----  ----------  ----------  -----------------------------------------
4985bd8deadSopenharmony_ci      2    11/2/2016  sgrajewski  Updated to OpenGL 4.5 and OpenGL ES 3.2.
4995bd8deadSopenharmony_ci                                  Aligned with ARB_post_dept_coverage extension.
5005bd8deadSopenharmony_ci
5015bd8deadSopenharmony_ci      1    10/1/2013  sgrajewski  Initial revision.
502