15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    EXT_conservative_depth
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName String
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_EXT_conservative_depth
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Tobias Hector, Imagination Technologies (tobias.hector 'at' imgtec.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciContributors
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Contributors to the original ARB_conservative_depth
165bd8deadSopenharmony_ci    Ian Romanick
175bd8deadSopenharmony_ci    Daniel Koch
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ciStatus
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ci    Final
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ciVersion
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ci    Last Modified Date:         14/09/2016
265bd8deadSopenharmony_ci    Author Revision:            3
275bd8deadSopenharmony_ci
285bd8deadSopenharmony_ciNumber
295bd8deadSopenharmony_ci
305bd8deadSopenharmony_ci    OpenGL ES Extension #268
315bd8deadSopenharmony_ci
325bd8deadSopenharmony_ciDependencies
335bd8deadSopenharmony_ci
345bd8deadSopenharmony_ci    OpenGL ES 3.0 is required.
355bd8deadSopenharmony_ci
365bd8deadSopenharmony_ci    This extension is written against the OpenGL ES Shading Language Version 3.00.6
375bd8deadSopenharmony_ci
385bd8deadSopenharmony_ciOverview
395bd8deadSopenharmony_ci
405bd8deadSopenharmony_ci    There is a common optimization for hardware accelerated implementation of
415bd8deadSopenharmony_ci    OpenGL ES which relies on an early depth test to be run before the fragment
425bd8deadSopenharmony_ci    shader so that the shader evaluation can be skipped if the fragment ends
435bd8deadSopenharmony_ci    up being discarded because it is occluded.
445bd8deadSopenharmony_ci
455bd8deadSopenharmony_ci    This optimization does not affect the final rendering, and is typically
465bd8deadSopenharmony_ci    possible when the fragment does not change the depth programmatically.
475bd8deadSopenharmony_ci    (i.e.: it does not write to the built-in gl_FragDepth output). There are,
485bd8deadSopenharmony_ci    however a class of operations on the depth in the shader which could
495bd8deadSopenharmony_ci    still be performed while allowing the early depth test to operate.
505bd8deadSopenharmony_ci
515bd8deadSopenharmony_ci    This extension allows the application to pass enough information to the
525bd8deadSopenharmony_ci    GL implementation to activate such optimizations safely.
535bd8deadSopenharmony_ci
545bd8deadSopenharmony_ciNew Procedures and Functions
555bd8deadSopenharmony_ci
565bd8deadSopenharmony_ci    None.
575bd8deadSopenharmony_ci
585bd8deadSopenharmony_ciNew Tokens
595bd8deadSopenharmony_ci
605bd8deadSopenharmony_ci    None.
615bd8deadSopenharmony_ci
625bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL ES Shading Language 3.00.06 Specification (Basics)
635bd8deadSopenharmony_ci
645bd8deadSopenharmony_ci    Add a new Section 3.5.x, GL_EXT_conservative_depth Extension
655bd8deadSopenharmony_ci
665bd8deadSopenharmony_ci    Including the following line in a shader can be used to control the language
675bd8deadSopenharmony_ci    features described in this extension:
685bd8deadSopenharmony_ci
695bd8deadSopenharmony_ci        #extension GL_EXT_conservative_depth: <behavior>
705bd8deadSopenharmony_ci
715bd8deadSopenharmony_ci    where <behavior> is as described in section 3.5.
725bd8deadSopenharmony_ci
735bd8deadSopenharmony_ci    A new preprocessor #define is added to the OpenGL Shading Language:
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ci        #define GL_EXT_conservative_depth 1
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL Shading Language 3.00.06 Specification (Variables and Types)
785bd8deadSopenharmony_ci
795bd8deadSopenharmony_ci    Modify Section 4.3.8.2 (Output Layout Qualifiers) page 47
805bd8deadSopenharmony_ci
815bd8deadSopenharmony_ci    Modify the paragraph beginning: "Fragment shaders allow output layout
825bd8deadSopenharmony_ci    qualifiers only..."
835bd8deadSopenharmony_ci
845bd8deadSopenharmony_ci        Fragment shaders allow output layout qualifiers only on the interface
855bd8deadSopenharmony_ci        out, or for the purposes of redeclaring the built-in variable
865bd8deadSopenharmony_ci        gl_FragDepth (see Section 7.2, Fragment Shader Special Variables).
875bd8deadSopenharmony_ci
885bd8deadSopenharmony_ci    Insert the following at the end of the section:
895bd8deadSopenharmony_ci
905bd8deadSopenharmony_ci        The built-in fragment shader variable gl_FragDepth may be redeclared using
915bd8deadSopenharmony_ci        one of the following layout qualifiers.
925bd8deadSopenharmony_ci
935bd8deadSopenharmony_ci        layout-qualifier-id
945bd8deadSopenharmony_ci            depth_any
955bd8deadSopenharmony_ci            depth_greater
965bd8deadSopenharmony_ci            depth_less
975bd8deadSopenharmony_ci            depth_unchanged
985bd8deadSopenharmony_ci
995bd8deadSopenharmony_ci        For example:
1005bd8deadSopenharmony_ci
1015bd8deadSopenharmony_ci            layout (depth_greater) out float gl_FragDepth;
1025bd8deadSopenharmony_ci
1035bd8deadSopenharmony_ci        The layout qualifier for gl_FragDepth specifies constraints on the final
1045bd8deadSopenharmony_ci        value of gl_FragDepth written by any shader invocation.  GL implementations
1055bd8deadSopenharmony_ci        may perform optimizations assuming that the depth test fails (or passes)
1065bd8deadSopenharmony_ci        for a given fragment if all values of gl_FragDepth consistent with the layout
1075bd8deadSopenharmony_ci        qualifier would fail (or pass).  If the final value of gl_FragDepth
1085bd8deadSopenharmony_ci        is inconsistent with its layout qualifier, the result of the depth test for
1095bd8deadSopenharmony_ci        the corresponding fragment is undefined.  However, no error will be
1105bd8deadSopenharmony_ci        generated in this case.  When the depth test passes and depth writes are
1115bd8deadSopenharmony_ci        enabled, the value written to the depth buffer is always the value of
1125bd8deadSopenharmony_ci        gl_FragDepth, whether or not it is consistent with the layout qualifier.
1135bd8deadSopenharmony_ci
1145bd8deadSopenharmony_ci        By default, gl_FragDepth assumes the <depth_any> layout qualifier. When
1155bd8deadSopenharmony_ci        the layout qualifier for gl_FragDepth is <depth_any>, the shader compiler
1165bd8deadSopenharmony_ci        will note any assignment to gl_FragDepth modifying it in an unknown way,
1175bd8deadSopenharmony_ci        and depth testing will always be performed after the shader has executed.
1185bd8deadSopenharmony_ci        When the layout qualifier is "depth_greater", the GL will assume that the
1195bd8deadSopenharmony_ci        final value of gl_FragDepth is greater than or equal to the fragment's
1205bd8deadSopenharmony_ci        interpolated depth value, as given by the <z> component of gl_FragCoord.
1215bd8deadSopenharmony_ci        When the layout qualifier is <depth_less>, the GL will assume that any
1225bd8deadSopenharmony_ci        modification of gl_FragDepth will only decrease its value. When the
1235bd8deadSopenharmony_ci        layout qualifier is <depth_unchanged>, the shader compiler will honor
1245bd8deadSopenharmony_ci        any modification to gl_FragDepth, but the rest of the GL assume that
1255bd8deadSopenharmony_ci        gl_FragDepth is not assigned a new value.
1265bd8deadSopenharmony_ci
1275bd8deadSopenharmony_ci        Redeclarations of gl_FragDepth are performed as follows:
1285bd8deadSopenharmony_ci
1295bd8deadSopenharmony_ci            // redeclaration that changes nothing is allowed
1305bd8deadSopenharmony_ci
1315bd8deadSopenharmony_ci            out float gl_FragDepth;
1325bd8deadSopenharmony_ci
1335bd8deadSopenharmony_ci            // assume it may be modified in any way
1345bd8deadSopenharmony_ci            layout (depth_any) out float gl_FragDepth;
1355bd8deadSopenharmony_ci
1365bd8deadSopenharmony_ci            // assume it may be modified such that its value will only increase
1375bd8deadSopenharmony_ci            layout (depth_greater) out float gl_FragDepth;
1385bd8deadSopenharmony_ci
1395bd8deadSopenharmony_ci            // assume it may be modified such that its value will only decrease
1405bd8deadSopenharmony_ci            layout (depth_less) out float gl_FragDepth;
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ci            // assume it will not be modified
1435bd8deadSopenharmony_ci            layout (depth_unchanged) out float gl_FragDepth;
1445bd8deadSopenharmony_ci
1455bd8deadSopenharmony_ci        Within any shader, the first redeclarations of gl_FragDepth must appear
1465bd8deadSopenharmony_ci        before any use of gl_FragDepth. The built-in gl_FragDepth is only
1475bd8deadSopenharmony_ci        predeclared in fragment shaders, so redeclaring it in any other shader
1485bd8deadSopenharmony_ci        language will be illegal.
1495bd8deadSopenharmony_ci
1505bd8deadSopenharmony_ciRevision History
1515bd8deadSopenharmony_ci
1525bd8deadSopenharmony_ci    Rev.  Date        Author   Changes
1535bd8deadSopenharmony_ci    ----  ----------  -------  -------------------------------------------------
1545bd8deadSopenharmony_ci    1     08/09/2016  thector  Initial draft based on ARB_conservative_depth
1555bd8deadSopenharmony_ci    2     12/09/2016  thector  Converted to EXT as per feedback from Ian Romanick
1565bd8deadSopenharmony_ci    3     14/09/2016  thector  Removed reference to multiple fragment shaders as per Daniel Koch's feedback
157