1Name 2 3 NV_framebuffer_mixed_samples 4 5Name Strings 6 7 GL_NV_framebuffer_mixed_samples 8 GL_EXT_raster_multisample 9 10Contact 11 12 Jeff Bolz, NVIDIA Corporation (jbolz 'at' nvidia.com) 13 14Contributors 15 16 Pat Brown, NVIDIA 17 Mathias Heyer, NVIDIA 18 Mark Kilgard, NVIDIA 19 Chris Dalton, NVIDIA 20 Rui Bastros, NVIDIA 21 22Status 23 24 Shipping 25 26Version 27 28 Last Modified Date: February 15, 2017 29 Revision: 3 30 31Number 32 33 OpenGL Extension #469 34 OpenGL ES Extension #231 35 36Dependencies 37 38 This extension is written against the OpenGL 4.3 39 (Compatibility Profile) and OpenGL ES 3.0.3 (December 18, 2013) 40 specification. 41 42 This extension is written as a superset of EXT_raster_multisample, since 43 so many of the edits overlap each other and it is not expected for an 44 implementation to support NV_framebuffer_mixed_samples but not 45 EXT_raster_multisample. 46 47 This extension interacts with NV_fragment_coverage_to_color. 48 49 This extension interacts with EXT_depth_bounds_test. 50 51 This extension interacts with OES_sample_shading 52 53 This extension interacts with OES_sample_variables 54 55 This extension interacts with NV_framebuffer_multisample 56 57 This extension interacts with the OpenGL ES 3.1 specification. 58 59 This extension interacts with ARB_blend_func_extended 60 61Overview 62 63 This extension allows multisample rendering with a raster and 64 depth/stencil sample count that is larger than the color sample count. 65 Rasterization and the results of the depth and stencil tests together 66 determine the portion of a pixel that is "covered". It can be useful to 67 evaluate coverage at a higher frequency than color samples are stored. 68 This coverage is then "reduced" to a collection of covered color samples, 69 each having an opacity value corresponding to the fraction of the color 70 sample covered. The opacity can optionally be blended into individual 71 color samples. 72 73 In the current hardware incarnation both depth and stencil testing are 74 supported with mixed samples, although the API accommodates supporting 75 only one or the other. 76 77 Rendering with fewer color samples than depth/stencil samples can greatly 78 reduce the amount of memory and bandwidth consumed by the color buffer. 79 However, converting the coverage values into opacity can introduce 80 artifacts where triangles share edges and may not be suitable for normal 81 triangle mesh rendering. 82 83 One expected use case for this functionality is Stencil-then-Cover path 84 rendering (NV_path_rendering). The stencil step determines the coverage 85 (in the stencil buffer) for an entire path at the higher sample frequency, 86 and then the cover step can draw the path into the lower frequency color 87 buffer using the coverage information to antialias path edges. With this 88 two-step process, internal edges are fully covered when antialiasing is 89 applied and there is no corruption on these edges. 90 91 The key features of this extension are: 92 93 - It allows a framebuffer object to be considered complete when its depth 94 or stencil samples are a multiple of the number of color samples. 95 96 - It redefines SAMPLES to be the number of depth/stencil samples (if any); 97 otherwise, it uses the number of color samples. SAMPLE_BUFFERS is one if 98 there are multisample depth/stencil attachments. Multisample 99 rasterization and multisample fragment ops are allowed if SAMPLE_BUFFERS 100 is one. 101 102 - It replaces several error checks involving SAMPLE_BUFFERS by error 103 checks directly referencing the number of samples in the relevant 104 attachments. 105 106 - A coverage reduction step is added to Per-Fragment Operations which 107 converts a set of covered raster/depth/stencil samples to a set of 108 covered color samples. The coverage reduction step also includes an 109 optional coverage modulation step, multiplying color values by a 110 fractional opacity corresponding to the number of associated 111 raster/depth/stencil samples covered. 112 113 114New Procedures and Functions 115 116 void RasterSamplesEXT(uint samples, boolean fixedsamplelocations); 117 void CoverageModulationTableNV(sizei n, const float *v); 118 void GetCoverageModulationTableNV(sizei bufsize, float *v); 119 void CoverageModulationNV(enum components); 120 121New Tokens 122 123 Accepted by the <cap> parameter of Enable, Disable, IsEnabled: 124 125 RASTER_MULTISAMPLE_EXT 0x9327 126 COVERAGE_MODULATION_TABLE_NV 0x9331 127 128 Accepted by the <pname> parameter of GetBooleanv, GetDoublev, 129 GetIntegerv, and GetFloatv: 130 131 RASTER_SAMPLES_EXT 0x9328 132 MAX_RASTER_SAMPLES_EXT 0x9329 133 RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A 134 MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B 135 EFFECTIVE_RASTER_SAMPLES_EXT 0x932C 136 137 // COLOR_SAMPLES_NV is shared with NV_multisample_coverage 138 COLOR_SAMPLES_NV 0x8E20 139 DEPTH_SAMPLES_NV 0x932D 140 STENCIL_SAMPLES_NV 0x932E 141 MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F 142 MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 143 COVERAGE_MODULATION_NV 0x9332 144 COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 145 146Additions to Chapter 8 of the OpenGL 4.3 (Compatibility Profile) Specification 147(Textures and Samplers) 148 149 Modify the error list for CopyTex(Sub)Image in Section 8.6 (Alternate 150 Texture Image Specification Commands), p. 228. [This language redefines 151 one error condition in terms of the sample count of the targeted color 152 buffer instead of SAMPLE_BUFFERS.] 153 154 An INVALID_OPERATION error is generated by CopyTexSubImage3D, 155 CopyTexImage2D, CopyTexSubImage2D, CopyTexImage1D, or CopyTexSubImage1D 156 if 157 158 * the value of READ_BUFFER is NONE. 159 160 * the value of READ_FRAMEBUFFER_BINDING is non-zero, and 161 162 - the read buffer selects an attachment that has no image attached, 163 or 164 165 - the number of samples in the read buffer is greater than one. 166 167 168Additions to Chapter 9 of the OpenGL 4.3 (Compatibility Profile) Specification 169(Framebuffers and Framebuffer Objects) 170 171 Edit Section 9.4.2 (Whole Framebuffer Completeness), p. 314 172 173 - The number of samples in an attached image is determined by the value of 174 RENDERBUFFER_SAMPLES for renderbuffer images, and by the value of 175 TEXTURE_SAMPLES for texture images. All attached color images must have 176 the same number of samples. If the depth and stencil attachments are both 177 populated, those two images must have the same number of samples. If any 178 color attachments are populated and either the depth or stencil 179 attachments are populated, the following rules apply. If there is an 180 image attached to the depth (stencil) attachment, it must have the same 181 number of samples as the color attachments if the value of 182 MIXED_DEPTH_SAMPLES_SUPPORTED_NV (MIXED_STENCIL_SAMPLES_SUPPORTED_NV) is 183 FALSE. If the value of MIXED_DEPTH_SAMPLES_SUPPORTED_NV 184 (MIXED_STENCIL_SAMPLES_SUPPORTED_NV) is TRUE, then the number of samples 185 in the depth (stencil) image must be an integer multiple of the number 186 of samples in the color attachments. 187 188 { FRAMEBUFFER_INCOMPLETE_MULTISAMPLE } 189 190 ... 191 192 The values of SAMPLE_BUFFERS, SAMPLES, COLOR_SAMPLES_NV, DEPTH_SAMPLES_NV, 193 and STENCIL_SAMPLES_NV are derived from the attachments of the currently 194 bound draw framebuffer object. If the current DRAW_FRAMEBUFFER_BINDING is 195 not framebuffer complete, then all these values are undefined. Otherwise, 196 COLOR_SAMPLES_NV is equal to the value of RENDERBUFFER_SAMPLES or 197 TEXTURE_SAMPLES (depending on the type of the attached images) of the 198 attached color images, which must all have the same value. DEPTH_SAMPLES_NV 199 and STENCIL_SAMPLES_NV are equal to the number of samples in the 200 corresponding attached images. If there are no corresponding attachments, 201 these values are equal to zero. SAMPLES is equal to the first non-zero 202 value from the list of STENCIL_SAMPLES_NV, DEPTH_SAMPLES_NV, and 203 COLOR_SAMPLES_NV. SAMPLE_BUFFERS is one if any attachment has more than one 204 sample. Otherwise, SAMPLE_BUFFERS is zero. 205 206 207Additions to Chapter 14 of the OpenGL 4.3 (Compatibility Profile) Specification 208(Rasterization) 209 210 Modify Section 14.3.1 (Multisampling), p. 478 211 212 (replace the introductory language at the beginning of the section to 213 account for the new ability to use multisample rasterization without 214 having multisample storage) 215 216 Multisampling is a mechanism to antialias all GL primitives: points, 217 lines, polygons, bitmaps, and images. The technique is to sample all 218 primitives multiple times at each pixel. The color sample values are 219 resolved to a single, displayable color. For window system-provided 220 framebuffers, this occurs each time a pixel is updated, so the 221 antialiasing appears to be automatic at the application level. For 222 application-created framebuffers, this must be requested by calling 223 the BlitFramebuffer command (see section 18.3.1). Because each sample 224 includes color, depth, and stencil information, the color (including 225 texture operation), depth, and stencil functions perform 226 equivalently to the single-sample mode. 227 228 When the framebuffer includes a multisample buffer, separate color, depth, 229 and stencil values are stored in this buffer for each sample location. 230 Samples contain separate color values for each fragment color. 231 Framebuffers including a multisample buffer do not include non-multisample 232 depth or stencil buffers, even if the multisample buffer does not store 233 depth or stencil values. Color buffers do coexist with the multisample 234 buffer, however. 235 236 The color sample values are resolved to a single, displayable color each 237 time a pixel is updated, so the antialiasing appears to be automatic at 238 the application level. Because each sample includes color, depth, and 239 stencil information, the color (including texture operation), depth, and 240 stencil functions perform equivalently to the single-sample mode. 241 242 Multisample antialiasing is most valuable for rendering polygons, because 243 it requires no sorting for hidden surface elimination, and it correctly 244 handles adjacent polygons, object silhouettes, and even intersecting 245 polygons. If only points or lines are being rendered, the "smooth" 246 antialiasing mechanism provided by the base GL may result in a higher 247 quality image. This mechanism is designed to allow multisample and smooth 248 antialiasing techniques to be alternated during the rendering of a single 249 scene. 250 251 If the value of MULTISAMPLE_RASTERIZATION_ALLOWED_EXT is TRUE, the 252 rasterization of all primitives is changed, and is referred to as 253 multisample rasterization. Otherwise, primitive rasterization is 254 referred to as single-sample rasterization. The value of MULTISAMPLE- 255 _RASTERIZATION_ALLOWED_EXT is queried by calling GetIntegerv 256 with pname set to MULTISAMPLE_RASTERIZATION_ALLOWED_EXT. 257 258 During multisample rendering the contents of a pixel fragment are changed 259 in two ways. First, each fragment includes a coverage value with 260 EFFECTIVE_RASTER_SAMPLES_EXT bits. The value of EFFECTIVE_RASTER_- 261 SAMPLES_EXT is an implementation-dependent constant, and 262 is queried by calling GetIntegerv with pname set to EFFECTIVE_RASTER- 263 _SAMPLES_EXT. 264 265 266 Multisample rasterization may also be enabled without introducing 267 additional storage for the multisample buffer, by calling Enable with a 268 <target> of RASTER_MULTISAMPLE_EXT. The command: 269 270 void RasterSamplesEXT(uint samples, boolean fixedsamplelocations); 271 272 selects the number of samples to be used for rasterization. <samples> 273 represents a request for a desired minimum number of samples. Since 274 different implementations may support different sample counts, the actual 275 sample pattern used is implementation-dependent. However, the resulting 276 value for RASTER_SAMPLES_EXT is guaranteed to be greater than or equal to 277 <samples> and no more than the next larger sample count supported by the 278 implementation. If <fixedsamplelocations> is TRUE, identical sample 279 locations will be used for all pixels. The sample locations chosen are a 280 function of only the parameters to RasterSamplesEXT and not of any other 281 state. 282 283 If RASTER_MULTISAMPLE_EXT is enabled, then the sample pattern chosen by 284 RasterSamplesEXT will be used instead of sampling at the center of the 285 pixel. The sample locations can be queried with GetMultisamplefv with a 286 <pname> of SAMPLE_POSITION, similar to normal multisample sample locations. 287 288 The value MULTISAMPLE_RASTERIZATION_ALLOWED_EXT is TRUE if SAMPLE_BUFFERS 289 is one or if RASTER_MULTISAMPLE_EXT is enabled. The value 290 EFFECTIVE_RASTER_SAMPLES_EXT is equal to RASTER_SAMPLES_EXT if 291 RASTER_MULTISAMPLE_EXT is enabled, otherwise is equal to SAMPLES. 292 293 Explicit multisample rasterization is not allowed if the raster sample 294 count is less than the color sample count, or if the raster sample count 295 does not match the depth or stencil sample counts when depth or stencil 296 testing is performed. If RASTER_MULTISAMPLE_EXT is enabled, the error 297 INVALID_OPERATION will be generated by Draw, Bitmap, DrawPixels, and 298 CopyPixels commands if 299 300 - the value of RASTER_SAMPLES_EXT is zero; 301 302 - the value of RASTER_SAMPLES_EXT is less than the value of 303 COLOR_SAMPLES_NV; 304 305 - the depth or depth bounds test is enabled, the draw framebuffer 306 includes a depth buffer, and the value of RASTER_SAMPLES_EXT does not 307 equal the value of DEPTH_SAMPLES_NV; or 308 309 - the stencil test is enabled, the draw framebuffer includes a stencil 310 buffer, and the value of RASTER_SAMPLES_EXT does not equal the value 311 of STENCIL_SAMPLES_NV; 312 313 Errors 314 315 - An INVALID_VALUE error is generated if <samples> is greater than the 316 value of MAX_RASTER_SAMPLES_EXT. 317 318 319 Add to the end of Section 14.3.1.1 (Sample Shading), p. 479 320 321 If RASTER_MULTISAMPLE_EXT is enabled, the number of unique samples to 322 process is implementation-dependent and need not be more than one. 323 324 If RASTER_MULTISAMPLE_EXT is disabled but the value of SAMPLES is 325 greater than the value of COLOR_SAMPLES, the number of unique samples 326 to process is implementation-dependent and need not be more than one. 327 328 Modify Section 14.4.3 (Point Multisample Rasterization) 329 330 If MULTISAMPLE is enabled and MULTISAMPLE_RASTERIZATION_ALLOWED_EXT is 331 TRUE, then points are rasterized using the following algorithm, regardless 332 of whether point antialiasing (POINT_SMOOTH) is enabled or disabled. 333 334 Modify Section 14.5.4 (Line Multisample Rasterization) 335 336 If MULTISAMPLE is enabled and MULTISAMPLE_RASTERIZATION_ALLOWED_EXT is 337 TRUE, then lines are rasterized using the following algorithm, regardless 338 of whether line antialiasing (LINE_SMOOTH) is enabled or disabled. 339 340 Modify Section 14.6.6 (Polygon Multisample Rasterization) 341 342 If MULTISAMPLE is enabled and MULTISAMPLE_RASTERIZATION_ALLOWED_EXT is 343 TRUE, then polygons are rasterized using the following algorithm, 344 regardless of whether polygon antialiasing (POLYGON_SMOOTH) is enabled or 345 disabled. 346 347 Modify Section 14.8.0.1 (Bitmap Multisample Rasterization) 348 349 If MULTISAMPLE is enabled and MULTISAMPLE_RASTERIZATION_ALLOWED_EXT is 350 TRUE, then bitmaps are rasterized using the following algorithm. 351 352Additions to Chapter 15 of the OpenGL 4.3 (Compatibility Profile) Specification 353(Programmable Fragment Processing) 354 355 Modify Section 15.2.2 (Shader Inputs), p. 512 356 357 The built-in variable gl_SampleMaskIn is an integer array holding bitfields 358 indicating the set of fragment samples covered by the primitive 359 corresponding to the fragment shader invocation. The number of elements in 360 the array is 361 362 ceil(s/32), 363 364 where <s> is the maximum number of color or raster samples supported by the 365 implementation. Bit <n> of element <w> in the array is set if and only if 366 the raster sample numbered 32<w> + <n> is considered covered for this 367 fragment shader invocation. 368 369 Modify Section 15.2.3 (Shader Outputs), p. 513 370 371 The built-in integer array gl_SampleMask can be used to change the sample 372 coverage for a fragment from within the shader. The number of elements in 373 the array is 374 375 ceil(s/32), 376 377 where <s> is the maximum number of color or raster samples supported by the 378 implementation. 379 380Additions to Chapter 17 of the OpenGL 4.3 (Compatibility Profile) Specification 381(Writing Fragments and Samples to the Framebuffer) 382 383 Modify Figure 17.1 (Per-fragment operations) 384 385 Add a new stage called "Coverage Reduction" between "Occlusion Query" and 386 "Blending". 387 388 (note: If NV_fragment_coverage_to_color is supported, the "Coverage 389 Reduction" stage is after the "Fragment coverage to color" stage.) 390 391 392 Modify Section 17.3.3 (Multisample Fragment Operations) 393 394 First paragraph: 395 ...No changes to the fragment alpha or coverage values are made at this 396 step if MULTISAMPLE is disabled or MULTISAMPLE_RASTERIZATION_ALLOWED_EXT is 397 FALSE. 398 399 ... 400 401 If SAMPLE_ALPHA_TO_COVERAGE is enabled, a temporary coverage value is 402 generated where each bit is determined by the alpha value at the 403 corresponding sample location. The coverage value has 404 EFFECTIVE_RASTER_SAMPLES_EXT bits. 405 406 407 Modify Section 17.3.7 (Occlusion Queries), p.538 408 409 When an occlusion query is started with target SAMPLES_PASSED, the samples- 410 passed count maintained by the GL is set to zero. When an occlusion query 411 is active, the samples-passed count is incremented for each fragment that 412 passes the depth test. If MULTISAMPLE_RASTERIZATION_ALLOWED_EXT is FALSE, 413 then the samples-passed count is incremented by 1 for each fragment. If 414 MULTISAMPLE_RASTERIZATION_ALLOWED_EXT is TRUE, then the samples-passed 415 count is incremented by the number of samples whose coverage bit is set. 416 However, implementations, at their discretion, may instead increase the 417 samples-passed count by the value of EFFECTIVE_RASTER_SAMPLES_EXT if any 418 sample in the fragment is covered. Additionally, if 419 RASTER_MULTISAMPLE_EXT is enabled, implementations may instead increase 420 the samples-passed count by one for the entire fragment if any sample 421 is covered. 422 423 424 Add a new Section 17.3.Y (Coverage Reduction) after 17.3.7. 425 426 If the value of EFFECTIVE_RASTER_SAMPLES_EXT is greater than the value of 427 COLOR_SAMPLES_NV, a fragment's coverage is reduced from 428 EFFECTIVE_RASTER_SAMPLES_EXT bits to COLOR_SAMPLES_NV bits. There is an 429 implementation-dependent association of raster samples to color samples. 430 The reduced "color coverage" is computed such that the coverage bit for 431 each color sample is 1 if any of the associated bits in the fragment's 432 coverage is on, and 0 otherwise. Blending and writes to the framebuffer 433 are not performed on samples whose color coverage bit is zero. 434 435 For each color sample, the associated bits of the fragment's coverage are 436 counted and divided by the number of associated bits to produce a 437 modulation factor R in the range (0,1] (a value of zero would have been 438 killed due to a color coverage of 0). Specifically: 439 440 N = value of EFFECTIVE_RASTER_SAMPLES_EXT; 441 M = value of COLOR_SAMPLES_NV; 442 R = popcount(associated coverage bits) / (N / M); 443 444 If COVERAGE_MODULATION_TABLE_NV is enabled, the value R is mapped 445 through a programmable lookup table to produce another value. The lookup 446 table has a fixed, implementation-dependent, size according to the value 447 of COVERAGE_MODULATION_TABLE_SIZE_NV. 448 449 S = value of COVERAGE_MODULATION_TABLE_SIZE_NV 450 I = max(1, int(R*S)); 451 R = table[I-1]; 452 453 Note that the table does not have an entry for R=0, because such samples 454 would have been killed. The table is controlled by the command: 455 456 CoverageModulationTableNV(sizei n, const float *v); 457 458 where <v> contains S floating point values. The values are rounded on use 459 to an implementation dependent precision, which is at least as fine as 460 1 / N, and clamped to [0,1]. Initially, COVERAGE_MODULATION_TABLE_NV is 461 disabled, and the table is initialized with entry i = ((i+1) / S). An 462 INVALID_VALUE error is generated if <n> is not equal to 463 COVERAGE_MODULATION_TABLE_SIZE_NV. The command 464 465 GetCoverageModulationTableNV(sizei bufsize, float *v); 466 467 obtains the coverage modulation table. min(bufsize/sizeof(float),S) 468 floating point values are written to <v>, in order. 469 470 For each draw buffer with a floating point or normalized color format, the 471 fragment's color value and second source color [for ARB_blend_func_extended] 472 is replicated to M values which may each be modulated (multiplied) by 473 that color sample's associated value of R. This modulation is controlled 474 by the function: 475 476 CoverageModulationNV(enum components); 477 478 <components> may be RGB, RGBA, ALPHA, or NONE. If <components> is RGB or 479 RGBA, the red, green, and blue components are modulated. If components is 480 RGBA or ALPHA, the alpha component is modulated. The initial value of 481 COVERAGE_MODULATION_NV is NONE. 482 483 Each sample's color value is then blended and written to the framebuffer 484 independently. 485 486 487Additions to Chapter 18 of the OpenGL 4.3 (Compatibility Profile) Specification 488(Drawing, Reading, and Copying Pixels) 489 490 Modify Section 18.1.3 (Pixel Rectangle Multisample Rasterization) 491 492 If MULTISAMPLE is enabled and MULTISAMPLE_RASTERIZATION_ALLOWED_EXT is TRUE, 493 then pixel rectangles are rasterized using the following algorithm. 494 495 Modify Section 18.2 (Reading Pixels) 496 497 Replace the error check for ReadPixels, redefining one error condition in 498 terms of the sample count of the targeted color buffer instead of 499 SAMPLE_BUFFERS: 500 501 An INVALID_OPERATION error is generated if the value of READ_- 502 FRAMEBUFFER_BINDING (see section 9) is non-zero, the read framebuffer is 503 framebuffer complete, and the number of samples in the read buffer is 504 greater than one. 505 506 Modify Section 18.3 (Copying Pixels) 507 508 Replace the second error check for CopyPixels, redefining one error 509 condition in terms of the sample count of the targeted color buffer 510 instead of SAMPLE_BUFFERS: 511 512 An INVALID_OPERATION error is generated if the object bound to 513 READ_FRAMEBUFFER_BINDING is framebuffer complete and the number of samples 514 in the read buffer is greater than one. 515 516 An INVALID_OPERATION error is generated if the value of READ_- 517 FRAMEBUFFER_BINDING (see section 9) is non-zero, the read framebuffer is 518 framebuffer complete, and the number of samples in the read buffer is 519 greater than one. 520 521 Modify Section 18.3.1 (Blitting Pixel Rectangles), p. 580 522 523 (redefine various language in terms of sample counts in individual buffers 524 instead of SAMPLE_BUFFERS) 525 526 If the number of samples in the source buffer is greater than one and the 527 number of samples in the destination buffers is equal to one, the samples 528 corresponding to each pixel location in the source are converted to a 529 single sample before being written to the destination. 530 531 If the number of samples in the source buffer is one and the number of 532 samples in the destination buffers are greater than one, the value of the 533 source sample is replicated in each of the destination samples. 534 535 If the number of samples in the source buffer or in any of the destination 536 buffers is greater than one, no copy is performed and an INVALID_OPERATION 537 error is generated if the dimensions of the source and destination 538 rectangles provided to BlitFramebuffer are not identical, or if the formats 539 of the read and draw framebuffers are not identical. 540 541 If the number of samples in the source and destination buffers are equal 542 and greater than zero, the samples are copied without modification from the 543 read framebuffer to the draw framebuffer. Otherwise, no copy is performed 544 and an INVALID_OPERATION error is generated. 545 546 547New Implementation Dependent State 548 549 Minimum 550 Get Value Type Get Command Value Description Sec. 551 --------- ------- ----------- ------- ------------------------ ------ 552 MAX_RASTER_SAMPLES_EXT Z+ GetIntegerv 2 Maximum number of raster 14.3.1 553 samples 554 MIXED_DEPTH_SAMPLES_- B GetBooleanv FALSE(*)Support for number of depth 9.4.2 555 SUPPORTED_NV samples not equal to number 556 of color samples 557 MIXED_STENCIL_SAMPLES_- B GetBooleanv FALSE(*)Support for number of depth 9.4.2 558 SUPPORTED_NV samples not equal to number 559 of color samples 560 COVERAGE_MODULATION_TABLE_- Z+ GetIntegerv 2(**) Number of entries in the table 17.3.Y 561 SIZE_NV 562 563 (*) footnote: Either MIXED_DEPTH_SAMPLES_SUPPORTED_NV or 564 MIXED_STENCIL_SAMPLES_SUPPORTED_NV must be TRUE for this extension to be 565 useful. 566 567 (**) Must be at least as large as MAX_RASTER_SAMPLES_EXT. 568 569New State 570 571 Get Value Get Command Type Initial Value Description Sec. Attribute 572 --------- ----------- ---- ------------- ----------- ---- --------- 573 RASTER_MULTISAMPLE_EXT IsEnabled B FALSE Multisample Rasterization 14.3.1 enable/multisample 574 without multiple color 575 samples 576 RASTER_SAMPLES_EXT GetIntegerv Z+ 0 Number of raster samples 14.3.1 multisample 577 RASTER_FIXED_SAMPLE_- GetBooleanv B FALSE Require same sample 14.3.1 multisample 578 LOCATIONS_EXT locations 579 MULTISAMPLE_RASTERIZATION_- GetBooleanv B FALSE Whether MS rasterization 14.3.1 - 580 ALLOWED_EXT can be used 581 EFFECTIVE_RASTER_SAMPLES_EXT GetIntegerv Z+ 0 How many samples are used 14.3.1 - 582 for rasterization and 583 fragment operations 584 COLOR_SAMPLES_NV GetIntegerv Z+ 0 Number of color samples 9.4.2 - 585 DEPTH_SAMPLES_NV GetIntegerv Z+ 0 Number of depth samples 9.4.2 - 586 STENCIL_SAMPLES_NV GetIntegerv Z+ 0 Number of stencil samples 9.4.2 - 587 <blank> GetCoverage- R^k[0,1] (i+1)/S Lookup table for coverage 17.3.Y - 588 ModulationTableNV values 589 COVERAGE_MODULATION_TABLE_NV IsEnabled B FALSE Enable lookup table for 17.3.Y - 590 coverage values 591 COVERAGE_MODULATION_NV GetIntegerv E NONE Which components are 17.3.Y - 592 multiplied by coverage 593 fraction 594 595 596Additions to the AGL/GLX/WGL Specifications 597 598 None. 599 600GLX Protocol 601 602 None. 603 604Modifications to the OpenGL Shading Language Specification, Version 4.30 605 606 Modify Section 7.1 (Built-In Language Variables), p. 118 607 608 For both the input array gl_SampleMaskIn[] and the output array 609 gl_SampleMask[], bit B of mask M (gl_SampleMaskIn[M] or gl_SampleMask[M]) 610 corresponds to sample 32*M+B. These arrays have ceil(s/32) elements, where 611 s is the maximum number of color or raster samples supported by the 612 implementation. 613 614 615Interactions with OpenGL ES 3.0 616 617 For OpenGL ES, remove references to images, bitmaps and GetDoublev. 618 Disregard references to POINT_SMOOTH, LINE_SMOOTH and POLYGON_SMOOTH. 619 620 Omit changes to Section 14.8.0.1 (Bitmap Multisample Rasterization). 621 Also, omit changes to Section 18.1.3 (Pixel Rectangle Multisample 622 Rasterization) and Section 18.3 (Copying Pixels). 623 624 Since OpenGL ES does not support enabling/disabling MULTISAMPLE 625 rasterization via MULTISAMPLE, read all occurrences of MULTISAMPLE 626 as if it was enabled. 627 628 629Interactions with OpenGL ES 3.1 630 631 If this extension is implemented on OpenGL ES and OpenGL ES 3.1 is 632 not supported, remove any language referring to TEXTURE_SAMPLES. 633 634 635Dependencies on ARB_blend_func_extended 636 637 If this extension is not supported, remove the phrase "and second 638 source color [for ARB_blend_func_extended]" from the new Section 17.3.Y 639 (Coverage Reduction). 640 641 642Dependencies on NV_framebuffer_multisample 643 644 If this extension is implemented on OpenGL ES and NV_framebuffer_multisample 645 is not supported, disregard changes to BlitFramebuffer where the 646 number of samples in the draw framebuffer is greater than one. 647 648 649Dependencies on OES_sample_shading 650 651 If this extension is implemented on OpenGL ES and if 652 OES_sample_shading is not supported, omit changes to Section 14.3.3.1 653 (Sample Shading). 654 655 656Dependencies on OES_sample_variables 657 658 If this extension is implemented on OpenGL ES and if 659 OES_sample_variables is not supported, omit changes to Section 3.9.2 660 (Shader Inputs; Shader Outputs). 661 662 663Dependencies on EXT_depth_bounds_test 664 665 If EXT_depth_bounds_test is not supported, remove the error check when 666 DBT is enabled. 667 668Errors 669 670 Various errors prohibiting read/copy operations involving multisample 671 color buffers are redefined to refer to the sample count of the targeted 672 color buffer instead of a whole-framebuffer RASTER_SAMPLES. This 673 extension allows a single-sample color buffer to be combined with a 674 multisample depth/stencil buffer and defines RASTER_SAMPLES to be 1 in 675 that case. 676 677 The error INVALID_OPERATION is be generated by Draw, Bitmap, DrawPixels, 678 and CopyPixels commands if RASTER_MULTISAMPLE_EXT is enabled, and any of 679 the following is true: 680 681 - the value of RASTER_SAMPLES_EXT is zero; 682 683 - the value of RASTER_SAMPLES_EXT is less than the value of 684 COLOR_SAMPLES_NV; 685 686 - the depth or depth bounds test is enabled, the draw framebuffer 687 includes a depth buffer, and the value of RASTER_SAMPLES_EXT does not 688 equal the value of DEPTH_SAMPLES_NV; or 689 690 - the stencil test is enabled, the draw framebuffer includes a stencil 691 buffer, and the value of RASTER_SAMPLES_EXT does not equal the value 692 of STENCIL_SAMPLES_NV. 693 694 The error INVALID_VALUE is generated by RasterSamplesEXT if <samples> is 695 greater than the value of MAX_RASTER_SAMPLES_EXT. 696 697 The error INVALID_VALUE is generated by CoverageModulationTableNV if <n> 698 is not equal to COVERAGE_MODULATION_TABLE_SIZE_NV. 699 700NVIDIA Implementation Details 701 702 NVIDIA GPUs before the Maxwell 2 generation do not support this 703 extension. This includes GM10x GPUs from the first Maxwell 704 generation. 705 706 GM20x-based GPUs (GeForce 9xx series, Quadro M6000, Tegra X1, etc.) 707 and later GPUs support the following mixtures of samples: 708 709 Color samples Stencil samples Depth samples 710 ============= =============== ============= 711 1 1 1 712 1 2 2 713 1 4 4 714 1 8 8 715 1 16 0 716 ------------- --------------- ------------- 717 2 2 2 718 2 4 4 719 2 8 8 720 2 16 0 721 ------------- --------------- ------------- 722 4 4 4 723 4 8 8 724 4 16 0 725 ------------- --------------- ------------- 726 8 8 8 727 8 16 0 728 729 A non-zero stencil or depth sample count can always be made zero. 730 For example, 4 color samples with 8 stencil samples but no depth 731 samples is supported. 732 733 If you have a non-zero number of 24-bit fixed-point depth samples, 734 the corresponding storage for the sample number of stencil samples 735 is allocated even if zero samples are requested. 736 737 When there are zero depth samples but non-zero stencil samples, GM20x 738 benefits from stencil bandwidth mitigation technology. So rendering 739 performance (e.g. path rendering) is significantly better when an 740 application can use the stencil buffer without allocating a depth 741 buffer. 742 743 As the table indicates, rendering with 16 stencil samples requires 744 no depth samples. 745 746 NVIDIA's implementation-dependent behavior when sample shading enabled 747 when the number of effective raster samples is not equal to the number 748 of color samples shades at the pixel rate, effectively ignoring the 749 per-sample shading (as allowed by the language in section 14.3.3.1). 750 751Issues 752 753 (1) How is coverage modulation intended to be used? 754 755 RESOLVED: Coverage modulation allows the coverage to be converted to 756 "opacity", which can then be blended into the color buffer to accomplish 757 antialiasing. This is similar to the intent of POLYGON_SMOOTH. For example, 758 if non-premultiplied alpha colors are in use (common OpenGL usage): 759 760 glCoverageModulationNV(GL_ALPHA); 761 glEnable(GL_BLEND); 762 glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 763 GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 764 765 or if using pre-multiplied alpha colors (common in 2D rendering): 766 767 glCoverageModulationNV(GL_RGBA); 768 glEnable(GL_BLEND); 769 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 770 771 (2) How is the coverage modulation table intended to be used? 772 773 RESOLVED: It could be used to accomplish the coverage modulation 774 "downsample" in a modified color space (akin to an sRGB downsample). It 775 could also be used (in conjunction with blending) to kill any partially 776 covered color samples. 777 778 Note that for lower ratios of N/M, the table's entries are used sparsely. 779 For example, if N=16, M=4, and S=16, the initial calculation of R would 780 produce values of 0.25, 0.5, 0.75, and 1. Then I = 4, 8, 12, or 16, and 781 entries 3, 7, 11, and 15 would be used. The intent is that the table 782 should be treated like a function from (0,1] to [0,1]. 783 784 (3) What combinations of AA modes are supported? 785 786 RESOLVED: Depth/stencil samples being an integer multiple of color samples 787 is a necessary condition, but is not sufficient. There may be other 788 implementation-dependent limitations that cause certain combinations not 789 to be supported and report as an incomplete framebuffer. 790 791 (4) What errors should be generated when RasterSamples and depth/stencil 792 sample counts mismatch? 793 794 RESOLVED: Commands that do any sort of rasterization, including Draw, 795 Bitmap, DrawPixels, and CopyPixels, should have errors if the depth/stencil 796 buffer may be touched (depth test, stencil test, depth bounds test 797 enabled). Clear does not rasterize, so should not have any such errors. 798 799 (5) When using both NV_fragment_coverage_to_color and EXT_raster_multisample 800 or NV_framebuffer_mixed_samples, how do these features interact? 801 802 RESOLVED: Both may be used simultaneously, and the coverage_to_color 803 functionality is applied before coverage reduction in the pipeline. This 804 means the full raster sample mask will be written to the color buffer, not 805 the reduced color sample mask. 806 807 (6) How do EXT_raster_multisample and NV_framebuffer_mixed_samples 808 interact? Why are there two extensions? 809 810 RESOLVED: The functionality in EXT_raster_multisample is equivalent to 811 "Target-Independent Rasterization" in Direct3D 11.1, and is expected to be 812 supportable today by other hardware vendors. It allows using multiple 813 raster samples with a single color sample, as long as depth and stencil 814 tests are disabled, with the number of raster samples controlled by a 815 piece of state. 816 817 NV_framebuffer_mixed_samples is an extension/enhancement of this feature 818 with a few key improvements: 819 820 - Multiple color samples are allowed, with the requirement that the number 821 of raster samples must be a multiple of the number of color samples. 822 823 - Depth and stencil buffers and tests are supported, with the requirement 824 that the number of raster/depth/stencil samples must all be equal for 825 any of the three that are in use. 826 827 - The addition of the coverage modulation feature, which allows the 828 multisample coverage information to accomplish blended antialiasing. 829 830 Using mixed samples does not require enabling RASTER_MULTISAMPLE_EXT; the 831 number of raster samples can be inferred from the depth/stencil 832 attachments. But if it is enabled, RASTER_SAMPLES_EXT must equal the 833 number of depth/stencil samples. 834 835 (7) How do ARB_blend_func_extended (dual-source blending) interact 836 with this extension? 837 838 RESOLVED: Coverage modulation affects both the source color and the 839 source factor color (GL_SRC1_COLOR, etc.). 840 841 (8) How does ARB_sample_shading (per-sample shading) interact with 842 this extension? 843 844 RESOLVED: Implementations have the option of shading just a single 845 sample when the number of raster samples doesn't match the number 846 of color samples, be that because RASTER_MULTISAMPLE_EXT is enabled 847 or the number of depth and/or stencil samples is greater than the 848 number of color samples. 849 850 See the language added to the end of Section 14.3.1.1 (Sample 851 Shading). 852 853 (9) Why does the antialiasing quality look "ropey" even with 8 or 854 even 16 raster samples? 855 856 Because of the color values on typical displays (e.g. devices 857 displaying color values encoded in the sRGB color space) do not have 858 a perceptually-linear color response, antialiasing quality based on 859 fractional coverage is best achieved on such sRGB displays by 860 enabling sRGB framebuffer blending (i.e. GL_FRAMEBUFFER_SRGB). 861 Otherwise antialiased edges rendered with coverage modulation may 862 have a "ropey" appearance. 863 864 The benefit of enabling sRGB framebuffer blending is a more noticable 865 improvement in edge antialiasing quality than moving from 4 to 8 or 866 8 to 16 samples. 867 868 If you are going to use 8 or 16 (or even 4) raster samples with 869 blended coverage modulation, you are well-advised to use sRGB 870 framebuffer blending for best quality. 871 872Revision History 873 874 Revision 3, 2017/02/15 (not merged to Khronos earlier) 875 - ARB_blend_func_extended interaction specified 876 - Mixed samples may not work with sample shading, NVIDIA 877 - Added implementation Details, sRGB advice. 878 879 Revision 2, 2015/03/27 880 - Add ES interactions 881 882 Revision 1 883 - Internal revisions. 884