[RESOLVED] Setting up depth buffer in RenderPlugin Prepar3D

SDK supports Prepar3D’s philosophy of an open development architecture and encourages third parties to bring new innovations with improved add-ons and training content.
Locked
antox
Posts: 4
Joined: Mon Dec 18, 2017 11:23 pm

[RESOLVED] Setting up depth buffer in RenderPlugin Prepar3D

Post by antox »

Render target view comes from PDK::IRenderData, but how do you configure a suitable depth stencil view?

In a stand-alone application I had control over both of those, and also, parameter mismatch was easy to diagnose with D3D debug layer (D3D11_CREATE_DEVICE_DEBUG). Now in a plugin DLL, I am lost and only can tell something is wrong because nothing is rendered after the OMSetRenderTargets() call. Any hint would be much appreciated.

Here is the essence of what I am doing:
UINT width, height;
ID3D11RenderTargetView* targetView;
ID3D11Texture2D* depthTex;
ID3D11DepthStencilView* depthView;

width = (UINT)pRenderData->GetTextureWidth();
height = (UINT)pRenderData->GetTextureHeight();

targetView = pRenderData->GetOutputColor();

D3D11_TEXTURE2D_DESC texDesc = // <--
    CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_D32_FLOAT, width, height, 1, 1, D3D11_BIND_DEPTH_STENCIL);
D3D11_DEPTH_STENCIL_VIEW_DESC viewDesc =
    CD3D11_DEPTH_STENCIL_VIEW_DESC(D3D11_DSV_DIMENSION_TEXTURE2D);
dev->CreateTexture2D(&texDesc, nullptr, &depthTex);
dev->CreateDepthStencilView(depthTex, &viewDesc, &depthView);
ctx->ClearDepthStencilView(depthView, D3D11_CLEAR_DEPTH, 1.0f, 0);

ctx->OMSetRenderTargets(1, &targetView, depthView); // <--

Thanks,
Antons
JB3DG
Posts: 609
Joined: Mon Jan 09, 2012 6:44 pm

Re: Setting up depth buffer in RenderPlugin

Post by JB3DG »

You can force debugging on via the DirectX control panel in your VS2015.
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun
antox
Posts: 4
Joined: Mon Dec 18, 2017 11:23 pm

Re: Setting up depth buffer in RenderPlugin

Post by antox »

Thank you! This has helped a lot.
Locked