{
struct CommandBuffer::Impl
{
- Impl( CommandPool& commandPool, const vk::CommandBufferAllocateInfo& allocateInfo, vk::CommandBuffer commandBuffer )
- : mGraphics( commandPool.GetGraphics() ),
+ Impl( CommandBuffer& owner, CommandPool& commandPool, uint32_t poolIndex, const vk::CommandBufferAllocateInfo& allocateInfo, vk::CommandBuffer commandBuffer )
+ : mOwner( owner ),
+ mGraphics( commandPool.GetGraphics() ),
mOwnerCommandPool( commandPool ),
+ mPoolAllocationIndex( poolIndex ),
mAllocateInfo( allocateInfo ),
mCommandBuffer( commandBuffer )
{
~Impl()
{
- mResources.clear();
mGraphics.GetDevice().freeCommandBuffers( mOwnerCommandPool.GetPool(),
1, &mCommandBuffer );
}
+ void ReleaseCommandBuffer()
+ {
+ mResources.clear();
+
+ // tell pool the buffer is not in use anymore
+ mOwnerCommandPool.ReleaseCommandBuffer(mOwner, false);
+ }
+
bool Initialise()
{
return true;
.setSubresourceRange( vk::ImageSubresourceRange{ aspectMask, 0, image->GetLevelCount(), 0, image->GetLayerCount() } );
}
-
+ CommandBuffer& mOwner;
Graphics& mGraphics;
CommandPool& mOwnerCommandPool;
+ uint32_t mPoolAllocationIndex;
vk::CommandBufferAllocateInfo mAllocateInfo{};
vk::CommandBuffer mCommandBuffer{};
*/
CommandBuffer::CommandBuffer( CommandPool& commandPool,
+ uint32_t poolIndex,
const vk::CommandBufferAllocateInfo& allocateInfo,
vk::CommandBuffer vkCommandBuffer )
{
- mImpl = MakeUnique<Impl>( commandPool, allocateInfo, vkCommandBuffer );
+ mImpl = MakeUnique<Impl>( *this, commandPool, poolIndex, allocateInfo, vkCommandBuffer );
}
CommandBuffer::~CommandBuffer()
mImpl->Free();
}
-void CommandBuffer::OnRelease( uint32_t refcount )
-{
- VkManaged::OnRelease( refcount );
-}
-
/** Push wait semaphores */
void CommandBuffer::PushWaitSemaphores( const std::vector<vk::Semaphore>& semaphores,
const std::vector<vk::PipelineStageFlags>& stages )
aspectMask );
}
+uint32_t CommandBuffer::GetPoolAllocationIndex() const
+{
+ return mImpl->mPoolAllocationIndex;
+}
+
+bool CommandBuffer::OnDestroy()
+{
+ mImpl->ReleaseCommandBuffer();
+ return true;
+}
+
} // namespace Vulkan
} // namespace Graphics
} // namespace Dali