[D3D12] Shadow map only renders on every other frame rtv.

Started by
4 comments, last by Anthom 8 years, 7 months ago

Hello,

im currently experiencing a weird problem. My shadow mapping only applies to the rtv im not seeing (Using doublebuffered swapchain)

Checking with Visual Studios graphics debugger shows that the shadow map is written fine (depth stencil texture with state transition to shader resource)

In the mid the picture i see while running the application. On the left the debugger output of the other rtv. Its always with shadow mapping applied. On the right the shadow map.

The Shadow map is always on one rtv, but this never seems to be the one visible. Its not even flickering (not one rtv with shadow map and one without), its constant without any shadows. Only the debugger shows the shadows.

Any idea what could cause this problem?

Edit:

Outputting the shadow depth texture as a diffuse texture just shows that the visible rtv somehow has a depth texture from camera perspective (the default depth stencil used). In the debugger, the other one rtv has the real shadow map applied. What the hell?

lLvvJbJ.jpg

Advertisement
Have you turned on D3D12's validation layer (ID3D12Debug::EnableDebugLayer) to see if it reports any obvious mistakes?
yes i do. no error or warning. its that it binds my default stencil to the shadow texture. it uses the depth the the camera is "seeing" (default depth stencil texture) as texture i bind the svadow texture to. really weird behavior. i checked shadow texture and the depth stencil resources in the gpu debbuger and they are fine. as seen in the picture i posted.

Have you unbound resources before using them as input in your shaders?

.:vinterberg:.

unbound? i created a dsv and a srv poinzing to the shadow texture resource. i use the dsv in the shadow pass and the rsv in the rendering/sampling pass. in between i transition resource state from depth write to shader resource state and back after sampling

Edit:

ok i got it working by unwrapping my class. looks like a resource lifetime problem or maybe lifetime descriptor problems. Now im able to wrap it step by step back into a class and check for errors.

Edit:

Just read: https://msdn.microsoft.com/en-us/library/windows/desktop/dn788714(v=vs.85).aspx

"Currently, there is one graphics and one compute root signature per app."

So my only option would be to deserialize the root signature and serialize again with new parameters? Or just define all possible tables at the beginning?

Original:

ok i isolated the problem and its my pipeline state object.

if i use the same root parameters as for the main shader, its working.

if i use different root parameters for each graphics pipeline (root signature and pso, each), and bind the shadow texture at descriptor table 0 instead of 2, i get the behavior i explained in the other posts.

in the multithreaded example from microsoft they are also reusing the same root parameters (or root signatures) for both pso`s?!

debug layer is not complaining about anything.

This topic is closed to new replies.

Advertisement