Detecting MSAA modes based on render target format?

· by Steve · Read in about 2 min · (421 Words)

Hmm, I’m beginning to think this isn’t possible. I’m adding support for multisample AA on render textures to Ogre right now (as opposed to AA on render windows, which we’ve supported for ages), because I need it for a project I’m working on. It’s a little bit more convoluted than I expected since you actually have to create 2 separate render surfaces in both GL and D3D, and blit between them to trigger the AA ‘resolve’ stage, and given the complications particularly in GL with shareable FBO surfaces and making sure that you match AA modes on the shared depth / stencil / colour buffers all adds to the implementation time. Anyway, it appears to be working in GL now, which is where I need it initially but I’ll be doing Dx9/10 too before I commit it, and I also need to make it easy to enable on compositor surfaces. What struck me though is that there doesn’t appear to be any way to detect what pixel formats are supported for AA.

When you’re setting up a render window, you can detect the AA modes supported in both GL and D3D. However, I believe this is all implemented in the RAMDAC and in fact the number of samples supported is the same for all final display formats, at least in most modern cards. When it comes to render textures though, you obviously have more flexibility, such as rendering to floating point surfaces (HDR). AA has not been supported on floating point surfaces in the past, but the recent generations of cards from both nVidia and ATI now support doing this (8800 and R600). This is obviously a good thing - however I can’t seem to find a way of detecting this ability, beyond a brute-force detection of the card by vendor / device ID. Unlike the window-based AA detection which is format based, the ‘number of samples’ reported from the likes of glGetIntegerv(GL_MAX_SAMPLES_EXT) seem to ignore destination formats, and seem to be just based on the global ability of the card to multisample, irrespective of the fact that not all cards can do it on floating point surfaces.

This isn’t a problem for me right now since I know the product I’m working on will only be run on machines beefy enough to do this, but it would be nice to have the ability to know when you can’t do AA with HDR for example, rather than it just not work. If anyone knows any better, I’d love to hear it.