PDA

View Full Version : GL_MULTISAMPLE performance implications against unsupporting rendering targets.



mlfarrell
12-31-2014, 12:44 PM
Does anyone know if there's a performance penalty leaving GL_MULTISAMPLE enabled when switching (say via FBO) to a standard (non multisampled) rendering target?

I'd rather avoid tons of little state checking and glEnable/glDisable API calls every time I bind and unbind to an offscreen FBO. My hope is that the driver just ignores it in these cases.

Alfonse Reinheart
12-31-2014, 05:19 PM
I have no actual knowledge of the performance characteristics of the various implementations on this matter.

But I do know the GL spec. And the specification states that GL_MULTISAMPLE is enabled by default. While that would not be the first time that OpenGL's defaults were a low-performance route, I rather suspect that implementations would take appropriate precautions to ensure that this was not a performance problem in practice. They can always tell if the FBO is multisampled, so they can know whether to turn on the expensive multisample stuff, regardless of the enable/disable state.

mlfarrell
12-31-2014, 05:40 PM
very helpful. thanks!

Dark Photon
12-31-2014, 05:46 PM
Does anyone know if there's a performance penalty leaving GL_MULTISAMPLE enabled when switching (say via FBO) to a standard (non multisampled) rendering target?

I'd rather avoid tons of little state checking and glEnable/glDisable API calls every time I bind and unbind to an offscreen FBO. My hope is that the driver just ignores it in these cases.

Per-spec, for multisample rasterization to be performed, both GL_MULTISAMPLE must be enabled and the value of SAMPLE_BUFFERS must be set to one (true). Your single-sample render targets should have SAMPLE_BUFFERS == 0. So AFAIK there's no functional reason to disable GL_MULTISAMPLE when rasterizing to these single-sample render targets.

And while anything is possible, I doubt that any vendor GL drivers are going to exhibit a performance penalty when rasterizing to a single-sample render target with GL_MULTISAMPLE enabled. But test both ways and verify that on the vendor driver's you care about if you're unsure.