gpt4 book ai didi

c++ - 编译着色器时出错 - DirectX11

转载 作者:行者123 更新时间:2023-11-28 04:52:03 30 4
gpt4 key购买 nike

从昨天开始,我一直在努力解决一些编译器错误,试图编译一个 DirectX11 项目。在我创建并定义要渲染的对象之前,一切都运行良好。为此,我添加了一个着色器(类型效果)。

编译器告诉我““fxc.exe”以代码 1 退出”。为了解决这个问题,我遵循了这个答案:DirectX compilation error: error MSB6006: "fxc.exe" exited with code 1

因此,我将 HLSL 编译器的着色器模型定义为:

Shader Model 5.0 (/5_0)

但在此之后,我仍然会遇到一些错误:

1>c:\program files (x86)\windows kits\8.1\include\um\d3d11shader.h(68): error C3646: 'MinPrecision': unknown override specifier
1>c:\program files (x86)\windows kits\8.1\include\um\d3d11shader.h(68): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\8.1\include\um\d3d11shader.h(235): error C3646: 'InterpolationMode': unknown override specifier
1>c:\program files (x86)\windows kits\8.1\include\um\d3d11shader.h(235): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\8.1\include\shared\dxgi1_2.h(1271): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\8.1\include\shared\dxgi1_2.h(1271): error C2143: syntax error: missing ',' before '*'
1>c:\program files (x86)\windows kits\8.1\include\shared\dxgi1_2.h(1275): error C2061: syntax error: identifier 'DXGI_RGBA'

对于最后三个错误,我以前遇到过,但按照此 MSDN 页面的步骤 5-a 修复了它们:https://msdn.microsoft.com/en-us/library/windows/desktop/ee663275(v=vs.85).aspx但是现在这些错误又回来了,我不明白为什么。我确实再次检查了项目属性,但错误仍然存​​在。

我认为这些是一些编译器错误,我尝试按照上述链接的第 6 步修复它,但没有成功。

顺便说一句,我正在使用 Visual Studio 2015。

有人可以帮我吗?我真的一直在寻找答案并试图修复它,但目前似乎没有任何效果。谢谢。

最佳答案

您很可能错误地混合了旧版 DirectX SDK 和 Windows 8.1 SDK。 D3D_MIN_PRECISION缺少在 Windows 8.1 SDK 版本的 d3dcommon.h 中定义的定义但在旧版 DirectX SDK 中

确保您的 include/libs 路径首先列出了 Windows 8.1 SDK。

确保您明确包含 <d3d11.h>在你包括 <d3dx11.h> 之前以确保您选择正确的版本。

您可能还想明确包含 <d3dcommon.h>也是第一个。

Ideally you'd just not use the legacy DirectX SDK at all in your project. See Living without D3DX and The Zombie DirectX SDK.

当然,所有这些都适用于您的 C++ 代码。标题 d3d11shader.hdxgi1_2.h不能包含在 HLSL 着色器代码中。

关于c++ - 编译着色器时出错 - DirectX11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47980068/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com