Sign in to follow this  
chrisendymion

Compile shaders in build time with common functions

Recommended Posts

Hello ;)

 

I'm in an optimization time for my project.
 
My shaders are actualy compiled in build time (VS 2012) to "shadername.cso" files.
 
For some complex computations (atmospheric scattering, ...), there is a lot of "common functions" for multiple shaders.
They are duplicate in every hlsl file.. It's not very convenient when changes are made :-(
 
Is there a simple solution for compiling shader with only one "common hlsl file", unique for all shaders.. ?
 
Thank you in advance and sorry for my poor english.

 

Chris

Share this post


Link to post
Share on other sites

Hodgman's answer is definitely what you are after.

 

Another option, that although is not what you after is interesting non-the-less, is that DirectX 11.2 supports HLSL shader linking. Adding support for precompiled HLSL functions that can be packaged into libraries and linked into shaders at runtime. This would allow you to build up your shader libraries to support more variations without the cost of runtime HLSL compiler times.

Share this post


Link to post
Share on other sites

Another option, that although is not what you after is interesting non-the-less, is that DirectX 11.2 supports HLSL shader linking. Adding support for precompiled HLSL functions that can be packaged into libraries and linked into shaders at runtime. This would allow you to build up your shader libraries to support more variations without the cost of runtime HLSL compiler times.

 

Unfortunately this is still not a pure HLSL approach but requires mainly C++ (or whatever language is used) host application side code to address the respective API function. It's a shame that we cannot simply reference and use a pre-compiled shader (e.g. assembly source) file the way we do it with HLSL source files using the #include command.

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