user4663214
user4663214

Reputation: 167

HLSL compilation speed

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:

Edit:

Parallel thread on msdn forum:

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

Upvotes: 0

Views: 1755

Answers (2)

galop1n
galop1n

Reputation: 8824

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.

Upvotes: 1

Quinchilion
Quinchilion

Reputation: 922

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.

Upvotes: 0

Related Questions