Search code examples
c++visual-studio-2019directx-12

d3dx12.h gives a bunch of errors


I'm trying to learn DirectX 12 and i found out these tutorials on github. I downloaded everything and i tried to run the HelloWindow project. I linked the d3d12.lib in Debug->Options->Linker->Input. Unfortunately, it gives me a bunch of errors from d3dx12.h. For most of them, Intellisense says to include d3d12.h even if i already did it. For example, D3D12_RESOURCE_DESC1 is undefined and all his attributes too etc. Did i missed something if yes pls help me.


Solution

  • You are using the 'latest' copy of D3DX12.H which requires you use the 'latest' version of the Windows 10 SDK (19041). If D3D12_RESOURCE_DESC1 is undefined, you are using an older Windows 10 SDK.

    Note that there are three different options for fixing this mismatch:

    1. Install the latest Windows 10 SDK (19041). For VS 2019, this is done by running Visual Studio Installer and selecting the new Windows 10 SDK as a component. For VS 2017, you need to run the standalone installer. VS 2015 and earlier are not supported.

    2. Use a version of the D3DX12.H utility header that supports older SDKs. I maintain a version of the 'latest' D3DX12.H header that contains a bunch of preprocessor conditionals so that it will support Windows 10 SDK (14393) or later. That happens to be last version of the Windows 10 SDK to support VS 2015. Obtain it from GitHub: directx-vs-templates.

    3. Use GitHub DirectX-Headers: A new option is to get the latest headers including D3DX12.H as a set from GitHub. You still need a Windows 10 SDK for the link libraries.

    See this blog post for details on why D3DX12.H is not part of the Windows 10 SDK.

    The samples on DirectX-Graphics-Samples in the main/master branch assume you are using the latest Windows 10 SDK (19041).

    As you are new to DirectX 12, you may want to take a look at DirectX Tool Kit for DX12 as a more gentle introduction to the latest version of the API.