Sign in to follow this  
schupf

Includer shader in multiple shader files

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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! [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this