Jump to content
  • Advertisement
Sign in to follow this  
exextatic

Rendering onto DepthStencilSurface causing black screen

This topic is 2496 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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())?

Share this post


Link to post
Share on other sites

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);
}

Share this post


Link to post
Share on other sites
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)?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!