Here is a picture:
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;
}
}
}