15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci EXT_post_depth_coverage 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_EXT_post_depth_coverage 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Jeff Bolz, NVIDIA Corporation (jbolz 'at' nvidia.com) 125bd8deadSopenharmony_ci Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com) 135bd8deadSopenharmony_ci 145bd8deadSopenharmony_ciContributors 155bd8deadSopenharmony_ci 165bd8deadSopenharmony_ci Jeff Bolz, NVIDIA 175bd8deadSopenharmony_ci Pat Brown, NVIDIA 185bd8deadSopenharmony_ci James Helferty, NVIDIA 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ciStatus 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ci Shipping 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ciVersion 255bd8deadSopenharmony_ci 265bd8deadSopenharmony_ci Last Modified Date: March 27, 2015 275bd8deadSopenharmony_ci Revision: 2 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ciNumber 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ci OpenGL Extension #461 325bd8deadSopenharmony_ci OpenGL ES Extension #225 335bd8deadSopenharmony_ci 345bd8deadSopenharmony_ciDependencies 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ci This extension is written against the OpenGL 4.3 specification 375bd8deadSopenharmony_ci (Compatibility Profile). 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ci This extension is written against version 4.30 of the OpenGL 405bd8deadSopenharmony_ci Shading Language Specification. 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ci This extension interacts with NV_fragment_program4. 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci This extension interacts with OpenGL ES 3.1 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ci If implemented in OpenGL ES 3.1, OES_sample_variables (providing 475bd8deadSopenharmony_ci gl_SampleMaskIn) is required. 485bd8deadSopenharmony_ci 495bd8deadSopenharmony_ciOverview 505bd8deadSopenharmony_ci 515bd8deadSopenharmony_ci This extension allows the fragment shader to control whether values in 525bd8deadSopenharmony_ci gl_SampleMaskIn[] reflect the coverage after application of the early 535bd8deadSopenharmony_ci depth and stencil tests. This feature can be enabled with the following 545bd8deadSopenharmony_ci layout qualifier in the fragment shader: 555bd8deadSopenharmony_ci 565bd8deadSopenharmony_ci layout(post_depth_coverage) in; 575bd8deadSopenharmony_ci 585bd8deadSopenharmony_ci To use this feature, early fragment tests must also be enabled in the 595bd8deadSopenharmony_ci fragment shader via: 605bd8deadSopenharmony_ci 615bd8deadSopenharmony_ci layout(early_fragment_tests) in; 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ciNew Procedures and Functions 645bd8deadSopenharmony_ci 655bd8deadSopenharmony_ci None. 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ciNew Tokens 685bd8deadSopenharmony_ci 695bd8deadSopenharmony_ci None. 705bd8deadSopenharmony_ci 715bd8deadSopenharmony_ciAdditions to Chapter 15 of the OpenGL 4.3 (Compatibility Profile) Specification 725bd8deadSopenharmony_ci(Rasterization) 735bd8deadSopenharmony_ci 745bd8deadSopenharmony_ci Modify Section 15.1 Fragment Shader Variables, p. 508 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ci (modify the third paragraph on p. 509) 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ci ...When interpolating variables declared using "centroid in", the variable 795bd8deadSopenharmony_ci is sampled at a location within the pixel covered by the primitive 805bd8deadSopenharmony_ci generating the fragment. The fragment shader layout qualifier 815bd8deadSopenharmony_ci "post_depth_coverage" (Section 15.2.2) does not affect the determination of the 825bd8deadSopenharmony_ci centroid location. 835bd8deadSopenharmony_ci 845bd8deadSopenharmony_ci Modify Section 15.2.2 Shader Inputs, p. 511 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ci (modify the first paragraph on p. 513) 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ci ...Bit <n> of element <w> in the array is set if and only if the sample 895bd8deadSopenharmony_ci numbered <32w + n> is considered covered for this fragment shader 905bd8deadSopenharmony_ci invocation. If the fragment shader specifies the "early_fragment_tests" and 915bd8deadSopenharmony_ci "post_depth_coverage" layout qualifiers, then the sample is considered covered 925bd8deadSopenharmony_ci if and only if the sample is covered by the primitive and the sample passes 935bd8deadSopenharmony_ci the early fragment tests (as described in Section 15.2.4). If these layout 945bd8deadSopenharmony_ci qualifiers are not specified, then the sample is considered covered if the 955bd8deadSopenharmony_ci sample is covered by the primitive, regardless of the result of the 965bd8deadSopenharmony_ci fragment tests. ... 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ciNew Implementation Dependent State 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ci None. 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ciNew State 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci None. 1065bd8deadSopenharmony_ci 1075bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 1085bd8deadSopenharmony_ci 1095bd8deadSopenharmony_ci None. 1105bd8deadSopenharmony_ci 1115bd8deadSopenharmony_ciGLX Protocol 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ci None. 1145bd8deadSopenharmony_ci 1155bd8deadSopenharmony_ciModifications to the OpenGL Shading Language Specification, Version 4.30 1165bd8deadSopenharmony_ci 1175bd8deadSopenharmony_ci Including the following line in a shader can be used to control the 1185bd8deadSopenharmony_ci language features described in this extension: 1195bd8deadSopenharmony_ci 1205bd8deadSopenharmony_ci #extension GL_EXT_post_depth_coverage : <behavior> 1215bd8deadSopenharmony_ci 1225bd8deadSopenharmony_ci where <behavior> is as specified in section 3.3. 1235bd8deadSopenharmony_ci 1245bd8deadSopenharmony_ci New preprocessor #defines are added to the OpenGL Shading Language: 1255bd8deadSopenharmony_ci 1265bd8deadSopenharmony_ci #define GL_EXT_post_depth_coverage 1 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ci 1295bd8deadSopenharmony_ci Modify Section 4.4.1.3 Fragment Shader Inputs (p. 58) 1305bd8deadSopenharmony_ci 1315bd8deadSopenharmony_ci (replace the discussion of early_fragment_tests on p. 59) 1325bd8deadSopenharmony_ci 1335bd8deadSopenharmony_ci Fragment shaders also allow the following layout qualifiers on "in" only (not 1345bd8deadSopenharmony_ci with variable declarations) 1355bd8deadSopenharmony_ci 1365bd8deadSopenharmony_ci layout-qualifier-id 1375bd8deadSopenharmony_ci early_fragment_tests 1385bd8deadSopenharmony_ci post_depth_coverage 1395bd8deadSopenharmony_ci 1405bd8deadSopenharmony_ci For example, 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci layout(early_fragment_tests) in; 1435bd8deadSopenharmony_ci layout(post_depth_coverage) in; 1445bd8deadSopenharmony_ci 1455bd8deadSopenharmony_ci "early_fragment_tests" requests that fragment tests be performed before 1465bd8deadSopenharmony_ci fragment shader execution, as described in section 15.2.4 "Early Fragment 1475bd8deadSopenharmony_ci Tests" of the OpenGL Specification. If this is not declared, per-fragment 1485bd8deadSopenharmony_ci tests will be performed after fragment shader execution. 1495bd8deadSopenharmony_ci "post_depth_coverage" requests that the built-in "gl_SampleMaskIn[]" will 1505bd8deadSopenharmony_ci reflect the result of the early fragment tests, as described in section 1515bd8deadSopenharmony_ci 15.2.2 "Shader Inputs" of the OpenGL Specification. 1525bd8deadSopenharmony_ci 1535bd8deadSopenharmony_ci Only one fragment shader (compilation unit) need declare these, though 1545bd8deadSopenharmony_ci more than one can. If at least one fragment shader declares one of these, 1555bd8deadSopenharmony_ci then it is enabled. If any fragment shader declares "post_depth_coverage" 1565bd8deadSopenharmony_ci and none declare "early_fragment_tests", a link-time error will occur. 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ci 1595bd8deadSopenharmony_ciDependencies on NV_fragment_program4 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci Modify Section 2.X.6.Y of the NV_fragment_program4 specification 1625bd8deadSopenharmony_ci 1635bd8deadSopenharmony_ci (add new option section) 1645bd8deadSopenharmony_ci 1655bd8deadSopenharmony_ci + Post-depth Coverage (EXT_post_depth_coverage) 1665bd8deadSopenharmony_ci 1675bd8deadSopenharmony_ci If a fragment program specifies the "EXT_post_depth_coverage" option, the 1685bd8deadSopenharmony_ci sample mask will reflect the result of the early fragment tests, as 1695bd8deadSopenharmony_ci described in Section 15.2.2 "Shader Inputs". If a fragment program 1705bd8deadSopenharmony_ci specifies the EXT_post_depth_coverage option and not the 1715bd8deadSopenharmony_ci NV_early_fragment_tests option, it will fail to compile. 1725bd8deadSopenharmony_ci 1735bd8deadSopenharmony_ci 1745bd8deadSopenharmony_ciInteractions with OpenGL ES 3.1 1755bd8deadSopenharmony_ci 1765bd8deadSopenharmony_ci If OpenGL ES 3.1 is supported, edits similar to those above are applied to 1775bd8deadSopenharmony_ci OpenGL ES 3.1 and GLSL ES 3.10 specifications. 1785bd8deadSopenharmony_ci 1795bd8deadSopenharmony_ci Modify the edits under "Fragment Shader Inputs" as follows: 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ci Add the following to the paragraph discussing behavior when 1825bd8deadSopenharmony_ci "early_fragment_tests" is enabled to reflect a pre-existing error not 1835bd8deadSopenharmony_ci shared with GLSL 4.30: 1845bd8deadSopenharmony_ci 1855bd8deadSopenharmony_ci It is an error to statically write to gl_FragDepth in the fragment 1865bd8deadSopenharmony_ci shader. 1875bd8deadSopenharmony_ci 1885bd8deadSopenharmony_ci Change the paragraph beginning "Only one fragment shader (compilation unit) 1895bd8deadSopenharmony_ci need declare..." to the following, since GLSL ES 3.10 does not support 1905bd8deadSopenharmony_ci linking multiple shaders of the same type: 1915bd8deadSopenharmony_ci 1925bd8deadSopenharmony_ci If a fragment shader declares "post_depth_coverage" and doesn't declare 1935bd8deadSopenharmony_ci "early_fragment_tests", a link-time error will occur. 1945bd8deadSopenharmony_ci 1955bd8deadSopenharmony_ciErrors 1965bd8deadSopenharmony_ci 1975bd8deadSopenharmony_ci None. 1985bd8deadSopenharmony_ci 1995bd8deadSopenharmony_ciIssues 2005bd8deadSopenharmony_ci 2015bd8deadSopenharmony_ci (1) Should the determination of a fragment's centroid use the pre-depth or 2025bd8deadSopenharmony_ci post-depth coverage? 2035bd8deadSopenharmony_ci 2045bd8deadSopenharmony_ci RESOLVED: In this extension, it uses the pre-depth coverage. This way the 2055bd8deadSopenharmony_ci centroid location (and hence the result of shading) does not depend on the 2065bd8deadSopenharmony_ci rendering order, which is almost certainly the desired result for 3D 2075bd8deadSopenharmony_ci rendering. 2085bd8deadSopenharmony_ci 2095bd8deadSopenharmony_ci For path rendering, it would be desirable to use post-depth centroid since 2105bd8deadSopenharmony_ci the stencil test really determines whether samples are inside the primitive 2115bd8deadSopenharmony_ci rather than whether samples are "occluded," and guaranteeing attributes 2125bd8deadSopenharmony_ci are sampled inside the path would be nice. 2135bd8deadSopenharmony_ci 2145bd8deadSopenharmony_ciRevision History 2155bd8deadSopenharmony_ci 2165bd8deadSopenharmony_ci Revision 2, 2015/03/27 2175bd8deadSopenharmony_ci - Add ES interactions 2185bd8deadSopenharmony_ci 2195bd8deadSopenharmony_ci Revision 1, September 12, 2014 (jbolz, pbrown, jhelferty) 2205bd8deadSopenharmony_ci 2215bd8deadSopenharmony_ci Internal spec development. 222