1Name 2 3 3DFX_multisample 4 5Name Strings 6 7 GL_3DFX_multisample 8 GLX_3DFX_multisample 9 WGL_3DFX_multisample 10 11Contact 12 13 Paula Womack, 3dfx Interactive (paulaw 'at' 3dfx.com) 14 15Status 16 17 Complete. 18 19Version 20 21 Date: April 18, 2000; Version 1.1 22 23Number 24 25 207 26 27Dependencies 28 29 OpenGL 1.1 is required. 30 GLX 1.2 is required. 31 WGL_ARB_extensions_string is required. 32 WGL_ARB_pixel_format is required. 33 GLX_EXT_fbconfig and GLX 1.3 affect the definition of this extension. 34 This spec is written against OpenGL 1.2 and GLX 1.3 35 36Overview 37 38 This extension provides a mechanism to antialias all GL primitives: 39 points, lines, polygons, bitmaps, and images. The technique is to 40 sample all primitives multiple times at each pixel. The color sample 41 values are resolved to a single, displayable color each time a pixel 42 is updated, so the antialiasing appears to be automatic at the 43 application level. Because each sample includes depth and stencil 44 information, the depth and stencil functions perform equivalently to 45 the single-sample mode. 46 47 An additional buffer, called the multisample buffer, is added to the 48 framebuffer. Pixel sample values, including color, depth, and 49 stencil values, are stored in this buffer. When the framebuffer 50 includes a multisample buffer, it does not also include separate 51 depth or stencil buffers, even if the multisample buffer does not 52 store depth or stencil values. Color buffers (left/right, 53 front/back, and aux) do coexist with the multisample buffer, 54 however. 55 56 Multisample antialiasing is most valuable for rendering polygons, 57 because it requires no sorting for hidden surface elimination, and 58 it correctly handles adjacent polygons, object silhouettes, and even 59 intersecting polygons. If only points or lines are being rendered, 60 the "smooth" antialiasing mechanism provided by the base GL may 61 result in a higher quality image. 62 63 This extension is a subset of SGIS_multisample. It differs in these 64 key ways: 65 66 * Fragment alpha values are not affected by the fragment sample mask 67 * The sample locations may or may not be fixed. Thus, there is no 68 support for rendering the scene multiple times with different 69 sample points. 70 * Fragment masks are not computed for images or for bitmasks. 71 72 Because of these differences a new extension was created. However, 73 it is not expected that this extension will co-exist with 74 SGIS_multisample. Because of this and the fact that there are only 75 32 push/pop bits the MULTISAMPLE_BIT_SGIS state value is the same as 76 MUTLISAMPLE_BIT_3DFX. 77 78IP Status 79 80 No issues. 81 82Issues 83 84 Should tbuffer be kept as a separate extension? 85 86 Yes. The ability to define a write mask for the fragment mask should 87 be kept separate. This feature is orthogonal to SGIS_multisample, 88 while 3DFX_multisample is not. 3DFX_multisample is a strict subset 89 of SGIS_multisample. 90 91 Should the multisample buffer be defined as a separate buffer? 92 93 Yes. It does not need to be implemented this way though. Since GL 94 rendering is done off screen and then blitted (to handle window 95 clipping) the multisample buffer can actually be the same as the 96 offscreen front and back buffers. The blit engine handles reads and 97 writes to/from AA buffers so ReadPixels will work correctly. 98 99 Should we allow the depth values for the different samples to differ 100 when AA is off? 101 102 No. This will be a bug on hardware that operates this way. In 103 practice it should not be a big issue. 104 105New Procedures and Functions 106 107 None 108 109New Tokens 110 111 Accepted by the <attrib_list> parameter of glXChooseFBConfig and 112 glXChooseVisual and by the <attribute> parameter of 113 glXGetFBConfigAttrib and glXGetConfig: 114 115 GLX_SAMPLE_BUFFERS_3DFX 0x8050 116 GLX_SAMPLES_3DFX 0x8051 117 118 Accepted in the <piAttributes> parameter array of 119 wglGetPixelFormatAttribivARB, and wglGetPixelFormatAttribfvARB, and 120 in the <piAttribIList> and <pfAttribFList> parameter arrays of 121 wglChoosePixelFormatARB: 122 123 WGL_SAMPLE_BUFFERS_3DFX 0x2060 124 WGL_SAMPLES_3DFX 0x2061 125 126 Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, 127 and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, 128 and GetDoublev: 129 130 MULTISAMPLE_3DFX 0x86B2 131 132 Accepted by the <pname> parameter of GetBooleanv, GetDoublev, 133 GetIntegerv, and GetFloatv: 134 135 SAMPLE_BUFFERS_3DFX 0x86B3 136 SAMPLES_3DFX 0x86B4 137 138 Accepted by the <mask> parameter of PushAttrib: 139 140 MULTISAMPLE_BIT_3DFX 0x20000000 141 142Additions to Chapter 2 of the 1.2 Specification (OpenGL Operation) 143 144 None 145 146Additions to Chapter 3 of the 1.2 Specification (Rasterization) 147 148 If SAMPLE_BUFFERS_3DFX is one, the rasterization of all GL 149 primitives is changed, and is referred to as multisample 150 rasterization. Otherwise primitive rasterization operates as it is 151 described in the GL specification, and is referred to as 152 single-sample rasterization. The value of SAMPLE_BUFFERS_3DFX is an 153 implementation dependent constant, and is queried by calling 154 GetIntegerv with pname set to SAMPLE_BUFFERS_3DFX. 155 156 During multisample rasterization the contents of a pixel fragment 157 are changed in two ways. First, each fragment includes a coverage 158 mask with SAMPLES_3DFX bits. The value of SAMPLES_3DFX is an 159 implementation dependent constant, and is queried by calling 160 GetIntegerv with pname set to SAMPLES_3DFX. Second, each fragment 161 includes SAMPLES_3DFX depth values, instead of the single depth 162 value that is maintained in single-sample rasterization mode. Each 163 pixel fragment thus consists of integer x and y grid coordinates, a 164 color, SAMPLES_3DFX depth values, texture coordinates, a coverage 165 value, and the SAMPLES_3DFX-bit mask. 166 167 The behavior of multisample rasterization is a function of 168 MULTISAMPLE_3DFX, which is enabled and disabled by calling Enable or 169 Disable, with cap set to MULTISAMPLE_3DFX. Its value is queried 170 using IsEnabled, with cap set to MULTISAMPLE_3DFX. 171 172 If MULTISAMPLE_3DFX is disabled, multisample rasterization of all 173 primitives is equivalent to single-sample rasterization, except that 174 the fragment coverage mask is set to all ones. The depth values may 175 all be set to the single value that would have been assigned by 176 single-sample rasterization, or they may be assigned as described 177 below for MULTISAMPLE_3DFX-enabled multisample rasterization. 178 179 If MULTISAMPLE_3DFX is enabled, multisample rasterization of all 180 primitives differs substantially from single-sample rasterization. 181 It is understood that each pixel in the framebuffer has SAMPLES_3DFX 182 locations associated with it. These locations are exact positions, 183 rather than regions or areas, and each is referred to as a sample 184 point. The sample points associated with a pixel may be located 185 inside or outside of the unit square that is considered to bound the 186 pixel. Furthermore, the pattern (relative location) of sample points 187 may be identical for each pixel in the framebuffer, or it may 188 differ. The locations of the sample points are fixed by the 189 implementation and it is not possible to query the actual sample 190 locations of a pixel. 191 192 If the sample patterns differ per pixel, they should be aligned to 193 window, not screen, boundaries. Otherwise rendering results will be 194 window-position specific. The invariance requirement described in 195 section 3.1 is relaxed for all enabled multisample rasterization, 196 because the sample patterns may be a function of pixel location. 197 198 3.3.2 Point Multisample Rasterization 199 200 If MULTISAMPLE_3DFX is enabled, and SAMPLE_BUFFERS_3DFX is one, then 201 points are rasterized using the following algorithm, regardless of 202 whether point antialiasing (POINT_SMOOTH) is enabled or disabled. 203 Point rasterization produces a fragment for each framebuffer pixel 204 with one or more sample points that intersect the region lying 205 within the circle having diameter equal to the current point width 206 and centered at the point's (Xw,Yw). The coverage value for each 207 fragment is 1. Mask bits that correspond to sample points that 208 intersect the circular region are 1, other mask bits are 0. All 209 depth values of the fragment are assigned the depth value of the 210 point being rasterized. The data associated with each fragment are 211 otherwise the data associated with the point being rasterized. 212 213 Point size range and number of gradations are equivalent to those 214 supported for antialiased points. 215 216 3.4.4 Line Multisample Rasterization 217 218 If MULTISAMPLE_3DFX is enabled, and SAMPLE_BUFFERS_3DFX is one, then 219 lines are rasterized using the following algorithm, regardless of 220 whether line antialiasing (LINE_SMOOTH) is enabled or disabled. Line 221 rasterization produces a fragment for each framebuffer pixel with 222 one or more sample points that intersect the rectangular region that 223 is described in the Antialiasing section of 3.4.2 (Other Line 224 Segment Features). If line stippling is enabled, the rectangular 225 region is subdivided into adjacent unit-length rectangles, with some 226 rectangles eliminated according to the procedure given under Line 227 Stipple, where "fragment" is replaced by "rectangle". 228 229 The coverage value for each fragment is 1. Mask bits that correspond 230 to sample points that intersect a retained rectangle are 1, other 231 mask bits are 0. Each depth value is produced by substituting the 232 corresponding sample location into equation 3.1, then using the 233 result to evaluate equation 3.3. The data associated with each 234 fragment are otherwise computed by evaluating equation 3.1 at the 235 fragment center, then substituting into equation 3.2. 236 237 Line width range and number of gradations are equivalent to those 238 supported for antialiased lines. 239 240 3.5.7 Polygon Multisample Rasterization 241 242 If MULTISAMPLE_3DFX is enabled, and SAMPLE_BUFFERS_3DFX is one, then 243 polygons are rasterized using the following algorithm, regardless of 244 whether polygon antialiasing (POLYGON_SMOOTH) is enabled or 245 disabled. Polygon rasterization produces a fragment for each 246 framebuffer pixel with one or more sample points that satisfy the 247 point sampling criteria described in section 3.5.1, including the 248 special treatment for sample points that lie on a polygon boundary 249 edge. If a polygon is culled, based on its orientation and the 250 CullFace mode, then no fragments are produced during rasterization. 251 Fragments are culled by the polygon stipple just as they are for 252 aliased and antialiased polygons. 253 254 The coverage value for each fragment is 1. Mask bits that correspond 255 to sample points that satisfy the point sampling criteria are 1, 256 other mask bits are 0. Each depth value is produced by substituting 257 the corresponding sample location into the barycentric equations 258 described in section 3.5.1, using the approximation to equation 3.4 259 that omits w components. The data associated with each fragment are 260 otherwise computed by barycentric evaluation using the fragment's 261 center point. 262 263 If POLYGON_OFFSET_FILL is enabled then the offset value computed in 264 equation 3.7 is added to all sample depth values. 265 266 The rasterization described above applies only to the FILL state of 267 PolygonMode. For POINT and LINE, the rasterizations described in 268 3.3.2 (Point Multisample Rasterization) and 3.4.4 (Line Multisample 269 Rasterization) apply with the additional requirement that the sample 270 depth values must be offset by the value computed in equation 3.7 271 when POLYGON_OFFSET_POINT or POLYGON_OFFSET_LINE is enabled. 272 273 3.6.5 Multisample Rasterization of Pixel Rectangles 274 275 If MULTISAMPLE_3DFX is enabled, and SAMPLE_BUFFERS_3DFX is one, then 276 pixel rectangles are rasterized using the following algorithm. Let 277 (Xrp,Yrp) be the current raster position. (If the current raster 278 position is invalid, then DrawPixels is ignored.) If a particular 279 group (index or components) is the nth in a row and belongs to the 280 mth row, consider the region in window coordinates bounded by the 281 rectangle with corners 282 283 (Xrp + Zx*n, Yrp + Zy*m) 284 285 and 286 287 (Xrp + Zx*(n+1), Yrp + Zy*(m+1)) 288 289 where Zx and Zy are the pixel zoom factors specified by PixelZoom, 290 and may each be either positive or negative. A fragment representing 291 group n,m is produced for each framebuffer pixel with one or more 292 sample points that lie inside, or on the bottom or left boundary, of 293 this rectangle. Each fragment so produced takes its associated data 294 from the group and from the current raster position, in a manner 295 consistent with SGIX_pixel_texture (if it is implemented) or in a 296 manner consistent with the discussion in the Conversion to Fragments 297 subsection of section 3.6.4 of the GL specification. All depth 298 sample values are assigned the same value, taken either from the 299 group (if it is a depth component group) or from the current raster 300 position (if it is not). 301 302 A single pixel rectangle will generate multiple, perhaps very many 303 fragments for the same framebuffer pixel, depending on the pixel 304 zoom factors. 305 306 3.7.1 Bitmap Multisample Rasterization 307 308 If MULTISAMPLE_3DFX is enabled, and SAMPLE_BUFFERS_3DFX is one, then 309 bitmaps are rasterized using the following algorithm. If the current 310 raster position is invalid, the bitmap is ignored. Otherwise, a 311 screen-aligned array of pixel-size rectangles is constructed, with 312 its lower-left corner at (Xrp,Yrp), and its upper right corner a 313 (Xrp+w,Yrp+h), where w and h are the width and height of the bitmap. 314 Rectangles in this array are eliminated if the corresponding bit in 315 the bitmap is zero, and are retained otherwise. Bitmap rasterization 316 produces a fragment for each framebuffer pixel with one or more 317 sample points either inside or on the bottom or left edge of a 318 retained rectangle. 319 320Additions to Chapter 4 of the 1.2 Specification (Per-Fragment Operations 321and the Frame Buffer) 322 323 4.1.9 Multisample Fragment Operations 324 325 If the DrawBuffers mode is NONE, no change is made to any 326 multisample or color buffer. Otherwise, fragment processing is as 327 described below. 328 329 If MULTISAMPLE_3DFX is enabled, and SAMPLE_BUFFERS_3DFX is one, the 330 stencil test, depth test, blending, and dithering operations 331 described in sections 4.1.4, 4.1.5, 4.1.6, and 4.1.7 are performed 332 for each pixel sample, rather than just once for each fragment. 333 Failure of the stencil or depth test results in termination of the 334 processing of that sample, rather than discarding of the fragment. 335 All operations are performed on the color, depth, and stencil values 336 stored in the multisample buffer (to be described in a following 337 section). The contents of the color buffers are not modified at this 338 point. 339 340 Stencil, depth, blending, and dithering operations are performed for 341 a pixel sample only if that sample's fragment mask bit is 1. If the 342 corresponding mask bit is 0, no operations are performed for that 343 sample. Depth operations use the fragment depth value that is 344 specific to each sample. The single fragment color value is used for 345 all sample operations, however, as is the current stencil value. 346 347 If MULTISAMPLE_3DFX is disabled, and SAMPLE_BUFFERS_3DFX is one, the 348 fragment may be treated exactly as described above, with 349 optimization possible because the fragment mask must be all 1's. 350 Further optimization is allowed, however. An implementation may 351 choose to identify a centermost sample, and to perform stencil and 352 depth tests on only that sample. Regardless of the outcome of the 353 stencil test, all multisample buffer stencil sample values are set 354 to the appropriate new stencil value. If the depth test passes, all 355 multisample buffer depth sample values are set to the depth of the 356 fragment's centermost sample's depth value, and all multisample 357 buffer color sample values are set to the color value of the 358 incoming fragment. Otherwise, no change is made to any multisample 359 buffer color or depth value. 360 361 After all operations have been completed on the multisample buffer, 362 the color sample values are combined to produce a single color 363 value, and that value is written into each color buffer that is 364 currently enabled, based on the DrawBuffers mode. The method of 365 combination is not specified, though a simple average computed 366 independently for each color component is recommended. 367 368 4.2.2.5 Fine Control of Multisample Buffer Updates 369 370 When SAMPLE_BUFFERS_3DFX is one, ColorMask, DepthMask, and 371 StencilMask control the modification of values in the multisample 372 buffer. The color mask has no effect on modifications to the color 373 buffers. If the color mask is entirely disabled, the color sample 374 values must still be combined (as described above) and the result 375 used to replace the color values of the buffers enabled by 376 DrawBuffers. 377 378 4.2.3.5 Clearing the Multisample Buffer 379 380 The color samples of the multisample buffer are cleared when one or 381 more color buffers are cleared, as specified by the Clear mask bit 382 COLOR_BUFFER_BIT and the DrawBuffers mode. If the DrawBuffers mode 383 is NONE, the color samples of the multisample buffer cannot be 384 cleared. 385 386 Clear mask bits DEPTH_BUFFER_BIT and STENCIL_BUFFER_BIT indicate 387 that the depth and stencil samples of the multisample buffer are to 388 be cleared. If Clear mask bit DEPTH_BUFFER_BIT is specified, and if 389 the DrawBuffers mode is not NONE, then the multisample depth buffer 390 samples are cleared. Likewise, if Clear mask bit STENCIL_BUFFER_BIT 391 is specified, and if the DrawBuffers mode is not NONE, then the 392 multisample stencil buffer is cleared. 393 394 4.3.2 Reading Pixels 395 396 [These changes are made to the text in section 4.3.2, following the 397 subheading Obtaining Pixels from the Framebuffer.] 398 399 Follow the sentence "If there is no depth buffer, the error 400 INVALID_OPERATION occurs." with: If there is a multisample buffer 401 (SAMPLE_BUFFERS_3DFX is 1) then values are obtained from the depth 402 samples in this buffer. It is recommended that the depth value of 403 the centermost sample be used, though implementations may choose any 404 function of the depth sample values at each pixel. 405 406 Follow the sentence "if there is no stencil buffer, the error 407 INVALID_OPERATION occurs." with: If there is a multisample buffer, 408 then values are obtained from the stencil samples in this buffer. It 409 is recommended that the stencil value of the centermost sample be 410 used, though implementations may choose any function of the stencil 411 sample values at each pixel. 412 413 This extension makes no change to the way that color values are 414 obtained from the framebuffer. 415 416Additions to Chapter 5 of the 1.2 Specification (Special Functions) 417 418 None 419 420Additions to Chapter 6 of the 1.2 Specification (State and State Requests) 421 422 An additional group of state variables, MULTISAMPLE_BIT_3DFX, is 423 defined by this extension. When PushAttrib is called with bit 424 MULTISAMPLE_BIT_3DFX set, the multisample group of state variables 425 is pushed onto the attribute stack. When PopAttrib is called, these 426 state variables are restored to their previous values if they were 427 pushed. Some multisample state is included in the ENABLE_BIT group 428 as well. In order to avoid incompatibility with GL implementations 429 that do not support 3DFX_multisample, ALL_ATTRIB_BITS does not 430 include MULTISAMPLE_BIT_3DFX. 431 432Additions to the GLX 1.3 Specification 433 434 The parameter GLX_SAMPLE_BUFFERS_3DFX is added to 435 glXGetFBConfigAttrib. When queried, by calling glXGetFBConfigAttrib 436 with attribute set to GLX_SAMPLE_BUFFERS_3DFX, it returns the number 437 of multisample buffers included in the visual. For a normal visual, 438 the return value is zero. A return value of one indicates that a 439 single multisample buffer is available. The number of samples per 440 pixel is queried by calling glXGetFBConfigAttrib with attribute set 441 to GLX_SAMPLES_3DFX. It is understood that the number of color, 442 depth, and stencil bits per sample in the multisample buffer are as 443 specified by the GLX_*_SIZE parameters. It is also understood that 444 there are no single-sample depth or stencil buffers associated with 445 this visual -- the only depth and stencil buffers are those in the 446 multisample buffer. GLX_SAMPLES_3DFX is zero if 447 GLX_SAMPLE_BUFFERS_3DFX is zero. 448 449 glXChooseFBConfig accepts GLX_SAMPLE_BUFFERS_3DFX in attrib_list, 450 followed by the minimum number of multisample buffers that can be 451 accepted. Visuals with the smallest number of multisample buffers 452 that meets or exceeds the specified minimum number are preferred. 453 Currently operation with more than one multisample buffer is 454 undefined, so the returned value will be either zero or one. 455 456 glXChooseFBConfig accepts GLX_SAMPLES_3DFX in attrib_list, followed 457 by the minimum number of samples that can be accepted in the 458 multisample buffer. Visuals with the smallest number of samples that 459 meets or exceeds the specified minimum number are preferred. 460 461 The multisample FBConfig attributes are added to table 3.4 as follows: 462 463 Attribute Default Selection Criteria Sort Priority 464 --------- ------- ------------------ ------------- 465 GLX_SAMPLE_BUFFERS_3DFX 0 Smaller 466 GLX_SAMPLES_3DFX 0 Smaller 467 468 If the GLX implementation is 1.2 or less, then 469 GLX_SAMPLE_BUFFERS_3DFX and GLX_SAMPLES_3DFX are accepted by 470 glXChooseVisual and glXGetConfig. 471 472 If the color samples in the multisample buffer store fewer bits than 473 are stored in the color buffers, this fact will not be reported 474 accurately. Presumably a compression scheme is being employed, and 475 is expected to maintain an aggregate resolution equal to that of the 476 color buffers. 477 478Additions to WGL 479 480 The parameters WGL_SAMPLE_BUFFERS_3DFX and WGL_SAMPLES_3DFX are 481 added to wglGetPixelFormatAttribivARB and 482 wglGetPixelFormatAttribfvARB. WGL_SAMPLE_BUFFERS_3DFX indicates the 483 number of multisample buffers included in the pixel format. For a 484 normal pixel format, the return value is zero. A return value of one 485 indicates that a single multisample buffer is available. 486 WGL_SAMPLES_3DFX gives the number of samples per pixel. It is 487 understood that the number of color, depth, and stencil bits per 488 sample in the multisample buffer are as specified by the WGL_*_BITS 489 parameters. It is also understood that there are no single-sample 490 depth or stencil buffers associated with this pixel format -- the 491 only depth and stencil buffers are those in the multisample buffer. 492 WGL_SAMPLES_3DFX is zero if WGL_SAMPLE_BUFFERS_3DFX is zero. 493 494 wglChoosePixelFormatARB accepts WGL_SAMPLE_BUFFERS_3DFX in 495 piAttribIList and/or pfAttribFList, followed by the minimum number 496 of multisample buffers that can be accepted. Pixel formats with the 497 smallest number of multisample buffers that meet or exceed the 498 specified minimum number are preferred. Currently operation with 499 more than one multisample buffer is undefined, so the returned value 500 will be either zero or one. 501 502 wglChoosePixelFormatARB accepts WGL_SAMPLES_3DFX in piAttribIList 503 and/or pfAttribFList, followed by the minimum number of samples that 504 can be accepted in the multisample buffer. Pixel formats with the 505 smallest number of samples that meet or exceed the specified minimum 506 number are preferred. 507 508Errors 509 510 None 511 512New State 513 514 515 Get Value Get Command Type Initial Value Attribute 516 --------- ----------- ---- ------------- --------- 517 MULTISAMPLE_3DFX IsEnabled B TRUE multisample/enable 518 519New Implementation Dependent State 520 521 Get Value Get Command Type Minimum Value 522 --------- ----------- ---- ------------- 523 SAMPLE_BUFFERS_3DFX GetIntegerv Z+ 0 524 SAMPLES_3DFX GetIntegerv Z+ 0 525 526Dependencies on GLX 1.3 and GLX_EXT_fbconfig 527 528 If GLX 1.3 is not supported and GLX_EXT_fbconfig is not supported 529 then all references to glXGetFBConfigAttrib and glXGetConfig are 530 removed. 531 532Revision History 533 534 Version 1.1 - April 18, 2000 (Jon Leech, SGI) 535 536 Specified value of MULTISAMPLE_BIT_3DFX. Assigned values to 537 GLX_SAMPLE_BUFFERS_3DFX and GLX_SAMPLES_3DFX. Conversion from 538 HTML -> text and formatting cleanup. 539