Skip to content

Commit

Permalink
Add D3D_FEATURE_LEVEL_12_2 (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
2A5F authored Nov 27, 2024
1 parent 708741e commit 4540839
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Graphics/GraphicsEngineD3D11/include/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@

#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

#include "Errors.hpp"
#include "RefCntAutoPtr.hpp"
#include "DebugUtilities.hpp"
Expand Down
7 changes: 7 additions & 0 deletions Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ static const ShaderVersion HLSLValidateShaderVersion(const ShaderVersion& Versio

static const ShaderVersion GetD3D11ShaderModel(D3D_FEATURE_LEVEL d3dDeviceFeatureLevel, const ShaderVersion& HLSLVersion)
{
#if defined(_MSC_VER) && !defined(NTDDI_WIN10_FE)
# pragma warning(disable : 4063)
#endif
switch (d3dDeviceFeatureLevel)
{
// 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
Expand All @@ -83,6 +87,9 @@ static const ShaderVersion GetD3D11ShaderModel(D3D_FEATURE_LEVEL d3dDeviceFeatur
UNEXPECTED("Unexpected D3D feature level ", static_cast<Uint32>(d3dDeviceFeatureLevel));
return ShaderVersion{4, 0};
}
#if defined(_MSC_VER) && !defined(NTDDI_WIN10_FE)
# pragma warning(default : 4063)
#endif
}

ShaderD3D11Impl::ShaderD3D11Impl(IReferenceCounters* pRefCounters,
Expand Down
4 changes: 4 additions & 0 deletions Graphics/GraphicsEngineD3D12/include/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@

#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)
Expand Down
8 changes: 8 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 @@ -175,8 +176,12 @@ RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCo
m_DeviceInfo.Features = EnableDeviceFeatures(m_AdapterInfo.Features, EngineCI.Features);

auto FeatureLevel = GetD3DFeatureLevelFromDevice(m_pd3d12Device);
#if defined(_MSC_VER) && !defined(NTDDI_WIN10_FE)
# pragma warning(disable : 4063)
#endif
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 All @@ -185,6 +190,9 @@ RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCo
case D3D_FEATURE_LEVEL_10_0: m_DeviceInfo.APIVersion = {10, 0}; break;
default: UNEXPECTED("Unexpected D3D feature level");
}
#if defined(_MSC_VER) && !defined(NTDDI_WIN10_FE)
# pragma warning(default : 4063)
#endif

// Detect maximum shader model.
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ class EngineFactoryD3DBase : public EngineFactoryBase<BaseInterface>
{
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;
Expand Down

0 comments on commit 4540839

Please sign in to comment.