I’m trying to implement DirectX 12 compatibility with my plugin and am running into an issue with referencing D3D12 RHI classes/data: I need to get access to the D3D12CommandQueue so I can add a command, but this seems to requires access to D3D12RHIPrivate.h, which I can’t include without encountering a slew of compiler errors.
I’ve tried to copy the strategy used by the OculusHMD or SteamVR modules (Build.cs and actual include references) since they accomplish what I need but still hit compiler errors that I haven’t been able to resolve.
Compiler Errors
1>D:\Program Files\UE_4.25\Engine\Source\ThirdParty\Windows\DirectX\Include\d3d11.h(917): warning C4005: 'D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS': macro redefinition
1> C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\winerror.h(56303): note: see previous definition of 'D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS'
1>D:\Program Files\UE_4.25\Engine\Source\ThirdParty\Windows\DirectX\Include\d3d11.h(918): warning C4005: 'D3D11_ERROR_FILE_NOT_FOUND': macro redefinition
1> C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\winerror.h(56312): note: see previous definition of 'D3D11_ERROR_FILE_NOT_FOUND'
1>D:\Program Files\UE_4.25\Engine\Source\ThirdParty\Windows\DirectX\Include\d3d11.h(919): warning C4005: 'D3D11_ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS': macro redefinition
1> C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\winerror.h(56322): note: see previous definition of 'D3D11_ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS'
1>D:\Program Files\UE_4.25\Engine\Source\ThirdParty\Windows\DirectX\Include\d3d11.h(920): warning C4005: 'D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD': macro redefinition
1> C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\winerror.h(56331): note: see previous definition of 'D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD'
1>D:\Program Files\UE_4.25\Engine\Source\ThirdParty\Windows\DirectX\Include\d3d10.h(608): warning C4005: 'D3D10_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS': macro redefinition
1> C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\winerror.h(56279): note: see previous definition of 'D3D10_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS'
1>D:\Program Files\UE_4.25\Engine\Source\ThirdParty\Windows\DirectX\Include\d3d10.h(609): warning C4005: 'D3D10_ERROR_FILE_NOT_FOUND': macro redefinition
1> C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\winerror.h(56288): note: see previous definition of 'D3D10_ERROR_FILE_NOT_FOUND'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2539): error C3646: 'BufferType': unknown override specifier
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2539): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2552): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2552): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2552): error C2238: unexpected token(s) preceding ';'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2648): error C2504: 'ID3D11VideoContext': base class undefined
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2652): error C2061: syntax error: identifier 'ID3D11VideoDecoder'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2660): error C2061: syntax error: identifier 'ID3D11CryptoSession'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2670): error C2061: syntax error: identifier 'ID3D11CryptoSession'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2676): error C2061: syntax error: identifier 'ID3D11VideoDecoder'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2686): error C2061: syntax error: identifier 'ID3D11VideoDecoder'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2692): error C2061: syntax error: identifier 'ID3D11VideoProcessor'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2698): error C2061: syntax error: identifier 'ID3D11VideoProcessor'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2704): error C2061: syntax error: identifier 'ID3D11VideoProcessor'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2710): error C2061: syntax error: identifier 'ID3D11VideoProcessor'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2716): error C2061: syntax error: identifier 'ID3D11VideoProcessor'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2724): error C2061: syntax error: identifier 'ID3D11VideoProcessor'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2736): error C2061: syntax error: identifier 'ID3D11VideoProcessor'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2744): error C2061: syntax error: identifier 'ID3D11VideoProcessor'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(2756): error C2061: syntax error: identifier 'ID3D11VideoProcessor'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(3844): error C2504: 'ID3D11VideoDevice': base class undefined
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(3876): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(3876): error C2143: syntax error: missing ',' before '*'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(3892): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(3892): error C2143: syntax error: missing ',' before '*'
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um\d3d11_1.h(4239): error C2504: 'ID3D11VideoProcessorEnumerator': base class undefined`
I understand that this could relate to code defined in both DX11 and DX12 headers but thought that OculusHMD worked around that correctly by wrapping the include lines like so:
Include Code
#define GetD3D11CubeFace GetD3D12CubeFace
#define VerifyD3D11Result VerifyD3D12Result
#define GetD3D11TextureFromRHITexture GetD3D12TextureFromRHITexture
#define FRingAllocation FRingAllocation_D3D12
#define GetRenderTargetFormat GetRenderTargetFormat_D3D12
#define ED3D11ShaderOffsetBuffer ED3D12ShaderOffsetBuffer
#define FindShaderResourceDXGIFormat FindShaderResourceDXGIFormat_D3D12
#define FindUnorderedAccessDXGIFormat FindUnorderedAccessDXGIFormat_D3D12
#define FindDepthStencilDXGIFormat FindDepthStencilDXGIFormat_D3D12
#define HasStencilBits HasStencilBits_D3D12
#define FVector4VertexDeclaration FVector4VertexDeclaration_D3D12
#define GLOBAL_CONSTANT_BUFFER_INDEX GLOBAL_CONSTANT_BUFFER_INDEX_D3D12
#define MAX_CONSTANT_BUFFER_SLOTS MAX_CONSTANT_BUFFER_SLOTS_D3D12
#define FD3DGPUProfiler FD3D12GPUProfiler
#define FRangeAllocator FRangeAllocator_D3D12
#include "D3D12RHIPrivate.h"
#include "D3D12Util.h"
#undef GetD3D11CubeFace
#undef VerifyD3D11Result
#undef GetD3D11TextureFromRHITexture
#undef FRingAllocation
#undef GetRenderTargetFormat
#undef ED3D11ShaderOffsetBuffer
#undef FindShaderResourceDXGIFormat
#undef FindUnorderedAccessDXGIFormat
#undef FindDepthStencilDXGIFormat
#undef HasStencilBits
#undef FVector4VertexDeclaration
#undef GLOBAL_CONSTANT_BUFFER_INDEX
#undef MAX_CONSTANT_BUFFER_SLOTS
#undef FD3DGPUProfiler
#undef FRangeAllocator
Could the version of the Windows SDK targeted somehow be part of the issue? I’m otherwise at a loss for ideas!