Jump to content

View more

Image of the Day

Working on an auto spawn system. #gamedev #indiedev #screenshotsaturday https://t.co/Mm2kfekz7b
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Includer shader in multiple shader files

4: Adsense

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   

221
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!

#2 Tsus   Members   

1186
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   

19402
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.