Resource barrier pre and post states

Started by
4 comments, last by Dingleberry 7 years, 11 months ago

Resource barriers expect a pre-state as well as a post-state. Does that pre state have to match the current state of the resource in the driver? Or can you have "don't care" states where you are just transitioning from an unknown state to something new.

For instance, in my frame I might have a transition after the buffer flip that goes from "present" to "render target" mode, and vice versa at the end of the frame.

But what if I create the resource in some other initial state (like common), do I have to explicitly transform it before I hit the main render loop? Or can it go from a common "uninitialized" state to the render target state without issue?

Thanks!

Advertisement

Heh, I believe I've just answered my own question through the MSDN docs...

At any given time, a subresource is in exactly one state (determined by a set of flags). The application must ensure that the states are matched when making a sequence of ResourceBarrier calls. In other words, the before and after states in consecutive calls toResourceBarrier must agree.

I also found this video, which answers how to handle state tracking with multiple threads:

https://www.youtube.com/embed/nmB2XMasz2o

This videos is very informative but leaves me wondering about sub resource states management.

Subresources can be in different states, but the rules still apply when setting resource barriers in that the before and after states must be correct. So for example, you could set mip level 0 to a shader resource and mip level 1 as a render target. See the documentation for D3D12_RESOURCE_TRANSITION_BARRIER, specifically the Subresource member.

Yes exactly but what if one need to update the state of many but not all sub resources like regions in a volume texture. Does that mean we have create a bunch of resource barriers?
Is is valid to group a barrier with "all sub-resources" and a specific sub-resource with a different state?

That sounds kind of sketchy, I'd assume the command list processes the barrier group sequentially so it might work but would be doing an unnecessary state change.

This topic is closed to new replies.

Advertisement