0

The topic may sound like a duplicate question but the problem in my case is that I don't have any HLSL files included in the project. Thus, I can not manually disable/change the dxc compiler. Though, I have added a pre-build command using CMake to generate SPIR-V from HLSL files. While compiling the project I get the following error:

dxc failed : SPIR-V CodeGen not available. Please recompile with -DENABLE_SPIRV_CODEGEN=ON.

meaning that Visual Studio uses the built-in dxc which does not have support for SPIR-V CodeGen. How can I explicitly tell which dxc version to use using CMake?

Tunti
  • 79
  • 6

1 Answers1

0

Explicitly specifying the dxc path to use VulkanSDK's version fixed the issue

add_custom_command(
    TARGET ${target}
    PRE_BUILD
    COMMAND $ENV{VULKAN_SDK}/bin/dxc.exe -spirv -fvk-invert-y -T vs_6_0 -E ${vertexEntry} ${file} -Fo ${CMAKE_SOURCE_DIR}/Assets/${vertexEntry}.spv
    COMMAND $ENV{VULKAN_SDK}/bin/dxc.exe -spirv -T ps_6_0 -E ${fragmentEntry} ${file} -Fo ${CMAKE_SOURCE_DIR}/Assets/${fragmentEntry}.spv
)
Tunti
  • 79
  • 6