From 63e7fb85ec521cb7bf65dacf1897ca77bdbcb795 Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Wed, 14 Dec 2022 16:16:43 +0100 Subject: [PATCH] Fix `GetNativePtr` on Vulkan --- Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp | 2 +- Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp | 5 ++++- Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h | 1 + Source/Engine/GraphicsDevice/Vulkan/GPUTextureVulkan.h | 1 - 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp index 546f3d59e..24621a560 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp @@ -783,7 +783,7 @@ void GPUContextVulkan::EventEnd() void* GPUContextVulkan::GetNativePtr() const { const auto cmdBuffer = _cmdBufferManager->GetCmdBuffer(); - return (void*)cmdBuffer; + return (void*)cmdBuffer->GetHandle(); } bool GPUContextVulkan::IsDepthBufferBinded() diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp index 470469aa1..90059c281 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp @@ -1486,7 +1486,10 @@ GPUAdapter* GPUDeviceVulkan::GetAdapter() const void* GPUDeviceVulkan::GetNativePtr() const { - return static_cast(Device); + // Return both Instance and Device as pointer to void*[2] + _nativePtr[0] = (void*)Instance; + _nativePtr[1] = (void*)Device; + return _nativePtr; } static int32 GetMaxSampleCount(VkSampleCountFlags counts) diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h index b4fec211e..88b9d3d8d 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h @@ -459,6 +459,7 @@ class GPUDeviceVulkan : public GPUDevice private: CriticalSection _fenceLock; + mutable void* _nativePtr[2]; Dictionary _renderPasses; Dictionary _framebuffers; diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUTextureVulkan.h b/Source/Engine/GraphicsDevice/Vulkan/GPUTextureVulkan.h index fcbbd2c01..bd1294a87 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUTextureVulkan.h +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUTextureVulkan.h @@ -111,7 +111,6 @@ public: /// /// Gets the Vulkan image handle. /// - /// The image handle. FORCE_INLINE VkImage GetHandle() const { return _image;