Advertisement

Can I define DirectX 11 HLSL preprocessor directives from C++ code?

Started by November 06, 2020 07:45 PM
1 comment, last by Juliean 4 years, 2 months ago

Say In C++ I want to parameterize the way I want my .hlsl shader to be compiled based on various things happening.

Can I set a preprocessor keyword in C++ say MSAASamples_ to be defined in the HLSL file?

hlsl:

// ...
#ifndef MSAASamples_
   #define MSAASamples_ 1
#endif
// ...

None

When you compile a shader, you can pass an array of D3D10_SHADER_MACRO to D3DCompile, which is key/value-pair for defines. You should check the documentation for details.

This topic is closed to new replies.

Advertisement