Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use DirectX-Headers #637

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ ehthumbs.db
ehthumbs_vista.db
# Folder config file
[Dd]esktop.ini

.idea/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
[submodule "ThirdParty/xxHash"]
path = ThirdParty/xxHash
url = https://github.com/DiligentGraphics/xxHash
[submodule "ThirdParty/DirectX-Headers"]
path = ThirdParty/DirectX-Headers
url = https://github.com/Microsoft/DirectX-Headers
4 changes: 2 additions & 2 deletions Graphics/Archiver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ PRIVATE
)

if(D3D11_SUPPORTED)
target_link_libraries(Diligent-Archiver-static PRIVATE Diligent-GraphicsEngineD3D11-static)
target_link_libraries(Diligent-Archiver-static PRIVATE Diligent-GraphicsEngineD3D11-static DirectX-Headers)
target_include_directories(Diligent-Archiver-static PRIVATE ../GraphicsEngineD3D11/include)
endif()

if(D3D12_SUPPORTED)
target_link_libraries(Diligent-Archiver-static PRIVATE Diligent-GraphicsEngineD3D12-static)
target_link_libraries(Diligent-Archiver-static PRIVATE Diligent-GraphicsEngineD3D12-static DirectX-Headers)
target_include_directories(Diligent-Archiver-static PRIVATE ../GraphicsEngineD3D12/include)
endif()

Expand Down
3 changes: 2 additions & 1 deletion Graphics/GraphicsEngineD3D11/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ PRIVATE
Diligent-GraphicsEngineD3DBase
Diligent-TargetPlatform
Diligent-Common
Diligent-ShaderTools
Diligent-ShaderTools
DirectX-Headers
dxgi.lib
d3d11.lib
d3dcompiler.lib
Expand Down
2 changes: 2 additions & 0 deletions Graphics/GraphicsEngineD3D11/include/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

#include "PlatformDefinitions.h"

#include "directx/d3dcommon.h"

