From 801c65731c10ae61a0fb9252ab8add6bb65ba4d0 Mon Sep 17 00:00:00 2001 From: azhirnov Date: Wed, 19 Aug 2020 18:50:31 +0300 Subject: Use ShaderVersion instead of Uint8 --- .../src/RenderDeviceD3D12Impl.cpp | 20 +++++++++----------- Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp | 11 ++++++++--- 2 files changed, 17 insertions(+), 14 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp index c9e0ee88..8b0b05eb 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp @@ -67,25 +67,23 @@ static CComPtr DXGIAdapterFromD3D12Device(ID3D12Device* pd3d12Dev D3D_SHADER_MODEL RenderDeviceD3D12Impl::GetShaderModel() const { -#ifdef HAS_DXIL_COMPILER // Header may not have constants for D3D_SHADER_MODEL_6_5 and above. const D3D_SHADER_MODEL Models[] = { D3D_SHADER_MODEL(0x65), // for mesh shader D3D_SHADER_MODEL(0x64), - D3D_SHADER_MODEL(0x60)}; + D3D_SHADER_MODEL(0x63), + D3D_SHADER_MODEL(0x62), + D3D_SHADER_MODEL(0x61), + D3D_SHADER_MODEL_6_0}; - // Get maximum supported shader model + // Get maximum supported shader model. D3D12_FEATURE_DATA_SHADER_MODEL ShaderModel = {}; - if (m_pd3d12Device) + for (auto Model : Models) { - for (auto Model : Models) - { - ShaderModel.HighestShaderModel = Model; - if (SUCCEEDED(m_pd3d12Device->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &ShaderModel, sizeof(ShaderModel)))) - return ShaderModel.HighestShaderModel; - } + ShaderModel.HighestShaderModel = Model; + if (SUCCEEDED(m_pd3d12Device->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &ShaderModel, sizeof(ShaderModel)))) + return ShaderModel.HighestShaderModel; } -#endif // Direct3D12 supports shader model 5.1 on all feature levels. // https://docs.microsoft.com/en-us/windows/win32/direct3d12/hardware-feature-levels#feature-level-support diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp index dc723614..86ccaa02 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp @@ -36,16 +36,21 @@ namespace Diligent { -static const Uint8 GetD3D12ShaderModel(RenderDeviceD3D12Impl* pDevice, const ShaderVersion& HLSLVersion) +static ShaderVersion GetD3D12ShaderModel(RenderDeviceD3D12Impl* pDevice, const ShaderVersion& HLSLVersion) { if (HLSLVersion.Major == 0 && HLSLVersion.Minor == 0) { +#ifdef HAS_D12_DXIL_COMPILER D3D_SHADER_MODEL ver = pDevice->GetShaderModel(); - return Uint8((ver & 0xF0) | (ver & 0x0F)); + return ShaderVersion{Uint8((ver >> 4) & 0xF), Uint8(ver & 0xF)}; +#else + // without DXIL compiler you can use only SM 5.1 + return ShaderVersion{5, 1}; +#endif } else { - return Uint8(((HLSLVersion.Major & 0xF) << 4) | (HLSLVersion.Minor & 0xF)); + return HLSLVersion; } } -- cgit v1.2.3