1Name 2 3 ARB_post_depth_coverage 4 5Name Strings 6 7 GL_ARB_post_depth_coverage 8 9Contact 10 11 Piers Daniell, NVIDIA Corporation (pdaniell 'at' nvidia.com) 12 13Contributors 14 15 Jeff Bolz, NVIDIA 16 Pat Brown, NVIDIA 17 James Helferty, NVIDIA 18 Eric Werness, NVIDIA 19 20Notice 21 22 Copyright (c) 2015 The Khronos Group Inc. Copyright terms at 23 http://www.khronos.org/registry/speccopyright.html 24 25Specification Update Policy 26 27 Khronos-approved extension specifications are updated in response to 28 issues and bugs prioritized by the Khronos OpenGL Working Group. For 29 extensions which have been promoted to a core Specification, fixes will 30 first appear in the latest version of that core Specification, and will 31 eventually be backported to the extension document. This policy is 32 described in more detail at 33 https://www.khronos.org/registry/OpenGL/docs/update_policy.php 34 35Status 36 37 Complete. Approved by the ARB on June 26, 2015. 38 Ratified by the Khronos Board of Promoters on August 7, 2015. 39 40Version 41 42 Last Modified Date: June 25, 2015 43 Revision: 3 44 45Number 46 47 ARB Extension #180 48 49Dependencies 50 51 This extension is written against the OpenGL 4.5 specification 52 (Compatibility Profile). 53 54 This extension is written against version 4.50 of the OpenGL 55 Shading Language Specification. 56 57 This extension interacts with NV_fragment_program4. 58 59 This extension interacts with EXT_post_depth_coverage. 60 61Overview 62 63 This extension allows the fragment shader to control whether values in 64 gl_SampleMaskIn[] reflect the coverage after application of the early 65 depth and stencil tests. This feature can be enabled with the following 66 layout qualifier in the fragment shader: 67 68 layout(post_depth_coverage) in; 69 70 Use of this feature implicitly enables early fragment tests. 71 72New Procedures and Functions 73 74 None. 75 76New Tokens 77 78 None. 79 80Additions to Chapter 15 of the OpenGL 4.5 (Compatibility Profile) Specification 81(Rasterization) 82 83 Modify Section 15.1 Fragment Shader Variables, p. 558 84 85 (modify the third paragraph on p. 559) 86 87 ...When interpolating variables declared using "centroid in", the variable 88 is sampled at a location within the pixel covered by the primitive 89 generating the fragment. The fragment shader layout qualifier 90 "post_depth_coverage" (Section 15.2.2) does not affect the determination of the 91 centroid location. 92 93 Modify Section 15.2.2 Shader Inputs, p. 560 94 95 (modify the fourth paragraph on p. 562) 96 97 ...Bit <n> of element <w> in the array is set if and only if the sample 98 numbered <32w + n> is considered covered for this fragment shader 99 invocation. If the fragment shader specifies the "early_fragment_tests" and 100 "post_depth_coverage" layout qualifiers, then the sample is considered covered 101 if and only if the sample is covered by the primitive and the sample passes 102 the early fragment tests (as described in Section 15.2.4). If these layout 103 qualifiers are not specified, then the sample is considered covered if the 104 sample is covered by the primitive, regardless of the result of the 105 fragment tests. ... 106 107 108New Implementation Dependent State 109 110 None. 111 112New State 113 114 None. 115 116Additions to the AGL/GLX/WGL Specifications 117 118 None. 119 120GLX Protocol 121 122 None. 123 124Modifications to the OpenGL Shading Language Specification, Version 4.50 125 126 Including the following line in a shader can be used to control the 127 language features described in this extension: 128 129 #extension GL_ARB_post_depth_coverage : <behavior> 130 131 where <behavior> is as specified in section 3.3. 132 133 New preprocessor #defines are added to the OpenGL Shading Language: 134 135 #define GL_ARB_post_depth_coverage 1 136 137 138 Modify Section 4.4.1.3 Fragment Shader Inputs (p. 63) 139 140 (replace the discussion of early_fragment_tests on p. 64) 141 142 Fragment shaders also allow the following layout qualifiers on "in" only (not 143 with variable declarations) 144 145 layout-qualifier-id 146 early_fragment_tests 147 post_depth_coverage 148 149 For example, 150 151 layout(early_fragment_tests) in; 152 layout(post_depth_coverage) in; 153 154 "early_fragment_tests" requests that fragment tests be performed before 155 fragment shader execution, as described in section 15.2.4 "Early Fragment 156 Tests" of the OpenGL Specification. If neither this nor post_depth_coverage 157 are declared, per-fragment tests will be performed after fragment shader 158 execution. 159 160 "post_depth_coverage" requests that the built-in "gl_SampleMaskIn[]" will 161 reflect the result of the early fragment tests, as described in section 162 15.2.2 "Shader Inputs" of the OpenGL Specification. 163 164 Only one fragment shader (compilation unit) need declare these, though 165 more than one can. If at least one fragment shader declares one of these, 166 then it is enabled. 167 168 169Dependencies on NV_fragment_program4 170 171 Modify Section 2.X.6.Y of the NV_fragment_program4 specification 172 173 (add new option section) 174 175 + Post-depth Coverage (ARB_post_depth_coverage) 176 177 If a fragment program specifies the "ARB_post_depth_coverage" option, the 178 sample mask will reflect the result of the early fragment tests, as 179 described in Section 15.2.2 "Shader Inputs". If a fragment program 180 specifies the ARB_post_depth_coverage option and not the 181 NV_early_fragment_tests option, it will fail to compile. 182 183Dependencies on EXT_post_depth_coverage 184 185 If a shader enables both EXT_post_depth_coverage and ARB_post_depth_coverage 186 the behavior of layout(post_depth_coverage) will match 187 ARB_post_depth_coverage. 188 189Errors 190 191 None. 192 193Issues 194 195 (1) Should the determination of a fragment's centroid use the pre-depth or 196 post-depth coverage? 197 198 RESOLVED: In this extension, it uses the pre-depth coverage. This way the 199 centroid location (and hence the result of shading) does not depend on the 200 rendering order, which is almost certainly the desired result for 3D 201 rendering. 202 203 For path rendering, it would be desirable to use post-depth centroid since 204 the stencil test really determines whether samples are inside the primitive 205 rather than whether samples are "occluded," and guaranteeing attributes 206 are sampled inside the path would be nice. 207 208 (2) What happens if you write gl_FragDepth? What about side-effects? 209 210 RESOLVED: Because the post_depth_coverage option implies 211 early_fragment_tests, the behavior for these cases is inhereted from the 212 basic early_fragment_tests behavior, so writes to gl_FragDepth are ignored 213 and side effects are only executed on shaders that are executed which have 214 already passed the early fragment operations. 215 216Revision History 217 218 Revision 3, June 25, 2015 219 220 Add interaction between ARB_post_depth_coverage and 221 EXT_post_depth_coverage behaviors 222 223 Revision 2, April 29, 2015 224 225 Implicitly enable early_fragment_tests when post_depth_coverage 226 is enabled. Add a clarification issue. 227 228 Revision 1, April 20, 2015 229 230 Initial ARB spec branched from EXT_post_depth_coverage 231