diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-07-25 15:09:57 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-07-25 15:09:57 +0000 |
| commit | 404459e2cb9a17e94ee7d26c22fbe2485828b496 (patch) | |
| tree | 7b81d6ed6fa0612a35443b91e7b7948c51d824c5 /Graphics/GraphicsEngineVulkan | |
| parent | Few improvements to RefCntAutoPtr & DeviceContextBase::SetPipelineState (diff) | |
| download | DiligentCore-404459e2cb9a17e94ee7d26c22fbe2485828b496.tar.gz DiligentCore-404459e2cb9a17e94ee7d26c22fbe2485828b496.zip | |
Improved performance of DeviceObjectBase::Release()
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
18 files changed, 64 insertions, 66 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h b/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h index 5d6671ce..1108597d 100644 --- a/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h @@ -30,6 +30,7 @@ #include "RenderDeviceVk.h" #include "BufferViewBase.h" #include "VulkanUtilities/VulkanObjectWrappers.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { @@ -38,13 +39,13 @@ class FixedBlockMemoryAllocator; class BufferVkImpl; /// Implementation of the Diligent::IBufferViewVk interface -class BufferViewVkImpl : public BufferViewBase<IBufferViewVk> +class BufferViewVkImpl : public BufferViewBase<IBufferViewVk, RenderDeviceVkImpl> { public: - using TBufferViewBase = BufferViewBase<IBufferViewVk>; + using TBufferViewBase = BufferViewBase<IBufferViewVk, RenderDeviceVkImpl>; BufferViewVkImpl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceVkImpl* pDevice, const BufferViewDesc& ViewDesc, class IBuffer* pBuffer, VulkanUtilities::BufferViewWrapper&& BuffView, diff --git a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h index 6b448e1b..e94ed304 100644 --- a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h @@ -35,6 +35,7 @@ #include "VulkanUtilities/VulkanMemoryManager.h" #include "VulkanDynamicHeap.h" #include "STDAllocator.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { @@ -42,14 +43,14 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IBufferVk interface -class BufferVkImpl : public BufferBase<IBufferVk, BufferViewVkImpl, FixedBlockMemoryAllocator> +class BufferVkImpl : public BufferBase<IBufferVk, RenderDeviceVkImpl, BufferViewVkImpl, FixedBlockMemoryAllocator> { public: - using TBufferBase = BufferBase<IBufferVk, BufferViewVkImpl, FixedBlockMemoryAllocator>; + using TBufferBase = BufferBase<IBufferVk, RenderDeviceVkImpl, BufferViewVkImpl, FixedBlockMemoryAllocator>; BufferVkImpl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, - class RenderDeviceVkImpl* pDeviceVk, + RenderDeviceVkImpl* pDeviceVk, const BufferDesc& BuffDesc, const BufferData& BuffData = BufferData()); diff --git a/Graphics/GraphicsEngineVulkan/include/CommandListVkImpl.h b/Graphics/GraphicsEngineVulkan/include/CommandListVkImpl.h index d4507a28..19051478 100644 --- a/Graphics/GraphicsEngineVulkan/include/CommandListVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/CommandListVkImpl.h @@ -28,18 +28,19 @@ #include "vulkan.h" #include "CommandListBase.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { /// Implementation of the Diligent::ICommandList interface -class CommandListVkImpl : public CommandListBase<ICommandList> +class CommandListVkImpl : public CommandListBase<ICommandList, RenderDeviceVkImpl> { public: - using TCommandListBase = CommandListBase<ICommandList>; + using TCommandListBase = CommandListBase<ICommandList, RenderDeviceVkImpl>; CommandListVkImpl(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceVkImpl* pDevice, IDeviceContext* pDeferredCtx, VkCommandBuffer vkCmdBuff, Uint64 CommandListNumber) : diff --git a/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h index fcb5f979..7883d268 100644 --- a/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h @@ -30,18 +30,18 @@ #include "FenceVk.h" #include "FenceBase.h" #include "VulkanUtilities/VulkanFencePool.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { class FixedBlockMemoryAllocator; -class RenderDeviceVkImpl; /// Implementation of the Diligent::IFenceVk interface -class FenceVkImpl : public FenceBase<IFenceVk> +class FenceVkImpl : public FenceBase<IFenceVk, RenderDeviceVkImpl> { public: - using TFenceBase = FenceBase<IFenceVk>; + using TFenceBase = FenceBase<IFenceVk, RenderDeviceVkImpl>; FenceVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRendeDeviceVkImpl, diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h index b98dedf5..bb5bdd3f 100644 --- a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h @@ -38,6 +38,7 @@ #include "VulkanUtilities/VulkanObjectWrappers.h" #include "VulkanUtilities/VulkanCommandBuffer.h" #include "PipelineLayout.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { @@ -45,12 +46,12 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IRenderDeviceVk interface -class PipelineStateVkImpl : public PipelineStateBase<IPipelineStateVk, IRenderDeviceVk> +class PipelineStateVkImpl : public PipelineStateBase<IPipelineStateVk, RenderDeviceVkImpl> { public: - using TPipelineStateBase = PipelineStateBase<IPipelineStateVk, IRenderDeviceVk>; + using TPipelineStateBase = PipelineStateBase<IPipelineStateVk, RenderDeviceVkImpl>; - PipelineStateVkImpl( IReferenceCounters* pRefCounters, class RenderDeviceVkImpl* pDeviceVk, const PipelineStateDesc &PipelineDesc ); + PipelineStateVkImpl( IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pDeviceVk, const PipelineStateDesc &PipelineDesc ); ~PipelineStateVkImpl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject** ppInterface ); diff --git a/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.h b/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.h index c3595b0e..290ce87c 100644 --- a/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.h @@ -30,17 +30,19 @@ #include "RenderDeviceVk.h" #include "SamplerBase.h" #include "VulkanUtilities/VulkanObjectWrappers.h" +#include "RenderDeviceVkImpl.h" + namespace Diligent { class FixedBlockMemoryAllocator; /// Implementation of the Diligent::ISamplerVk interface -class SamplerVkImpl : public SamplerBase<ISamplerVk, IRenderDeviceVk> +class SamplerVkImpl : public SamplerBase<ISamplerVk, RenderDeviceVkImpl> { public: - using TSamplerBase = SamplerBase<ISamplerVk, IRenderDeviceVk>; + using TSamplerBase = SamplerBase<ISamplerVk, RenderDeviceVkImpl>; - SamplerVkImpl(IReferenceCounters* pRefCounters, class RenderDeviceVkImpl* pRenderDeviceVk, const SamplerDesc& SamplerDesc); + SamplerVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRenderDeviceVk, const SamplerDesc& SamplerDesc); ~SamplerVkImpl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h b/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h index 09d14a9b..c091a46a 100644 --- a/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h @@ -32,6 +32,7 @@ #include "ShaderResourceLayoutVk.h" #include "SPIRVShaderResources.h" #include "ShaderVariableVk.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { @@ -40,12 +41,12 @@ class ResourceMapping; class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IShaderVk interface -class ShaderVkImpl : public ShaderBase<IShaderVk, IRenderDeviceVk> +class ShaderVkImpl : public ShaderBase<IShaderVk, RenderDeviceVkImpl> { public: - using TShaderBase = ShaderBase<IShaderVk, IRenderDeviceVk>; + using TShaderBase = ShaderBase<IShaderVk, RenderDeviceVkImpl>; - ShaderVkImpl(IReferenceCounters* pRefCounters, class RenderDeviceVkImpl* pRenderDeviceVk, const ShaderCreationAttribs &CreationAttribs); + ShaderVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRenderDeviceVk, const ShaderCreationAttribs &CreationAttribs); ~ShaderVkImpl(); //virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; diff --git a/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.h b/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.h index 9863d6aa..4d283d51 100644 --- a/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.h @@ -30,19 +30,20 @@ #include "RenderDeviceVk.h" #include "TextureViewBase.h" #include "VulkanUtilities/VulkanObjectWrappers.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { class FixedBlockMemoryAllocator; /// Implementation of the Diligent::ITextureViewVk interface -class TextureViewVkImpl : public TextureViewBase<ITextureViewVk> +class TextureViewVkImpl : public TextureViewBase<ITextureViewVk, RenderDeviceVkImpl> { public: - using TTextureViewBase = TextureViewBase<ITextureViewVk>; + using TTextureViewBase = TextureViewBase<ITextureViewVk, RenderDeviceVkImpl>; TextureViewVkImpl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceVkImpl* pDevice, const TextureViewDesc& ViewDesc, class ITexture* pTexture, VulkanUtilities::ImageViewWrapper&& ImgView, diff --git a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h index 825a5f44..b027710a 100644 --- a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h @@ -31,6 +31,7 @@ #include "TextureBase.h" #include "TextureViewVkImpl.h" #include "VulkanUtilities/VulkanMemoryManager.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { @@ -38,15 +39,15 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Base implementation of the Diligent::ITextureVk interface -class TextureVkImpl : public TextureBase<ITextureVk, TextureViewVkImpl, FixedBlockMemoryAllocator> +class TextureVkImpl : public TextureBase<ITextureVk, RenderDeviceVkImpl, TextureViewVkImpl, FixedBlockMemoryAllocator> { public: - using TTextureBase = TextureBase<ITextureVk, TextureViewVkImpl, FixedBlockMemoryAllocator>; + using TTextureBase = TextureBase<ITextureVk, RenderDeviceVkImpl, TextureViewVkImpl, FixedBlockMemoryAllocator>; // Creates a new Vk resource TextureVkImpl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceVkImpl* pDeviceVk, + RenderDeviceVkImpl* pDeviceVk, const TextureDesc& TexDesc, const TextureData& InitData = TextureData()); diff --git a/Graphics/GraphicsEngineVulkan/src/BufferViewVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/BufferViewVkImpl.cpp index fe8778c8..355aae7a 100644 --- a/Graphics/GraphicsEngineVulkan/src/BufferViewVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/BufferViewVkImpl.cpp @@ -30,7 +30,7 @@ namespace Diligent { BufferViewVkImpl::BufferViewVkImpl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceVkImpl* pDevice, const BufferViewDesc& ViewDesc, IBuffer* pBuffer, VulkanUtilities::BufferViewWrapper&& BuffView, @@ -42,8 +42,7 @@ BufferViewVkImpl::BufferViewVkImpl( IReferenceCounters* pRefCou BufferViewVkImpl::~BufferViewVkImpl() { - auto *pDeviceVkImpl = GetDevice<RenderDeviceVkImpl>(); - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_BuffView)); + m_pDevice->SafeReleaseVkObject(std::move(m_BuffView)); } IMPLEMENT_QUERY_INTERFACE( BufferViewVkImpl, IID_BufferViewVk, TBufferViewBase ) diff --git a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp index 4a55a902..93ac343b 100644 --- a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp @@ -255,12 +255,11 @@ BufferVkImpl :: BufferVkImpl(IReferenceCounters* pRefCounters, BufferVkImpl :: ~BufferVkImpl() { - auto *pDeviceVkImpl = GetDevice<RenderDeviceVkImpl>(); // Vk object can only be destroyed when it is no longer used by the GPU if(m_VulkanBuffer != VK_NULL_HANDLE) - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_VulkanBuffer)); + m_pDevice->SafeReleaseVkObject(std::move(m_VulkanBuffer)); if(m_MemoryAllocation.Page != nullptr) - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_MemoryAllocation)); + m_pDevice->SafeReleaseVkObject(std::move(m_MemoryAllocation)); } IMPLEMENT_QUERY_INTERFACE( BufferVkImpl, IID_BufferVk, TBufferBase ) @@ -287,7 +286,6 @@ void BufferVkImpl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapF TBufferBase::Map( pContext, MapType, MapFlags, pMappedData ); auto* pDeviceContextVk = ValidatedCast<DeviceContextVkImpl>(pContext); - auto* pDeviceVk = GetDevice<RenderDeviceVkImpl>(); #ifdef DEVELOPMENT if(pDeviceContextVk != nullptr) m_DvpMapType[pDeviceContextVk->GetContextId()] = std::make_pair(MapType, MapFlags); @@ -299,7 +297,7 @@ void BufferVkImpl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapF #if 0 LOG_WARNING_MESSAGE_ONCE("Mapping CPU buffer for reading on Vk currently requires flushing context and idling GPU"); pDeviceContextVk->Flush(); - pDeviceVk->IdleGPU(false); + m_pDevice->IdleGPU(false); VERIFY(m_Desc.Usage == USAGE_CPU_ACCESSIBLE, "Buffer must be created as USAGE_CPU_ACCESSIBLE to be mapped for reading"); Vk_RANGE MapRange; @@ -346,7 +344,7 @@ void BufferVkImpl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapF if (DynAllocation.pParentDynamicHeap != nullptr) { - const auto& DynamicHeap = pDeviceVk->GetDynamicHeapRingBuffer(); + const auto& DynamicHeap = m_pDevice->GetDynamicHeapRingBuffer(); auto* CPUAddress = DynamicHeap.GetCPUAddress(); pMappedData = CPUAddress + DynAllocation.Offset; } @@ -443,8 +441,7 @@ void BufferVkImpl::CreateViewInternal( const BufferViewDesc& OrigViewDesc, IBuff try { - auto *pDeviceVkImpl = GetDevice<RenderDeviceVkImpl>(); - auto &BuffViewAllocator = pDeviceVkImpl->GetBuffViewObjAllocator(); + auto& BuffViewAllocator = m_pDevice->GetBuffViewObjAllocator(); VERIFY( &BuffViewAllocator == &m_dbgBuffViewAllocator, "Buff view allocator does not match allocator provided at buffer initialization" ); BufferViewDesc ViewDesc = OrigViewDesc; @@ -482,8 +479,7 @@ VulkanUtilities::BufferViewWrapper BufferVkImpl::CreateView(struct BufferViewDes ViewCI.offset = ViewDesc.ByteOffset; ViewCI.range = ViewDesc.ByteWidth; // size in bytes of the buffer view - auto *pDeviceVkImpl = GetDevice<RenderDeviceVkImpl>(); - const auto& LogicalDevice = pDeviceVkImpl->GetLogicalDevice(); + const auto& LogicalDevice = m_pDevice->GetLogicalDevice(); BuffView = LogicalDevice.CreateBufferView(ViewCI, ViewDesc.Name); } return BuffView; @@ -496,7 +492,7 @@ VkBuffer BufferVkImpl::GetVkBuffer()const else { VERIFY(m_Desc.Usage == USAGE_DYNAMIC, "Dynamic buffer expected"); - return GetDevice<RenderDeviceVkImpl>()->GetDynamicHeapRingBuffer().GetVkBuffer(); + return m_pDevice->GetDynamicHeapRingBuffer().GetVkBuffer(); } } @@ -506,7 +502,7 @@ void BufferVkImpl::DvpVerifyDynamicAllocation(Uint32 ContextId)const const auto& DynAlloc = m_DynamicAllocations[ContextId]; if (DynAlloc.pParentDynamicHeap == nullptr) LOG_ERROR_MESSAGE("Dynamic buffer '", m_Desc.Name, "' was not mapped before its first use. Context Id: ", ContextId); - auto CurrentFrame = GetDevice<RenderDeviceVkImpl>()->GetCurrentFrameNumber(); + auto CurrentFrame = m_pDevice->GetCurrentFrameNumber(); if (DynAlloc.dbgFrameNumber != CurrentFrame) LOG_ERROR_MESSAGE("Dynamic allocation is out-of-date. Dynamic buffer '", m_Desc.Name, "' must be mapped in the same frame it is used."); } diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index ba888614..dc04f2a2 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -1217,8 +1217,9 @@ namespace Diligent auto err = vkEndCommandBuffer(vkCmdBuff); VERIFY(err == VK_SUCCESS, "Failed to end command buffer"); + auto* pDeviceVkImpl = m_pDevice.RawPtr<RenderDeviceVkImpl>(); CommandListVkImpl *pCmdListVk( NEW_RC_OBJ(m_CmdListAllocator, "CommandListVkImpl instance", CommandListVkImpl) - (m_pDevice, this, vkCmdBuff, m_NextCmdBuffNumber) ); + (pDeviceVkImpl, this, vkCmdBuff, m_NextCmdBuffNumber) ); pCmdListVk->QueryInterface( IID_CommandList, reinterpret_cast<IObject**>(ppCommandList) ); m_CommandBuffer.SetVkCmdBuffer(VK_NULL_HANDLE); diff --git a/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp index bbd872fc..caafb42b 100644 --- a/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp @@ -50,7 +50,7 @@ FenceVkImpl :: ~FenceVkImpl() Uint64 FenceVkImpl :: GetCompletedValue() { - const auto& LogicalDevice = GetDevice<RenderDeviceVkImpl>()->GetLogicalDevice(); + const auto& LogicalDevice = m_pDevice->GetLogicalDevice(); while (!m_PendingFences.empty()) { auto& Value_Fence = m_PendingFences.front(); @@ -81,7 +81,7 @@ void FenceVkImpl :: Reset(Uint64 Value) void FenceVkImpl :: Wait() { - const auto& LogicalDevice = GetDevice<RenderDeviceVkImpl>()->GetLogicalDevice(); + const auto& LogicalDevice = m_pDevice->GetLogicalDevice(); for (auto& val_fence : m_PendingFences) { while (LogicalDevice.GetFenceStatus(val_fence.second) != VK_SUCCESS) diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp index 985ce5ab..f3c60eb2 100644 --- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp @@ -403,15 +403,14 @@ PipelineStateVkImpl :: PipelineStateVkImpl(IReferenceCounters* pRefCounters PipelineStateVkImpl::~PipelineStateVkImpl() { - auto pDeviceVkImpl = GetDevice<RenderDeviceVkImpl>(); - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_Pipeline)); - m_PipelineLayout.Release(pDeviceVkImpl); + m_pDevice->SafeReleaseVkObject(std::move(m_Pipeline)); + m_PipelineLayout.Release(m_pDevice); for (auto& ShaderModule : m_ShaderModules) { if (ShaderModule != VK_NULL_HANDLE) { - pDeviceVkImpl->SafeReleaseVkObject(std::move(ShaderModule)); + m_pDevice->SafeReleaseVkObject(std::move(ShaderModule)); } } @@ -432,8 +431,7 @@ IMPLEMENT_QUERY_INTERFACE( PipelineStateVkImpl, IID_PipelineStateVk, TPipelineSt void PipelineStateVkImpl::CreateShaderResourceBinding(IShaderResourceBinding **ppShaderResourceBinding) { - auto* pRenderDeviceVk = GetDevice<RenderDeviceVkImpl>(); - auto& SRBAllocator = pRenderDeviceVk->GetSRBAllocator(); + auto& SRBAllocator = m_pDevice->GetSRBAllocator(); auto pResBindingVk = NEW_RC_OBJ(SRBAllocator, "ShaderResourceBindingVkImpl instance", ShaderResourceBindingVkImpl)(this, false); pResBindingVk->QueryInterface(IID_ShaderResourceBinding, reinterpret_cast<IObject**>(ppShaderResourceBinding)); } diff --git a/Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp index ff248c3a..8f748100 100644 --- a/Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp @@ -75,8 +75,7 @@ SamplerVkImpl::SamplerVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImp SamplerVkImpl::~SamplerVkImpl() { - auto pDeviceVkImpl = GetDevice<RenderDeviceVkImpl>(); - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_VkSampler)); + m_pDevice->SafeReleaseVkObject(std::move(m_VkSampler)); } IMPLEMENT_QUERY_INTERFACE( SamplerVkImpl, IID_SamplerVk, TSamplerBase ) diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp index 4e8e4edf..4d1f1015 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp @@ -35,10 +35,10 @@ ShaderResourceBindingVkImpl::ShaderResourceBindingVkImpl( IReferenceCounters* pR TBase( pRefCounters, pPSO, IsPSOInternal ), m_ShaderResourceCache(ShaderResourceCacheVk::DbgCacheContentType::SRBResources) { - auto *ppShaders = pPSO->GetShaders(); + auto* ppShaders = pPSO->GetShaders(); m_NumShaders = pPSO->GetNumShaders(); - auto *pRenderDeviceVkImpl = pPSO->GetDevice<RenderDeviceVkImpl>(); + auto* pRenderDeviceVkImpl = pPSO->GetDevice(); // This will only allocate memory and initialize descriptor sets in the resource cache // Resources will be initialized by InitializeResourceMemoryInCache() auto& ResourceCacheDataAllocator = pPSO->GetSRBMemoryAllocator().GetResourceCacheDataAllocator(0); diff --git a/Graphics/GraphicsEngineVulkan/src/TextureViewVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureViewVkImpl.cpp index a1263f98..72b6b34b 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureViewVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureViewVkImpl.cpp @@ -30,7 +30,7 @@ namespace Diligent { TextureViewVkImpl::TextureViewVkImpl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceVkImpl* pDevice, const TextureViewDesc& ViewDesc, ITexture* pTexture, VulkanUtilities::ImageViewWrapper&& ImgView, @@ -42,10 +42,9 @@ TextureViewVkImpl::TextureViewVkImpl( IReferenceCounters* pRefCo TextureViewVkImpl::~TextureViewVkImpl() { - auto *pDeviceVkImpl = GetDevice<RenderDeviceVkImpl>(); if(m_Desc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL || m_Desc.ViewType == TEXTURE_VIEW_RENDER_TARGET) - pDeviceVkImpl->GetFramebufferCache().OnDestroyImageView(m_ImageView); - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_ImageView)); + m_pDevice->GetFramebufferCache().OnDestroyImageView(m_ImageView); + m_pDevice->SafeReleaseVkObject(std::move(m_ImageView)); } IMPLEMENT_QUERY_INTERFACE( TextureViewVkImpl, IID_TextureViewVk, TTextureViewBase ) diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp index eb396192..2d3a74cc 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp @@ -437,8 +437,7 @@ void TextureVkImpl::CreateViewInternal( const struct TextureViewDesc &ViewDesc, try { - auto *pDeviceVkImpl = GetDevice<RenderDeviceVkImpl>(); - auto &TexViewAllocator = pDeviceVkImpl->GetTexViewObjAllocator(); + auto &TexViewAllocator = m_pDevice->GetTexViewObjAllocator(); VERIFY( &TexViewAllocator == &m_dbgTexViewObjAllocator, "Texture view allocator does not match allocator provided during texture initialization" ); auto UpdatedViewDesc = ViewDesc; @@ -464,11 +463,10 @@ void TextureVkImpl::CreateViewInternal( const struct TextureViewDesc &ViewDesc, TextureVkImpl :: ~TextureVkImpl() { - auto *pDeviceVkImpl = GetDevice<RenderDeviceVkImpl>(); // 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_MemoryAllocation)); + m_pDevice->SafeReleaseVkObject(std::move(m_VulkanImage)); + m_pDevice->SafeReleaseVkObject(std::move(m_MemoryAllocation)); } void TextureVkImpl::UpdateData( IDeviceContext *pContext, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData ) @@ -703,8 +701,7 @@ VulkanUtilities::ImageViewWrapper TextureVkImpl::CreateImageView(TextureViewDesc ImageViewCI.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; } - auto *pRenderDeviceVk = GetDevice<RenderDeviceVkImpl>(); - const auto& LogicalDevice = pRenderDeviceVk->GetLogicalDevice(); + const auto& LogicalDevice = m_pDevice->GetLogicalDevice(); std::string ViewName = "Image view for \'"; ViewName += m_Desc.Name; |
