Sign in to follow this  
ZachBethel

Resource barrier pre and post states

Recommended Posts

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!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Edited by WFP

Share this post


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

Share this post


Link to post
Share on other sites

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.

Edited by Dingleberry

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

Sign in to follow this