Skip to main content
GameDev.net gamedev.net
🔒 Locked

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

Started by Key_C0de Nov 6, 2020 at 7:45 PM 1 replies 5.2k views
Original Post
Key_C0de
Key_C0de

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
Juliean
Juliean

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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.