15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci EXT_multisample_compatibility 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_EXT_multisample_compatibility 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Mark Kilgard, NVIDIA Corporation (mjk 'at' nvidia.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Daniel Koch, NVIDIA Corporation 165bd8deadSopenharmony_ci Slawomir Grajewski, Intel 175bd8deadSopenharmony_ci Shannon Woods, Google 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ciStatus 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ci Complete 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ci Exposed in ES contexts in NVIDIA drivers 358.00 (Septmeber 2015) 245bd8deadSopenharmony_ci and later. 255bd8deadSopenharmony_ci 265bd8deadSopenharmony_ciVersion 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ci Last Modified Date: July 30, 2015 295bd8deadSopenharmony_ci Revision: 5 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ciNumber 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci OpenGL ES Extension #248 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ciDependencies 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ci This extension is written against the OpenGL ES 3.1 (April 29, 2015) 385bd8deadSopenharmony_ci specification, but can apply to earlier versions. 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ci This extension interacts with OES_sample_variables. 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ciOverview 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci This extension allows disabling and enabling of multisampling. 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ci OpenGL ES 2.x/3.x both support multisampling but provide no way to 475bd8deadSopenharmony_ci disable multisampling for drawables with multiple samples. 485bd8deadSopenharmony_ci 495bd8deadSopenharmony_ci This introduces the MULTISAMPLE and SAMPLE_ALPHA_TO_ONE enables 505bd8deadSopenharmony_ci (though EXT suffixed) that operate identically to the OpenGL 4.5 core 515bd8deadSopenharmony_ci profile (as they have existed in OpenGL since OpenGL 1.3 and earlier 525bd8deadSopenharmony_ci with the ARB_multisample, EXT_multisample, and SGIS_multisample 535bd8deadSopenharmony_ci extensions). 545bd8deadSopenharmony_ci 555bd8deadSopenharmony_ciNew Procedures and Functions 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ci None 585bd8deadSopenharmony_ci 595bd8deadSopenharmony_ciNew Tokens 605bd8deadSopenharmony_ci 615bd8deadSopenharmony_ci Accepted by the <cap> parameter to Enable, Disable, and IsEnabled 625bd8deadSopenharmony_ci and the <pname> parameter to GetBooleanv, GetIntegerv, GetFloatv, 635bd8deadSopenharmony_ci and GetInteger64v: 645bd8deadSopenharmony_ci 655bd8deadSopenharmony_ci MULTISAMPLE_EXT 0x809D 665bd8deadSopenharmony_ci SAMPLE_ALPHA_TO_ONE_EXT 0x809F 675bd8deadSopenharmony_ci 685bd8deadSopenharmony_ciAdditions to Chapter 13 of the OpenGL ES 3.1 Specification (Fixed-Function 695bd8deadSopenharmony_ciPrimitive Assembly and Rasterization) 705bd8deadSopenharmony_ci 715bd8deadSopenharmony_ci Insert between the 8th and 9th paragraphs in Section 13.2.1 725bd8deadSopenharmony_ci (Multisampling) the following: 735bd8deadSopenharmony_ci 745bd8deadSopenharmony_ci "Multisample rasterization is enabled or disabled by calling Enable 755bd8deadSopenharmony_ci or Disable with the symbolic constant MULTISAMPLE_EXT. 765bd8deadSopenharmony_ci 775bd8deadSopenharmony_ci If MULTISAMPLE_EXT is disabled, multisample rasterization of all 785bd8deadSopenharmony_ci primitives is equivalent to single-sample (fragment-center) 795bd8deadSopenharmony_ci rasterization, except that the fragment coverage value is set to 805bd8deadSopenharmony_ci full coverage. The color and depth values and the sets of texture 815bd8deadSopenharmony_ci coordinates may all be set to the values that would have been assigned 825bd8deadSopenharmony_ci by single-sample rasterization, or they may be assigned as described 835bd8deadSopenharmony_ci below for multisample rasterization." 845bd8deadSopenharmony_ci 855bd8deadSopenharmony_ci Replace the first sentence of Section 13.3.2 (Point Multisample 865bd8deadSopenharmony_ci Rasterization) with: 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ci "If MULTISAMPLE_EXT is enabled, and the value of SAMPLE_BUFFERS is 895bd8deadSopenharmony_ci one, then points are rasterized using the following algorithm." 905bd8deadSopenharmony_ci 915bd8deadSopenharmony_ci Replace the first sentence of Section 13.4.3 (Line Multisample 925bd8deadSopenharmony_ci Rasterization) with: 935bd8deadSopenharmony_ci 945bd8deadSopenharmony_ci "If MULTISAMPLE_EXT is enabled, and the value of SAMPLE_BUFFERS is 955bd8deadSopenharmony_ci one, then lines are rasterized using the following algorithm." 965bd8deadSopenharmony_ci 975bd8deadSopenharmony_ci Replace the first sentence of Section 13.5.3 (Polygon Multisample 985bd8deadSopenharmony_ci Rasterization) with: 995bd8deadSopenharmony_ci 1005bd8deadSopenharmony_ci "If MULTISAMPLE_EXT is enabled, and the value of SAMPLE_BUFFERS is 1015bd8deadSopenharmony_ci one, then polygons are rasterized using the following algorithm." 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ciAdditions to Chapter 15 of the OpenGL ES 3.1 Specification (Writing Fragments and 1045bd8deadSopenharmony_ciSamples to the Framebuffer) 1055bd8deadSopenharmony_ci 1065bd8deadSopenharmony_ci Change the first sentence of 15.1.1 (Alpha to Coverage) to read: 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci "This step modifies fragment alpha and coverage values based on the 1095bd8deadSopenharmony_ci value of SAMPLE_ALPHA_TO_COVERAGE and SAMPLE_ALPHA_TO_ONE_EXT. If the 1105bd8deadSopenharmony_ci value of SAMPLE_BUFFERS is not one, MULTISAMPLE_EXT is disabled, 1115bd8deadSopenharmony_ci or if draw buffer zero is not NONE and the buffer it references has 1125bd8deadSopenharmony_ci an integer format, the operation is skipped." 1135bd8deadSopenharmony_ci 1145bd8deadSopenharmony_ci Add the following paragraph after the 2nd paragraph starting "Alpha 1155bd8deadSopenharmony_ci to coverage is enabled...": 1165bd8deadSopenharmony_ci 1175bd8deadSopenharmony_ci "Alpha to one is enabled or disabled by calling Enable and Disable 1185bd8deadSopenharmony_ci with target SAMPLE_ALPHA_TO_ONE_EXT." 1195bd8deadSopenharmony_ci 1205bd8deadSopenharmony_ci Add the following paragraph after the fourth paragraph ("If 1215bd8deadSopenharmony_ci SAMPLE_ALPHA_TO_COVERAGE ...") in 15.1.1: 1225bd8deadSopenharmony_ci 1235bd8deadSopenharmony_ci "Next, if SAMPLE_ALPHA_TO_ONE_EXT is enabled, each alpha value is 1245bd8deadSopenharmony_ci replaced by the maximum representable alpha value for fixed-point 1255bd8deadSopenharmony_ci color buffers, or by 1.0 for floating-point buffers. Otherwise, 1265bd8deadSopenharmony_ci the alpha values are not changed." 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ci Insert the following paragraph after the third paragraph in Section 1295bd8deadSopenharmony_ci 15.1.8: 1305bd8deadSopenharmony_ci 1315bd8deadSopenharmony_ci "If MULTISAMPLE_EXT is disabled, and the value of SAMPLE_BUFFERS 1325bd8deadSopenharmony_ci is one, the fragment may be treated exactly as described above, 1335bd8deadSopenharmony_ci with optimization possible because the fragment coverage must 1345bd8deadSopenharmony_ci be set to full coverage. Further optimization is allowed, 1355bd8deadSopenharmony_ci however. An implementation may choose to identify a centermost 1365bd8deadSopenharmony_ci sample, and to perform alpha, stencil, and depth tests on only that 1375bd8deadSopenharmony_ci sample. Regardless of the outcome of the stencil test, all multisample 1385bd8deadSopenharmony_ci buffer stencil sample values are set to the appropriate new stencil 1395bd8deadSopenharmony_ci value. If the depth test passes, all multisample buffer depth sample 1405bd8deadSopenharmony_ci values are set to the depth of the fragment's centermost sample's 1415bd8deadSopenharmony_ci depth value, and all multisample buffer color sample values are set 1425bd8deadSopenharmony_ci to the color value of the incoming fragment. Otherwise, no change 1435bd8deadSopenharmony_ci is made to any multisample buffer color or depth value." 1445bd8deadSopenharmony_ci 1455bd8deadSopenharmony_ciDependencies on OES_sample_variables 1465bd8deadSopenharmony_ci 1475bd8deadSopenharmony_ci When OES_sample_variables is supported, amend its language so 1485bd8deadSopenharmony_ci multisampling related sample variables depend on the MULTISAMPLE_EXT 1495bd8deadSopenharmony_ci enable state. 1505bd8deadSopenharmony_ci 1515bd8deadSopenharmony_ci Change the paragraph describing the gl_SampleID and gl_NumSamples 1525bd8deadSopenharmony_ci variables to read: 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci "The built-in read-only variable gl_SampleID is filled with 1555bd8deadSopenharmony_ci the sample number of the sample currently being processed. This 1565bd8deadSopenharmony_ci variable is in the range zero to gl_NumSamples minus one, where 1575bd8deadSopenharmony_ci gl_NumSamples is the total number of samples in the framebuffer, or 1585bd8deadSopenharmony_ci one if rendering to a non-multisample framebuffer or MULTISAMPLE_EXT 1595bd8deadSopenharmony_ci is disabled. Using gl_SampleID in a fragment shader causes the entire 1605bd8deadSopenharmony_ci shader to be executed per-sample. When rendering to a non-multisample 1615bd8deadSopenharmony_ci buffer or MULTISAMPLE_EXT is disabled, gl_SampleID will always be 1625bd8deadSopenharmony_ci zero. gl_NumSamples is the sample count of the framebuffer regardless 1635bd8deadSopenharmony_ci of whether the framebuffer is multisampled or not." 1645bd8deadSopenharmony_ci 1655bd8deadSopenharmony_ci Change the last sentence of the paragraph describing the 1665bd8deadSopenharmony_ci gl_SamplePosition variable: 1675bd8deadSopenharmony_ci 1685bd8deadSopenharmony_ci "When rendering to a non-multisample buffer or MULTISAMPLE_EXT is 1695bd8deadSopenharmony_ci disabled, gl_SamplePosition will always be (0.5, 0.5)." 1705bd8deadSopenharmony_ci 1715bd8deadSopenharmony_ci Change the appropriate sentence describing the gl_SampleMaskIn 1725bd8deadSopenharmony_ci variable: 1735bd8deadSopenharmony_ci 1745bd8deadSopenharmony_ci "When rendering to a non-multisample buffer or MULTISAMPLE_EXT 1755bd8deadSopenharmony_ci is disabled, all bits are zero except for bit zero of the first 1765bd8deadSopenharmony_ci array element. That bit will be one if the pixel is covered and 1775bd8deadSopenharmony_ci zero otherwise." 1785bd8deadSopenharmony_ci 1795bd8deadSopenharmony_ci Change the paragraph of the GLSL language (section 7.2) describing 1805bd8deadSopenharmony_ci gl_SampleID to read: 1815bd8deadSopenharmony_ci 1825bd8deadSopenharmony_ci "The input variable gl_SampleID is filled with the sample number of 1835bd8deadSopenharmony_ci the sample currently being processed. This variable is in the range 1845bd8deadSopenharmony_ci 0 to gl_NumSamples-1, where gl_NumSamples is the total number of 1855bd8deadSopenharmony_ci samples in the framebuffer, or one if rendering to a non-multisample 1865bd8deadSopenharmony_ci framebuffer or MULTISAMPLE_EXT is disabled. Any static use of 1875bd8deadSopenharmony_ci gl_SampleID in a fragment shader causes the entire shader to be 1885bd8deadSopenharmony_ci executed per-sample." 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ciNew State 1915bd8deadSopenharmony_ci 1925bd8deadSopenharmony_ci Modify Table 20.7, Multisampling 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ci Add: 1955bd8deadSopenharmony_ci 1965bd8deadSopenharmony_ci Initial 1975bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec. 1985bd8deadSopenharmony_ci ----------------------- ---- ----------- ------- ------------------------- ------ 1995bd8deadSopenharmony_ci MULTISAMPLE_EXT B IsEnabled TRUE Multisample rasterization 13.2.1 2005bd8deadSopenharmony_ci enable 2015bd8deadSopenharmony_ci SAMPLE_ALPHA_TO_ONE_EXT B IsEnabled FALSE Set alpha to max 15.1.3 2025bd8deadSopenharmony_ci 2035bd8deadSopenharmony_ciErrors 2045bd8deadSopenharmony_ci 2055bd8deadSopenharmony_ci None 2065bd8deadSopenharmony_ci 2075bd8deadSopenharmony_ciIssues 2085bd8deadSopenharmony_ci 2095bd8deadSopenharmony_ci 0. What should this extension be named? 2105bd8deadSopenharmony_ci 2115bd8deadSopenharmony_ci RESOLVED: EXT_multisample_compatibility. EXT_multisample is a 2125bd8deadSopenharmony_ci pre-existing extension so we avoid that name. The phrase 2135bd8deadSopenharmony_ci "compatibility" helps indicate this extension adds nothing not 2145bd8deadSopenharmony_ci available for years in OpenGL 1.3 (and even before that). 2155bd8deadSopenharmony_ci 2165bd8deadSopenharmony_ci 1. Why is this extension necessary? 2175bd8deadSopenharmony_ci 2185bd8deadSopenharmony_ci RESOLVED: While OpenGL ES 2.x/3.x support multisampling, they do not 2195bd8deadSopenharmony_ci provide a way to disable multisampling when rendering to a multisample 2205bd8deadSopenharmony_ci framebuffer. Conventional OpenGL provides the GL_MULTISAMPLE enable 2215bd8deadSopenharmony_ci for this purpose. 2225bd8deadSopenharmony_ci 2235bd8deadSopenharmony_ci 2. Is disabling multisampling necessary? 2245bd8deadSopenharmony_ci 2255bd8deadSopenharmony_ci RESOLVED: Yes, if you are trying to reproduce aliased rendering 2265bd8deadSopenharmony_ci results in a multisample buffer. 2275bd8deadSopenharmony_ci 2285bd8deadSopenharmony_ci Rasterization with multisampling disabled can also provide faster 2295bd8deadSopenharmony_ci rendering as the rasterization process is simpler and the shading 2305bd8deadSopenharmony_ci results are more conducive to color compression. 2315bd8deadSopenharmony_ci 2325bd8deadSopenharmony_ci NV_framebuffer_mixed_samples relies on being able to disable 2335bd8deadSopenharmony_ci multisampling to achieve color rate sampling when there is just one 2345bd8deadSopenharmony_ci color sample per pixel. 2355bd8deadSopenharmony_ci 2365bd8deadSopenharmony_ci 3. Should the GL_SAMPLE_ALPHA_TO_ONE_EXT enable be included too? 2375bd8deadSopenharmony_ci 2385bd8deadSopenharmony_ci RESOLVED: Yes. OpenGL ES 2.x/3.x lack this enable. While rarely 2395bd8deadSopenharmony_ci used, this enable is standard in OpenGL 1.3 and on so it can be 2405bd8deadSopenharmony_ci assumed implementations that support enabling/disabling multisampling 2415bd8deadSopenharmony_ci can also support this enable too. 2425bd8deadSopenharmony_ci 2435bd8deadSopenharmony_ci 4. Should sample shading support ("sample in") for GLSL be introduced 2445bd8deadSopenharmony_ci by this extension? 2455bd8deadSopenharmony_ci 2465bd8deadSopenharmony_ci RESOLVED: No. That support is better left to a different 2475bd8deadSopenharmony_ci extension as it builds on OES_sample_shading. In fact, 2485bd8deadSopenharmony_ci OES_shader_multisample_interpolation does this and is included in 2495bd8deadSopenharmony_ci Android Extension Pack (AEP) and ES 3.2. 2505bd8deadSopenharmony_ci 2515bd8deadSopenharmony_ci 5. Do we need to worry that the EXT token names "collide" with the 2525bd8deadSopenharmony_ci existing tokens of EXT_multisample? 2535bd8deadSopenharmony_ci 2545bd8deadSopenharmony_ci RESOLVED: No. GL token names are hex values with capital letters A 2555bd8deadSopenharmony_ci through F. C allows identical redefinition of #defines with exactly 2565bd8deadSopenharmony_ci the same lexical string ignoring white space. This means including 2575bd8deadSopenharmony_ci tokens from a header with EXT_multisample and this extension creates 2585bd8deadSopenharmony_ci no problem as the tokens have identical token values and names. 2595bd8deadSopenharmony_ci 2605bd8deadSopenharmony_ci 6. Direct3D has AlphaToCoverageEnable, but nothing equivalent to 2615bd8deadSopenharmony_ci GL_SAMPLE_ALPHA_TO_ONE_EXT. Given issue #3, how would Direct3D 2625bd8deadSopenharmony_ci implement GL_SAMPLE_ALPHA_TO_ONE_EXT? 2635bd8deadSopenharmony_ci 2645bd8deadSopenharmony_ci RESOLVED: The GL_SAMPLE_ALPHA_TO_ONE_EXT functionality is included 2655bd8deadSopenharmony_ci because if the fractional coverage held in the alpha component is 2665bd8deadSopenharmony_ci transferred to sample mask, leaving the alpha value "as is" would 2675bd8deadSopenharmony_ci result in "double accounting" for the alpha, once by the sample mask 2685bd8deadSopenharmony_ci and a second time by any enabled blending based on source alpha. 2695bd8deadSopenharmony_ci The expectation is if an application uses GL_SAMPLE_ALPHA_TO_COVERAGE 2705bd8deadSopenharmony_ci and doing blending with source alpha, it should be using 2715bd8deadSopenharmony_ci GL_SAMPLE_ALPHA_TO_ONE_EXT. 2725bd8deadSopenharmony_ci 2735bd8deadSopenharmony_ci While it is odd that Direct3D leaves out the 2745bd8deadSopenharmony_ci GL_SAMPLE_ALPHA_TO_ONE_EXT functionality from Direct3D, that doesn't 2755bd8deadSopenharmony_ci undercut the rationale for the functionality nor the compatibility 2765bd8deadSopenharmony_ci requirement for it if an application uses/needs the functionality. 2775bd8deadSopenharmony_ci 2785bd8deadSopenharmony_ci Direct3D can still emulate GL_SAMPLE_ALPHA_TO_COVERAGE and 2795bd8deadSopenharmony_ci GL_SAMPLE_ALPHA_TO_ONE_EXT both enabled in the shader by computing 2805bd8deadSopenharmony_ci the sample mask and/or forcing alpha to one in the fragment shader. 2815bd8deadSopenharmony_ci 2825bd8deadSopenharmony_ciRevision History 2835bd8deadSopenharmony_ci 2845bd8deadSopenharmony_ci Rev. Date Author Changes 2855bd8deadSopenharmony_ci ---- -------- --------- ----------------------------------------- 2865bd8deadSopenharmony_ci 6 08/25/15 mjk Status updated 2875bd8deadSopenharmony_ci 5 07/30/15 mjk Comments from Shannon; match language to 2885bd8deadSopenharmony_ci April 29, 2015 ES 3.1 specification 2895bd8deadSopenharmony_ci 4 07/09/15 mjk Improve issue 4 2905bd8deadSopenharmony_ci 3 07/08/15 mjk Typos 2915bd8deadSopenharmony_ci 2 05/02/15 mjk Complete 2925bd8deadSopenharmony_ci 1 04/02/15 mjk Initial revision. 293