From d38159fbc894a1f63be32b4dce65fdcb7527a637 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 8 Apr 2018 11:47:36 -0700 Subject: Minor updates --- Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h | 1 - .../GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp | 2 +- Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp | 18 +++++++----------- 3 files changed, 8 insertions(+), 13 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h index 754a063d..5a98975a 100644 --- a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h @@ -116,7 +116,6 @@ protected: */ VulkanUtilities::ImageWrapper m_VulkanImage; VulkanUtilities::DeviceMemoryWrapper m_ImageMemory; - const bool m_IsExternalHandle; }; } diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index db6fc6e6..f708b6aa 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -76,7 +76,7 @@ RenderDeviceVkImpl :: RenderDeviceVkImpl(IReferenceCounters *pRefCounters, m_StaleVkObjects(STD_ALLOCATOR_RAW_MEM(ReleaseQueueElemType, GetRawAllocator(), "Allocator for queue")),/*, m_UploadHeaps(STD_ALLOCATOR_RAW_MEM(UploadHeapPoolElemType, GetRawAllocator(), "Allocator for vector>")) */ - m_CmdBufferPool(m_LogicalVkDevice, pCmdQueue->GetQueueFamilyIndex(), VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT) + m_CmdBufferPool(m_LogicalVkDevice->GetSharedPtr(), pCmdQueue->GetQueueFamilyIndex(), VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT) { m_DeviceCaps.DevType = DeviceType::Vulkan; m_DeviceCaps.MajorVersion = 1; diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp index bb069dd9..05895085 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp @@ -62,8 +62,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters *pRefCounters, RenderDeviceVkImpl *pRenderDeviceVk, const TextureDesc& TexDesc, const TextureData &InitData /*= TextureData()*/) : - TTextureBase(pRefCounters, TexViewObjAllocator, pRenderDeviceVk, TexDesc), - m_IsExternalHandle(false) + TTextureBase(pRefCounters, TexViewObjAllocator, pRenderDeviceVk, TexDesc) { if( m_Desc.Usage == USAGE_STATIC && InitData.pSubResources == nullptr ) LOG_ERROR_AND_THROW("Static Texture must be initialized with data at creation time"); @@ -346,8 +345,7 @@ TextureVkImpl::TextureVkImpl(IReferenceCounters *pRefCounters, const TextureDesc& TexDesc, VkImage VkImageHandle) : TTextureBase(pRefCounters, TexViewObjAllocator, pDeviceVk, InitTexDescFromVkImage(VkImageHandle, TexDesc)), - m_VulkanImage(nullptr, VkImageHandle), - m_IsExternalHandle(true) + m_VulkanImage(nullptr, VkImageHandle) { } IMPLEMENT_QUERY_INTERFACE( TextureVkImpl, IID_TextureVk, TTextureBase ) @@ -425,13 +423,11 @@ void TextureVkImpl::CreateViewInternal( const struct TextureViewDesc &ViewDesc, TextureVkImpl :: ~TextureVkImpl() { - if(!m_IsExternalHandle) - { - auto *pDeviceVkImpl = ValidatedCast(GetDevice()); - // Vk object can only be destroyed when it is no longer used by the GPU - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_VulkanImage)); - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_ImageMemory)); - } + auto *pDeviceVkImpl = ValidatedCast(GetDevice()); + // Vk object can only be destroyed when it is no longer used by the GPU + // Wrappers for external texture will not be destroyed as they are created with null device pointer + pDeviceVkImpl->SafeReleaseVkObject(std::move(m_VulkanImage)); + pDeviceVkImpl->SafeReleaseVkObject(std::move(m_ImageMemory)); } void TextureVkImpl::UpdateData( IDeviceContext *pContext, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData ) -- cgit v1.2.3