From 1e9a3e52dac3f499d0b1de9ea9e378fe7a185f78 Mon Sep 17 00:00:00 2001 From: Angelos Gkountis Date: Fri, 18 May 2018 10:16:14 +0100 Subject: [PATCH] Altered the aliases of reference counted Vulkan objects Changed to better describe their purpose following the Dali::RefCounterVector paradigm. e.g: ShaderRef -> RefCountedShader Change-Id: I8996f09b949ec0dc40b4ec214bad64cae95547cb --- .../vulkan/api/internal/vulkan-ubo-pool.cpp | 12 ++-- .../graphics/vulkan/api/internal/vulkan-ubo-pool.h | 4 +- dali/graphics/vulkan/api/vulkan-api-buffer.cpp | 2 +- dali/graphics/vulkan/api/vulkan-api-buffer.h | 4 +- dali/graphics/vulkan/api/vulkan-api-controller.cpp | 8 +-- dali/graphics/vulkan/api/vulkan-api-controller.h | 2 +- .../vulkan/api/vulkan-api-render-command.cpp | 6 +- .../vulkan/api/vulkan-api-render-command.h | 14 ++-- dali/graphics/vulkan/api/vulkan-api-shader.cpp | 8 +-- dali/graphics/vulkan/api/vulkan-api-shader.h | 8 +-- .../gpu-memory/vulkan-gpu-memory-allocator.h | 6 +- .../gpu-memory/vulkan-gpu-memory-manager.cpp | 12 ++-- dali/graphics/vulkan/tests/texture-test.cpp | 8 +-- dali/graphics/vulkan/vulkan-buffer.cpp | 18 ++--- dali/graphics/vulkan/vulkan-buffer.h | 8 +-- dali/graphics/vulkan/vulkan-command-buffer.cpp | 20 +++--- dali/graphics/vulkan/vulkan-command-buffer.h | 8 +-- dali/graphics/vulkan/vulkan-command-pool.cpp | 10 +-- dali/graphics/vulkan/vulkan-command-pool.h | 4 +- dali/graphics/vulkan/vulkan-descriptor-set.cpp | 4 +- dali/graphics/vulkan/vulkan-descriptor-set.h | 4 +- dali/graphics/vulkan/vulkan-framebuffer.cpp | 28 ++++---- dali/graphics/vulkan/vulkan-framebuffer.h | 8 +-- dali/graphics/vulkan/vulkan-graphics-texture.cpp | 20 +++--- dali/graphics/vulkan/vulkan-graphics-texture.h | 8 +-- dali/graphics/vulkan/vulkan-graphics.cpp | 16 ++--- dali/graphics/vulkan/vulkan-graphics.h | 37 +++++----- dali/graphics/vulkan/vulkan-image.cpp | 34 ++++----- dali/graphics/vulkan/vulkan-image.h | 14 ++-- dali/graphics/vulkan/vulkan-pipeline-cache.cpp | 18 ++--- dali/graphics/vulkan/vulkan-pipeline-cache.h | 10 +-- dali/graphics/vulkan/vulkan-pipeline.cpp | 10 +-- dali/graphics/vulkan/vulkan-pipeline.h | 6 +- dali/graphics/vulkan/vulkan-queue.cpp | 10 +-- dali/graphics/vulkan/vulkan-queue.h | 6 +- dali/graphics/vulkan/vulkan-resource-cache.cpp | 80 +++++++++++----------- dali/graphics/vulkan/vulkan-resource-cache.h | 48 ++++++------- dali/graphics/vulkan/vulkan-sampler.cpp | 10 +-- dali/graphics/vulkan/vulkan-sampler.h | 4 +- dali/graphics/vulkan/vulkan-shader.h | 2 +- dali/graphics/vulkan/vulkan-standalone-test.cpp | 22 +++--- dali/graphics/vulkan/vulkan-surface.cpp | 4 +- dali/graphics/vulkan/vulkan-surface.h | 2 +- dali/graphics/vulkan/vulkan-swapchain.cpp | 48 ++++++------- dali/graphics/vulkan/vulkan-swapchain.h | 12 ++-- dali/graphics/vulkan/vulkan-types.h | 30 ++++---- dali/integration-api/graphics/graphics.cpp | 2 +- 47 files changed, 329 insertions(+), 330 deletions(-) diff --git a/dali/graphics/vulkan/api/internal/vulkan-ubo-pool.cpp b/dali/graphics/vulkan/api/internal/vulkan-ubo-pool.cpp index 72c387a..66d4979 100644 --- a/dali/graphics/vulkan/api/internal/vulkan-ubo-pool.cpp +++ b/dali/graphics/vulkan/api/internal/vulkan-ubo-pool.cpp @@ -84,7 +84,7 @@ struct Ubo::Impl return size; } - Vulkan::BufferRef GetBuffer() const + Vulkan::RefCountedBuffer GetBuffer() const { return mPool.GetBuffer( mUbo ); } @@ -109,12 +109,12 @@ struct UboPool::Impl { struct PoolBuffer { - explicit PoolBuffer( Vulkan::BufferRef buf ) : + explicit PoolBuffer( Vulkan::RefCountedBuffer buf ) : mappedPtr( nullptr ), buffer( buf ) {} ~PoolBuffer() = default; void* mappedPtr; - Vulkan::BufferRef buffer; + Vulkan::RefCountedBuffer buffer; }; explicit Impl( UboPool& uboPool, Controller& controller, uint32_t blockSize, uint32_t initialCapacity ) @@ -233,7 +233,7 @@ struct UboPool::Impl return (nullptr != mBuffers[bufferIndex].mappedPtr); } - Vulkan::BufferRef GetBuffer( Ubo& ubo ) const + Vulkan::RefCountedBuffer GetBuffer( Ubo& ubo ) const { auto& impl = ubo.GetImplementation(); auto bufferIndex = uint32_t(impl.mAllocationInfo.allocationIndex / mInitialCapacity); @@ -272,7 +272,7 @@ bool UboPool::IsMapped( Ubo& ubo ) return mImpl->IsMapped( ubo ); } -Vulkan::BufferRef UboPool::GetBuffer( Ubo& ubo ) const +Vulkan::RefCountedBuffer UboPool::GetBuffer( Ubo& ubo ) const { return mImpl->GetBuffer( ubo ); } @@ -330,7 +330,7 @@ uint32_t Ubo::WriteKeepMapped( const void* data, uint32_t offset, uint32_t size return mImpl->WriteKeepMapped( data, offset, size ); } -Vulkan::BufferRef Ubo::GetBuffer() const +Vulkan::RefCountedBuffer Ubo::GetBuffer() const { return mImpl->GetBuffer(); } diff --git a/dali/graphics/vulkan/api/internal/vulkan-ubo-pool.h b/dali/graphics/vulkan/api/internal/vulkan-ubo-pool.h index ee21087..cd2a8c8 100644 --- a/dali/graphics/vulkan/api/internal/vulkan-ubo-pool.h +++ b/dali/graphics/vulkan/api/internal/vulkan-ubo-pool.h @@ -104,7 +104,7 @@ public: * @param ubo * @return */ - Vulkan::BufferRef GetBuffer( Ubo& ubo ) const; + Vulkan::RefCountedBuffer GetBuffer( Ubo& ubo ) const; private: @@ -142,7 +142,7 @@ struct Ubo * Returns buffer associated with the UBO * @return */ - Vulkan::BufferRef GetBuffer() const; + Vulkan::RefCountedBuffer GetBuffer() const; /** * Returns binding offset within Vulkan buffer object diff --git a/dali/graphics/vulkan/api/vulkan-api-buffer.cpp b/dali/graphics/vulkan/api/vulkan-api-buffer.cpp index 693a755..bdcd1ab 100644 --- a/dali/graphics/vulkan/api/vulkan-api-buffer.cpp +++ b/dali/graphics/vulkan/api/vulkan-api-buffer.cpp @@ -92,7 +92,7 @@ void Buffer::Write( void* src, uint32_t srcSize, uint32_t dstOffset ) mController.ScheduleBufferMemoryTransfer( std::move(transfer) ); } -Vulkan::BufferRef Buffer::GetBufferRef() const +Vulkan::RefCountedBuffer Buffer::GetBufferRef() const { return mBufferRef; } diff --git a/dali/graphics/vulkan/api/vulkan-api-buffer.h b/dali/graphics/vulkan/api/vulkan-api-buffer.h index eeb0e10..e4c5124 100644 --- a/dali/graphics/vulkan/api/vulkan-api-buffer.h +++ b/dali/graphics/vulkan/api/vulkan-api-buffer.h @@ -63,7 +63,7 @@ public: */ void Write( void* src, uint32_t srcSize, uint32_t dstOffset ) override; - Vulkan::BufferRef GetBufferRef() const; + Vulkan::RefCountedBuffer GetBufferRef() const; private: @@ -73,7 +73,7 @@ private: API::Buffer::UsageHint mUsageHints; uint32_t mSize; - Vulkan::BufferRef mBufferRef; + Vulkan::RefCountedBuffer mBufferRef; }; } } // namespace Graphics diff --git a/dali/graphics/vulkan/api/vulkan-api-controller.cpp b/dali/graphics/vulkan/api/vulkan-api-controller.cpp index 7a79f27..746b5ac 100644 --- a/dali/graphics/vulkan/api/vulkan-api-controller.cpp +++ b/dali/graphics/vulkan/api/vulkan-api-controller.cpp @@ -146,7 +146,7 @@ struct Controller::Impl mBufferTransferRequests.clear(); } - std::vector cmdBufRefs{}; + std::vector cmdBufRefs{}; // Prepare pipelines for( auto&& command : commands ) @@ -209,8 +209,8 @@ struct Controller::Impl // resources std::vector mTextures; - std::vector mShaders; - std::vector mBuffers; + std::vector mShaders; + std::vector mBuffers; // owner objects ObjectOwner mTexturesOwner; @@ -226,7 +226,7 @@ struct Controller::Impl std::unique_ptr mBufferFactory; // todo: should be per thread - Vulkan::CommandPoolRef mCommandPool; + Vulkan::RefCountedCommandPool mCommandPool; std::vector> mBufferTransferRequests; diff --git a/dali/graphics/vulkan/api/vulkan-api-controller.h b/dali/graphics/vulkan/api/vulkan-api-controller.h index 1aee136..1580d86 100644 --- a/dali/graphics/vulkan/api/vulkan-api-controller.h +++ b/dali/graphics/vulkan/api/vulkan-api-controller.h @@ -49,7 +49,7 @@ struct BufferMemoryTransfer std::unique_ptr srcPtr{ nullptr }; uint32_t srcSize{ 0u }; - Vulkan::BufferRef dstBuffer {}; + Vulkan::RefCountedBuffer dstBuffer {}; uint32_t dstOffset { 0u }; }; diff --git a/dali/graphics/vulkan/api/vulkan-api-render-command.cpp b/dali/graphics/vulkan/api/vulkan-api-render-command.cpp index 8969b30..3fcdd12 100644 --- a/dali/graphics/vulkan/api/vulkan-api-render-command.cpp +++ b/dali/graphics/vulkan/api/vulkan-api-render-command.cpp @@ -410,7 +410,7 @@ const vk::PipelineViewportStateCreateInfo* RenderCommand::PrepareViewportStateCr setScissorCount( Vulkan::U32(viewState.scissors.size())) ); } -const Vulkan::CommandBufferRef& RenderCommand::GetCommandBuffer() const +const Vulkan::RefCountedCommandBuffer& RenderCommand::GetCommandBuffer() const { return mCommandBuffer; } @@ -420,7 +420,7 @@ const Vulkan::PipelineCache& RenderCommand::GetPipelineCache() const return mPipelineCache; } -const Vulkan::PipelineRef& RenderCommand::GetPipeline() const +const Vulkan::RefCountedPipeline& RenderCommand::GetPipeline() const { return mPipeline; } @@ -467,7 +467,7 @@ void RenderCommand::BindTexturesAndSamplers() } } -const std::vector& RenderCommand::GetDescriptorSets() const +const std::vector& RenderCommand::GetDescriptorSets() const { return mDescriptorSets; } diff --git a/dali/graphics/vulkan/api/vulkan-api-render-command.h b/dali/graphics/vulkan/api/vulkan-api-render-command.h index ea304fb..6799ff6 100644 --- a/dali/graphics/vulkan/api/vulkan-api-render-command.h +++ b/dali/graphics/vulkan/api/vulkan-api-render-command.h @@ -87,13 +87,13 @@ public: * Returns an array of updated descriptor sets * @return */ - const std::vector& GetDescriptorSets() const; + const std::vector& GetDescriptorSets() const; /** * Returns associated Vulkan command buffer * @return */ - const Vulkan::CommandBufferRef& GetCommandBuffer() const; + const Vulkan::RefCountedCommandBuffer& GetCommandBuffer() const; /** * Returns pipeline cache @@ -105,7 +105,7 @@ public: * Returns pipeline * @return */ - const Vulkan::PipelineRef& GetPipeline() const; + const Vulkan::RefCountedPipeline& GetPipeline() const; @@ -145,13 +145,13 @@ private: VulkanAPI::Controller& mController; Vulkan::Graphics& mGraphics; Vulkan::PipelineCache& mPipelineCache; - Vulkan::CommandBufferRef mCommandBuffer; - Vulkan::PipelineRef mPipeline; - Vulkan::DescriptorPoolRef mDescriptorPool; + Vulkan::RefCountedCommandBuffer mCommandBuffer; + Vulkan::RefCountedPipeline mPipeline; + Vulkan::RefCountedDescriptorPool mDescriptorPool; std::vector mVkDescriptorSetLayouts; - std::vector mDescriptorSets; + std::vector mDescriptorSets; std::vector> mUboBuffers; diff --git a/dali/graphics/vulkan/api/vulkan-api-shader.cpp b/dali/graphics/vulkan/api/vulkan-api-shader.cpp index 22fdab5..2a7b23a 100644 --- a/dali/graphics/vulkan/api/vulkan-api-shader.cpp +++ b/dali/graphics/vulkan/api/vulkan-api-shader.cpp @@ -38,7 +38,7 @@ mGraphics( graphics ) } -ShaderRef Shader::GetShader( vk::ShaderStageFlagBits shaderStage ) const +RefCountedShader Shader::GetShader( vk::ShaderStageFlagBits shaderStage ) const { switch( shaderStage ) { @@ -59,7 +59,7 @@ ShaderRef Shader::GetShader( vk::ShaderStageFlagBits shaderStage ) const { } } - return ShaderRef(); + return RefCountedShader(); } Shader& Shader::DownCast( Dali::Graphics::API::Shader& shader ) @@ -67,7 +67,7 @@ Shader& Shader::DownCast( Dali::Graphics::API::Shader& shader ) return *( dynamic_cast( &shader ) ); } -Vulkan::ShaderRef Shader::GetShaderRef( vk::ShaderStageFlagBits shaderStage ) const +Vulkan::RefCountedShader Shader::GetShaderRef( vk::ShaderStageFlagBits shaderStage ) const { if(shaderStage == vk::ShaderStageFlagBits::eVertex) { @@ -79,7 +79,7 @@ Vulkan::ShaderRef Shader::GetShaderRef( vk::ShaderStageFlagBits shaderStage ) co } else { - return Vulkan::ShaderRef( ); + return Vulkan::RefCountedShader( ); } } diff --git a/dali/graphics/vulkan/api/vulkan-api-shader.h b/dali/graphics/vulkan/api/vulkan-api-shader.h index 3c4d94a..5be6e3a 100644 --- a/dali/graphics/vulkan/api/vulkan-api-shader.h +++ b/dali/graphics/vulkan/api/vulkan-api-shader.h @@ -47,11 +47,11 @@ public: Graphics::API::ShaderDetails::Language language, Graphics::API::ShaderDetails::ShaderSource shaderSource ); - Vulkan::ShaderRef GetShader( vk::ShaderStageFlagBits shaderStage ) const ; + Vulkan::RefCountedShader GetShader( vk::ShaderStageFlagBits shaderStage ) const ; static Shader& DownCast( Dali::Graphics::API::Shader& shader ); - Vulkan::ShaderRef GetShaderRef( vk::ShaderStageFlagBits shaderStage ) const; + Vulkan::RefCountedShader GetShaderRef( vk::ShaderStageFlagBits shaderStage ) const; // REFLECTION @@ -99,8 +99,8 @@ protected: private: Vulkan::Graphics& mGraphics; - Vulkan::ShaderRef mVertexShader; - Vulkan::ShaderRef mFragmentShader; + Vulkan::RefCountedShader mVertexShader; + Vulkan::RefCountedShader mFragmentShader; std::vector mVertexInputAttributes; std::vector mUniformBlocks; diff --git a/dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-allocator.h b/dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-allocator.h index 26dabe3..5c25ea4 100644 --- a/dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-allocator.h +++ b/dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-allocator.h @@ -50,7 +50,7 @@ public: * @param memoryProperties * @return */ - virtual GpuMemoryBlockRef Allocate( const vk::MemoryRequirements& requirements, vk::MemoryPropertyFlags memoryProperties ) = 0; + virtual RefCountedGpuMemoryBlock Allocate( const vk::MemoryRequirements& requirements, vk::MemoryPropertyFlags memoryProperties ) = 0; /** * @@ -58,7 +58,7 @@ public: * @param memoryProperties * @return */ - virtual GpuMemoryBlockRef Allocate( const BufferRef& buffer, vk::MemoryPropertyFlags memoryProperties ) = 0; + virtual RefCountedGpuMemoryBlock Allocate( const RefCountedBuffer& buffer, vk::MemoryPropertyFlags memoryProperties ) = 0; /** * @@ -66,7 +66,7 @@ public: * @param memoryProperties * @return */ - virtual GpuMemoryBlockRef Allocate( const ImageRef& buffer, vk::MemoryPropertyFlags memoryProperties ) = 0; + virtual RefCountedGpuMemoryBlock Allocate( const RefCountedImage& buffer, vk::MemoryPropertyFlags memoryProperties ) = 0; // refcounting managed via allocator which ownes all the blocks, allocator may // implement this feature any way ( or simply ignore it ) diff --git a/dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-manager.cpp b/dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-manager.cpp index 0b3b72f..fa23ccf 100644 --- a/dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-manager.cpp +++ b/dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-manager.cpp @@ -83,7 +83,7 @@ struct GpuMemoryDefaultAllocator : public GpuMemoryAllocator ~GpuMemoryDefaultAllocator() override = default; - GpuMemoryBlockRef Allocate( const vk::MemoryRequirements& requirements, vk::MemoryPropertyFlags memoryProperties ) override + RefCountedGpuMemoryBlock Allocate( const vk::MemoryRequirements& requirements, vk::MemoryPropertyFlags memoryProperties ) override { auto memoryTypeIndex = GetMemoryIndex(mGraphics.GetMemoryProperties(), requirements.memoryTypeBits, @@ -96,7 +96,7 @@ struct GpuMemoryDefaultAllocator : public GpuMemoryAllocator .setAllocationSize(requirements.size), mGraphics.GetAllocator())); // add allocated memory to the heap of memories as a base handle - auto handle = GpuMemoryBlockRef( new GpuMemoryBlock( *this, MakeUnique() ) ); + auto handle = RefCountedGpuMemoryBlock( new GpuMemoryBlock( *this, MakeUnique() ) ); auto &block = *handle->GetData(); block.requirements = requirements; @@ -105,7 +105,7 @@ struct GpuMemoryDefaultAllocator : public GpuMemoryAllocator block.alignment = requirements.alignment; block.memory = memory; - mUniqueBlocks.emplace_back( MakeUnique(handle) ); + mUniqueBlocks.emplace_back( MakeUnique(handle) ); return handle; } @@ -115,7 +115,7 @@ struct GpuMemoryDefaultAllocator : public GpuMemoryAllocator * @param memoryProperties * @return */ - virtual GpuMemoryBlockRef Allocate( const Handle& buffer, vk::MemoryPropertyFlags memoryProperties ) override + virtual RefCountedGpuMemoryBlock Allocate( const Handle& buffer, vk::MemoryPropertyFlags memoryProperties ) override { return Allocate( mGraphics.GetDevice().getBufferMemoryRequirements(buffer->GetVkHandle() ), memoryProperties ); @@ -127,7 +127,7 @@ struct GpuMemoryDefaultAllocator : public GpuMemoryAllocator * @param memoryProperties * @return */ - GpuMemoryBlockRef Allocate( const ImageRef& image, vk::MemoryPropertyFlags memoryProperties ) override + RefCountedGpuMemoryBlock Allocate( const RefCountedImage& image, vk::MemoryPropertyFlags memoryProperties ) override { return Allocate( mGraphics.GetDevice().getImageMemoryRequirements(image->GetVkHandle() ), memoryProperties ); @@ -190,7 +190,7 @@ struct GpuMemoryDefaultAllocator : public GpuMemoryAllocator GpuMemoryManager& mGpuManager; Graphics& mGraphics; - std::vector> mUniqueBlocks; + std::vector> mUniqueBlocks; }; struct GpuMemoryManager::Impl diff --git a/dali/graphics/vulkan/tests/texture-test.cpp b/dali/graphics/vulkan/tests/texture-test.cpp index edc458a..f5c6b56 100644 --- a/dali/graphics/vulkan/tests/texture-test.cpp +++ b/dali/graphics/vulkan/tests/texture-test.cpp @@ -145,11 +145,11 @@ struct Texture } Graphics& mGraphics; - ImageRef mImage; - ImageViewRef mImageView; + RefCountedImage mImage; + RefCountedImageView mImageView; - CommandPoolRef mCommandPool; - CommandBufferRef mCommandBuffer; // primary buffer, executed independent + RefCountedCommandPool mCommandPool; + RefCountedCommandBuffer mCommandBuffer; // primary buffer, executed independent // layouts vk::ImageLayout mOldLayout; diff --git a/dali/graphics/vulkan/vulkan-buffer.cpp b/dali/graphics/vulkan/vulkan-buffer.cpp index 25f1c11..c939bea 100644 --- a/dali/graphics/vulkan/vulkan-buffer.cpp +++ b/dali/graphics/vulkan/vulkan-buffer.cpp @@ -87,7 +87,7 @@ struct Buffer::Impl final return mBuffer; } - void BindMemory( GpuMemoryBlockRef handle ) + void BindMemory( RefCountedGpuMemoryBlock handle ) { assert( mBuffer && "Buffer not initialised!"); VkAssert(mGraphics.GetDevice().bindBufferMemory( mBuffer, (*handle), 0 )); @@ -96,12 +96,12 @@ struct Buffer::Impl final Vulkan::Graphics& mGraphics; Vulkan::Buffer& mInterface; - GpuMemoryBlockRef mDeviceMemory; + RefCountedGpuMemoryBlock mDeviceMemory; vk::BufferCreateInfo mInfo; vk::Buffer mBuffer; }; -BufferRef Buffer::New(Graphics& graphics, size_t size, Type type) +RefCountedBuffer Buffer::New(Graphics& graphics, size_t size, Type type) { auto usageFlags = vk::BufferUsageFlags{}; @@ -117,7 +117,7 @@ BufferRef Buffer::New(Graphics& graphics, size_t size, Type type) info.setSharingMode( vk::SharingMode::eExclusive ); info.setSize( size ); info.setUsage( usageFlags | vk::BufferUsageFlagBits::eTransferDst ); - auto buffer = BufferRef( new Buffer(graphics, info) ); + auto buffer = RefCountedBuffer( new Buffer(graphics, info) ); if(buffer && buffer->mImpl->Initialise()) { @@ -126,15 +126,15 @@ BufferRef Buffer::New(Graphics& graphics, size_t size, Type type) return buffer; } -BufferRef Buffer::New( Graphics& graphics, vk::BufferCreateInfo info ) +RefCountedBuffer Buffer::New( Graphics& graphics, vk::BufferCreateInfo info ) { - auto buffer = BufferRef( new Buffer(graphics, info) ); + auto buffer = RefCountedBuffer( new Buffer(graphics, info) ); if( buffer && buffer->mImpl->Initialise() ) { graphics.AddBuffer( buffer ); return buffer; } - return BufferRef(); + return RefCountedBuffer(); } Buffer::Buffer(Graphics& graphics, const vk::BufferCreateInfo& createInfo) @@ -150,7 +150,7 @@ vk::BufferUsageFlags Buffer::GetUsage() const return mImpl->GetUsage(); } -const GpuMemoryBlockRef& Buffer::GetMemoryHandle() const +const RefCountedGpuMemoryBlock& Buffer::GetMemoryHandle() const { return mImpl->mDeviceMemory; } @@ -165,7 +165,7 @@ vk::Buffer Buffer::GetVkHandle() const return mImpl->GetVkHandle(); } -void Buffer::BindMemory( const GpuMemoryBlockRef& handle ) +void Buffer::BindMemory( const RefCountedGpuMemoryBlock& handle ) { mImpl->BindMemory( handle ); } diff --git a/dali/graphics/vulkan/vulkan-buffer.h b/dali/graphics/vulkan/vulkan-buffer.h index c0ce0b4..621789c 100644 --- a/dali/graphics/vulkan/vulkan-buffer.h +++ b/dali/graphics/vulkan/vulkan-buffer.h @@ -56,7 +56,7 @@ public: * @param type * @return */ - static BufferRef New( Graphics& graphics, size_t size, Type type ); + static RefCountedBuffer New( Graphics& graphics, size_t size, Type type ); /** * @@ -64,7 +64,7 @@ public: * @param info * @return */ - static BufferRef New( Graphics& graphics, vk::BufferCreateInfo info ); + static RefCountedBuffer New( Graphics& graphics, vk::BufferCreateInfo info ); /** * Returns buffer usage flags @@ -88,13 +88,13 @@ public: * Returns handle to the allocated memory * @return */ - const GpuMemoryBlockRef& GetMemoryHandle() const; + const RefCountedGpuMemoryBlock& GetMemoryHandle() const; /** * Binds buffer memory * @param handle */ - void BindMemory( const GpuMemoryBlockRef& handle ); + void BindMemory( const RefCountedGpuMemoryBlock& handle ); public: diff --git a/dali/graphics/vulkan/vulkan-command-buffer.cpp b/dali/graphics/vulkan/vulkan-command-buffer.cpp index 585515e..6f85def 100644 --- a/dali/graphics/vulkan/vulkan-command-buffer.cpp +++ b/dali/graphics/vulkan/vulkan-command-buffer.cpp @@ -173,7 +173,7 @@ struct CommandBuffer::Impl mCommandBuffer.bindVertexBuffers( firstBinding, bindingCount, vkBuffers.data(), pOffsets ); } - void BindIndexBuffer( BufferRef buffer, uint32_t offset, vk::IndexType indexType ) + void BindIndexBuffer( RefCountedBuffer buffer, uint32_t offset, vk::IndexType indexType ) { // validate assert( ( buffer->GetUsage() & vk::BufferUsageFlagBits::eIndexBuffer ) && @@ -291,7 +291,7 @@ struct CommandBuffer::Impl { for( auto&& imageBarrier : imageBarriers ) { - ImageRef imageResource{}; + RefCountedImage imageResource{}; if( (imageResource = mGraphics.FindImage( imageBarrier.image )) ) { PushResource( imageResource ); @@ -303,7 +303,7 @@ struct CommandBuffer::Impl mCommandBuffer.pipelineBarrier( srcStageMask, dstStageMask, dependencyFlags, memoryBarriers, bufferBarriers, imageBarriers ); } - void CopyBufferToImage( BufferRef srcBuffer, ImageRef dstImage, vk::ImageLayout dstLayout, std::vector regions ) + void CopyBufferToImage( RefCountedBuffer srcBuffer, RefCountedImage dstImage, vk::ImageLayout dstLayout, std::vector regions ) { PushResource( srcBuffer ); PushResource( dstImage ); @@ -311,7 +311,7 @@ struct CommandBuffer::Impl mCommandBuffer.copyBufferToImage(srcBuffer->GetVkHandle(), dstImage->GetVkHandle(), dstLayout, regions ); } - vk::ImageMemoryBarrier ImageLayoutTransitionBarrier( ImageRef image, + vk::ImageMemoryBarrier ImageLayoutTransitionBarrier( RefCountedImage image, const vk::AccessFlags& srcAccessMask, const vk::AccessFlags& dstAccessMask, vk::ImageLayout oldLayout, @@ -343,11 +343,11 @@ struct CommandBuffer::Impl std::vector> mResources; // used resources - PipelineRef mCurrentPipeline; + RefCountedPipeline mCurrentPipeline; vk::RenderPass mCurrentRenderPass; - FenceRef mFinishedFence; + RefCountedFence mFinishedFence; bool mRecording{false}; }; @@ -440,7 +440,7 @@ void CommandBuffer::BindVertexBuffers( uint32_t firstBinding, mImpl->BindVertexBuffers( firstBinding, bindingCount, buffers, pOffsets ); } -void CommandBuffer::BindIndexBuffer( BufferRef buffer, uint32_t offset, vk::IndexType indexType ) +void CommandBuffer::BindIndexBuffer( RefCountedBuffer buffer, uint32_t offset, vk::IndexType indexType ) { mImpl->BindIndexBuffer( buffer, offset, indexType ); } @@ -513,13 +513,13 @@ void CommandBuffer::PipelineBarrier( vk::PipelineStageFlags srcStageMask, mImpl->PipelineBarrier( srcStageMask, dstStageMask, dependencyFlags, memoryBarriers, bufferBarriers, imageBarriers ); } -void CommandBuffer::CopyBufferToImage( BufferRef srcBuffer, ImageRef dstImage, +void CommandBuffer::CopyBufferToImage( RefCountedBuffer srcBuffer, RefCountedImage dstImage, vk::ImageLayout dstLayout, std::vector regions ) { mImpl->CopyBufferToImage( srcBuffer, dstImage, dstLayout, regions ); } -vk::ImageMemoryBarrier CommandBuffer::ImageLayoutTransitionBarrier( ImageRef image, +vk::ImageMemoryBarrier CommandBuffer::ImageLayoutTransitionBarrier( RefCountedImage image, vk::AccessFlags srcAccessMask, vk::AccessFlags dstAccessMask, vk::ImageLayout oldLayout, @@ -533,7 +533,7 @@ vk::ImageMemoryBarrier CommandBuffer::ImageLayoutTransitionBarrier( ImageRef ima aspectMask ); } -vk::ImageMemoryBarrier CommandBuffer::ImageLayoutTransitionBarrier( ImageRef image, +vk::ImageMemoryBarrier CommandBuffer::ImageLayoutTransitionBarrier( RefCountedImage image, vk::ImageLayout oldLayout, vk::ImageLayout newLayout, vk::ImageAspectFlags aspectMask diff --git a/dali/graphics/vulkan/vulkan-command-buffer.h b/dali/graphics/vulkan/vulkan-command-buffer.h index 1b4c489..b526152 100644 --- a/dali/graphics/vulkan/vulkan-command-buffer.h +++ b/dali/graphics/vulkan/vulkan-command-buffer.h @@ -112,7 +112,7 @@ public: * @param offset * @param indexType */ - void BindIndexBuffer( BufferRef buffer, uint32_t offset, vk::IndexType indexType); + void BindIndexBuffer( RefCountedBuffer buffer, uint32_t offset, vk::IndexType indexType); /** * Binds single vertex buffer @@ -213,14 +213,14 @@ public: * @param dtsLayout * @param regions */ - void CopyBufferToImage( BufferRef srcBuffer, ImageRef dstImage, vk::ImageLayout dstLayout, + void CopyBufferToImage( RefCountedBuffer srcBuffer, RefCountedImage dstImage, vk::ImageLayout dstLayout, std::vector regions ); /** * Creates layout transition barrier * @return */ - vk::ImageMemoryBarrier ImageLayoutTransitionBarrier( ImageRef image, + vk::ImageMemoryBarrier ImageLayoutTransitionBarrier( RefCountedImage image, vk::AccessFlags srcAccessMask, vk::AccessFlags dstAccessMask, vk::ImageLayout oldLayout, @@ -235,7 +235,7 @@ public: * @param aspectMask * @return */ - vk::ImageMemoryBarrier ImageLayoutTransitionBarrier( ImageRef image, + vk::ImageMemoryBarrier ImageLayoutTransitionBarrier( RefCountedImage image, vk::ImageLayout olsLayout, vk::ImageLayout newLayout, vk::ImageAspectFlags aspectMask diff --git a/dali/graphics/vulkan/vulkan-command-pool.cpp b/dali/graphics/vulkan/vulkan-command-pool.cpp index 3805959..17fd0af 100644 --- a/dali/graphics/vulkan/vulkan-command-pool.cpp +++ b/dali/graphics/vulkan/vulkan-command-pool.cpp @@ -122,7 +122,7 @@ struct CommandBufferPool * Allocates new command buffer * @return */ - CommandBufferRef AllocateCommandBuffer( bool reset ) + RefCountedCommandBuffer AllocateCommandBuffer( bool reset ) { // resize if no more nodes if( mFirstFree == INVALID_NODE_INDEX ) @@ -139,7 +139,7 @@ struct CommandBufferPool } ++mAllocationCount; - return CommandBufferRef(node.commandBuffer); + return RefCountedCommandBuffer(node.commandBuffer); } /** @@ -216,7 +216,7 @@ struct CommandPool::Impl mGraphics.GetDevice().resetCommandPool( mCommandPool, releaseResources ? vk::CommandPoolResetFlagBits::eReleaseResources : vk::CommandPoolResetFlags{} ); } - CommandBufferRef NewCommandBuffer( const vk::CommandBufferAllocateInfo& allocateInfo ) + RefCountedCommandBuffer NewCommandBuffer( const vk::CommandBufferAllocateInfo& allocateInfo ) { auto& usedPool = allocateInfo.level == vk::CommandBufferLevel::ePrimary ? *mInternalPoolPrimary.get() : *mInternalPoolSecondary.get(); auto retval = usedPool.AllocateCommandBuffer( false ); @@ -291,12 +291,12 @@ bool CommandPool::OnDestroy() return false; } -CommandBufferRef CommandPool::NewCommandBuffer( const vk::CommandBufferAllocateInfo& allocateInfo ) +RefCountedCommandBuffer CommandPool::NewCommandBuffer( const vk::CommandBufferAllocateInfo& allocateInfo ) { return mImpl->NewCommandBuffer( allocateInfo ); } -CommandBufferRef CommandPool::NewCommandBuffer( bool isPrimary ) +RefCountedCommandBuffer CommandPool::NewCommandBuffer( bool isPrimary ) { return mImpl->NewCommandBuffer( vk::CommandBufferAllocateInfo{}.setLevel( isPrimary ? vk::CommandBufferLevel::ePrimary : vk::CommandBufferLevel::eSecondary diff --git a/dali/graphics/vulkan/vulkan-command-pool.h b/dali/graphics/vulkan/vulkan-command-pool.h index 93a56a8..fae3ba8 100644 --- a/dali/graphics/vulkan/vulkan-command-pool.h +++ b/dali/graphics/vulkan/vulkan-command-pool.h @@ -77,14 +77,14 @@ public: * @param allocateInfo * @return */ - CommandBufferRef NewCommandBuffer( const vk::CommandBufferAllocateInfo& allocateInfo ); + RefCountedCommandBuffer NewCommandBuffer( const vk::CommandBufferAllocateInfo& allocateInfo ); /** * * @param isPrimary * @return */ - CommandBufferRef NewCommandBuffer( bool isPrimary = true ); + RefCountedCommandBuffer NewCommandBuffer( bool isPrimary = true ); /** * Releases command buffer diff --git a/dali/graphics/vulkan/vulkan-descriptor-set.cpp b/dali/graphics/vulkan/vulkan-descriptor-set.cpp index 56454c0..6f1ff4a 100644 --- a/dali/graphics/vulkan/vulkan-descriptor-set.cpp +++ b/dali/graphics/vulkan/vulkan-descriptor-set.cpp @@ -164,7 +164,7 @@ struct DescriptorSet::Impl mGraphics.GetDevice().updateDescriptorSets( 1, &write, 0, nullptr ); } - void WriteCombinedImageSampler( uint32_t binding, SamplerRef sampler, ImageViewRef imageView ) + void WriteCombinedImageSampler( uint32_t binding, RefCountedSampler sampler, RefCountedImageView imageView ) { // add resource to the list mResources.emplace_back( sampler.StaticCast() ); @@ -220,7 +220,7 @@ vk::DescriptorSet DescriptorSet::GetVkDescriptorSet() const return mImpl->mVkDescriptorSet; } -void DescriptorSet::WriteCombinedImageSampler( uint32_t binding, SamplerRef sampler, ImageViewRef imageView ) +void DescriptorSet::WriteCombinedImageSampler( uint32_t binding, RefCountedSampler sampler, RefCountedImageView imageView ) { mImpl->WriteCombinedImageSampler( binding, sampler, imageView ); } diff --git a/dali/graphics/vulkan/vulkan-descriptor-set.h b/dali/graphics/vulkan/vulkan-descriptor-set.h index 4f77fc6..cdb859d 100644 --- a/dali/graphics/vulkan/vulkan-descriptor-set.h +++ b/dali/graphics/vulkan/vulkan-descriptor-set.h @@ -53,7 +53,7 @@ public: * @param sampler * @param imageView */ - void WriteCombinedImageSampler( uint32_t binding, SamplerRef sampler, ImageViewRef imageView ); + void WriteCombinedImageSampler( uint32_t binding, RefCountedSampler sampler, RefCountedImageView imageView ); /** * * @param buffer @@ -93,7 +93,7 @@ class DescriptorPool : public VkManaged { public: - static DescriptorPoolRef New( Graphics& graphics, const vk::DescriptorPoolCreateInfo& createInfo ); + static RefCountedDescriptorPool New( Graphics& graphics, const vk::DescriptorPoolCreateInfo& createInfo ); ~DescriptorPool() override; diff --git a/dali/graphics/vulkan/vulkan-framebuffer.cpp b/dali/graphics/vulkan/vulkan-framebuffer.cpp index 99e599b..413fa67 100644 --- a/dali/graphics/vulkan/vulkan-framebuffer.cpp +++ b/dali/graphics/vulkan/vulkan-framebuffer.cpp @@ -153,7 +153,7 @@ struct Framebuffer::Impl return false; } - void SetAttachment( ImageViewRef imageViewRef, Framebuffer::AttachmentType type, uint32_t index ) + void SetAttachment( RefCountedImageView imageViewRef, Framebuffer::AttachmentType type, uint32_t index ) { // TODO: all array-type atyachments if( type == AttachmentType::COLOR ) @@ -171,7 +171,7 @@ struct Framebuffer::Impl } } - ImageViewRef GetAttachment( AttachmentType type, uint32_t index ) const + RefCountedImageView GetAttachment( AttachmentType type, uint32_t index ) const { switch( type ) { @@ -188,15 +188,15 @@ struct Framebuffer::Impl case AttachmentType::RESOLVE: case AttachmentType::PRESERVE: { - return ImageViewRef(); + return RefCountedImageView(); } } - return ImageViewRef(); + return RefCountedImageView(); } - std::vector GetAttachments( AttachmentType type ) const + std::vector GetAttachments( AttachmentType type ) const { - std::vector retval{}; + std::vector retval{}; switch( type ) { case AttachmentType::COLOR: @@ -222,7 +222,7 @@ struct Framebuffer::Impl uint32_t GetAttachmentCount( AttachmentType type ) const { - std::vector retval{}; + std::vector retval{}; switch( type ) { case AttachmentType::COLOR: @@ -267,8 +267,8 @@ struct Framebuffer::Impl uint32_t mWidth; uint32_t mHeight; - std::vector mColorImageViewAttachments; - ImageViewRef mDepthStencilImageViewAttachment; + std::vector mColorImageViewAttachments; + RefCountedImageView mDepthStencilImageViewAttachment; vk::Framebuffer mVkFramebuffer; vk::RenderPass mVkRenderPass; @@ -280,9 +280,9 @@ struct Framebuffer::Impl bool mInitialised{false}; }; -FramebufferRef Framebuffer::New( Graphics& graphics, uint32_t width, uint32_t height ) +RefCountedFramebuffer Framebuffer::New( Graphics& graphics, uint32_t width, uint32_t height ) { - FramebufferRef ref( new Framebuffer( graphics, width, height ) ); + RefCountedFramebuffer ref( new Framebuffer( graphics, width, height ) ); return ref; } @@ -291,7 +291,7 @@ Framebuffer::Framebuffer( Graphics& graphics, uint32_t width, uint32_t height ) mImpl = std::make_unique( *this, graphics, width, height ); } -void Framebuffer::SetAttachment( ImageViewRef imageViewRef, Framebuffer::AttachmentType type, uint32_t index ) +void Framebuffer::SetAttachment( RefCountedImageView imageViewRef, Framebuffer::AttachmentType type, uint32_t index ) { mImpl->SetAttachment( imageViewRef, type, index ); } @@ -306,12 +306,12 @@ uint32_t Framebuffer::GetHeight() const return mImpl->mHeight; } -ImageViewRef Framebuffer::GetAttachment( AttachmentType type, uint32_t index ) const +RefCountedImageView Framebuffer::GetAttachment( AttachmentType type, uint32_t index ) const { return mImpl->GetAttachment( type, index ); } -std::vector Framebuffer::GetAttachments( AttachmentType type ) const +std::vector Framebuffer::GetAttachments( AttachmentType type ) const { return mImpl->GetAttachments( type ); } diff --git a/dali/graphics/vulkan/vulkan-framebuffer.h b/dali/graphics/vulkan/vulkan-framebuffer.h index 8780e29..176adb9 100644 --- a/dali/graphics/vulkan/vulkan-framebuffer.h +++ b/dali/graphics/vulkan/vulkan-framebuffer.h @@ -48,19 +48,19 @@ public: PRESERVE }; - static FramebufferRef New( Graphics& graphics, uint32_t width, uint32_t height ); + static RefCountedFramebuffer New( Graphics& graphics, uint32_t width, uint32_t height ); uint32_t GetWidth() const; uint32_t GetHeight() const; - ImageViewRef GetAttachment( AttachmentType type, uint32_t index ) const; + RefCountedImageView GetAttachment( AttachmentType type, uint32_t index ) const; - std::vector GetAttachments( AttachmentType type ) const; + std::vector GetAttachments( AttachmentType type ) const; uint32_t GetAttachmentCount( AttachmentType type ) const; - void SetAttachment( ImageViewRef imageViewRef, Framebuffer::AttachmentType type, uint32_t index ); + void SetAttachment( RefCountedImageView imageViewRef, Framebuffer::AttachmentType type, uint32_t index ); void Commit(); diff --git a/dali/graphics/vulkan/vulkan-graphics-texture.cpp b/dali/graphics/vulkan/vulkan-graphics-texture.cpp index 5641165..503298f 100644 --- a/dali/graphics/vulkan/vulkan-graphics-texture.cpp +++ b/dali/graphics/vulkan/vulkan-graphics-texture.cpp @@ -193,20 +193,20 @@ struct Texture::Impl mSampler->GetVkHandle(); } - SamplerRef GetSampler() const + RefCountedSampler GetSampler() const { return mSampler; } Graphics& mGraphics; - ImageRef mImage; - ImageViewRef mImageView; - SamplerRef mSampler; + RefCountedImage mImage; + RefCountedImageView mImageView; + RefCountedSampler mSampler; // command pools should be 'per-thread' so they can be safely // used withing one single thread before submitting them - CommandPoolRef mCommandPool; - CommandBufferRef mCommandBuffer; // primary buffer, executed independent + RefCountedCommandPool mCommandPool; + RefCountedCommandBuffer mCommandBuffer; // primary buffer, executed independent // layouts vk::ImageLayout mOldLayout; @@ -255,22 +255,22 @@ void Texture::UploadData( const void* data, size_t size, TextureUploadMode mode * @param buffer * @param mode */ -void Texture::UploadFromBuffer( BufferRef buffer, TextureUploadMode mode ) +void Texture::UploadFromBuffer( RefCountedBuffer buffer, TextureUploadMode mode ) { } -ImageRef Texture::GetImage() const +RefCountedImage Texture::GetImage() const { return mImpl->mImage; } -ImageViewRef Texture::GetImageView() const +RefCountedImageView Texture::GetImageView() const { return mImpl->mImageView; } -SamplerRef Texture::GetSampler() const +RefCountedSampler Texture::GetSampler() const { return mImpl->mSampler; } diff --git a/dali/graphics/vulkan/vulkan-graphics-texture.h b/dali/graphics/vulkan/vulkan-graphics-texture.h index d53bba2..9ac5ee1 100644 --- a/dali/graphics/vulkan/vulkan-graphics-texture.h +++ b/dali/graphics/vulkan/vulkan-graphics-texture.h @@ -67,25 +67,25 @@ public: * @param buffer * @param mode */ - void UploadFromBuffer( BufferRef buffer, TextureUploadMode mode ); + void UploadFromBuffer( RefCountedBuffer buffer, TextureUploadMode mode ); /** * Returns Image object * @return */ - ImageRef GetImage() const; + RefCountedImage GetImage() const; /** * Returns image view * @return */ - ImageViewRef GetImageView() const; + RefCountedImageView GetImageView() const; /** * Returns sampler * @return */ - SamplerRef GetSampler() const; + RefCountedSampler GetSampler() const; private: diff --git a/dali/graphics/vulkan/vulkan-graphics.cpp b/dali/graphics/vulkan/vulkan-graphics.cpp index dece57a..4413f20 100644 --- a/dali/graphics/vulkan/vulkan-graphics.cpp +++ b/dali/graphics/vulkan/vulkan-graphics.cpp @@ -283,13 +283,13 @@ FBID Graphics::CreateSurface(std::unique_ptr< SurfaceFactory > surfaceFactory) // map surface to FBID auto fbid = ++mBaseFBID; - mSurfaceFBIDMap[fbid] = SwapchainSurfacePair{ SwapchainRef{}, surfaceRef }; + mSurfaceFBIDMap[fbid] = SwapchainSurfacePair{ RefCountedSwapchain{}, surfaceRef }; return fbid; } return -1; } -SwapchainRef Graphics::CreateSwapchainForSurface( SurfaceRef surface ) +RefCountedSwapchain Graphics::CreateSwapchainForSurface( RefCountedSurface surface ) { auto swapchain = Swapchain::New( *this, GetGraphicsQueue(0u), @@ -308,7 +308,7 @@ SwapchainRef Graphics::CreateSwapchainForSurface( SurfaceRef surface ) return swapchain; } -SwapchainRef Graphics::GetSwapchainForSurface( SurfaceRef surface ) +RefCountedSwapchain Graphics::GetSwapchainForSurface( RefCountedSurface surface ) { for( auto&& val : mSurfaceFBIDMap ) { @@ -318,10 +318,10 @@ SwapchainRef Graphics::GetSwapchainForSurface( SurfaceRef surface ) .swapchain; } } - return SwapchainRef(); + return RefCountedSwapchain(); } -SwapchainRef Graphics::GetSwapchainForFBID( FBID surfaceId ) +RefCountedSwapchain Graphics::GetSwapchainForFBID( FBID surfaceId ) { if(surfaceId == 0) { @@ -534,7 +534,7 @@ Handle< CommandPool > Graphics::CreateCommandPool(const vk::CommandPoolCreateInf return cmdpool; } -SurfaceRef Graphics::GetSurface( FBID surfaceId ) +RefCountedSurface Graphics::GetSurface( FBID surfaceId ) { // TODO: FBID == 0 means default framebuffer, but there should be no // such thing as default framebuffer. @@ -612,12 +612,12 @@ void Graphics::RemoveSampler( Sampler& sampler ) mResourceCache->RemoveSampler(sampler); } -ShaderRef Graphics::FindShader( vk::ShaderModule shaderModule ) +RefCountedShader Graphics::FindShader( vk::ShaderModule shaderModule ) { return mResourceCache->FindShader(shaderModule); } -ImageRef Graphics::FindImage( vk::Image image ) +RefCountedImage Graphics::FindImage( vk::Image image ) { return mResourceCache->FindImage(image); } diff --git a/dali/graphics/vulkan/vulkan-graphics.h b/dali/graphics/vulkan/vulkan-graphics.h index 6cec1a3..d5a46ef 100644 --- a/dali/graphics/vulkan/vulkan-graphics.h +++ b/dali/graphics/vulkan/vulkan-graphics.h @@ -60,8 +60,8 @@ class ResourceCache; struct SwapchainSurfacePair { - SwapchainRef swapchain; - SurfaceRef surface; + RefCountedSwapchain swapchain; + RefCountedSurface surface; }; class Graphics @@ -69,7 +69,6 @@ class Graphics public: Graphics(); - explicit Graphics(std::unique_ptr< SurfaceFactory > surfaceFactory); Graphics(const Graphics&) = delete; Graphics& operator=(const Graphics&) = delete; ~Graphics(); @@ -79,18 +78,18 @@ public: // new way FBID CreateSurface(std::unique_ptr< SurfaceFactory > surfaceFactory); - SwapchainRef CreateSwapchainForSurface( SurfaceRef surface ); + RefCountedSwapchain CreateSwapchainForSurface( RefCountedSurface surface ); - SurfaceRef GetSurface( FBID surfaceId ); + RefCountedSurface GetSurface( FBID surfaceId ); - SwapchainRef GetSwapchainForSurface( SurfaceRef surface ); + RefCountedSwapchain GetSwapchainForSurface( RefCountedSurface surface ); - SwapchainRef GetSwapchainForFBID( FBID surfaceId ); + RefCountedSwapchain GetSwapchainForFBID( FBID surfaceId ); void CreateDevice(); /** Creates new command pool */ - CommandPoolRef CreateCommandPool(const vk::CommandPoolCreateInfo& info); + RefCountedCommandPool CreateCommandPool(const vk::CommandPoolCreateInfo& info); vk::Device GetDevice() const; @@ -131,9 +130,9 @@ private: private: - std::unique_ptr mDeviceMemoryManager; + std::unique_ptr mDeviceMemoryManager; - vk::Instance mInstance; + vk::Instance mInstance; std::unique_ptr mAllocator{nullptr}; // physical device @@ -164,16 +163,16 @@ private: public: // TODO: all this stuff should go into some vulkan cache - void AddBuffer( BufferRef buffer ); - void AddImage( ImageRef image ); - void AddPipeline( PipelineRef pipeline ); - void AddShader( ShaderRef shader ); - void AddCommandPool( CommandPoolRef pool ); - void AddDescriptorPool( DescriptorPoolRef pool ); - void AddFramebuffer( FramebufferRef framebuffer ); + void AddBuffer( RefCountedBuffer buffer ); + void AddImage( RefCountedImage image ); + void AddPipeline( RefCountedPipeline pipeline ); + void AddShader( RefCountedShader shader ); + void AddCommandPool( RefCountedCommandPool pool ); + void AddDescriptorPool( RefCountedDescriptorPool pool ); + void AddFramebuffer( RefCountedFramebuffer framebuffer ); - ShaderRef FindShader( vk::ShaderModule shaderModule ); - ImageRef FindImage( vk::Image image ); + RefCountedShader FindShader( vk::ShaderModule shaderModule ); + RefCountedImage FindImage( vk::Image image ); void RemoveBuffer( Buffer& buffer ); void RemoveShader( Shader& shader ); diff --git a/dali/graphics/vulkan/vulkan-image.cpp b/dali/graphics/vulkan/vulkan-image.cpp index 5971bed..fe4d5f8 100644 --- a/dali/graphics/vulkan/vulkan-image.cpp +++ b/dali/graphics/vulkan/vulkan-image.cpp @@ -58,7 +58,7 @@ struct Image::Impl return true; } - void BindMemory( const GpuMemoryBlockRef& handle ) + void BindMemory( const RefCountedGpuMemoryBlock& handle ) { mGraphics.GetDevice().bindImageMemory( mVkImage, *handle, 0 ); mDeviceMemory = handle; @@ -70,15 +70,15 @@ struct Image::Impl vk::ImageLayout mVkImageLayout; vk::ImageCreateInfo mCreateInfo; - GpuMemoryBlockRef mDeviceMemory; + RefCountedGpuMemoryBlock mDeviceMemory; bool mIsExternal; }; Image::~Image() = default; -ImageRef Image::New( Graphics& graphics, vk::ImageCreateInfo createInfo ) +RefCountedImage Image::New( Graphics& graphics, vk::ImageCreateInfo createInfo ) { - ImageRef retval( new Image( graphics, createInfo, nullptr ) ); + RefCountedImage retval( new Image( graphics, createInfo, nullptr ) ); if( !retval->mImpl->Initialise() ) { retval.Reset(); @@ -90,9 +90,9 @@ ImageRef Image::New( Graphics& graphics, vk::ImageCreateInfo createInfo ) return retval; } -ImageRef Image::New( Graphics& graphics, vk::ImageCreateInfo createInfo, vk::Image externalImage ) +RefCountedImage Image::New( Graphics& graphics, vk::ImageCreateInfo createInfo, vk::Image externalImage ) { - ImageRef retval( new Image( graphics, createInfo, externalImage ) ); + RefCountedImage retval( new Image( graphics, createInfo, externalImage ) ); if( !retval->mImpl->Initialise() ) { retval.Reset(); @@ -154,7 +154,7 @@ vk::ImageTiling Image::GetVkImageTiling() const return mImpl->mCreateInfo.tiling; } -void Image::BindMemory( const GpuMemoryBlockRef& handle ) +void Image::BindMemory( const RefCountedGpuMemoryBlock& handle ) { mImpl->BindMemory( handle ); } @@ -172,7 +172,7 @@ vk::ImageUsageFlags Image::GetVkImageUsageFlags() const struct ImageView::Impl { - Impl( ImageView& owner, Graphics& graphics, ImageRef image, vk::ImageViewCreateInfo createInfo ) + Impl( ImageView& owner, Graphics& graphics, RefCountedImage image, vk::ImageViewCreateInfo createInfo ) : mOwner( owner ), mGraphics( graphics ), mImage( image ), mCreateInfo( createInfo ) { } @@ -193,25 +193,25 @@ struct ImageView::Impl ImageView& mOwner; Graphics& mGraphics; - ImageRef mImage; + RefCountedImage mImage; vk::ImageViewCreateInfo mCreateInfo; vk::ImageView mVkImageView; }; -ImageViewRef ImageView::New( Graphics& graphics, ImageRef image, vk::ImageViewCreateInfo info ) +RefCountedImageView ImageView::New( Graphics& graphics, RefCountedImage image, vk::ImageViewCreateInfo info ) { - auto retval = ImageViewRef( new ImageView( graphics, image, info ) ); + auto retval = RefCountedImageView( new ImageView( graphics, image, info ) ); if( !retval->mImpl->Initialise() ) { - return ImageViewRef(); + return RefCountedImageView(); } return retval; } #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wframe-larger-than=" -ImageViewRef ImageView::New( Graphics& graphics, ImageRef image ) +RefCountedImageView ImageView::New( Graphics& graphics, RefCountedImage image ) { vk::ComponentMapping componentsMapping = { vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB,vk::ComponentSwizzle::eA }; vk::ImageAspectFlags aspectFlags{}; @@ -237,7 +237,7 @@ ImageViewRef ImageView::New( Graphics& graphics, ImageRef image ) .setLayerCount( image->GetLayerCount() ); // create reference, image may be null - auto retval = ImageViewRef( new ImageView( graphics, + auto retval = RefCountedImageView( new ImageView( graphics, image, vk::ImageViewCreateInfo{} .setViewType( vk::ImageViewType::e2D ) @@ -247,14 +247,14 @@ ImageViewRef ImageView::New( Graphics& graphics, ImageRef image ) .setImage(image->GetVkHandle() ))); if(!retval->mImpl->Initialise()) { - return ImageViewRef(); + return RefCountedImageView(); } return retval; } #pragma GCC diagnostic pop -ImageView::ImageView( Graphics& graphics, ImageRef image, const VkImageViewCreateInfo& createInfo ) +ImageView::ImageView( Graphics& graphics, RefCountedImage image, const VkImageViewCreateInfo& createInfo ) { mImpl = MakeUnique( *this, graphics, image, createInfo ); } @@ -267,7 +267,7 @@ const vk::ImageView& ImageView::GetVkImageView() const return mImpl->mVkImageView; } -ImageRef ImageView::GetImage() const +RefCountedImage ImageView::GetImage() const { return mImpl->mImage; } diff --git a/dali/graphics/vulkan/vulkan-image.h b/dali/graphics/vulkan/vulkan-image.h index 060caa5..28cbb1b 100644 --- a/dali/graphics/vulkan/vulkan-image.h +++ b/dali/graphics/vulkan/vulkan-image.h @@ -37,7 +37,7 @@ public: * @param createInfo * @return */ - static ImageRef New( Graphics& graphics, vk::ImageCreateInfo createInfo ); + static RefCountedImage New( Graphics& graphics, vk::ImageCreateInfo createInfo ); /** * Creates new managed object from external image, lifecycle must be managed @@ -47,7 +47,7 @@ public: * @param image * @return */ - static ImageRef New( Graphics& graphics, vk::ImageCreateInfo createInfo, vk::Image externalImage ); + static RefCountedImage New( Graphics& graphics, vk::ImageCreateInfo createInfo, vk::Image externalImage ); /** * Destructor @@ -118,7 +118,7 @@ public: * Binds image memory * @param handle */ - void BindMemory( const GpuMemoryBlockRef& handle ); + void BindMemory( const RefCountedGpuMemoryBlock& handle ); /** * Creates new VkImage with given specification, it doesn't @@ -153,7 +153,7 @@ public: * @param info * @return */ - static ImageViewRef New( Graphics& graphics, ImageRef image, vk::ImageViewCreateInfo info ); + static RefCountedImageView New( Graphics& graphics, RefCountedImage image, vk::ImageViewCreateInfo info ); /** * Creates default image view which includes single layer and level, aspect @@ -162,7 +162,7 @@ public: * @param image * @return */ - static ImageViewRef New( Graphics& graphics, ImageRef image = ImageRef() ); + static RefCountedImageView New( Graphics& graphics, RefCountedImage image = RefCountedImage() ); virtual ~ImageView() override; @@ -177,7 +177,7 @@ public: * Returns bound ImageRef * @return */ - ImageRef GetImage() const; + RefCountedImage GetImage() const; /** * @@ -269,7 +269,7 @@ public: private: - ImageView( Graphics& graphics, ImageRef image, const VkImageViewCreateInfo& createInfo ); + ImageView( Graphics& graphics, RefCountedImage image, const VkImageViewCreateInfo& createInfo ); struct Impl; std::unique_ptr mImpl; diff --git a/dali/graphics/vulkan/vulkan-pipeline-cache.cpp b/dali/graphics/vulkan/vulkan-pipeline-cache.cpp index d02b615..c6855ce 100644 --- a/dali/graphics/vulkan/vulkan-pipeline-cache.cpp +++ b/dali/graphics/vulkan/vulkan-pipeline-cache.cpp @@ -33,12 +33,12 @@ struct PipelineCache::Impl struct PipelineCacheItem { - PipelineCacheItem( PipelineRef _pipeline, const PipelineDescription& _description ) + PipelineCacheItem( RefCountedPipeline _pipeline, const PipelineDescription& _description ) : pipeline(_pipeline), description(_description) { } - PipelineRef pipeline; + RefCountedPipeline pipeline; PipelineDescription description; }; @@ -55,7 +55,7 @@ struct PipelineCache::Impl * @param pipelineInfo * @return */ - PipelineRef GetPipeline( const PipelineDescription& description ) + RefCountedPipeline GetPipeline( const PipelineDescription& description ) { for( auto&& item : mPipelines ) { @@ -64,17 +64,17 @@ struct PipelineCache::Impl return item.pipeline; } } - return PipelineRef(); + return RefCountedPipeline(); } - bool AddPipeline( PipelineRef pipeline, const PipelineDescription& description ) + bool AddPipeline( RefCountedPipeline pipeline, const PipelineDescription& description ) { mPipelines.emplace_back( pipeline, description ); return true; } - std::vector GetDescriptorSetLayouts( const PipelineRef& pipeline ) const + std::vector GetDescriptorSetLayouts( const RefCountedPipeline& pipeline ) const { auto retval = std::vector{}; for( auto&& item : mPipelines ) @@ -102,17 +102,17 @@ PipelineCache::PipelineCache( Graphics& graphics ) PipelineCache::~PipelineCache() = default; -PipelineRef PipelineCache::GetPipeline( const PipelineDescription& desc ) const +RefCountedPipeline PipelineCache::GetPipeline( const PipelineDescription& desc ) const { return mImpl->GetPipeline( desc ); } -bool PipelineCache::AddPipeline( PipelineRef pipeline, const PipelineDescription& desc ) +bool PipelineCache::AddPipeline( RefCountedPipeline pipeline, const PipelineDescription& desc ) { return mImpl->AddPipeline( pipeline,desc ); } -std::vector PipelineCache::GetDescriptorSetLayouts( const PipelineRef& pipeline ) const +std::vector PipelineCache::GetDescriptorSetLayouts( const RefCountedPipeline& pipeline ) const { return mImpl->GetDescriptorSetLayouts( pipeline ); } diff --git a/dali/graphics/vulkan/vulkan-pipeline-cache.h b/dali/graphics/vulkan/vulkan-pipeline-cache.h index 17617ea..3209dcd 100644 --- a/dali/graphics/vulkan/vulkan-pipeline-cache.h +++ b/dali/graphics/vulkan/vulkan-pipeline-cache.h @@ -31,8 +31,8 @@ class Graphics; struct PipelineDescription { - ShaderRef vertexShader; - ShaderRef fragmentShader; + RefCountedShader vertexShader; + RefCountedShader fragmentShader; API::RenderCommand::RenderState::BlendState blendState; @@ -55,11 +55,11 @@ public: ~PipelineCache(); - PipelineRef GetPipeline( const PipelineDescription& desc ) const; + RefCountedPipeline GetPipeline( const PipelineDescription& desc ) const; - bool AddPipeline( PipelineRef pipeline, const PipelineDescription& desc ); + bool AddPipeline( RefCountedPipeline pipeline, const PipelineDescription& desc ); - std::vector GetDescriptorSetLayouts( const PipelineRef& pipeline ) const; + std::vector GetDescriptorSetLayouts( const RefCountedPipeline& pipeline ) const; private: struct Impl; diff --git a/dali/graphics/vulkan/vulkan-pipeline.cpp b/dali/graphics/vulkan/vulkan-pipeline.cpp index ce7beb6..a8149ee 100644 --- a/dali/graphics/vulkan/vulkan-pipeline.cpp +++ b/dali/graphics/vulkan/vulkan-pipeline.cpp @@ -252,7 +252,7 @@ struct Pipeline::Impl * @param stage * @return */ - bool SetShader( ShaderRef shader, Shader::Type stage ) + bool SetShader( RefCountedShader shader, Shader::Type stage ) { assert( !mPipeline && "Pipeline cannot be changed anymore!"); @@ -344,7 +344,7 @@ struct Pipeline::Impl } #pragma GCC diagnostic pop - vk::ShaderStageFlagBits GetShaderStage( ShaderRef shader ) + vk::ShaderStageFlagBits GetShaderStage( RefCountedShader shader ) { for( auto&& stage : mShaderStageCreateInfo ) { @@ -397,7 +397,7 @@ struct Pipeline::Impl Graphics& mGraphics; // resources - std::vector mShaderResources; + std::vector mShaderResources; vk::PipelineViewportStateCreateInfo mViewportState {}; std::vector mViewports {}; @@ -437,7 +437,7 @@ struct Pipeline::Impl * */ -PipelineRef Pipeline::New( Graphics& graphics, const vk::GraphicsPipelineCreateInfo& info ) +RefCountedPipeline Pipeline::New( Graphics& graphics, const vk::GraphicsPipelineCreateInfo& info ) { auto pipeline = Handle( new Pipeline(graphics, info) ); graphics.AddPipeline(pipeline); @@ -466,7 +466,7 @@ void Pipeline::SetViewport( float x, float y, float width, float height ) mImpl->SetViewport( x, y, width, height ); } -bool Pipeline::SetShader( ShaderRef shader, Shader::Type stage ) +bool Pipeline::SetShader( RefCountedShader shader, Shader::Type stage ) { return mImpl->SetShader( shader, stage ); } diff --git a/dali/graphics/vulkan/vulkan-pipeline.h b/dali/graphics/vulkan/vulkan-pipeline.h index 5d33d13..40b36e4 100644 --- a/dali/graphics/vulkan/vulkan-pipeline.h +++ b/dali/graphics/vulkan/vulkan-pipeline.h @@ -39,7 +39,7 @@ public: * @param info * @return */ - static PipelineRef New( Graphics& graphics, const vk::GraphicsPipelineCreateInfo& info = vk::GraphicsPipelineCreateInfo{} ); + static RefCountedPipeline New( Graphics& graphics, const vk::GraphicsPipelineCreateInfo& info = vk::GraphicsPipelineCreateInfo{} ); /** * Destructor @@ -61,7 +61,7 @@ public: * @param stage * @return */ - bool SetShader( ShaderRef shader, Shader::Type stage ); + bool SetShader( RefCountedShader shader, Shader::Type stage ); /** * @@ -139,7 +139,7 @@ private: std::unique_ptr mImpl; }; -using PipelineRef = Handle; +using RefCountedPipeline = Handle; } // Namespace Vulkan diff --git a/dali/graphics/vulkan/vulkan-queue.cpp b/dali/graphics/vulkan/vulkan-queue.cpp index 15dfed5..32a8f56 100644 --- a/dali/graphics/vulkan/vulkan-queue.cpp +++ b/dali/graphics/vulkan/vulkan-queue.cpp @@ -51,7 +51,7 @@ inline uint32_t u32(T val) return static_cast< uint32_t >(val); } -inline PrepareSemaphoresData PrepareSemaphores(const std::vector< CommandBufferRef >& commandBuffers) +inline PrepareSemaphoresData PrepareSemaphores(const std::vector< RefCountedCommandBuffer >& commandBuffers) { PrepareSemaphoresData retval{}; for(auto& cmdbufref : commandBuffers) @@ -97,15 +97,15 @@ Queue::~Queue() // queues are non-destructible { } -std::unique_ptr< Submission > Queue::Submit( CommandBufferRef commandBuffer, Handle fence) +std::unique_ptr< Submission > Queue::Submit( RefCountedCommandBuffer commandBuffer, Handle fence) { - auto buffers = std::vector< CommandBufferRef >({commandBuffer}); + auto buffers = std::vector< RefCountedCommandBuffer >({commandBuffer}); return Submit(buffers, fence); } #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wframe-larger-than=" -std::unique_ptr< Submission > Queue::Submit(const std::vector< CommandBufferRef >& commandBuffers, Handle fence) +std::unique_ptr< Submission > Queue::Submit(const std::vector< RefCountedCommandBuffer >& commandBuffers, Handle fence) { // Prepare command buffers for submission auto buffers = PrepareBuffers(commandBuffers); @@ -129,7 +129,7 @@ std::unique_ptr< Submission > Queue::Submit(const std::vector< CommandBufferRef } #pragma GCC diagnostic pop -std::vector< vk::CommandBuffer > Queue::PrepareBuffers(const std::vector< CommandBufferRef >& commandBuffers) const +std::vector< vk::CommandBuffer > Queue::PrepareBuffers(const std::vector< RefCountedCommandBuffer >& commandBuffers) const { std::vector< vk::CommandBuffer > retval(commandBuffers.size()); for(uint32_t i = 0; i < commandBuffers.size(); ++i) diff --git a/dali/graphics/vulkan/vulkan-queue.h b/dali/graphics/vulkan/vulkan-queue.h index d7819d0..6f74fe3 100644 --- a/dali/graphics/vulkan/vulkan-queue.h +++ b/dali/graphics/vulkan/vulkan-queue.h @@ -50,11 +50,11 @@ public: ~Queue(); // queues are non-destructible /** Submits command buffers */ - std::unique_ptr< Submission > Submit(const std::vector< CommandBufferRef >& commandBuffers, + std::unique_ptr< Submission > Submit(const std::vector< RefCountedCommandBuffer >& commandBuffers, Handle fence); /** Helper function to submit single command buffer */ - std::unique_ptr< Submission > Submit(CommandBufferRef commandBuffer, Handle fence); + std::unique_ptr< Submission > Submit(RefCountedCommandBuffer commandBuffer, Handle fence); void WaitIdle() const; @@ -75,7 +75,7 @@ public: private: /** Prepares command buffers for submission */ std::vector< vk::CommandBuffer > PrepareBuffers( - const std::vector< CommandBufferRef >& commandBuffers) const; + const std::vector< RefCountedCommandBuffer >& commandBuffers) const; diff --git a/dali/graphics/vulkan/vulkan-resource-cache.cpp b/dali/graphics/vulkan/vulkan-resource-cache.cpp index 6200289..741a33f 100644 --- a/dali/graphics/vulkan/vulkan-resource-cache.cpp +++ b/dali/graphics/vulkan/vulkan-resource-cache.cpp @@ -35,124 +35,124 @@ namespace Graphics namespace Vulkan { -ResourceCache& ResourceCache::AddBuffer( BufferRef buffer ) +ResourceCache& ResourceCache::AddBuffer( RefCountedBuffer buffer ) { mBuffers.push_back( buffer ); return *this; } -ResourceCache& ResourceCache::AddImage( ImageRef image ) +ResourceCache& ResourceCache::AddImage( RefCountedImage image ) { mImages.push_back( image ); return *this; } -ResourceCache& ResourceCache::AddPipeline( PipelineRef pipeline ) +ResourceCache& ResourceCache::AddPipeline( RefCountedPipeline pipeline ) { mPipelines.push_back( pipeline ); return *this; } -ResourceCache& ResourceCache::AddShader( ShaderRef shader ) +ResourceCache& ResourceCache::AddShader( RefCountedShader shader ) { mShaders.push_back( shader ); return *this; } -ResourceCache& ResourceCache::AddCommandPool( CommandPoolRef pool ) +ResourceCache& ResourceCache::AddCommandPool( RefCountedCommandPool pool ) { mCommandPools.push_back( pool ); return *this; } -ResourceCache& ResourceCache::AddDescriptorPool( DescriptorPoolRef pool ) +ResourceCache& ResourceCache::AddDescriptorPool( RefCountedDescriptorPool pool ) { mDescriptorPools.push_back( pool ); return *this; } -ResourceCache& ResourceCache::AddFramebuffer( FramebufferRef framebuffer ) +ResourceCache& ResourceCache::AddFramebuffer( RefCountedFramebuffer framebuffer ) { mFramebuffers.push_back( framebuffer ); return *this; } -ResourceCache& ResourceCache::AddSampler( SamplerRef sampler ) +ResourceCache& ResourceCache::AddSampler( RefCountedSampler sampler ) { mSamplers.push_back(sampler); return *this; } -PipelineRef ResourceCache::FindPipeline( vk::Pipeline pipeline ) +RefCountedPipeline ResourceCache::FindPipeline( vk::Pipeline pipeline ) { auto iterator = std::find_if(mPipelines.begin(), mPipelines.end(), - [&](const PipelineRef entry) { return entry->GetVkHandle() == pipeline; }); + [&](const RefCountedPipeline entry) { return entry->GetVkHandle() == pipeline; }); - return iterator == mPipelines.end() ? PipelineRef() : PipelineRef(&**iterator); + return iterator == mPipelines.end() ? RefCountedPipeline() : RefCountedPipeline(&**iterator); } -ShaderRef ResourceCache::FindShader( vk::ShaderModule shaderModule ) +RefCountedShader ResourceCache::FindShader( vk::ShaderModule shaderModule ) { auto iterator = std::find_if(mShaders.begin(), mShaders.end(), - [&](const ShaderRef entry) { return entry->GetVkHandle() == shaderModule; }); + [&](const RefCountedShader entry) { return entry->GetVkHandle() == shaderModule; }); - return iterator == mShaders.end() ? ShaderRef() : ShaderRef(&**iterator); + return iterator == mShaders.end() ? RefCountedShader() : RefCountedShader(&**iterator); } -CommandPoolRef ResourceCache::FindCommandPool( vk::CommandPool commandPool ) +RefCountedCommandPool ResourceCache::FindCommandPool( vk::CommandPool commandPool ) { auto iterator = std::find_if(mCommandPools.begin(), mCommandPools.end(), - [&](const CommandPoolRef entry) { return entry->GetVkHandle() == commandPool; }); + [&](const RefCountedCommandPool entry) { return entry->GetVkHandle() == commandPool; }); - return iterator == mCommandPools.end() ? CommandPoolRef() : CommandPoolRef(&**iterator); + return iterator == mCommandPools.end() ? RefCountedCommandPool() : RefCountedCommandPool(&**iterator); } -DescriptorPoolRef ResourceCache::FindDescriptorPool( vk::DescriptorPool descriptorPool ) +RefCountedDescriptorPool ResourceCache::FindDescriptorPool( vk::DescriptorPool descriptorPool ) { auto iterator = std::find_if(mDescriptorPools.begin(), mDescriptorPools.end(), - [&](const DescriptorPoolRef entry) { return entry->GetVkHandle() == descriptorPool; }); + [&](const RefCountedDescriptorPool entry) { return entry->GetVkHandle() == descriptorPool; }); - return iterator == mDescriptorPools.end() ? DescriptorPoolRef() : DescriptorPoolRef(&**iterator); + return iterator == mDescriptorPools.end() ? RefCountedDescriptorPool() : RefCountedDescriptorPool(&**iterator); } -FramebufferRef ResourceCache::FindFramebuffer( vk::Framebuffer framebuffer ) +RefCountedFramebuffer ResourceCache::FindFramebuffer( vk::Framebuffer framebuffer ) { auto iterator = std::find_if(mFramebuffers.begin(), mFramebuffers.end(), - [&](const FramebufferRef entry) { return entry->GetVkHandle() == framebuffer; }); + [&](const RefCountedFramebuffer entry) { return entry->GetVkHandle() == framebuffer; }); - return iterator == mFramebuffers.end() ? FramebufferRef() : FramebufferRef(&**iterator); + return iterator == mFramebuffers.end() ? RefCountedFramebuffer() : RefCountedFramebuffer(&**iterator); } -SamplerRef ResourceCache::FindSampler( vk::Sampler sampler ) +RefCountedSampler ResourceCache::FindSampler( vk::Sampler sampler ) { auto iterator = std::find_if(mSamplers.begin(), mSamplers.end(), - [&](const SamplerRef entry) { return entry->GetVkHandle() == sampler; }); + [&](const RefCountedSampler entry) { return entry->GetVkHandle() == sampler; }); - return iterator == mSamplers.end() ? SamplerRef() : SamplerRef(&**iterator); + return iterator == mSamplers.end() ? RefCountedSampler() : RefCountedSampler(&**iterator); } -BufferRef ResourceCache::FindBuffer( vk::Buffer buffer ) +RefCountedBuffer ResourceCache::FindBuffer( vk::Buffer buffer ) { auto iterator = std::find_if(mBuffers.begin(), mBuffers.end(), - [&](const BufferRef entry) { return entry->GetVkHandle() == buffer; }); + [&](const RefCountedBuffer entry) { return entry->GetVkHandle() == buffer; }); - return iterator == mBuffers.end() ? BufferRef() : BufferRef(&**iterator); + return iterator == mBuffers.end() ? RefCountedBuffer() : RefCountedBuffer(&**iterator); } -ImageRef ResourceCache::FindImage( vk::Image image ) +RefCountedImage ResourceCache::FindImage( vk::Image image ) { auto iterator = std::find_if(mImages.begin(), mImages.end(), - [&](const ImageRef entry) { return entry->GetVkHandle() == image; }); + [&](const RefCountedImage entry) { return entry->GetVkHandle() == image; }); - return iterator == mImages.end() ? ImageRef() : ImageRef(&**iterator); + return iterator == mImages.end() ? RefCountedImage() : RefCountedImage(&**iterator); } ResourceCache& ResourceCache::RemoveBuffer( Buffer& buffer ) @@ -161,7 +161,7 @@ ResourceCache& ResourceCache::RemoveBuffer( Buffer& buffer ) { auto found = std::find_if(mBuffers.begin(), mBuffers.end(), - [&](const BufferRef entry) { return &(*entry) == &buffer; }); + [&](const RefCountedBuffer entry) { return &(*entry) == &buffer; }); std::iter_swap(found, std::prev(mBuffers.end())); mBuffers.back().Reset(); @@ -176,7 +176,7 @@ ResourceCache& ResourceCache::RemoveImage( Image& image ) { auto found = std::find_if(mImages.begin(), mImages.end(), - [&](const ImageRef entry) { return &(*entry) == ℑ }); + [&](const RefCountedImage entry) { return &(*entry) == ℑ }); std::iter_swap(found, std::prev(mImages.end())); mImages.back().Reset(); @@ -191,7 +191,7 @@ ResourceCache& ResourceCache::RemovePipeline( Pipeline &pipeline ) { auto found = std::find_if(mPipelines.begin(), mPipelines.end(), - [&](const PipelineRef entry) { return &(*entry) == &pipeline; }); + [&](const RefCountedPipeline entry) { return &(*entry) == &pipeline; }); std::iter_swap(found, std::prev(mPipelines.end())); mPipelines.back().Reset(); @@ -206,7 +206,7 @@ ResourceCache& ResourceCache::RemoveShader( Shader& shader ) { auto iterator = std::find_if(mShaders.begin(), mShaders.end(), - [&](const ShaderRef entry) { return &*entry == &shader; }); + [&](const RefCountedShader entry) { return &*entry == &shader; }); std::iter_swap(iterator, std::prev(mShaders.end())); mShaders.back().Reset(); @@ -221,7 +221,7 @@ ResourceCache& ResourceCache::RemoveCommandPool( CommandPool& commandPool ) { auto iterator = std::find_if(mCommandPools.begin(), mCommandPools.end(), - [&](const CommandPoolRef entry) { return &*entry == &commandPool; }); + [&](const RefCountedCommandPool entry) { return &*entry == &commandPool; }); std::iter_swap(iterator, std::prev(mCommandPools.end())); mCommandPools.back().Reset(); @@ -236,7 +236,7 @@ ResourceCache& ResourceCache::RemoveDescriptorPool( DescriptorPool& descriptorPo { auto iterator = std::find_if(mDescriptorPools.begin(), mDescriptorPools.end(), - [&](const DescriptorPoolRef entry) { return &*entry == &descriptorPool; }); + [&](const RefCountedDescriptorPool entry) { return &*entry == &descriptorPool; }); std::iter_swap(iterator, std::prev(mDescriptorPools.end())); mDescriptorPools.back().Reset(); @@ -251,7 +251,7 @@ ResourceCache& ResourceCache::RemoveFramebuffer( Framebuffer &framebuffer ) { auto iterator = std::find_if(mFramebuffers.begin(), mFramebuffers.end(), - [&](const FramebufferRef entry) { return &*entry == &framebuffer; }); + [&](const RefCountedFramebuffer entry) { return &*entry == &framebuffer; }); std::iter_swap(iterator, std::prev(mFramebuffers.end())); mFramebuffers.back().Reset(); @@ -266,7 +266,7 @@ ResourceCache& ResourceCache::RemoveSampler( Sampler &sampler ) { auto iterator = std::find_if(mSamplers.begin(), mSamplers.end(), - [&](const SamplerRef entry) { return &*entry == &sampler; }); + [&](const RefCountedSampler entry) { return &*entry == &sampler; }); std::iter_swap(iterator, std::prev(mSamplers.end())); mSamplers.back().Reset(); diff --git a/dali/graphics/vulkan/vulkan-resource-cache.h b/dali/graphics/vulkan/vulkan-resource-cache.h index ed25df8..71891a6 100644 --- a/dali/graphics/vulkan/vulkan-resource-cache.h +++ b/dali/graphics/vulkan/vulkan-resource-cache.h @@ -43,56 +43,56 @@ public: * @param buffer The buffer object to be added to the cache * @return A reference to the ResourceCache */ - ResourceCache& AddBuffer( BufferRef buffer ); + ResourceCache& AddBuffer( RefCountedBuffer buffer ); /** * Adds the provided image object to the image cache * @param image The image object to be added to the cache * @return A reference to the ResourceCache */ - ResourceCache& AddImage( ImageRef image ); + ResourceCache& AddImage( RefCountedImage image ); /** * Adds the provided pipeline object to the pipeline cache * @param pipeline The pipeline object to be added to the cache * @return A reference to the ResourceCache */ - ResourceCache& AddPipeline( PipelineRef pipeline ); + ResourceCache& AddPipeline( RefCountedPipeline pipeline ); /** * Adds the provided shader object to the pipeline cache * @param shader The shader object to be added to the cache * @return A reference to the ResourceCache */ - ResourceCache& AddShader( ShaderRef shader ); + ResourceCache& AddShader( RefCountedShader shader ); /** * Adds the provided command pool object to the command pool cache * @param pool The command pool object to be added to the cache * @return A reference to the ResourceCache */ - ResourceCache& AddCommandPool( CommandPoolRef pool ); + ResourceCache& AddCommandPool( RefCountedCommandPool pool ); /** * Adds the provided descriptor pool object to the descriptor pool cache * @param pool The descriptor pool object to be added to the cache * @return A reference to the ResourceCache */ - ResourceCache& AddDescriptorPool( DescriptorPoolRef pool ); + ResourceCache& AddDescriptorPool( RefCountedDescriptorPool pool ); /** * Adds the provided framebuffer object to the framebuffer cache * @param framebuffer The framebuffer object to be added to the cache * @return A reference to the ResourceCache */ - ResourceCache& AddFramebuffer( FramebufferRef framebuffer ); + ResourceCache& AddFramebuffer( RefCountedFramebuffer framebuffer ); /** * Adds the provided sampler object to the sampler cache * @param sampler The sampler object to be added to the cache * @return A reference to the ResourceCache */ - ResourceCache& AddSampler( SamplerRef sampler ); + ResourceCache& AddSampler( RefCountedSampler sampler ); /** @@ -100,56 +100,56 @@ public: * @param buffer The Vulkan handle of the buffer object to be found * @return A Handle to the buffer object if found. An empty Handle otherwise */ - BufferRef FindBuffer( vk::Buffer buffer ); + RefCountedBuffer FindBuffer( vk::Buffer buffer ); /** * Finds the image object using the specified Vulkan handle in the cache * @param image The Vulkan handle of the image object to be found * @return A handle to the Image object if found. An empty Handle otherwise */ - ImageRef FindImage( vk::Image image); + RefCountedImage FindImage( vk::Image image); /** * Finds the Pipeline object using the specified Vulkan handle in the cache * @param pipeline The Vulkan handle of the Pipeline object to be found * @return A Handle to the Pipeline object if found. An empty Handle otherwise */ - PipelineRef FindPipeline( vk::Pipeline pipeline ); + RefCountedPipeline FindPipeline( vk::Pipeline pipeline ); /** * Finds the shader module using the specified Vulkan handle in the cache * @param shaderModule The Vulkan handle of the shader module to be found * @return A Handle to the Shader module if found. An empty Handle otherwise */ - ShaderRef FindShader( vk::ShaderModule shaderModule ); + RefCountedShader FindShader( vk::ShaderModule shaderModule ); /** * Finds the CommandPool object using the specified Vulkan handle in the cache * @param commandPool The Vulkan handle of the CommandPool object to be found * @return A Handle to the CommandPool object if found. An empty Handle otherwise */ - CommandPoolRef FindCommandPool( vk::CommandPool commandPool ); + RefCountedCommandPool FindCommandPool( vk::CommandPool commandPool ); /** * Finds the DescriptorPool object using the specified Vulkan handle in the cache * @param descriptorPool The Vulkan handle of the DescriptorPool object to be found * @return A Handle to the DescriptorPool object if found. An empty Handle otherwise */ - DescriptorPoolRef FindDescriptorPool( vk::DescriptorPool descriptorPool ); + RefCountedDescriptorPool FindDescriptorPool( vk::DescriptorPool descriptorPool ); /** * Finds the Framebuffer object using the specified Vulkan handle in the cache * @param framebuffer The Vulkan handle of the Framebuffer object to be found * @return A Handle to the Framebuffer object if found. An empty Handle otherwise */ - FramebufferRef FindFramebuffer( vk::Framebuffer framebuffer ); + RefCountedFramebuffer FindFramebuffer( vk::Framebuffer framebuffer ); /** * Finds the Sampler object using the specified Vulkan handle in the cache. * @param sampler The Vulkan handle of the Sampler object to be found * @return A Handle to the Sampler object if found. An empty Handle otherwise */ - SamplerRef FindSampler( vk::Sampler sampler ); + RefCountedSampler FindSampler( vk::Sampler sampler ); /** * Removes the specified Buffer from the cache @@ -220,14 +220,14 @@ public: ResourceCache&& operator=( ResourceCache&& other ) = delete; private: - std::vector mBuffers; - std::vector mImages; - std::vector mPipelines; - std::vector mShaders; - std::vector mCommandPools; - std::vector mDescriptorPools; - std::vector mFramebuffers; - std::vector mSamplers; + std::vector mBuffers; + std::vector mImages; + std::vector mPipelines; + std::vector mShaders; + std::vector mCommandPools; + std::vector mDescriptorPools; + std::vector mFramebuffers; + std::vector mSamplers; }; } //namespace Vulkan diff --git a/dali/graphics/vulkan/vulkan-sampler.cpp b/dali/graphics/vulkan/vulkan-sampler.cpp index 7e103b6..1b1dff7 100644 --- a/dali/graphics/vulkan/vulkan-sampler.cpp +++ b/dali/graphics/vulkan/vulkan-sampler.cpp @@ -87,9 +87,9 @@ struct Sampler::Impl * @param graphics * @return */ -SamplerRef Sampler::New( Graphics& graphics ) +RefCountedSampler Sampler::New( Graphics& graphics ) { - return SamplerRef(new Sampler(graphics, vk::SamplerCreateInfo{}, false)); + return RefCountedSampler(new Sampler(graphics, vk::SamplerCreateInfo{}, false)); } /** @@ -98,14 +98,14 @@ SamplerRef Sampler::New( Graphics& graphics ) * @param createInfo * @return */ -SamplerRef Sampler::NewImmutable( Graphics& graphics, vk::SamplerCreateInfo createInfo ) +RefCountedSampler Sampler::NewImmutable( Graphics& graphics, vk::SamplerCreateInfo createInfo ) { - auto retval = SamplerRef(new Sampler(graphics, createInfo, true)); + auto retval = RefCountedSampler(new Sampler(graphics, createInfo, true)); if( retval->mImpl->CreateSampler() ) { return retval; } - return SamplerRef(); + return RefCountedSampler(); } Sampler::Sampler( Graphics& graphics, vk::SamplerCreateInfo createInfo, bool immutable ) diff --git a/dali/graphics/vulkan/vulkan-sampler.h b/dali/graphics/vulkan/vulkan-sampler.h index 84c9dba..cb614e5 100644 --- a/dali/graphics/vulkan/vulkan-sampler.h +++ b/dali/graphics/vulkan/vulkan-sampler.h @@ -37,7 +37,7 @@ public: * @param graphics * @return */ - static SamplerRef New( Graphics& graphics ); + static RefCountedSampler New( Graphics& graphics ); /** * Creates new immutable sampler @@ -45,7 +45,7 @@ public: * @param createInfo * @return */ - static SamplerRef NewImmutable( Graphics& graphics, vk::SamplerCreateInfo createInfo ); + static RefCountedSampler NewImmutable( Graphics& graphics, vk::SamplerCreateInfo createInfo ); /** * Sets minification and magnifcation filters diff --git a/dali/graphics/vulkan/vulkan-shader.h b/dali/graphics/vulkan/vulkan-shader.h index 0357a72..4a88b82 100644 --- a/dali/graphics/vulkan/vulkan-shader.h +++ b/dali/graphics/vulkan/vulkan-shader.h @@ -96,7 +96,7 @@ private: std::unique_ptr mImpl; }; -using ShaderRef = Handle; +using RefCountedShader = Handle; } // Namespace Vulkan diff --git a/dali/graphics/vulkan/vulkan-standalone-test.cpp b/dali/graphics/vulkan/vulkan-standalone-test.cpp index c56b655..39c4bf3 100644 --- a/dali/graphics/vulkan/vulkan-standalone-test.cpp +++ b/dali/graphics/vulkan/vulkan-standalone-test.cpp @@ -54,9 +54,9 @@ using Dali::Graphics::Vulkan::DescriptorPool; using Dali::Graphics::Vulkan::GpuMemoryAllocator; using Dali::Graphics::Vulkan::GpuMemoryManager; using Dali::Graphics::Vulkan::Pipeline; -using Dali::Graphics::Vulkan::PipelineRef; +using Dali::Graphics::Vulkan::RefCountedPipeline; using Dali::Graphics::Vulkan::Shader; -using Dali::Graphics::Vulkan::ShaderRef; +using Dali::Graphics::Vulkan::RefCountedShader; using Dali::Integration::Graphics::Graphics; using Dali::Integration::Graphics::Vulkan::VkSurfaceFactory; @@ -230,7 +230,7 @@ std::unique_ptr create_xcb_window( int width, int height ) namespace VulkanTest { -Dali::Graphics::Vulkan::GpuMemoryBlockRef test_gpu_memory_manager( +Dali::Graphics::Vulkan::RefCountedGpuMemoryBlock test_gpu_memory_manager( Dali::Graphics::Vulkan::Graphics &graphics, GpuMemoryManager &gpuManager, const Dali::Graphics::Vulkan::Handle &buffer) @@ -257,7 +257,7 @@ struct UniformClipData mat4 MVP; template -void update_buffer(Dali::Graphics::Vulkan::BufferRef buffer, T &value) +void update_buffer(Dali::Graphics::Vulkan::RefCountedBuffer buffer, T &value) { auto ptr = reinterpret_cast( buffer->GetMemoryHandle() ->Map()); @@ -266,7 +266,7 @@ void update_buffer(Dali::Graphics::Vulkan::BufferRef buffer, T &value) ->Unmap(); } -void update_translation(Dali::Graphics::Vulkan::BufferRef buffer) +void update_translation(Dali::Graphics::Vulkan::RefCountedBuffer buffer) { static float x = 0.0f; x += 0.5f; @@ -284,7 +284,7 @@ void update_translation(Dali::Graphics::Vulkan::BufferRef buffer) */ } -Dali::Graphics::Vulkan::BufferRef create_uniform_buffer(Dali::Graphics::Vulkan::Graphics &gr) +Dali::Graphics::Vulkan::RefCountedBuffer create_uniform_buffer(Dali::Graphics::Vulkan::Graphics &gr) { // create uniform buffer auto uniformBuffer = Buffer::New(gr, sizeof(UniformData), Buffer::Type::UNIFORM); @@ -310,7 +310,7 @@ Dali::Graphics::Vulkan::BufferRef create_uniform_buffer(Dali::Graphics::Vulkan:: return uniformBuffer; } -Dali::Graphics::Vulkan::BufferRef create_clip_buffer(Dali::Graphics::Vulkan::Graphics &gr) +Dali::Graphics::Vulkan::RefCountedBuffer create_clip_buffer(Dali::Graphics::Vulkan::Graphics &gr) { const glm::mat4 clip( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 1.0f); @@ -392,15 +392,15 @@ void test_handle() { /* using namespace Dali::Graphics::Vulkan; - GpuMemoryBlockRef handle( new GpuMemoryBlock() ); + RefCountedGpuMemoryBlock handle( new GpuMemoryBlock() ); decltype(handle) handle2 = handle; handle.GetRefCount();*/ } -PipelineRef create_pipeline(Dali::Graphics::Vulkan::Graphics &graphics, - Dali::Graphics::Vulkan::ShaderRef vertexShader, - Dali::Graphics::Vulkan::ShaderRef fragmentShader) +RefCountedPipeline create_pipeline(Dali::Graphics::Vulkan::Graphics &graphics, + Dali::Graphics::Vulkan::RefCountedShader vertexShader, + Dali::Graphics::Vulkan::RefCountedShader fragmentShader) { using namespace Dali::Graphics::Vulkan; auto pipelineInfo = vk::GraphicsPipelineCreateInfo{}; diff --git a/dali/graphics/vulkan/vulkan-surface.cpp b/dali/graphics/vulkan/vulkan-surface.cpp index 4f7d310..71656cc 100644 --- a/dali/graphics/vulkan/vulkan-surface.cpp +++ b/dali/graphics/vulkan/vulkan-surface.cpp @@ -79,9 +79,9 @@ struct Surface::Impl * Surface */ -SurfaceRef Surface::New( Graphics& graphics, std::unique_ptr surfaceFactory ) +RefCountedSurface Surface::New( Graphics& graphics, std::unique_ptr surfaceFactory ) { - return SurfaceRef( new Surface( graphics, std::move(surfaceFactory) )); + return RefCountedSurface( new Surface( graphics, std::move(surfaceFactory) )); } Surface::Surface(Graphics& graphics, std::unique_ptr surfaceFactory ) diff --git a/dali/graphics/vulkan/vulkan-surface.h b/dali/graphics/vulkan/vulkan-surface.h index ff91837..8797c83 100644 --- a/dali/graphics/vulkan/vulkan-surface.h +++ b/dali/graphics/vulkan/vulkan-surface.h @@ -40,7 +40,7 @@ class Surface : public VkManaged { public: - static SurfaceRef New( Graphics& graphics, std::unique_ptr surfaceFactory ); + static RefCountedSurface New( Graphics& graphics, std::unique_ptr surfaceFactory ); Surface(Graphics& graphics, std::unique_ptr surfaceFactory ); ~Surface() final; diff --git a/dali/graphics/vulkan/vulkan-swapchain.cpp b/dali/graphics/vulkan/vulkan-swapchain.cpp index 933ae0b..c41c852 100644 --- a/dali/graphics/vulkan/vulkan-swapchain.cpp +++ b/dali/graphics/vulkan/vulkan-swapchain.cpp @@ -43,22 +43,22 @@ struct SwapchainBuffer * Each buffer has own master command buffer which executes * secondary buffers */ - CommandBufferRef masterCmdBuffer; + RefCountedCommandBuffer masterCmdBuffer; /* * Each buffer has a command pool to allocate from */ - CommandPoolRef masterCommandPool; + RefCountedCommandPool masterCommandPool; /* * Framebuffer object associated with the buffer */ - FramebufferRef framebuffer; + RefCountedFramebuffer framebuffer; /* * Sync primitives */ - FenceRef endOfFrameFence; + RefCountedFence endOfFrameFence; /* * Buffer index @@ -76,7 +76,7 @@ struct Swapchain::Impl Impl( Swapchain& owner, Graphics& graphics, Queue& presentationQueue, - SurfaceRef surface, + RefCountedSurface surface, uint32_t bufferCount, uint32_t flags ) : mOwner( owner ), @@ -175,7 +175,7 @@ struct Swapchain::Impl auto cmdBuffer = commandPool->NewCommandBuffer(); std::vector barriers; - ImageViewRef depthStencilImage{}; + RefCountedImageView depthStencilImage{}; for( auto&& buffer : mSwapchainBuffer ) { @@ -250,7 +250,7 @@ struct Swapchain::Impl cmdBuffer->End(); // use presentation queue to submit the call - mQueue.Submit( cmdBuffer, FenceRef{} ); + mQueue.Submit( cmdBuffer, RefCountedFence{} ); mQueue.WaitIdle(); } @@ -333,7 +333,7 @@ struct Swapchain::Impl * Creates depth stencil if necessary * @return */ - ImageViewRef CreateDepthStencil() + RefCountedImageView CreateDepthStencil() { // create depth stencil image auto dsImageRef = Image::New( mGraphics, @@ -364,14 +364,14 @@ struct Swapchain::Impl * @param image * @return */ - FramebufferRef CreateFramebuffer( vk::Image& image ) + RefCountedFramebuffer CreateFramebuffer( vk::Image& image ) { auto fbRef = Framebuffer::New( mGraphics, mSwapchainExtent.width, mSwapchainExtent.height ); // Create external Image reference // Note that despite we don't create VkImage, we still fill the createinfo structure // as this data will be used later - ImageRef imageRef = Image::New( mGraphics, + RefCountedImage imageRef = Image::New( mGraphics, vk::ImageCreateInfo{} .setFormat( mSwapchainImageFormat ) .setSamples( vk::SampleCountFlagBits::e1 ) @@ -386,7 +386,7 @@ struct Swapchain::Impl image ); // Create basic imageview ( all mipmaps, all layers ) - ImageViewRef iv = ImageView::New( mGraphics, imageRef ); + RefCountedImageView iv = ImageView::New( mGraphics, imageRef ); fbRef->SetAttachment( iv, Framebuffer::AttachmentType::COLOR, 0u ); @@ -514,7 +514,7 @@ struct Swapchain::Impl barriers ); } - CommandBufferRef GetPrimaryCommandBuffer() const + RefCountedCommandBuffer GetPrimaryCommandBuffer() const { return mSwapchainBuffer[mCurrentBufferIndex].masterCmdBuffer; } @@ -572,16 +572,16 @@ struct Swapchain::Impl Swapchain& mOwner; Graphics& mGraphics; Queue& mQueue; - SurfaceRef mSurface; + RefCountedSurface mSurface; uint32_t mBufferCount; uint32_t mFlags; uint32_t mCurrentBufferIndex; - FenceRef mFrameFence; + RefCountedFence mFrameFence; // swapchain framebuffers - std::vector mFramebuffers; + std::vector mFramebuffers; vk::SwapchainKHR mSwapchainKHR; vk::SwapchainCreateInfoKHR mSwapchainCreateInfoKHR; @@ -598,21 +598,21 @@ struct Swapchain::Impl /** * Swapchain API */ -SwapchainRef Swapchain::New( - Graphics& graphics, Queue& presentationQueue, SurfaceRef surface, uint8_t bufferCount, uint32_t flags ) +RefCountedSwapchain Swapchain::New( + Graphics& graphics, Queue& presentationQueue, RefCountedSurface surface, uint8_t bufferCount, uint32_t flags ) { - auto retval = SwapchainRef( new Swapchain( graphics, presentationQueue, surface, bufferCount, flags ) ); + auto retval = RefCountedSwapchain( new Swapchain( graphics, presentationQueue, surface, bufferCount, flags ) ); if( retval->mImpl->Initialise() ) { return retval; } - return SwapchainRef(); + return RefCountedSwapchain(); } Swapchain::Swapchain( - Graphics& graphics, Queue& presentationQueue, SurfaceRef surface, uint8_t bufferCount, uint32_t flags ) + Graphics& graphics, Queue& presentationQueue, RefCountedSurface surface, uint8_t bufferCount, uint32_t flags ) { mImpl = std::make_unique( *this, graphics, presentationQueue, surface, bufferCount, flags ); } @@ -620,17 +620,17 @@ Swapchain::Swapchain( Swapchain::Swapchain() = default; Swapchain::~Swapchain() = default; -FramebufferRef Swapchain::GetCurrentFramebuffer() const +RefCountedFramebuffer Swapchain::GetCurrentFramebuffer() const { return GetFramebuffer( mImpl->mCurrentBufferIndex ); } -FramebufferRef Swapchain::GetFramebuffer( uint32_t index ) const +RefCountedFramebuffer Swapchain::GetFramebuffer( uint32_t index ) const { return mImpl->mSwapchainBuffer[index].framebuffer; } -FramebufferRef Swapchain::AcquireNextFramebuffer() +RefCountedFramebuffer Swapchain::AcquireNextFramebuffer() { return mImpl->AcquireNextFramebuffer(); } @@ -645,7 +645,7 @@ void Swapchain::Present( std::vector waitSemaphores ) mImpl->Present( waitSemaphores ); } -CommandBufferRef Swapchain::GetPrimaryCommandBuffer() const +RefCountedCommandBuffer Swapchain::GetPrimaryCommandBuffer() const { return mImpl->GetPrimaryCommandBuffer(); } diff --git a/dali/graphics/vulkan/vulkan-swapchain.h b/dali/graphics/vulkan/vulkan-swapchain.h index 9081f85..2ba2418 100644 --- a/dali/graphics/vulkan/vulkan-swapchain.h +++ b/dali/graphics/vulkan/vulkan-swapchain.h @@ -37,7 +37,7 @@ class Swapchain : public VkManaged { public: - static SwapchainRef New( Graphics& graphics, Queue& presentationQueue, SurfaceRef surface, uint8_t bufferCount, uint32_t flags ); + static RefCountedSwapchain New( Graphics& graphics, Queue& presentationQueue, RefCountedSurface surface, uint8_t bufferCount, uint32_t flags ); public: @@ -48,27 +48,27 @@ public: * Returns current framebuffer ( the one which is rendering to ) * @return */ - FramebufferRef GetCurrentFramebuffer() const; + RefCountedFramebuffer GetCurrentFramebuffer() const; /** * Returns any framebuffer from the queue * @param index * @return */ - FramebufferRef GetFramebuffer( uint32_t index ) const; + RefCountedFramebuffer GetFramebuffer( uint32_t index ) const; /** * Requests for next framebuffer * @return */ - FramebufferRef AcquireNextFramebuffer(); + RefCountedFramebuffer AcquireNextFramebuffer(); /** * Returns primary command buffer associated with currently * being recorded frame * @return */ - CommandBufferRef GetPrimaryCommandBuffer() const; + RefCountedCommandBuffer GetPrimaryCommandBuffer() const; /** * Begins primary render pass, must be called after acquiring new image @@ -95,7 +95,7 @@ public: private: Swapchain(); - Swapchain( Graphics& graphics, Queue& presentationQueue, SurfaceRef surface, uint8_t bufferCount, uint32_t flags ); + Swapchain( Graphics& graphics, Queue& presentationQueue, RefCountedSurface surface, uint8_t bufferCount, uint32_t flags ); ~Swapchain() override; private: diff --git a/dali/graphics/vulkan/vulkan-types.h b/dali/graphics/vulkan/vulkan-types.h index a6e97e2..71f2341 100644 --- a/dali/graphics/vulkan/vulkan-types.h +++ b/dali/graphics/vulkan/vulkan-types.h @@ -305,21 +305,21 @@ assert( false && "Function no implemented" );\ /* * Forward declarations of reference types */ -using ShaderRef = Handle; -using PipelineRef = Handle; -using FenceRef = Handle; -using BufferRef = Handle; -using FramebufferRef = Handle; -using ImageRef = Handle; -using ImageViewRef = Handle; -using DescriptorPoolRef = Handle; -using CommandPoolRef = Handle; -using CommandBufferRef = Handle; -using GpuMemoryBlockRef = Handle; -using DescriptorSetRef = Handle; -using SwapchainRef = Handle; -using SurfaceRef = Handle; -using SamplerRef = Handle; +using RefCountedShader = Handle; +using RefCountedPipeline = Handle; +using RefCountedFence = Handle; +using RefCountedBuffer = Handle; +using RefCountedFramebuffer = Handle; +using RefCountedImage = Handle; +using RefCountedImageView = Handle; +using RefCountedDescriptorPool = Handle; +using RefCountedCommandPool = Handle; +using RefCountedCommandBuffer = Handle; +using RefCountedGpuMemoryBlock = Handle; +using RefCountedDescriptorSet = Handle; +using RefCountedSwapchain = Handle; +using RefCountedSurface = Handle; +using RefCountedSampler = Handle; /* #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wframe-larger-than=" diff --git a/dali/integration-api/graphics/graphics.cpp b/dali/integration-api/graphics/graphics.cpp index ac167ab..178469f 100644 --- a/dali/integration-api/graphics/graphics.cpp +++ b/dali/integration-api/graphics/graphics.cpp @@ -37,7 +37,7 @@ namespace Integration namespace Graphics { using Swapchain = Dali::Graphics::Vulkan::Swapchain; -using SwapchainRef = Dali::Graphics::Vulkan::SwapchainRef; +using SwapchainRef = Dali::Graphics::Vulkan::RefCountedSwapchain; Graphics::Graphics() { -- 2.7.4