#if PLATFORM_WIN32
# ifndef D3D11_VERSION
# define D3D11_VERSION 2
Expand Down
3 changes: 1 addition & 2 deletions Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ static const ShaderVersion GetD3D11ShaderModel(D3D_FEATURE_LEVEL d3dDeviceFeatur
// Direct3D11 only supports shader model 5.0 even if the device feature level is
// above 11.0 (for example, 11.1 or 12.0).
// https://docs.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-devices-downlevel-intro#overview-for-each-feature-level
#if defined(_WIN32_WINNT_WIN10) && (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
case D3D_FEATURE_LEVEL_12_2:
case D3D_FEATURE_LEVEL_12_1:
case D3D_FEATURE_LEVEL_12_0:
#endif
case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
return (HLSLVersion == ShaderVersion{0, 0}) ?
Expand Down
1 change: 1 addition & 0 deletions Graphics/GraphicsEngineD3D12/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ PRIVATE
Diligent-GraphicsEngineNextGenBase
Diligent-TargetPlatform
Diligent-ShaderTools
DirectX-Headers
dxgi.lib
d3dcompiler.lib
PUBLIC
Expand Down
35 changes: 20 additions & 15 deletions Graphics/GraphicsEngineD3D12/include/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@

#include "WinHPreface.h"

#include <d3d12.h>
#include "directx/d3d12.h"

#include <atlbase.h>

#if USE_D3D12_LOADER
Expand All @@ -44,22 +45,26 @@

#include "WinHPostface.h"

// #ifndef NTDDI_WIN10_FE // First defined in Win SDK 10.0.20348.0
// constexpr D3D_FEATURE_LEVEL D3D_FEATURE_LEVEL_12_2 = static_cast<D3D_FEATURE_LEVEL>(0xc200);
// #endif
//
#ifndef NTDDI_WIN10_VB // First defined in Win SDK 10.0.19041.0
# define D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_RAYS static_cast<D3D12_INDIRECT_ARGUMENT_TYPE>(D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW + 1)
# define D3D12_RAYTRACING_TIER_1_1 static_cast<D3D12_RAYTRACING_TIER>(11)
# define D3D12_HEAP_FLAG_CREATE_NOT_ZEROED D3D12_HEAP_FLAG_NONE
#endif

#ifndef NTDDI_WIN10_19H1 // First defined in Win SDK 10.0.18362.0
enum D3D12_SHADING_RATE
{
};
enum D3D12_SHADING_RATE_COMBINER
{
};

constexpr D3D12_RESOURCE_STATES D3D12_RESOURCE_STATE_SHADING_RATE_SOURCE = static_cast<D3D12_RESOURCE_STATES>(0x1000000);
// # define D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_RAYS static_cast<D3D12_INDIRECT_ARGUMENT_TYPE>(D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW + 1)
// # define D3D12_RAYTRACING_TIER_1_1 static_cast<D3D12_RAYTRACING_TIER>(11)
# define D3D12_HEAP_FLAG_CREATE_NOT_ZEROED D3D12_HEAP_FLAG_NONE
#endif
//
// #ifndef NTDDI_WIN10_19H1 // First defined in Win SDK 10.0.18362.0
// enum D3D12_SHADING_RATE
// {
// };
// enum D3D12_SHADING_RATE_COMBINER
// {
// };
//
// constexpr D3D12_RESOURCE_STATES D3D12_RESOURCE_STATE_SHADING_RATE_SOURCE = static_cast<D3D12_RESOURCE_STATES>(0x1000000);
// #endif

#include "PlatformDefinitions.h"
#include "Errors.hpp"
Expand Down
2 changes: 2 additions & 0 deletions Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ D3D_FEATURE_LEVEL GetD3DFeatureLevelFromDevice(ID3D12Device* pd3d12Device)
{
D3D_FEATURE_LEVEL FeatureLevels[] =
{
D3D_FEATURE_LEVEL_12_2,
D3D_FEATURE_LEVEL_12_1,
D3D_FEATURE_LEVEL_12_0,
D3D_FEATURE_LEVEL_11_1,
Expand Down Expand Up @@ -177,6 +178,7 @@ RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCo
auto FeatureLevel = GetD3DFeatureLevelFromDevice(m_pd3d12Device);
switch (FeatureLevel)
{
case D3D_FEATURE_LEVEL_12_2: m_DeviceInfo.APIVersion = {12, 2}; break;
case D3D_FEATURE_LEVEL_12_1: m_DeviceInfo.APIVersion = {12, 1}; break;
case D3D_FEATURE_LEVEL_12_0: m_DeviceInfo.APIVersion = {12, 0}; break;
case D3D_FEATURE_LEVEL_11_1: m_DeviceInfo.APIVersion = {11, 1}; break;
Expand Down
1 change: 1 addition & 0 deletions Graphics/GraphicsEngineD3DBase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ target_link_libraries(Diligent-GraphicsEngineD3DBase
PRIVATE
Diligent-BuildSettings
Diligent-ShaderTools
DirectX-Headers
PUBLIC
Diligent-GraphicsEngine
Diligent-GraphicsEngineD3DBaseInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,15 @@ class EngineFactoryD3DBase : public EngineFactoryBase<BaseInterface>
default: UNEXPECTED("unknown feature level 11.", Uint32{MinVersion.Minor});
}
break;
# if defined(_WIN32_WINNT_WIN10) && (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
case 12:
switch (MinVersion.Minor)
{
case 0: VERIFY_EXPR(FeatureLevel == D3D_FEATURE_LEVEL_12_0); break;
case 1: VERIFY_EXPR(FeatureLevel == D3D_FEATURE_LEVEL_12_1); break;
case 2: VERIFY_EXPR(FeatureLevel == D3D_FEATURE_LEVEL_12_2); break;
default: UNEXPECTED("unknown feature level 12.", Uint32{MinVersion.Minor});
}
break;
# endif
default:
UNEXPECTED("Unknown major version of the feature level");
}
Expand Down
4 changes: 4 additions & 0 deletions ThirdParty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ if (GL_SUPPORTED AND (PLATFORM_WIN32 OR PLATFORM_LINUX OR PLATFORM_MACOS) AND (N
install(FILES glew/LICENSE.txt DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME GLEW-License.txt)
endif()

if (D3D11_SUPPORTED OR D3D12_SUPPORTED)
add_subdirectory(DirectX-Headers)
endif ()

if (VULKAN_SUPPORTED)
if (NOT TARGET Vulkan::Headers)
# Manually add the Vulkan-Headers target as this is all we need and the
Expand Down
1 change: 1 addition & 0 deletions ThirdParty/DirectX-Headers
Submodule DirectX-Headers added at 453139