Sign in to follow this  
david_watt78

D3D11 Setting shader resource questions

Recommended Posts

david_watt78    133
I am currently implementing a replacement for effect files on my d3d11 engine. I have questions about Setting shader resources. When I call a SetShaderResource call does it effect all slots or just the ones I specify? For example I want to avoid the issue of leaving resources bound to the pipeline because my next shader uses 2 slots when the last used 3. Also does it take more cpu/gpu to set all 128 slots vs say 8?

Share this post


Link to post
Share on other sites
DieterVW    724
Settings resources only affects the slots you are targeting, all other slots maintain their current state.

The time it takes to set slots will grow linearly with the number of resources being set (due to some very minimal validation) plus whatever overhead it costs to call the API in general. Calling once and setting many resources should provide a only a small gain over setting each slot separately.

Leaving resources bound to the pipeline when the next shader doesn't use them isn't an issue. There's really no point in clearing resource slots except perhaps in some debugging situations.

Share this post


Link to post
Share on other sites
Jason Z    6436
I have implemented a simple system to remember which slots have been filled by a previous effect, and then the renderer only sets the needed number of extra null pointers for the next effect. Its little more than a pair of arrays, but you can check out the code from my engine in the link below.

Share this post


Link to post
Share on other sites
david_watt78    133
I believe remembering what slots were used is probably the best way to handle it. As to leaving them bound not being an issue, not if I use the resources in slot 3 or 4 as a render target or want to dispose of them. As well that is assuming that the driver doesnt have an issue with it. I prefer to always clean up after myself, it avoids many wierd why doesn't that work moments.

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