Jump to content

  • Log In with Google      Sign In   
  • Create Account

Includer shader in multiple shader files


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
2 replies to this topic

#1 schupf   Members   -  Reputation: 216

Like
0Likes
Like

Posted 18 February 2012 - 12:01 PM

Hello,

I have HLSL shaders in .txt files and I want to use a common function (computeLight()) in multiple shader files. If I write the shader in a file common.psh and include it (with #include "common.psh") in files A.psh and B.psh : Will common.psh be compiled two times (for both A.psh and B.psh) or just one time?

Thanks!

Sponsor:

#2 Tsus   Members   -  Reputation: 1061

Like
0Likes
Like

Posted 18 February 2012 - 12:45 PM

Hi!

It will be compiled twice. I haven’t seen an option to let fxc dump object files for each included file (and also no way to link against such) so fxc will compile them again. (This is better for optimizations, too). You always have to recompile shaders when an included file changed.

Cheers! Posted Image

#3 MJP   Moderators   -  Reputation: 11761

Like
0Likes
Like

Posted 19 February 2012 - 12:31 AM

The HLSL compiler will just compile everything. It's very simple in that regard...typically it will just inline everything when generating the assembly (which can be a really good thing, since it will tightly optimize everything along the way). The only real exception is if you use dynamic shader linkage in D3D11.




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