Jump to content

  • Log In with Google      Sign In   
  • Create Account


A basic questions about shader resources (textures)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 kubera   Members   -  Reputation: 860

Like
0Likes
Like

Posted 09 April 2012 - 08:06 AM

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.

Sponsor:

#2 MJP   Moderators   -  Reputation: 10219

Like
1Likes
Like

Posted 09 April 2012 - 03:22 PM

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.

#3 mhagain   Crossbones+   -  Reputation: 7418

Like
1Likes
Like

Posted 09 April 2012 - 06:27 PM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#4 kubera   Members   -  Reputation: 860

Like
0Likes
Like

Posted 10 April 2012 - 12:04 AM

Thank you very much for the answers.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS