Antialiasing causes depth buffer issues sometimes (DX9)

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
luthyr
Posts: 69
Joined: Wed Dec 30, 2009 5:47 pm

Antialiasing causes depth buffer issues sometimes (DX9)

Post by luthyr »

When using Antialiasing in the device creation parameters (like SIrrlichtCreationParameters::AntiAlias = 32) for DirectX 9, there is occasionally depth buffer issues (though it doesn't happen in all configurations).

Here is a picture:
Image

It seems like I can solve this issue if I make sure DirectX9 driver always creates at least one new depth buffer. I changed the for loop in checkDepthBuffer to start from index 1, rather than 0. I don't know if this fully solves the issue, but it does seem to make the issue go away. I assume this is some sort of multisampling mismatch when trying to share a depth buffer from a new render target with the backbuffer?

I can get this issue to occur with this configuration, but sometimes have trouble reproducing in other resolutions:
Desktop Resolution: 1920x1080
Window Resolution: 1920x1080 (Ends up reporting something like 1920x1063 because it clips on the bottom, since I'm in windowed mode).
Render Target Resolution: 1024x1024

Changed code:

Code: Select all

void CD3D9Driver::checkDepthBuffer(ITexture* tex)
{
    if (!tex)
        return;
    const core::dimension2du optSize = tex->getSize().getOptimalSize(
            !queryFeature(EVDF_TEXTURE_NPOT),
            !queryFeature(EVDF_TEXTURE_NSQUARE), true);
    SDepthSurface* depth=0;
    core::dimension2du destSize(0x7fffffff, 0x7fffffff);
    for (u32 i=1; i<DepthBuffers.size(); ++i)
    {
        if ((DepthBuffers[i]->Size.Width>=optSize.Width) &&
            (DepthBuffers[i]->Size.Height>=optSize.Height))
        {
            if ((DepthBuffers[i]->Size.Width<destSize.Width) &&
                (DepthBuffers[i]->Size.Height<destSize.Height))
            {
                depth = DepthBuffers[i];
                destSize=DepthBuffers[i]->Size;
            }
        }
    }
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Antialiasing causes depth buffer issues sometimes (DX9)

Post by hybrid »

I think it's due to a mismatch in Rendertarget AA settings with the framebuffer settings. We have similar issues with OpenGL as well, simply because the RTT setup does not feature all settings as of now. And some might even interfere, where maybe a new buffer might help as well. I guess adding one more depth buffer here wouldn't hurt anyway, though it might be still only a workaround.
Post Reply