Jump to content
  • Advertisement
Sign in to follow this  
Funkymunky

HLSL: next free register binding

This topic is 970 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 have a shader that #includes two other pieces of code.  Each of those #include files declares a Texture2D.  Is there any way to know in my main code what the currently "free" register is?  Like:

 

.

// Effect1.hlsl
Texture2D fx1;
...

// Effect2.hlsl
Texture2D fx2;
...

// Main.hlsl
#include "Effect1.hlsl"
#include "Effect2.hlsl"

Texture2D firstTexture : register(t#)
Texture2D secondTexture : register(t#)
...

.

 

Is there any way to know what those t#'s would be (in this case t2 and t3)?  Perhaps by some trick of a preprocessor directive with a #define passed from the engine code?  I know that explicitly declaring the register is optional, but I'm still curious.

Edited by Funkymunky

Share this post


Link to post
Share on other sites
Advertisement

I know that explicitly declaring the register is optional

That's the answer - if you want them to automatically go into the next free slot, leave off the explicit register declaration.
 
In my shader system I add these kinds of extensions by but machine-generating the code that declares resources (and declare resources in a declarative DSL alongside the HLSL code).

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!