Jump to content
  • Advertisement
Sign in to follow this  

D3D11 Setting shader resource questions

This topic is 2944 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!