0

I have one relatively complicated shader, which I want to compile. Shader has ~700 lines, which are compiled into ~3000 instructions.

Compilation time is with fxc (Windows 8 SDK) about 90 seconds. I have another shader of similar size and compilation time is 20 seconds.

So here are my questions:

  • Is possible to speed up the compilation from application viewpoint (faster version of fxc or fxc alternative)?
  • Is possible to speed up the compilation from code view point (is code constructs which massively slows down the compilation - which ones, how avoid them)?
  • Is possible to speed up the compilation from fxc settings viewpoint (some secre options as --fast-compile or whatever)?

Edit:

Parallel thread on msdn forum:

https://social.msdn.microsoft.com/Forums/en-US/5e60c68e-8902-48d6-b497-e86ac4f2cfe7/hlsl-compilation-speed?forum=vclanguage

user4663214
  • 147
  • 11

2 Answers2

1

There is no "faster" fxc or d3dcompile library.

You can different things to speed up things, turn off optimisation is one of them, as the driver will optimise anyway from dxbc to final microcode.

But the best advice is to implement a shader cache, if you for example pre-process and hash the shader file and trigger compilation only if it is actually different, you will save time.

The d3dcompile library is multi thread safe, and you want to take advantage of multi core CPU. Implementing the include interface to cache file load can be valuable too if you compile many shader.

Finally, when everything fail, you have no choice but experiment and find what takes that long, and do some rewrite, sometimes, a [branch] or [unroll] on the culprit may be enough to solve the compilation time.

galop1n
  • 8,573
  • 22
  • 36
0

Why is the shader compilation time a problem? Fxc is an offline compiler, meaning that the resulting bytecode is hardware independent and can be distributed with your application.

If you're looking to cut down on the iteration times during development, disabling optimalizations with the "/Od" command line option should help.

Quinchilion
  • 912
  • 6
  • 16
  • Problem is of course development. Compilation could be done relatively fast via incredibuild, but there is two critical parts - linking and compiling shaders. Because shader is configed from shared C++ header, every code update leads to new compilation. And that is annoying... – user4663214 Sep 22 '16 at 19:32