To compile shaders, I currently spin up a thread per core where each thread pulls a shader from a list and calls D3DX11CompileFromFile for dx11 and D3DXCompileShaderFromFile for dx9.

I've heard it mentioned that spinning up multiple processes instead of multiple threads can be faster, since there is some sort of per process driver contention.

Has anyone tried this, or does anyone have any tips on how to speed up shader compilation?

I have a modern machine w/ SSD drives.


1 Answer 1


From what I can find out (not having tried it myself), using a thread per core to do D3D compiles is reported to be safe and gives a good perf speedup, and there doesn't seem to be any contention between threads in the compiler itself.

However, Fabian Giesen notes that you might see lower perf when running under a debugger, due to contention in the Windows debug heap allocator, which can (and probably should) be disabled.

BTW, the functions you mentioned are both wrappers around D3DCompile, and don't involve the driver per se at all; they only do the GPU-independent "HLSL source to bytecode" step, and not the GPU-specific "bytecode to machine code" step. So they're entirely Microsoft code, not GPU IHV code.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.