diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-10-17 04:06:08 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-10-17 04:06:08 +0000 |
| commit | bc4a29a1fac0276e499bb37bb3c449ebdcacbe92 (patch) | |
| tree | 50316f6b243300fdf9ef25afe1aad5d619ccfa08 /Graphics/GraphicsEngineD3DBase | |
| parent | Added option to install PDB files on Windows (closed https://github.com/Dilig... (diff) | |
| download | DiligentCore-bc4a29a1fac0276e499bb37bb3c449ebdcacbe92.tar.gz DiligentCore-bc4a29a1fac0276e499bb37bb3c449ebdcacbe92.zip | |
A bunch of updates to specify minimum feature level for D3D11/D3D12 backends and to enable bindless mode (API version 240032)
Diffstat (limited to 'Graphics/GraphicsEngineD3DBase')
3 files changed, 61 insertions, 56 deletions
diff --git a/Graphics/GraphicsEngineD3DBase/include/EngineFactoryD3DBase.h b/Graphics/GraphicsEngineD3DBase/include/EngineFactoryD3DBase.h index 8b9f50cb..fac7683c 100644 --- a/Graphics/GraphicsEngineD3DBase/include/EngineFactoryD3DBase.h +++ b/Graphics/GraphicsEngineD3DBase/include/EngineFactoryD3DBase.h @@ -42,22 +42,12 @@ public: TEngineFactoryBase(FactoryIID) {} - /// Enumerates hardware adapters available on this machine - - /// \param [in,out] NumAdapters - Number of adapters. If Adapters is null, this value - /// will be overwritten with the number of adapters available - /// on this system. If Adapters is not null, this value should - /// contain maximum number of elements reserved in the array - /// pointed to by Adapters. In the latter case, this value - /// is overwritten with the actual number of elements written to - /// Adapters. - /// \param [out] Adapters - Pointer to the array conataining adapter information. If - /// null is provided, the number of available adapters is written to - /// NumAdapters - virtual void EnumerateHardwareAdapters(Uint32 &NumAdapters, - HardwareAdapterAttribs *Adapters)override final + + virtual void EnumerateHardwareAdapters(DIRECT3D_FEATURE_LEVEL MinFeatureLevel, + Uint32& NumAdapters, + HardwareAdapterAttribs* Adapters)override final { - auto DXGIAdapters = FindCompatibleAdapters(); + auto DXGIAdapters = FindCompatibleAdapters(MinFeatureLevel); if (Adapters == nullptr) NumAdapters = static_cast<Uint32>(DXGIAdapters.size()); @@ -89,24 +79,15 @@ public: } } - /// Enumerates available display modes for the specified output of the specified adapter - - /// \param [in] AdapterId - Id of the adapter enumerated by EnumerateHardwareAdapters(). - /// \param [in] OutputId - Adapter output id - /// \param [in] Format - Display mode format - /// \param [in, out] NumDisplayModes - Number of display modes. If DisplayModes is null, this - /// value is overwritten with the number of display modes - /// available for this output. If DisplayModes is not null, - /// this value should contain the maximum number of elements - /// to be written to DisplayModes array. It is overwritten with - /// the actual number of display modes written. - virtual void EnumerateDisplayModes(Uint32 AdapterId, - Uint32 OutputId, - TEXTURE_FORMAT Format, - Uint32 &NumDisplayModes, - DisplayModeAttribs *DisplayModes)override final + + virtual void EnumerateDisplayModes(DIRECT3D_FEATURE_LEVEL MinFeatureLevel, + Uint32 AdapterId, + Uint32 OutputId, + TEXTURE_FORMAT Format, + Uint32& NumDisplayModes, + DisplayModeAttribs* DisplayModes)override final { - auto DXGIAdapters = FindCompatibleAdapters(); + auto DXGIAdapters = FindCompatibleAdapters(MinFeatureLevel); if(AdapterId >= DXGIAdapters.size()) { LOG_ERROR("Incorrect adapter id ", AdapterId); @@ -156,7 +137,7 @@ public: } - std::vector<CComPtr<IDXGIAdapter1>> FindCompatibleAdapters() + std::vector<CComPtr<IDXGIAdapter1>> FindCompatibleAdapters(DIRECT3D_FEATURE_LEVEL MinFeatureLevel) { std::vector<CComPtr<IDXGIAdapter1>> DXGIAdapters; @@ -167,6 +148,7 @@ public: return std::move(DXGIAdapters); } + auto d3dFeatureLevel = GetD3DFeatureLevel(MinFeatureLevel); CComPtr<IDXGIAdapter1> pDXIAdapter; UINT adapter = 0; for (; pFactory->EnumAdapters1(adapter, &pDXIAdapter) != DXGI_ERROR_NOT_FOUND; ++adapter, pDXIAdapter.Release()) @@ -179,8 +161,7 @@ public: continue; } - bool IsCompatibleAdapter = CheckAdapterCompatibility<DevType>(pDXIAdapter); - + bool IsCompatibleAdapter = CheckAdapterCompatibility<DevType>(pDXIAdapter, d3dFeatureLevel); if (IsCompatibleAdapter) { DXGIAdapters.emplace_back(std::move(pDXIAdapter)); @@ -190,21 +171,58 @@ public: return std::move(DXGIAdapters); } + +protected: + + static D3D_FEATURE_LEVEL GetD3DFeatureLevel(DIRECT3D_FEATURE_LEVEL FeatureLevel) + { + switch(FeatureLevel) + { + case DIRECT3D_FEATURE_LEVEL_10_0: return D3D_FEATURE_LEVEL_10_0; + case DIRECT3D_FEATURE_LEVEL_10_1: return D3D_FEATURE_LEVEL_10_1; + case DIRECT3D_FEATURE_LEVEL_11_0: return D3D_FEATURE_LEVEL_11_0; + case DIRECT3D_FEATURE_LEVEL_11_1: return D3D_FEATURE_LEVEL_11_1; +#if defined(_WIN32_WINNT_WIN10) && (_WIN32_WINNT >=_WIN32_WINNT_WIN10) + case DIRECT3D_FEATURE_LEVEL_12_0: return D3D_FEATURE_LEVEL_12_0; + case DIRECT3D_FEATURE_LEVEL_12_1: return D3D_FEATURE_LEVEL_12_1; +#endif + + default: + UNEXPECTED("Unknown DIRECT3D_FEATURE_LEVEL ", static_cast<Uint32>(FeatureLevel)); + return D3D_FEATURE_LEVEL_11_0; + } + } + private: template<DeviceType DevType> - bool CheckAdapterCompatibility(IDXGIAdapter1 *pDXGIAdapter); + bool CheckAdapterCompatibility(IDXGIAdapter1* pDXGIAdapter, + D3D_FEATURE_LEVEL FeatureLevels); template<> - bool CheckAdapterCompatibility<DeviceType::D3D11>(IDXGIAdapter1 *pDXGIAdapter) + bool CheckAdapterCompatibility<DeviceType::D3D11>(IDXGIAdapter1* pDXGIAdapter, + D3D_FEATURE_LEVEL FeatureLevel) { - return true; + auto hr = D3D11CreateDevice( + nullptr, + D3D_DRIVER_TYPE_NULL, // There is no need to create a real hardware device. + 0, + 0, // Flags. + &FeatureLevel, // Feature levels. + 1, // Number of feature levels + D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps. + nullptr, // No need to keep the D3D device reference. + nullptr, // Feature level of the created adapter. + nullptr // No need to keep the D3D device context reference. + ); + return SUCCEEDED(hr); } template<> - bool CheckAdapterCompatibility<DeviceType::D3D12>(IDXGIAdapter1 *pDXGIAdapter) + bool CheckAdapterCompatibility<DeviceType::D3D12>(IDXGIAdapter1* pDXGIAdapter, + D3D_FEATURE_LEVEL FeatureLevel) { - auto hr = D3D12CreateDevice(pDXGIAdapter, D3D_FEATURE_LEVEL_11_0, _uuidof(ID3D12Device), nullptr); + auto hr = D3D12CreateDevice(pDXGIAdapter, FeatureLevel, _uuidof(ID3D12Device), nullptr); return SUCCEEDED(hr); } }; diff --git a/Graphics/GraphicsEngineD3DBase/include/ShaderD3DBase.h b/Graphics/GraphicsEngineD3DBase/include/ShaderD3DBase.h index 3a80d5ac..c8c4de8f 100644 --- a/Graphics/GraphicsEngineD3DBase/include/ShaderD3DBase.h +++ b/Graphics/GraphicsEngineD3DBase/include/ShaderD3DBase.h @@ -36,7 +36,7 @@ namespace Diligent class ShaderD3DBase { public: - ShaderD3DBase(const ShaderCreateInfo& ShaderCI); + ShaderD3DBase(const ShaderCreateInfo& ShaderCI, const char* ShaderModel); protected: CComPtr<ID3DBlob> m_pShaderByteCode; diff --git a/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp b/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp index 7ac4fb9d..02281be7 100644 --- a/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp +++ b/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp @@ -121,19 +121,7 @@ static HRESULT CompileShader(const char* Source, return hr; } -const char* DXShaderProfileToString(SHADER_PROFILE DXProfile) -{ - switch(DXProfile) - { - case SHADER_PROFILE_DX_4_0: return "4_0"; - case SHADER_PROFILE_DX_5_0: return "5_0"; - case SHADER_PROFILE_DX_5_1: return "5_1"; - //default: UNEXPECTED("Unknown DirectX shader profile" ); return ""; - default: return "5_0"; - } -} - -ShaderD3DBase::ShaderD3DBase(const ShaderCreateInfo& ShaderCI) +ShaderD3DBase::ShaderD3DBase(const ShaderCreateInfo& ShaderCI, const char* ShaderModel) { if (ShaderCI.Source || ShaderCI.FilePath) { @@ -153,8 +141,7 @@ ShaderD3DBase::ShaderD3DBase(const ShaderCreateInfo& ShaderCI) default: UNEXPECTED( "Unknown shader type" ); } strShaderProfile += "_"; - auto *pProfileSuffix = DXShaderProfileToString(ShaderCI.Desc.TargetProfile); - strShaderProfile += pProfileSuffix; + strShaderProfile += ShaderModel; String ShaderSource(g_HLSLDefinitions); if (ShaderCI.Source) |
