编译着色器的错误 - DirectX11

时间:2017-12-26 14:41:10

标签: c++ directx shader dxgi

自昨天以来,我一直在努力解决一些编译器错误,试图编译一个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。

有人可以帮我吗?我一直在寻找答案,并试图解决它,但现在似乎没有任何工作。 谢谢。

1 个答案:

答案 0 :(得分:1)

您很可能错误地混合使用旧版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>

  

理想情况下,您根本不在项目中使用传统的DirectX SDK。请参阅Living without D3DXThe Zombie DirectX SDK

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