![](/img/trans.png)
[英]How to use BuildManager to build .Net Core project or solution on Visual Studio 2017 (MsBuild 15)
[英]How do I get Visual Studio 2017 / msbuild to use the latest DirectX shader compiler?
我正在尝试编译一个利用HLSL着色器的C#游戏项目 。 这些着色器是.csproj项目的一部分,因此Visual Studio应该将其与代码一起编译。 着色器属性应该正确-着色器是正确的类型,着色器使用最新的足够的着色器模型(5.1)等。尽管如此,Visual Studio不会构建所有着色器,而是输出两个无用的错误:
error X8000 : D3D11 Internal Compiler error : Invalid Bytecode: Invalid operand type for operand #2 of opcode #107 (counts are 1-based).
error X8000 : D3D11 Internal Compiler error : Invalid Bytecode: Can't continue validation - aborting.
我的第一个猜测是,着色器一定存在某种缺陷。 我打开VS2017命令提示符,并且按预期方式,手动运行fxc
对某些像素着色器产生了相同的错误。 但是,我随后决定检查是否安装了其他版本的fxc
:
C:\koodia\OpenSAGE\src\OpenSage.DataViewer.Windows\Shaders>where fxc
C:\Program Files (x86)\Windows Kits\10\bin\x86\fxc.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x86\fxc.exe
后者来自更新的Windows SDK- fxc /?
报告版本为Direct3D Shader Compiler 10.1
,而第一个版本是Direct3D Shader Compiler 10.0.10011.16384
。 我使用Powershell脚本验证了所有着色器都可以使用较新的编译器成功编译。 然后,我使用msbuild
从命令行编译了项目,该项目确认msbuild(因此是Visual Studio)正在调用旧的fxc
:
FxCompile:
C:\Program Files (x86)\Windows Kits\10\bin\x86\Fxc.exe /nologo /Emain /T ps_5_1 /Fo obj\Debug\Shaders\MeshPS.cso /Zi /enable_unbounded_descriptor_tables Shade
rs\MeshPS.hlsl
error X8000 : D3D11 Internal Compiler error : Invalid Bytecode: Invalid operand type for operand #2 of opcode #107 (counts are 1-based). [C:\koodia\OpenSAGE\src
\OpenSage.DataViewer.Windows\OpenZH.DataViewer.Windows.csproj]
error X8000 : D3D11 Internal Compiler error : Invalid Bytecode: Can't continue validation - aborting. [C:\koodia\OpenSAGE\src\OpenSage.DataViewer.Windows\OpenZH
.DataViewer.Windows.csproj]
最后 ,问题本身:我如何确保msbuild使用最新安装的Windows SDK中的着色器编译器?
我已经安装了最新的Windows SDK,最新的Windows更新,并且已经升级到Visual Studio 15.3.5,但没有任何效果。 我在网上找不到任何与此问题直接相关的信息。 Visual Studio似乎没有与Windows SDK或DirectX版本相关的任何设置。
我设法用一种愚蠢的技巧暂时解决了这个问题。 我换成fxc.exe
和d3dcompiler_47.dll
在C:\\Program Files (x86)\\Windows Kits\\8.1\\bin\\x86
从那些C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.15063.0\\x86
(并备份了原件)。
手工修改Windows SDK并不是一个好主意,但是在我的用例中,它可能不会破坏任何东西,因为FXC应该向后兼容。
我仍在寻找更好的解决方案,或者至少是确认我的Windows + VS安装是否被搞砸了,或者这是否是msbuild中的实际错误/缺失功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.