Jump to content
  • Advertisement
NikiTo

DX12 DirectX 12 Render to Stencil Heap

Recommended Posts

I need to share heap between RTV and Stencil. I need to render to a texture and without copying it(only changing the barriers, etc) to be able to use that texture as stencil. without copying nothing around. But the creating of the placed resource fails. I think it could be because of the D3D12_RESOURCE_DESC has 8_UINT format, but D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL enabled too, and MSDN says Stencil does not support that format. Is the format the problem? And if the format is the problem, what format I have to use?

For the texture of that resource I have the flags like: "D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL" and it fails, but when I remove the allow-stencil flag, it works.

Share this post


Link to post
Share on other sites
Advertisement

Heap aliasing doesn't allow for data inheritance between multiple placed resources, only for memory re-use. If you need your data to be in a stencil buffer, you'll need to figure out a way to write it as stencil.

Share this post


Link to post
Share on other sites

Thanks, guys! Judging by the example given in the link to MSDN, I guess it would be complicated to render to multiple render targets, plus a stencil.
Now I am rendering to 5 multiple render targets and 4 of them are regular textures, but the fifth is gonna be used as a stencil. I will try later to compile a shader where one of the MRTs is a stencil output.

Share this post


Link to post
Share on other sites

The pixel shader does not compile with shader model 5.1.
I checked for PSSpecifiedStencilRefSupported and one of the adapters does support it, but it keeps failing for that adapter. (integrated Intel lacks support, but ATI/AMD has it)

In the shader I have like:

struct PSOutput
{
  float color0 : SV_Target0;
  float color1 : SV_Target1;
  float color2 : SV_Target2;
  float color3 : SV_Target3;
  int stnc : SV_StencilRef;     // When I delete this line, it compiles
}

I don't know how to read that BLOP where the error message comes in. Anyways, maybe the solution is something simple you could point me to.

Share this post


Link to post
Share on other sites

ok, it compiles if I return the SV_StencilRef semantic from another function. I haven't tested yet if it actually does something. I will not bump this topic anymore.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 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!