summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
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/GraphicsEngineVulkan
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/GraphicsEngineVulkan')
-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
4 files changed, 34 insertions, 47 deletions
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