Multisampling parameter ques.

I wonder how to approximate what are correct/optimal values for these parameters?


Should they all be at least 8?

Thanks in advance

That varies, it may be better to look through the various formats and pick one you want.

Also asking for 1 bit for example in the case of zbuffer is an indicator that you are flexible and it will give you as big a buffer as is available without failing.

if you are going to be explicit it’s important to code for fallbacks should your request fail.

For modern desktop hardware, some values that are probably universally supported are: RED = GREEN = BLUE = ALPHA = 8, DEPTH = 24, STENCIL = 8. I’m ignoring the old 16-bit RGB modes because I doubt anybody even uses them anymore. Memory’s too cheap. Also note: you don’t need any ALPHA bits unless you use destination alpha (most apps don’t), but the driver/GPU will very likely allocate 8 bits for you anyway just due to GPU memory padding.

Now as to SAMPLES (and SAMPLE_BUFFERS): These are the original MSAA settings that haven’t quite caught up with the times (you asked about multisampling parameters, so I’ll say a few words about them).

Originally there was only multisample antialiasing (MSAA). SAMPLES was designated for the number of MSAA samples per pixel to allocate for that system framebuffer. Clean, simple.

Then the GPU vendors added support for supersample antialiasing (SSAA), coverage sample antialiasing (CSAA), and combinations of the three. For instance, here are the modes available on an NVidia GTX285 on the latest OpenGL 3.3 drivers:

AA Mode / Description
0 - Off
1 - 2x (2xMS)
5 - 4x (4xMS)
7 - 8x (4xMS, 4xCS)
8 - 16x (4xMS, 12xCS)
9 - 8x (4xSS, 2xMS)
10 - 8x (8xMS)
12 - 16x (8xMS, 8xCS)[/b]

So how do you configure these through OpenGL (or GLX/WGL)? You don’t. You tell the driver which one to use via the __GL_FSAA_MODE environment variable.

And what does SAMPLES (and SAMPLE_BUFFERS) do if this is set? Nothing.

Further, suppose I only wanted to do MSAA anyway. Vendor drivers support pure 8x MSAA (and even 16x MSAA in the past IIRC). Can I select that via SAMPLES? No. At least in GLX, only visuals with SAMPLES of 1, 2, and 4 are available. This means you can’t get to 8x MSAA or higher, much less the combo or non-MSAA modes, via the SAMPLES route.

So bottom line: set SAMPLE_BUFFERS to 1 and SAMPLES to number of MSAA samples you’d ideally like to have, keeping in mind there may be a vendor-specific “back door way” to get more refined access to the antialiasing mode you “really” want (e.g. one which has better performance and lower memory requirements than the pure MSAA mode you’re asking for, or more samples per pixel).

Should they all be at least 8?

That’s going to depend on your application and it’s needs. If you don’t need a buffer channel (e.g. ALPHA, STENCIL), set them to 0 (or don’t even list them). Otherwise the numbers I suggested are reasonable minimums to request (assuming your app targets desktops).

Also (re multisampling), don’t forget to enable multisample rasterization too!: