Rendering onto DepthStencilSurface causing black screen

Started by
3 comments, last by Evil Steve 12 years, 2 months ago
Hi all,

Working on an editor for my game, with multiple swap chains (3 excluding implicit one to be exact) and I've run across a slight problem.
Since you cant have D3D9 create and manage the depth stencil with multiple swap chains, I've come across the need to make my own.
The swap chains initialize right, and are set to render to per frame. All the HRESULTs return S_OK and theres no errors in the log from DirectX (debug mode is on) - theres only warnings about redundant render states.
Any ideas? Please post if you want me to add some code from the editor.

Thanks,
James
Advertisement
What's the actual problem? The topic title refers to rendering into a depthstencil surface, but your post refers to multiple swap chains.

Does it work if you don't set a depth stencil buffer and render normally? Do you have the discard depth stencil buffer flag set at device creation (And you're not clearing the depth-stencil surface after calling SetDepthStencil())?

What's the actual problem? The topic title refers to rendering into a depthstencil surface, but your post refers to multiple swap chains.

Does it work if you don't set a depth stencil buffer and render normally? Do you have the discard depth stencil buffer flag set at device creation (And you're not clearing the depth-stencil surface after calling SetDepthStencil())?


Its the depth stencils, I was saying that without any explicit swap chains, the depth stencils can be managed by directx.
If the depth stencils are set to NULL, it renders fine. When they're initialised, I just get a black screen.
They're initialised like so:
for(int i = 0; i < 4; i++)
{
HRESULT hr;
d3dpp.BackBufferHeight = screenSize.y;
d3dpp.BackBufferWidth = screenSize.x;
d3dpp.hDeviceWindow = hWnd;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

if(i > 0)
hr = d3ddev->CreateAdditionalSwapChain(&d3dpp, &swapchains);

depthStencils = NULL;
hr = d3ddev->CreateDepthStencilSurface(d3dpp.BackBufferHeight, d3dpp.BackBufferWidth, d3dpp.AutoDepthStencilFormat, d3dpp.MultiSampleType, d3dpp.MultiSampleQuality, true, &depthStencils, NULL);
}
I dont really think I need DepthStencils, so I removed them. Thanks for the help though :)
When creating the depth-stencil buffer(s) yourself, you also need to enable the buffer (Which is done by D3D when using the auto depth-stencil):
pDevice->SetRenderState(D3DRS_ZENABLE, TRUE);

Any other relevant output from the DirectX debug runtimes (Start menu -> DirectX SDK -> Tools -> DirectX Control Panel -> Direct3D 9 tab, select "Use Debug Direct3D Runtime" and then see if there's relevant output in Visual Studio's debug output window)?

This topic is closed to new replies.

Advertisement