15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    EXT_frag_depth
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_EXT_frag_depth
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Maurice Ribble
125bd8deadSopenharmony_ci    Robert Simpson
135bd8deadSopenharmony_ci    Jeff Leger
145bd8deadSopenharmony_ci    Bruce Merry
155bd8deadSopenharmony_ci    Acorn Pooley
165bd8deadSopenharmony_ci
175bd8deadSopenharmony_ciContact
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ci    Maurice Ribble (mribble 'at' qualcomm.com)
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ciNotice
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ci    None
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ciStatus
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ci    Draft
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ciVersion
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ci    Date: July 21, 2010
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ciNumber
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ci    OpenGL ES Extension #86
365bd8deadSopenharmony_ci
375bd8deadSopenharmony_ciDependencies
385bd8deadSopenharmony_ci
395bd8deadSopenharmony_ci    OpenGL ES 2.0 is required.
405bd8deadSopenharmony_ci    
415bd8deadSopenharmony_ci    This extension is written against the OpenGL ES 2.0 specification, and
425bd8deadSopenharmony_ci    the OpenGL ES Shading Language 1.0.17 specification.
435bd8deadSopenharmony_ci    
445bd8deadSopenharmony_ci    OES_fragment_precision_high affects the definitions of this extension.
455bd8deadSopenharmony_ci
465bd8deadSopenharmony_ciOverview
475bd8deadSopenharmony_ci
485bd8deadSopenharmony_ci    This extension adds the ability to set the depth value of a fragment from
495bd8deadSopenharmony_ci    within the fragment shader.  Then this per-fragment depth value is used
505bd8deadSopenharmony_ci    for depth testing.  This extension adds a built-in GLSL fragment shader 
515bd8deadSopenharmony_ci    special varible to set the depth value.
525bd8deadSopenharmony_ci    
535bd8deadSopenharmony_ci    Much graphics hardware has the ability to do early depth testing before the
545bd8deadSopenharmony_ci    fragment shader.  On such hardware there may be a performance penality for
555bd8deadSopenharmony_ci    using this feature so use this feature only when needed.
565bd8deadSopenharmony_ci
575bd8deadSopenharmony_ciIssues
585bd8deadSopenharmony_ci
595bd8deadSopenharmony_ci    (1) Should the GLSL keyword be gl_FragDepth or gl_FragDepthEXT?
605bd8deadSopenharmony_ci    
615bd8deadSopenharmony_ci    RESOLVED: OpenGL has discussed this in the past and the agreement was that
625bd8deadSopenharmony_ci    we should use gl_FragDepthEXT.
635bd8deadSopenharmony_ci    
645bd8deadSopenharmony_ci    (2) What should the precission qualifier be for gl_FragDepthEXT?
655bd8deadSopenharmony_ci    
665bd8deadSopenharmony_ci    RESOLVED: If the OES_fragment_precision_high is supported then highp is
675bd8deadSopenharmony_ci    used, but if OES_fragment_precision_high not supported then mediump is 
685bd8deadSopenharmony_ci    used.
695bd8deadSopenharmony_ci
705bd8deadSopenharmony_ciNew Procedures and Functions
715bd8deadSopenharmony_ci
725bd8deadSopenharmony_ci    None
735bd8deadSopenharmony_ci
745bd8deadSopenharmony_ciNew Tokens
755bd8deadSopenharmony_ci
765bd8deadSopenharmony_ci    None
775bd8deadSopenharmony_ci
785bd8deadSopenharmony_ciNew Keywords
795bd8deadSopenharmony_ci
805bd8deadSopenharmony_ci    gl_FragDepthEXT
815bd8deadSopenharmony_ci
825bd8deadSopenharmony_ciNew Built-in Functions
835bd8deadSopenharmony_ci
845bd8deadSopenharmony_ci    None
855bd8deadSopenharmony_ci
865bd8deadSopenharmony_ciNew Macro Definitions
875bd8deadSopenharmony_ci
885bd8deadSopenharmony_ci    #define GL_EXT_frag_depth 1
895bd8deadSopenharmony_ci
905bd8deadSopenharmony_ciAdditions to Appendix A.3 Invariance Rules
915bd8deadSopenharmony_ci
925bd8deadSopenharmony_ci    Rule 4: All fragment shaders that either conditionally or unconditionally
935bd8deadSopenharmony_ci    assign gl_FragCoord.z to gl_FragDepthEXT are depth-invariant with respect
945bd8deadSopenharmony_ci    to each other, for those fragments where the assignment to gl_FragDepthEXT
955bd8deadSopenharmony_ci    actually is done.
965bd8deadSopenharmony_ci
975bd8deadSopenharmony_ciAdditions to Chapter 7 of the OpenGL ES Shading Language specification:
985bd8deadSopenharmony_ci
995bd8deadSopenharmony_ci    Make the following changes to section 7.2 (Fragment Shader Special 
1005bd8deadSopenharmony_ci    Varibles).
1015bd8deadSopenharmony_ci
1025bd8deadSopenharmony_ci    Replace the last sentence in the first paragraph with this:
1035bd8deadSopenharmony_ci
1045bd8deadSopenharmony_ci    "Fragment shaders output values to the OpenGL ES pipeline using the 
1055bd8deadSopenharmony_ci    built-in variables gl_FragColor, gl_FragData, and gl_FragDepthEXT, unless the
1065bd8deadSopenharmony_ci    discard keyword is executed."
1075bd8deadSopenharmony_ci    
1085bd8deadSopenharmony_ci    Add this between the first and second paragraphs:
1095bd8deadSopenharmony_ci    
1105bd8deadSopenharmony_ci    "The built-in varible gl_FragDepthEXT is optional, and must be enabled by
1115bd8deadSopenharmony_ci
1125bd8deadSopenharmony_ci    #extension GL_EXT_frag_depth : enable
1135bd8deadSopenharmony_ci
1145bd8deadSopenharmony_ci    before being used."
1155bd8deadSopenharmony_ci   
1165bd8deadSopenharmony_ci    Replace the first sentence in the second paragraph with this:
1175bd8deadSopenharmony_ci    
1185bd8deadSopenharmony_ci    "It is not a requirement for the fragment shader to write to gl_FragColor,
1195bd8deadSopenharmony_ci    gl_FragData, or gl_FragDepthEXT."
1205bd8deadSopenharmony_ci
1215bd8deadSopenharmony_ci    Add this paragraph after the paragraph that starts with "Writing to 
1225bd8deadSopenharmony_ci    gl_FragColor":
1235bd8deadSopenharmony_ci
1245bd8deadSopenharmony_ci    "Writing to gl_FragDepthEXT will establish the depth value for the fragment 
1255bd8deadSopenharmony_ci    being processed. If MSAA is enabled, the depth value is copied to all
1265bd8deadSopenharmony_ci    samples corresponding to the fragment. If depth buffering is enabled, and
1275bd8deadSopenharmony_ci    no shader writes gl_FragDepthEXT, then the fixed function value for depth 
1285bd8deadSopenharmony_ci    will be used as the fragment's depth value. If a shader statically assigns
1295bd8deadSopenharmony_ci    a value to gl_FragDepthEXT, and there is an execution path through the 
1305bd8deadSopenharmony_ci    shader that does not set gl_FragDepthEXT, then the value of the fragment's
1315bd8deadSopenharmony_ci    depth may be undefined for executions of the shader that take that path. 
1325bd8deadSopenharmony_ci    That is, if the set of linked fragment shaders statically contain a write 
1335bd8deadSopenharmony_ci    to gl_FragDepthEXT, then it is responsible for always writing it."
1345bd8deadSopenharmony_ci
1355bd8deadSopenharmony_ci    Replace the paragraph that starts with "If a shader executes the discard" 
1365bd8deadSopenharmony_ci    with this:
1375bd8deadSopenharmony_ci    
1385bd8deadSopenharmony_ci    "If a shader executes the discard keyword, the fragment is discarded, and
1395bd8deadSopenharmony_ci    the values of any user-defined fragment outputs, gl_FragDepthEXT, 
1405bd8deadSopenharmony_ci    gl_FragColor, and gl_FragData become irrelevant."
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ci    Replace the last sentence of the 9th paragraph with the following:
1435bd8deadSopenharmony_ci
1445bd8deadSopenharmony_ci    The z component is the depth value that would be used for the fragment's
1455bd8deadSopenharmony_ci    depth if the shader contained no writes to gl_FragDepthEXT.  This is useful
1465bd8deadSopenharmony_ci    for invariance if a shader conditionally computes gl_FragDepthEXT but 
1475bd8deadSopenharmony_ci    otherwise wants the fixed functionality fragment depth.
1485bd8deadSopenharmony_ci    
1495bd8deadSopenharmony_ci    Add this to the list of built-in varibles:
1505bd8deadSopenharmony_ci    
1515bd8deadSopenharmony_ci    If OES_fragment_precision_high is supported add this:
1525bd8deadSopenharmony_ci      "highp float gl_FragDepthEXT;"
1535bd8deadSopenharmony_ci    otherwise add this:
1545bd8deadSopenharmony_ci      "mediump float gl_FragDepthEXT;"
1555bd8deadSopenharmony_ci
1565bd8deadSopenharmony_ciNew State
1575bd8deadSopenharmony_ci
1585bd8deadSopenharmony_ci    None
1595bd8deadSopenharmony_ci
1605bd8deadSopenharmony_ciRevision History
1615bd8deadSopenharmony_ci
1625bd8deadSopenharmony_ci    6/14/2010  Created.
1635bd8deadSopenharmony_ci    6/14/2010  Added language to cover MSAA.
1645bd8deadSopenharmony_ci    6/15/2010  Fixed some typos.
1655bd8deadSopenharmony_ci    7/2/2010   Fixed issues from Bruce.
1665bd8deadSopenharmony_ci                Added wording to Appendix A.3.
1675bd8deadSopenharmony_ci                Added issues 1 and 2.
1685bd8deadSopenharmony_ci    7/8/2010   Changed from OES to EXT.
1695bd8deadSopenharmony_ci               Various updates from NV version of this extension.
1705bd8deadSopenharmony_ci    7/21/2010  Resolved issues 1 and 2.
1715bd8deadSopenharmony_ci                
172