Horde3D
http://horde3d.org/forums/

Multisample RenderTargets broken
http://horde3d.org/forums/viewtopic.php?f=3&t=1156
Page 1 of 1

Author:  AlexL [ 06.05.2010, 10:49 ]
Post subject:  Multisample RenderTargets broken

In the current SVN (240), multi-sampled render targets are broken, resulting in invalid pipeline and/or wrong depth resolve.
The first problem: The multisampled depth render buffer is not correctly initialized in egRendererBase.cpp, line 836:
Code:
glRenderbufferStorageMultisampleEXT( GL_RENDERBUFFER_EXT, rb.samples, tex.format, rb.width, rb.height );
tex.format is wrong, must be the _depthFormat (GL_DEPTH_COMPONENT16/24).
With this change, FBO setup will complete, so all fine here.

The next problem: the multisampled depth buffer is not correctly resolved when you want to bind it to a regular depth texture.
egRendererBase.cpp, line 917
Code:
glReadBuffer( GL_NONE );
glDrawBuffer( GL_NONE );
GL_NONE is wrong, as then no read/write buffer is bound, but actually we need GL_DEPTH_ATTACHMENT_EXT for both read/write.

I attached a patch (svn-diff to rev. 240 of egRendererBase.cpp) which fixes the problem, working both on Linux and OSX.

Alex

Attachments:
MultiSampleDepthRTFix.txt [1.12 KiB]
Downloaded 967 times

Author:  AlexL [ 06.05.2010, 23:44 ]
Post subject:  Re: Multisample RenderTargets broken

A small edit.
As Marciano pointed out, this does not seem to work on ATI as the calls in my patch
Code:
glReadBuffer(GL_DEPTH_ATTACHMENT_EXT)
glDrawBuffer(GL_DEPTH_ATTACHMENT_EXT)
seem to be illegal (although they worked for us).
We will further investigate, but if anybody has a suggestion, feel free to drop in...

Author:  AlexL [ 09.05.2010, 17:09 ]
Post subject:  Re: Multisample RenderTargets broken

I've just found out that Renderer::initStates disables multisampling and there is no call to enable it again (on a per-render-target basis).
So I added
Code:
if (rb.fboMS != 0)
  glEnable(GL_MULTISAMPLE);
else
  glDisable(GL_MULTISAMPLE);
in RendererBase::setRenderBuffer and now finally I got AA working.
Still I need a different target than GL_NONE
Code:
glDrawBuffer(GL_NONE);
glDrawBuffer(GL_NONE);
in RendererBase::resolveRenderBuffer, otherwise the depth buffer is not correctly resolved.
But I suspect this might be a driver bug (OSX 10.6.4, MBP).

Author:  marciano [ 11.05.2010, 22:33 ]
Post subject:  Re: Multisample RenderTargets broken

Thanks Alex, MSAA should be fixed now.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/