diff --git a/Common/interface/AdvancedMath.hpp b/Common/interface/AdvancedMath.hpp index c86b306f3..212f78da1 100644 --- a/Common/interface/AdvancedMath.hpp +++ b/Common/interface/AdvancedMath.hpp @@ -1444,9 +1444,9 @@ TriangulatePolygon3D(const std::vector>& Polygon, bool Ve const auto AbsNormal = abs(Normal); Vector3 Tangent; - if (AbsNormal.z > std::max(AbsNormal.x, AbsNormal.y)) + if (AbsNormal.z > (std::max)(AbsNormal.x, AbsNormal.y)) Tangent = cross(Vector3{ComponentType{0}, ComponentType{1}, ComponentType{0}}, Normal); - else if (AbsNormal.y > std::max(AbsNormal.x, AbsNormal.z)) + else if (AbsNormal.y > (std::max)(AbsNormal.x, AbsNormal.z)) Tangent = cross(Vector3{ComponentType{1}, ComponentType{0}, ComponentType{0}}, Normal); else Tangent = cross(Vector3{ComponentType{0}, ComponentType{0}, ComponentType{1}}, Normal); diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.hpp b/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.hpp index e1d7e1ebf..e6252abe5 100644 --- a/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.hpp +++ b/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.hpp @@ -405,8 +405,8 @@ class ShaderResourceCacheD3D11 : public ShaderResourceCacheBase typename CachedResourceTraits::D3D11ResourceType**> GetResourceArrays(Uint32 ShaderInd) const { - using CachedResourceType = CachedResourceTraits::CachedResourceType; - using D3D11ResourceType = CachedResourceTraits::D3D11ResourceType; + using CachedResourceType = typename CachedResourceTraits::CachedResourceType; + using D3D11ResourceType = typename CachedResourceTraits::D3D11ResourceType; static_assert(alignof(CachedResourceType) == alignof(D3D11ResourceType*), "Alignment mismatch, pointer to D3D11 resource may not be properly aligned"); const auto DataOffset = GetResourceDataOffset(ShaderInd); diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderVariableManagerD3D11.hpp b/Graphics/GraphicsEngineD3D11/include/ShaderVariableManagerD3D11.hpp index 81a477441..d7788fe40 100644 --- a/Graphics/GraphicsEngineD3D11/include/ShaderVariableManagerD3D11.hpp +++ b/Graphics/GraphicsEngineD3D11/include/ShaderVariableManagerD3D11.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -83,8 +83,10 @@ class ShaderVariableManagerD3D11 : ShaderVariableManagerBase { public: + using TBase = ShaderVariableBase; + ShaderVariableD3D11Base(ShaderVariableManagerD3D11& ParentLayout, Uint32 ResIndex) : - ShaderVariableBase{ParentLayout, ResIndex} + TBase{ParentLayout, ResIndex} {} // clang-format off @@ -94,6 +96,9 @@ class ShaderVariableManagerD3D11 : ShaderVariableManagerBaseGetResourceDesc(HLSLResDesc); HLSLResDesc.ShaderRegister = GetAttribs().BindPoints[m_ParentManager.m_ShaderTypeIndex]; } virtual IDeviceObject* DILIGENT_CALL_TYPE Get(Uint32 ArrayIndex) const override final { - VERIFY_EXPR(ArrayIndex < GetDesc().ArraySize); + VERIFY_EXPR(ArrayIndex < this->GetDesc().ArraySize); return m_ParentManager.m_ResourceCache.GetResource(GetAttribs().BindPoints + ArrayIndex).Get(); } diff --git a/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp index 9d5d5f103..3892c7342 100644 --- a/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -47,6 +47,23 @@ namespace Diligent { +bool CheckAdapterD3D11Compatibility(IDXGIAdapter1* pDXGIAdapter, D3D_FEATURE_LEVEL FeatureLevel) +{ + 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); +} + /// Engine factory for D3D11 implementation class EngineFactoryD3D11Impl : public EngineFactoryD3DBase { diff --git a/Graphics/GraphicsEngineD3D12/src/D3D12Utils.cpp b/Graphics/GraphicsEngineD3D12/src/D3D12Utils.cpp index a638ed279..a9a3fd52e 100644 --- a/Graphics/GraphicsEngineD3D12/src/D3D12Utils.cpp +++ b/Graphics/GraphicsEngineD3D12/src/D3D12Utils.cpp @@ -43,7 +43,7 @@ const Char* GetD3D12DescriptorHeapTypeLiteralName(D3D12_DESCRIPTOR_HEAP_TYPE Typ static_assert(D3D12_DESCRIPTOR_HEAP_TYPE_RTV == 2, "D3D12_DESCRIPTOR_HEAP_TYPE_RTV is expected to be 2"); static_assert(D3D12_DESCRIPTOR_HEAP_TYPE_DSV == 3, "D3D12_DESCRIPTOR_HEAP_TYPE_DSV is expected to be 3"); // clang-format on - static constexpr std::array HeapTypeNames{ + static constexpr std::array HeapTypeNames{ "D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV", "D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER", "D3D12_DESCRIPTOR_HEAP_TYPE_RTV", diff --git a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp index 8cd42f0fc..685cbe9cf 100644 --- a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp @@ -54,6 +54,13 @@ namespace Diligent { +bool CheckAdapterD3D12Compatibility(IDXGIAdapter1* pDXGIAdapter, + D3D_FEATURE_LEVEL FeatureLevel) +{ + auto hr = D3D12CreateDevice(pDXGIAdapter, FeatureLevel, _uuidof(ID3D12Device), nullptr); + return SUCCEEDED(hr); +} + /// Engine factory for D3D12 implementation class EngineFactoryD3D12Impl : public EngineFactoryD3DBase { diff --git a/Graphics/GraphicsEngineD3D12/src/FenceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/FenceD3D12Impl.cpp index 1ae82fc2e..5f5d938ee 100644 --- a/Graphics/GraphicsEngineD3D12/src/FenceD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/FenceD3D12Impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,6 +36,7 @@ #include "WinHPostface.h" #include "RenderDeviceD3D12Impl.hpp" +#include "StringTools.hpp" namespace Diligent { diff --git a/Graphics/GraphicsEngineD3DBase/include/EngineFactoryD3DBase.hpp b/Graphics/GraphicsEngineD3DBase/include/EngineFactoryD3DBase.hpp index a1ad52c48..6f2a55f55 100644 --- a/Graphics/GraphicsEngineD3DBase/include/EngineFactoryD3DBase.hpp +++ b/Graphics/GraphicsEngineD3DBase/include/EngineFactoryD3DBase.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,6 +36,9 @@ namespace Diligent { +bool CheckAdapterD3D11Compatibility(IDXGIAdapter1* pDXGIAdapter, D3D_FEATURE_LEVEL FeatureLevel); +bool CheckAdapterD3D12Compatibility(IDXGIAdapter1* pDXGIAdapter, D3D_FEATURE_LEVEL FeatureLevel); + template class EngineFactoryD3DBase : public EngineFactoryBase { @@ -302,27 +305,14 @@ class EngineFactoryD3DBase : public EngineFactoryBase bool CheckAdapterCompatibility(IDXGIAdapter1* pDXGIAdapter, D3D_FEATURE_LEVEL FeatureLevel) const { - 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); + return CheckAdapterD3D11Compatibility(pDXGIAdapter, FeatureLevel); } template <> bool CheckAdapterCompatibility(IDXGIAdapter1* pDXGIAdapter, D3D_FEATURE_LEVEL FeatureLevel) const { - auto hr = D3D12CreateDevice(pDXGIAdapter, FeatureLevel, _uuidof(ID3D12Device), nullptr); - return SUCCEEDED(hr); + return CheckAdapterD3D12Compatibility(pDXGIAdapter, FeatureLevel); } }; diff --git a/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.hpp b/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.hpp index 56efbee1a..b6a7d4b94 100644 --- a/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.hpp +++ b/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -57,7 +57,7 @@ class RenderDeviceD3DBase : public RenderDeviceBase // Flag texture formats always supported in D3D11 and D3D12 // clang-format off -#define FLAG_FORMAT(Fmt, IsSupported) m_TextureFormatsInfo[Fmt].Supported=IsSupported +#define FLAG_FORMAT(Fmt, IsSupported) this->m_TextureFormatsInfo[Fmt].Supported=IsSupported FLAG_FORMAT(TEX_FORMAT_RGBA32_TYPELESS, true); FLAG_FORMAT(TEX_FORMAT_RGBA32_FLOAT, true); @@ -161,9 +161,9 @@ class RenderDeviceD3DBase : public RenderDeviceBase #undef FLAG_FORMAT // clang-format on - m_DeviceInfo.NDC = NDCAttribs{0.0f, 1.0f, -0.5f}; + this->m_DeviceInfo.NDC = NDCAttribs{0.0f, 1.0f, -0.5f}; - if (m_AdapterInfo.Vendor == ADAPTER_VENDOR_NVIDIA) + if (this->m_AdapterInfo.Vendor == ADAPTER_VENDOR_NVIDIA) { m_NVApi.Load(); } diff --git a/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp b/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp index 3b75be30a..3c52d6a1b 100644 --- a/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp +++ b/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,6 +29,8 @@ #include #include "SwapChainBase.hpp" +#include "DXGITypeConversions.hpp" +#include "GraphicsAccessories.hpp" /// \file /// Base implementation of a D3D swap chain @@ -360,6 +362,10 @@ class SwapChainD3DBase : public SwapChainBase virtual void SetDXGIDeviceMaximumFrameLatency() {} + using TBase::m_pRenderDevice; + using TBase::m_SwapChainDesc; + using TBase::m_DesiredPreTransform; + FullScreenModeDesc m_FSDesc; CComPtr m_pSwapChain; NativeWindow m_Window;