1Name 2 3 EXT_multisample_compatibility 4 5Name Strings 6 7 GL_EXT_multisample_compatibility 8 9Contact 10 11 Mark Kilgard, NVIDIA Corporation (mjk 'at' nvidia.com) 12 13Contributors 14 15 Daniel Koch, NVIDIA Corporation 16 Slawomir Grajewski, Intel 17 Shannon Woods, Google 18 19Status 20 21 Complete 22 23 Exposed in ES contexts in NVIDIA drivers 358.00 (Septmeber 2015) 24 and later. 25 26Version 27 28 Last Modified Date: July 30, 2015 29 Revision: 5 30 31Number 32 33 OpenGL ES Extension #248 34 35Dependencies 36 37 This extension is written against the OpenGL ES 3.1 (April 29, 2015) 38 specification, but can apply to earlier versions. 39 40 This extension interacts with OES_sample_variables. 41 42Overview 43 44 This extension allows disabling and enabling of multisampling. 45 46 OpenGL ES 2.x/3.x both support multisampling but provide no way to 47 disable multisampling for drawables with multiple samples. 48 49 This introduces the MULTISAMPLE and SAMPLE_ALPHA_TO_ONE enables 50 (though EXT suffixed) that operate identically to the OpenGL 4.5 core 51 profile (as they have existed in OpenGL since OpenGL 1.3 and earlier 52 with the ARB_multisample, EXT_multisample, and SGIS_multisample 53 extensions). 54 55New Procedures and Functions 56 57 None 58 59New Tokens 60 61 Accepted by the <cap> parameter to Enable, Disable, and IsEnabled 62 and the <pname> parameter to GetBooleanv, GetIntegerv, GetFloatv, 63 and GetInteger64v: 64 65 MULTISAMPLE_EXT 0x809D 66 SAMPLE_ALPHA_TO_ONE_EXT 0x809F 67 68Additions to Chapter 13 of the OpenGL ES 3.1 Specification (Fixed-Function 69Primitive Assembly and Rasterization) 70 71 Insert between the 8th and 9th paragraphs in Section 13.2.1 72 (Multisampling) the following: 73 74 "Multisample rasterization is enabled or disabled by calling Enable 75 or Disable with the symbolic constant MULTISAMPLE_EXT. 76 77 If MULTISAMPLE_EXT is disabled, multisample rasterization of all 78 primitives is equivalent to single-sample (fragment-center) 79 rasterization, except that the fragment coverage value is set to 80 full coverage. The color and depth values and the sets of texture 81 coordinates may all be set to the values that would have been assigned 82 by single-sample rasterization, or they may be assigned as described 83 below for multisample rasterization." 84 85 Replace the first sentence of Section 13.3.2 (Point Multisample 86 Rasterization) with: 87 88 "If MULTISAMPLE_EXT is enabled, and the value of SAMPLE_BUFFERS is 89 one, then points are rasterized using the following algorithm." 90 91 Replace the first sentence of Section 13.4.3 (Line Multisample 92 Rasterization) with: 93 94 "If MULTISAMPLE_EXT is enabled, and the value of SAMPLE_BUFFERS is 95 one, then lines are rasterized using the following algorithm." 96 97 Replace the first sentence of Section 13.5.3 (Polygon Multisample 98 Rasterization) with: 99 100 "If MULTISAMPLE_EXT is enabled, and the value of SAMPLE_BUFFERS is 101 one, then polygons are rasterized using the following algorithm." 102 103Additions to Chapter 15 of the OpenGL ES 3.1 Specification (Writing Fragments and 104Samples to the Framebuffer) 105 106 Change the first sentence of 15.1.1 (Alpha to Coverage) to read: 107 108 "This step modifies fragment alpha and coverage values based on the 109 value of SAMPLE_ALPHA_TO_COVERAGE and SAMPLE_ALPHA_TO_ONE_EXT. If the 110 value of SAMPLE_BUFFERS is not one, MULTISAMPLE_EXT is disabled, 111 or if draw buffer zero is not NONE and the buffer it references has 112 an integer format, the operation is skipped." 113 114 Add the following paragraph after the 2nd paragraph starting "Alpha 115 to coverage is enabled...": 116 117 "Alpha to one is enabled or disabled by calling Enable and Disable 118 with target SAMPLE_ALPHA_TO_ONE_EXT." 119 120 Add the following paragraph after the fourth paragraph ("If 121 SAMPLE_ALPHA_TO_COVERAGE ...") in 15.1.1: 122 123 "Next, if SAMPLE_ALPHA_TO_ONE_EXT is enabled, each alpha value is 124 replaced by the maximum representable alpha value for fixed-point 125 color buffers, or by 1.0 for floating-point buffers. Otherwise, 126 the alpha values are not changed." 127 128 Insert the following paragraph after the third paragraph in Section 129 15.1.8: 130 131 "If MULTISAMPLE_EXT is disabled, and the value of SAMPLE_BUFFERS 132 is one, the fragment may be treated exactly as described above, 133 with optimization possible because the fragment coverage must 134 be set to full coverage. Further optimization is allowed, 135 however. An implementation may choose to identify a centermost 136 sample, and to perform alpha, stencil, and depth tests on only that 137 sample. Regardless of the outcome of the stencil test, all multisample 138 buffer stencil sample values are set to the appropriate new stencil 139 value. If the depth test passes, all multisample buffer depth sample 140 values are set to the depth of the fragment's centermost sample's 141 depth value, and all multisample buffer color sample values are set 142 to the color value of the incoming fragment. Otherwise, no change 143 is made to any multisample buffer color or depth value." 144 145Dependencies on OES_sample_variables 146 147 When OES_sample_variables is supported, amend its language so 148 multisampling related sample variables depend on the MULTISAMPLE_EXT 149 enable state. 150 151 Change the paragraph describing the gl_SampleID and gl_NumSamples 152 variables to read: 153 154 "The built-in read-only variable gl_SampleID is filled with 155 the sample number of the sample currently being processed. This 156 variable is in the range zero to gl_NumSamples minus one, where 157 gl_NumSamples is the total number of samples in the framebuffer, or 158 one if rendering to a non-multisample framebuffer or MULTISAMPLE_EXT 159 is disabled. Using gl_SampleID in a fragment shader causes the entire 160 shader to be executed per-sample. When rendering to a non-multisample 161 buffer or MULTISAMPLE_EXT is disabled, gl_SampleID will always be 162 zero. gl_NumSamples is the sample count of the framebuffer regardless 163 of whether the framebuffer is multisampled or not." 164 165 Change the last sentence of the paragraph describing the 166 gl_SamplePosition variable: 167 168 "When rendering to a non-multisample buffer or MULTISAMPLE_EXT is 169 disabled, gl_SamplePosition will always be (0.5, 0.5)." 170 171 Change the appropriate sentence describing the gl_SampleMaskIn 172 variable: 173 174 "When rendering to a non-multisample buffer or MULTISAMPLE_EXT 175 is disabled, all bits are zero except for bit zero of the first 176 array element. That bit will be one if the pixel is covered and 177 zero otherwise." 178 179 Change the paragraph of the GLSL language (section 7.2) describing 180 gl_SampleID to read: 181 182 "The input variable gl_SampleID is filled with the sample number of 183 the sample currently being processed. This variable is in the range 184 0 to gl_NumSamples-1, where gl_NumSamples is the total number of 185 samples in the framebuffer, or one if rendering to a non-multisample 186 framebuffer or MULTISAMPLE_EXT is disabled. Any static use of 187 gl_SampleID in a fragment shader causes the entire shader to be 188 executed per-sample." 189 190New State 191 192 Modify Table 20.7, Multisampling 193 194 Add: 195 196 Initial 197 Get Value Type Get Command Value Description Sec. 198 ----------------------- ---- ----------- ------- ------------------------- ------ 199 MULTISAMPLE_EXT B IsEnabled TRUE Multisample rasterization 13.2.1 200 enable 201 SAMPLE_ALPHA_TO_ONE_EXT B IsEnabled FALSE Set alpha to max 15.1.3 202 203Errors 204 205 None 206 207Issues 208 209 0. What should this extension be named? 210 211 RESOLVED: EXT_multisample_compatibility. EXT_multisample is a 212 pre-existing extension so we avoid that name. The phrase 213 "compatibility" helps indicate this extension adds nothing not 214 available for years in OpenGL 1.3 (and even before that). 215 216 1. Why is this extension necessary? 217 218 RESOLVED: While OpenGL ES 2.x/3.x support multisampling, they do not 219 provide a way to disable multisampling when rendering to a multisample 220 framebuffer. Conventional OpenGL provides the GL_MULTISAMPLE enable 221 for this purpose. 222 223 2. Is disabling multisampling necessary? 224 225 RESOLVED: Yes, if you are trying to reproduce aliased rendering 226 results in a multisample buffer. 227 228 Rasterization with multisampling disabled can also provide faster 229 rendering as the rasterization process is simpler and the shading 230 results are more conducive to color compression. 231 232 NV_framebuffer_mixed_samples relies on being able to disable 233 multisampling to achieve color rate sampling when there is just one 234 color sample per pixel. 235 236 3. Should the GL_SAMPLE_ALPHA_TO_ONE_EXT enable be included too? 237 238 RESOLVED: Yes. OpenGL ES 2.x/3.x lack this enable. While rarely 239 used, this enable is standard in OpenGL 1.3 and on so it can be 240 assumed implementations that support enabling/disabling multisampling 241 can also support this enable too. 242 243 4. Should sample shading support ("sample in") for GLSL be introduced 244 by this extension? 245 246 RESOLVED: No. That support is better left to a different 247 extension as it builds on OES_sample_shading. In fact, 248 OES_shader_multisample_interpolation does this and is included in 249 Android Extension Pack (AEP) and ES 3.2. 250 251 5. Do we need to worry that the EXT token names "collide" with the 252 existing tokens of EXT_multisample? 253 254 RESOLVED: No. GL token names are hex values with capital letters A 255 through F. C allows identical redefinition of #defines with exactly 256 the same lexical string ignoring white space. This means including 257 tokens from a header with EXT_multisample and this extension creates 258 no problem as the tokens have identical token values and names. 259 260 6. Direct3D has AlphaToCoverageEnable, but nothing equivalent to 261 GL_SAMPLE_ALPHA_TO_ONE_EXT. Given issue #3, how would Direct3D 262 implement GL_SAMPLE_ALPHA_TO_ONE_EXT? 263 264 RESOLVED: The GL_SAMPLE_ALPHA_TO_ONE_EXT functionality is included 265 because if the fractional coverage held in the alpha component is 266 transferred to sample mask, leaving the alpha value "as is" would 267 result in "double accounting" for the alpha, once by the sample mask 268 and a second time by any enabled blending based on source alpha. 269 The expectation is if an application uses GL_SAMPLE_ALPHA_TO_COVERAGE 270 and doing blending with source alpha, it should be using 271 GL_SAMPLE_ALPHA_TO_ONE_EXT. 272 273 While it is odd that Direct3D leaves out the 274 GL_SAMPLE_ALPHA_TO_ONE_EXT functionality from Direct3D, that doesn't 275 undercut the rationale for the functionality nor the compatibility 276 requirement for it if an application uses/needs the functionality. 277 278 Direct3D can still emulate GL_SAMPLE_ALPHA_TO_COVERAGE and 279 GL_SAMPLE_ALPHA_TO_ONE_EXT both enabled in the shader by computing 280 the sample mask and/or forcing alpha to one in the fragment shader. 281 282Revision History 283 284 Rev. Date Author Changes 285 ---- -------- --------- ----------------------------------------- 286 6 08/25/15 mjk Status updated 287 5 07/30/15 mjk Comments from Shannon; match language to 288 April 29, 2015 ES 3.1 specification 289 4 07/09/15 mjk Improve issue 4 290 3 07/08/15 mjk Typos 291 2 05/02/15 mjk Complete 292 1 04/02/15 mjk Initial revision. 293