summaryrefslogtreecommitdiffstats
path: root/Graphics
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-02-02 23:07:25 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-02-02 23:07:25 +0000
commit4c73f2d3fd5305b82d3413ebeab74cc566b57f33 (patch)
treea74cd97e9015a753b706e7305e3336430b634aa6 /Graphics
parentCleaned-up NativeWindow PR (diff)
downloadDiligentCore-4c73f2d3fd5305b82d3413ebeab74cc566b57f33.tar.gz
DiligentCore-4c73f2d3fd5305b82d3413ebeab74cc566b57f33.zip
Updated swap chain creation functions to use NativeWindow struct
Diffstat (limited to 'Graphics')
-rw-r--r--Graphics/GraphicsEngine/interface/APIInfo.h2
-rw-r--r--Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.hpp2
-rw-r--r--Graphics/GraphicsEngineD3D11/interface/EngineFactoryD3D11.h12
-rw-r--r--Graphics/GraphicsEngineD3D11/readme.md4
-rw-r--r--Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp6
-rw-r--r--Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp4
-rw-r--r--Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.hpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/interface/EngineFactoryD3D12.h12
-rw-r--r--Graphics/GraphicsEngineD3D12/readme.md4
-rw-r--r--Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp6
-rw-r--r--Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp4
-rw-r--r--Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp10
-rw-r--r--Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.hpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h26
-rw-r--r--Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp27
-rw-r--r--Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp26
16 files changed, 70 insertions, 79 deletions
diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h
index 3c19c2b8..85867de2 100644
--- a/Graphics/GraphicsEngine/interface/APIInfo.h
+++ b/Graphics/GraphicsEngine/interface/APIInfo.h
@@ -30,7 +30,7 @@
/// \file
/// Diligent API information
-#define DILIGENT_API_VERSION 240053
+#define DILIGENT_API_VERSION 240054
#include "../../../Primitives/interface/BasicTypes.h"
diff --git a/Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.hpp
index 945a57f2..fbc3fd01 100644
--- a/Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.hpp
+++ b/Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.hpp
@@ -47,7 +47,7 @@ public:
const FullScreenModeDesc& FSDesc,
class RenderDeviceD3D11Impl* pRenderDeviceD3D11,
class DeviceContextD3D11Impl* pDeviceContextD3D11,
- void* pNativeWndHandle);
+ const NativeWindow& Window);
~SwapChainD3D11Impl();
virtual void DILIGENT_CALL_TYPE QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
diff --git a/Graphics/GraphicsEngineD3D11/interface/EngineFactoryD3D11.h b/Graphics/GraphicsEngineD3D11/interface/EngineFactoryD3D11.h
index 406e7a7b..34ddc552 100644
--- a/Graphics/GraphicsEngineD3D11/interface/EngineFactoryD3D11.h
+++ b/Graphics/GraphicsEngineD3D11/interface/EngineFactoryD3D11.h
@@ -78,11 +78,11 @@ DILIGENT_BEGIN_INTERFACE(IEngineFactoryD3D11, IEngineFactory)
/// \param [in] pImmediateContext - Pointer to the immediate device context.
/// \param [in] SCDesc - Swap chain description.
/// \param [in] FSDesc - Fullscreen mode description.
- /// \param [in] pNativeWndHandle - Platform-specific native handle of the window
- /// the swap chain will be associated with:
- /// * On Win32 platform, this should be the window handle (HWND)
- /// * On Universal Windows Platform, this should be the reference
- /// to the core window (Windows::UI::Core::CoreWindow)
+ /// \param [in] Window - Platform-specific native window description that
+ /// the swap chain will be associated with:
+ /// * On Win32 platform, this is the window handle (HWND)
+ /// * On Universal Windows Platform, this is the reference
+ /// to the core window (Windows::UI::Core::CoreWindow)
///
/// \param [out] ppSwapChain - Address of the memory location where pointer to the new
/// swap chain will be written.
@@ -91,7 +91,7 @@ DILIGENT_BEGIN_INTERFACE(IEngineFactoryD3D11, IEngineFactory)
IDeviceContext* pImmediateContext,
const SwapChainDesc REF SCDesc,
const FullScreenModeDesc REF FSDesc,
- void* pNativeWndHandle,
+ const NativeWindow REF Window,
ISwapChain** ppSwapChain) PURE;
diff --git a/Graphics/GraphicsEngineD3D11/readme.md b/Graphics/GraphicsEngineD3D11/readme.md
index 7d3a7dc2..87dc075d 100644
--- a/Graphics/GraphicsEngineD3D11/readme.md
+++ b/Graphics/GraphicsEngineD3D11/readme.md
@@ -29,7 +29,9 @@ RefCntAutoPtr<IDeviceContext> pImmediateContext;
SwapChainDesc SwapChainDesc;
RefCntAutoPtr<ISwapChain> pSwapChain;
pFactoryD3D11->CreateDeviceAndContextsD3D11(EngineCI, &pRenderDevice, &pImmediateContext);
-pFactoryD3D11->CreateSwapChainD3D11(pRenderDevice, pImmediateContext, SwapChainDesc, hWnd, &pSwapChain);
+NativeWindow Window;
+Window.hWnd = hWnd;
+pFactoryD3D11->CreateSwapChainD3D11(pRenderDevice, pImmediateContext, SwapChainDesc, Window, &pSwapChain);
```
Alternatively, the engine can be initialized by attaching to existing D3D11 device and immediate context (see below).
diff --git a/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp
index 4cddbf6f..6dd980a6 100644
--- a/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp
@@ -66,7 +66,7 @@ public:
IDeviceContext* pImmediateContext,
const SwapChainDesc& SCDesc,
const FullScreenModeDesc& FSDesc,
- void* pNativeWndHandle,
+ const NativeWindow& Window,
ISwapChain** ppSwapChain) override final;
virtual void DILIGENT_CALL_TYPE AttachToD3D11Device(void* pd3d11NativeDevice,
@@ -284,7 +284,7 @@ void EngineFactoryD3D11Impl::CreateSwapChainD3D11(IRenderDevice* pDev
IDeviceContext* pImmediateContext,
const SwapChainDesc& SCDesc,
const FullScreenModeDesc& FSDesc,
- void* pNativeWndHandle,
+ const NativeWindow& Window,
ISwapChain** ppSwapChain)
{
VERIFY(ppSwapChain, "Null pointer provided");
@@ -299,7 +299,7 @@ void EngineFactoryD3D11Impl::CreateSwapChainD3D11(IRenderDevice* pDev
auto* pDeviceContextD3D11 = ValidatedCast<DeviceContextD3D11Impl>(pImmediateContext);
auto& RawMemAllocator = GetRawAllocator();
- auto* pSwapChainD3D11 = NEW_RC_OBJ(RawMemAllocator, "SwapChainD3D11Impl instance", SwapChainD3D11Impl)(SCDesc, FSDesc, pDeviceD3D11, pDeviceContextD3D11, pNativeWndHandle);
+ auto* pSwapChainD3D11 = NEW_RC_OBJ(RawMemAllocator, "SwapChainD3D11Impl instance", SwapChainD3D11Impl)(SCDesc, FSDesc, pDeviceD3D11, pDeviceContextD3D11, Window);
pSwapChainD3D11->QueryInterface(IID_SwapChain, reinterpret_cast<IObject**>(ppSwapChain));
}
catch (const std::runtime_error&)
diff --git a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp
index 2dceffc7..0d833427 100644
--- a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp
@@ -39,7 +39,7 @@ SwapChainD3D11Impl::SwapChainD3D11Impl(IReferenceCounters* pRefCounters,
const FullScreenModeDesc& FSDesc,
RenderDeviceD3D11Impl* pRenderDeviceD3D11,
DeviceContextD3D11Impl* pDeviceContextD3D11,
- void* pNativeWndHandle) :
+ const NativeWindow& Window) :
// clang-format off
TSwapChainBase
{
@@ -48,7 +48,7 @@ SwapChainD3D11Impl::SwapChainD3D11Impl(IReferenceCounters* pRefCounters,
pDeviceContextD3D11,
SCDesc,
FSDesc,
- pNativeWndHandle
+ Window
}
// clang-format on
{
diff --git a/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.hpp
index 42889126..2f32c6d7 100644
--- a/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.hpp
+++ b/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.hpp
@@ -48,7 +48,7 @@ public:
const FullScreenModeDesc& FSDesc,
class RenderDeviceD3D12Impl* pRenderDeviceD3D12,
class DeviceContextD3D12Impl* pDeviceContextD3D12,
- void* pNativeWndHandle);
+ const NativeWindow& Window);
~SwapChainD3D12Impl();
virtual void DILIGENT_CALL_TYPE QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
diff --git a/Graphics/GraphicsEngineD3D12/interface/EngineFactoryD3D12.h b/Graphics/GraphicsEngineD3D12/interface/EngineFactoryD3D12.h
index 205c8ffe..d5fb356e 100644
--- a/Graphics/GraphicsEngineD3D12/interface/EngineFactoryD3D12.h
+++ b/Graphics/GraphicsEngineD3D12/interface/EngineFactoryD3D12.h
@@ -114,11 +114,11 @@ DILIGENT_BEGIN_INTERFACE(IEngineFactoryD3D12, IEngineFactory)
/// \param [in] pImmediateContext - Pointer to the immediate device context.
/// \param [in] SCDesc - Swap chain description.
/// \param [in] FSDesc - Fullscreen mode description.
- /// \param [in] pNativeWndHandle - Platform-specific native handle of the window
- /// the swap chain will be associated with:
- /// * On Win32 platform, this should be the window handle (HWND)
- /// * On Universal Windows Platform, this should be the reference
- /// to the core window (Windows::UI::Core::CoreWindow)
+ /// \param [in] Window - Platform-specific native window description that
+ /// the swap chain will be associated with:
+ /// * On Win32 platform, this is the window handle (HWND)
+ /// * On Universal Windows Platform, this is the reference
+ /// to the core window (Windows::UI::Core::CoreWindow)
///
/// \param [out] ppSwapChain - Address of the memory location where pointer to the new
/// swap chain will be written
@@ -127,7 +127,7 @@ DILIGENT_BEGIN_INTERFACE(IEngineFactoryD3D12, IEngineFactory)
IDeviceContext* pImmediateContext,
const SwapChainDesc REF SwapChainDesc,
const FullScreenModeDesc REF FSDesc,
- void* pNativeWndHandle,
+ const NativeWindow REF Window,
ISwapChain** ppSwapChain) PURE;
diff --git a/Graphics/GraphicsEngineD3D12/readme.md b/Graphics/GraphicsEngineD3D12/readme.md
index 84d747c7..4dd26b91 100644
--- a/Graphics/GraphicsEngineD3D12/readme.md
+++ b/Graphics/GraphicsEngineD3D12/readme.md
@@ -28,7 +28,9 @@ RefCntAutoPtr<IDeviceContext> pImmediateContext;
SwapChainDesc SwapChainDesc;
RefCntAutoPtr<ISwapChain> pSwapChain;
pFactoryD3D12->CreateDeviceAndContextsD3D12(EngineCI, &pRenderDevice, &pImmediateContext);
-pFactoryD3D12->CreateSwapChainD3D12(pRenderDevice, pImmediateContext, SwapChainDesc, hWnd, &pSwapChain);
+NativeWindow Window;
+Window.hWnd = hWnd;
+pFactoryD3D12->CreateSwapChainD3D12(pRenderDevice, pImmediateContext, SwapChainDesc, Window, &pSwapChain);
```
Alternatively, the engine can be initialized by attaching to existing Direct3D12 device (see below).
diff --git a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp
index b313461d..1b61a393 100644
--- a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp
@@ -85,7 +85,7 @@ public:
IDeviceContext* pImmediateContext,
const SwapChainDesc& SwapChainDesc,
const FullScreenModeDesc& FSDesc,
- void* pNativeWndHandle,
+ const NativeWindow& Window,
ISwapChain** ppSwapChain) override final;
virtual void DILIGENT_CALL_TYPE EnumerateAdapters(DIRECT3D_FEATURE_LEVEL MinFeatureLevel,
@@ -447,7 +447,7 @@ void EngineFactoryD3D12Impl::CreateSwapChainD3D12(IRenderDevice* pDev
IDeviceContext* pImmediateContext,
const SwapChainDesc& SCDesc,
const FullScreenModeDesc& FSDesc,
- void* pNativeWndHandle,
+ const NativeWindow& Window,
ISwapChain** ppSwapChain)
{
VERIFY(ppSwapChain, "Null pointer provided");
@@ -462,7 +462,7 @@ void EngineFactoryD3D12Impl::CreateSwapChainD3D12(IRenderDevice* pDev
auto* pDeviceContextD3D12 = ValidatedCast<DeviceContextD3D12Impl>(pImmediateContext);
auto& RawMemAllocator = GetRawAllocator();
- auto* pSwapChainD3D12 = NEW_RC_OBJ(RawMemAllocator, "SwapChainD3D12Impl instance", SwapChainD3D12Impl)(SCDesc, FSDesc, pDeviceD3D12, pDeviceContextD3D12, pNativeWndHandle);
+ auto* pSwapChainD3D12 = NEW_RC_OBJ(RawMemAllocator, "SwapChainD3D12Impl instance", SwapChainD3D12Impl)(SCDesc, FSDesc, pDeviceD3D12, pDeviceContextD3D12, Window);
pSwapChainD3D12->QueryInterface(IID_SwapChain, reinterpret_cast<IObject**>(ppSwapChain));
}
catch (const std::runtime_error&)
diff --git a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp
index ef133c48..1703f4e9 100644
--- a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp
@@ -41,7 +41,7 @@ SwapChainD3D12Impl::SwapChainD3D12Impl(IReferenceCounters* pRefCounters,
const FullScreenModeDesc& FSDesc,
RenderDeviceD3D12Impl* pRenderDeviceD3D12,
DeviceContextD3D12Impl* pDeviceContextD3D12,
- void* pNativeWndHandle) :
+ const NativeWindow& Window) :
// clang-format off
TSwapChainBase
{
@@ -50,7 +50,7 @@ SwapChainD3D12Impl::SwapChainD3D12Impl(IReferenceCounters* pRefCounters,
pDeviceContextD3D12,
SCDesc,
FSDesc,
- pNativeWndHandle
+ Window
},
m_pBackBufferRTV(STD_ALLOCATOR_RAW_MEM(RefCntAutoPtr<ITextureView>, GetRawAllocator(), "Allocator for vector<RefCntAutoPtr<ITextureView>>"))
// clang-format on
diff --git a/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp b/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp
index b1088b4f..9479d72e 100644
--- a/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp
+++ b/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp
@@ -47,11 +47,11 @@ public:
IDeviceContext* pDeviceContext,
const SwapChainDesc& SCDesc,
const FullScreenModeDesc& FSDesc,
- void* pNativeWndHandle) :
+ const NativeWindow& Window) :
// clang-format off
TBase{pRefCounters, pDevice, pDeviceContext, SCDesc},
m_FSDesc {FSDesc},
- m_pNativeWndHandle {pNativeWndHandle}
+ m_Window {Window}
// clang-format on
{}
@@ -74,7 +74,7 @@ protected:
void CreateDXGISwapChain(IUnknown* pD3D11DeviceOrD3D12CmdQueue)
{
#if PLATFORM_WIN32
- auto hWnd = reinterpret_cast<HWND>(m_pNativeWndHandle);
+ auto hWnd = reinterpret_cast<HWND>(m_Window.hWnd);
if (m_SwapChainDesc.Width == 0 || m_SwapChainDesc.Height == 0)
{
RECT rc;
@@ -194,7 +194,7 @@ protected:
hr = factory->CreateSwapChainForCoreWindow(
pD3D11DeviceOrD3D12CmdQueue,
- reinterpret_cast<IUnknown*>(m_pNativeWndHandle),
+ reinterpret_cast<IUnknown*>(m_Window.pWindow),
&swapChainDesc,
nullptr,
&pSwapChain1);
@@ -242,7 +242,7 @@ protected:
FullScreenModeDesc m_FSDesc;
CComPtr<DXGISwapChainType> m_pSwapChain;
- void* m_pNativeWndHandle;
+ NativeWindow m_Window;
};
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.hpp
index 996817ca..e58c5f71 100644
--- a/Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.hpp
@@ -49,7 +49,7 @@ public:
const SwapChainDesc& SwapChainDesc,
class RenderDeviceVkImpl* pRenderDeviceVk,
class DeviceContextVkImpl* pDeviceContextVk,
- void* pNativeWndHandle);
+ const NativeWindow& Window);
~SwapChainVkImpl();
virtual void DILIGENT_CALL_TYPE QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
diff --git a/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h b/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h
index eb9c1f58..be79c99f 100644
--- a/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h
@@ -66,22 +66,36 @@ static const INTERFACE_ID IID_EngineFactoryVk =
DILIGENT_BEGIN_INTERFACE(IEngineFactoryVk, IEngineFactory)
{
+ /// Creates a render device and device contexts for Vulkan backend
+
+ /// \param [in] EngineCI - Engine creation attributes.
+ /// \param [out] ppDevice - Address of the memory location where pointer to
+ /// the created device will be written
+ /// \param [out] ppContexts - Address of the memory location where pointers to
+ /// the contexts will be written. Immediate context goes at
+ /// position 0. If EngineCI.NumDeferredContexts > 0,
+ /// pointers to the deferred contexts are written afterwards.
VIRTUAL void METHOD(CreateDeviceAndContextsVk)(THIS_
const EngineVkCreateInfo REF EngineCI,
IRenderDevice** ppDevice,
IDeviceContext** ppContexts) PURE;
- //virtual void AttachToVulkanDevice(void *pVkNativeDevice,
- // class ICommandQueueVk *pCommandQueue,
- // const EngineVkCreateInfo& EngineCI,
- // IRenderDevice **ppDevice,
- // IDeviceContext **ppContexts) = 0;
+ /// Creates a swap chain for Vulkan-based engine implementation
+
+ /// \param [in] pDevice - Pointer to the render device
+ /// \param [in] pImmediateContext - Pointer to the immediate device context
+ /// \param [in] SCDesc - Swap chain description
+ /// \param [in] Window - Platform-specific native window description that
+ /// the swap chain will be associated with.
+ ///
+ /// \param [out] ppSwapChain - Address of the memory location where pointer to the new
+ /// swap chain will be written
VIRTUAL void METHOD(CreateSwapChainVk)(THIS_
IRenderDevice* pDevice,
IDeviceContext* pImmediateContext,
const SwapChainDesc REF SwapChainDesc,
- void* pNativeWndHandle,
+ const NativeWindow REF Window,
ISwapChain** ppSwapChain) PURE;
};
DILIGENT_END_INTERFACE
diff --git a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp
index 77a6f49b..f695b372 100644
--- a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp
@@ -74,22 +74,14 @@ public:
virtual void DILIGENT_CALL_TYPE CreateSwapChainVk(IRenderDevice* pDevice,
IDeviceContext* pImmediateContext,
const SwapChainDesc& SwapChainDesc,
- void* pNativeWndHandle,
+ const NativeWindow& Window,
ISwapChain** ppSwapChain) override final;
private:
std::function<void(RenderDeviceVkImpl*)> OnRenderDeviceCreated = nullptr;
};
-/// Creates render device and device contexts for Vulkan backend
-/// \param [in] EngineCI - Engine creation attributes.
-/// \param [out] ppDevice - Address of the memory location where pointer to
-/// the created device will be written
-/// \param [out] ppContexts - Address of the memory location where pointers to
-/// the contexts will be written. Immediate context goes at
-/// position 0. If EngineCI.NumDeferredContexts > 0,
-/// pointers to the deferred contexts are written afterwards.
void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& _EngineCI,
IRenderDevice** ppDevice,
IDeviceContext** ppContexts)
@@ -317,23 +309,10 @@ void EngineFactoryVkImpl::AttachToVulkanDevice(std::shared_ptr<VulkanUtilities::
}
-/// Creates a swap chain for Direct3D12-based engine implementation
-
-/// \param [in] pDevice - Pointer to the render device
-/// \param [in] pImmediateContext - Pointer to the immediate device context
-/// \param [in] SCDesc - Swap chain description
-/// \param [in] pNativeWndHandle - Platform-specific native handle of the window
-/// the swap chain will be associated with:
-/// * On Win32 platform, this should be window handle (HWND)
-/// * On Universal Windows Platform, this should be reference to the
-/// core window (Windows::UI::Core::CoreWindow)
-///
-/// \param [out] ppSwapChain - Address of the memory location where pointer to the new
-/// swap chain will be written
void EngineFactoryVkImpl::CreateSwapChainVk(IRenderDevice* pDevice,
IDeviceContext* pImmediateContext,
const SwapChainDesc& SCDesc,
- void* pNativeWndHandle,
+ const NativeWindow& Window,
ISwapChain** ppSwapChain)
{
VERIFY(ppSwapChain, "Null pointer provided");
@@ -348,7 +327,7 @@ void EngineFactoryVkImpl::CreateSwapChainVk(IRenderDevice* pDevice,
auto* pDeviceContextVk = ValidatedCast<DeviceContextVkImpl>(pImmediateContext);
auto& RawMemAllocator = GetRawAllocator();
- auto* pSwapChainVk = NEW_RC_OBJ(RawMemAllocator, "SwapChainVkImpl instance", SwapChainVkImpl)(SCDesc, pDeviceVk, pDeviceContextVk, pNativeWndHandle);
+ auto* pSwapChainVk = NEW_RC_OBJ(RawMemAllocator, "SwapChainVkImpl instance", SwapChainVkImpl)(SCDesc, pDeviceVk, pDeviceContextVk, Window);
pSwapChainVk->QueryInterface(IID_SwapChain, reinterpret_cast<IObject**>(ppSwapChain));
}
catch (const std::runtime_error&)
diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
index 2a906a2b..d4282068 100644
--- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
@@ -40,7 +40,7 @@ SwapChainVkImpl::SwapChainVkImpl(IReferenceCounters* pRefCounters,
const SwapChainDesc& SCDesc,
RenderDeviceVkImpl* pRenderDeviceVk,
DeviceContextVkImpl* pDeviceContextVk,
- void* pNativeWndHandle) :
+ const NativeWindow& Window) :
// clang-format off
TSwapChainBase {pRefCounters, pRenderDeviceVk, pDeviceContextVk, SCDesc},
m_VulkanInstance {pRenderDeviceVk->GetVulkanInstance()},
@@ -55,50 +55,44 @@ SwapChainVkImpl::SwapChainVkImpl(IReferenceCounters* pRefCounters,
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
surfaceCreateInfo.hinstance = GetModuleHandle(NULL);
- surfaceCreateInfo.hwnd = (HWND)pNativeWndHandle;
+ surfaceCreateInfo.hwnd = (HWND)Window.hWnd;
auto err = vkCreateWin32SurfaceKHR(m_VulkanInstance->GetVkInstance(), &surfaceCreateInfo, nullptr, &m_VkSurface);
#elif defined(VK_USE_PLATFORM_ANDROID_KHR)
VkAndroidSurfaceCreateInfoKHR surfaceCreateInfo = {};
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
- surfaceCreateInfo.window = (ANativeWindow*)pNativeWndHandle;
+ surfaceCreateInfo.window = (ANativeWindow*)Window.pAWindow;
auto err = vkCreateAndroidSurfaceKHR(m_VulkanInstance->GetVkInstance(), &surfaceCreateInfo, NULL, &m_VkSurface);
#elif defined(VK_USE_PLATFORM_IOS_MVK)
VkIOSSurfaceCreateInfoMVK surfaceCreateInfo = {};
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK;
- surfaceCreateInfo.pView = pNativeWndHandle;
+ surfaceCreateInfo.pView = Window.pNSWindow;
auto err = vkCreateIOSSurfaceMVK(m_VulkanInstance->GetVkInstance(), &surfaceCreateInfo, nullptr, &m_VkSurface);
#elif defined(VK_USE_PLATFORM_MACOS_MVK)
VkMacOSSurfaceCreateInfoMVK surfaceCreateInfo = {};
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
- surfaceCreateInfo.pView = pNativeWndHandle;
+ surfaceCreateInfo.pView = Window.pNSView;
auto err = vkCreateMacOSSurfaceMVK(m_VulkanInstance->GetVkInstance(), &surfaceCreateInfo, NULL, &m_VkSurface);
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
VkWaylandSurfaceCreateInfoKHR surfaceCreateInfo = {};
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
- surfaceCreateInfo.display = display;
- surfaceCreatem_VkSurface = window;
+ surfaceCreateInfo.display = Window.pDisplay;
+ surfaceCreatem_VkSurface = Window.pWindow;
err = vkCreateWaylandSurfaceKHR(m_VulkanInstance->GetVkInstance(), &surfaceCreateInfo, nullptr, &m_VkSurface);
#elif defined(VK_USE_PLATFORM_XCB_KHR)
VkXcbSurfaceCreateInfoKHR surfaceCreateInfo = {};
- surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
- struct XCBInfo
- {
- xcb_connection_t* connection = nullptr;
- uint32_t window = 0;
- };
- XCBInfo& info = *reinterpret_cast<XCBInfo*>(pNativeWndHandle);
- surfaceCreateInfo.connection = info.connection;
- surfaceCreateInfo.window = info.window;
+ surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
+ surfaceCreateInfo.connection = Window.pXCBConnection;
+ surfaceCreateInfo.window = Window.pWindow;
auto err = vkCreateXcbSurfaceKHR(m_VulkanInstance->GetVkInstance(), &surfaceCreateInfo, nullptr, &m_VkSurface);
#endif