visual-studiodirectxhlsl

How to use DXC on Shader Model 5?


https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-part1:

This topic covers the FXC.EXE compiler used for Shader Models 2 through 5.1. For Shader Model 6, you use DXC.EXE instead, which is documented in Using dxc.exe and dxcompiler.dll. Visual Studio will use DXC.EXE automatically when Shader Model 6 is selected for the HLSL Property Page configuration.

I have an hlsl file, which visual studio is compiling at build time to a .cso file. As per the docs, Visual studio is automatically using fxc if I specify shader model 5 /T cs_5_0 in the file's properties.

But I need to use /HV 2021 which requires dxc. How can I get visual studio to use dxc with /T cs_5_0? Are there properties I can set?

ChatGPT want's be to use a Custom Build Step.

I tried changing Item Type from HLSL Compiler to Custom Build Tool but this caused CreateComputePipelineState to fail with 0x80004005 : 'Unspecified error'...


Solution

  • Seems like DXC is not compatible with shader models < 6. Would have been nice if they gave a warning...

    -T <profile>            Set target profile.
        <profile>: ps_6_0, ps_6_1, ps_6_2, ps_6_3, ps_6_4, ps_6_5, ps_6_6,
                    vs_6_0, vs_6_1, vs_6_2, vs_6_3, vs_6_4, vs_6_5, vs_6_6,
                    cs_6_0, cs_6_1, cs_6_2, cs_6_3, cs_6_4, cs_6_5, cs_6_6,
                    gs_6_0, gs_6_1, gs_6_2, gs_6_3, gs_6_4, gs_6_5, gs_6_6,
                    ds_6_0, ds_6_1, ds_6_2, ds_6_3, ds_6_4, ds_6_5, ds_6_6,
                    hs_6_0, hs_6_1, hs_6_2, hs_6_3, hs_6_4, hs_6_5, hs_6_6,
                    lib_6_3, lib_6_4, lib_6_5, lib_6_6,