• Advertisement
Sign in to follow this  

A basic questions about shader resources (textures)

This topic is 2112 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

Hi!

Could someone answer a simple qestion, please?
I have a few shaders.
They are using the different count of shader resources.
Have I to set unused slots to NULL before rendering?

Example (pseudocode):

ShaderA uses textures X and Y.
ShaderB uses only one, Z:

Which option is more correct:

ShaderA:
PSSetShaderResources( { X, Y } )
ShaderB:
PSSetShaderResources( { Z, NULL } )


or

ShaderA:
PSSetShaderResources( { X, Y } )
ShaderB:
PSSetShaderResources( { Z } )


They work similarly, but which is better?
(more efficient, more safe, etc.)

Thank you very much.

Share this post


Link to post
Share on other sites
Advertisement
You don't have to set unused slots back to NULL. It can make things easier when you're debugging in PIX, and it can also make it easier to avoid read/write conflicts that occur when you have a resource bound as both an input and an output. But in general it's not necessary, and I don't think there's much performance difference.

Share this post


Link to post
Share on other sites
I'd use PSSetShaderResources ({X, Y, Z}), then read from slots 0 and 1 in Shader A and from slot 2 in Shader B. PSSetShaderResources will persist across shader changes (it belongs to the context, not the shader, so it makes sense that it does when you think about it) and you'll only need to set it once.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement