microsoft / DirectX-Graphics-Samples

This repo contains the DirectX Graphics samples that demonstrate how to build graphics intensive applications on Windows.
MIT License
5.88k stars 2k forks source link

Cannot build ModelViewer because of errors in HLSL? #875

Closed panthuncia closed 2 weeks ago

panthuncia commented 2 weeks ago

When trying to build the MovelViewer solution (On the latest Visual Studio and Windows), I get this error:

1>------ Build started: Project: Core, Configuration: Debug x64 ------ 1>In file included from Shaders\AdaptExposureCS.hlsl:19: 1>In file included from Shaders/ShaderUtility.hlsli:19: 1>Shaders/ColorSpaceUtility.hlsli(40,12): error G13DA7946: use of undeclared identifier 'select' 1> return select(x < 0.0031308, 12.92 x, 1.055 pow(x, 1.0 / 2.4) - 0.055); 1> ^ 1>Shaders/ColorSpaceUtility.hlsli(46,12): error G13DA7946: use of undeclared identifier 'select' 1> return select(x < 0.04045, x / 12.92, pow( (x + 0.055) / 1.055, 2.4 )); 1> ^ 1>Shaders/ColorSpaceUtility.hlsli(52,12): error G13DA7946: use of undeclared identifier 'select' 1> return select(x < 0.0031308, 12.92 x, 1.13005 sqrt(x - 0.00228) - 0.13448 x + 0.005719); 1> ^ 1>Shaders/ColorSpaceUtility.hlsli(57,12): error G13DA7946: use of undeclared identifier 'select' 1> return select(x < 0.04045, x / 12.92, -7.43605 x - 31.24297 sqrt(-0.53792 x + 1.279924) + 35.34864); 1> ^ 1>Shaders/ColorSpaceUtility.hlsli(65,12): error G13DA7946: use of undeclared identifier 'select' 1> return select(x < 0.0181, 4.5 x, 1.0993 pow(x, 0.45) - 0.0993); 1> ^ 1>Shaders/ColorSpaceUtility.hlsli(70,12): error G13DA7946: use of undeclared identifier 'select' 1> return select(x < 0.08145, x / 4.5, pow((x + 0.0993) / 1.0993, 1.0 / 0.45)); 1> ^ 1> 1>Done building project "Core.vcxproj" -- FAILED.

Are other people seeing this? Or is this a problem with my configuration? Everything's up-to-date, so I'm not sure what might be wrong.

Squall-Leonhart commented 2 weeks ago

install Microsoft.Direct3D.DXC to the Core project via nuget.

panthuncia commented 2 weeks ago

Thanks, that worked. I assume that the DirectX compiler in that package is more up-to-date than the one distributed with Windows?

stanard commented 2 weeks ago

More recent distributions of DXC make HLSL 2021 the default rather than an option. The select() intrinsic was introduced with 2021. I'm submitting a pull request to enable HLSL 2021 even with older versions of DXC.