DALI_LOG_STREAM( gVulkanFilter, Debug::General, "[POOL] Allocating new page of block size " << mBlockSize << ", capacity: " << mInitialCapacity);
// add new Vulkan Buffer object
auto& graphics = mController.GetGraphics();
- mBuffers.emplace_back( Vulkan::Buffer::New( graphics, vk::BufferCreateInfo{}
- .setUsage( vk::BufferUsageFlagBits::eUniformBuffer)
- .setSharingMode( vk::SharingMode::eExclusive )
- .setSize( mBlockSize * mInitialCapacity ) ) );
+
+ mBuffers.emplace_back( graphics.CreateBuffer(vk::BufferCreateInfo{}
+ .setUsage( vk::BufferUsageFlagBits::eUniformBuffer)
+ .setSharingMode( vk::SharingMode::eExclusive )
+ .setSize( mBlockSize * mInitialCapacity ) ) );
mBuffers.back().buffer->BindMemory(
- graphics.GetDeviceMemoryManager().GetDefaultAllocator().Allocate( mBuffers.back().buffer, vk::MemoryPropertyFlagBits::eHostVisible )
- );
+ graphics
+ .GetDeviceMemoryManager()
+ .GetDefaultAllocator()
+ .Allocate( mBuffers.back().buffer, vk::MemoryPropertyFlagBits::eHostVisible ) );
auto startIndex = ((mBuffers.size()-1)*mInitialCapacity);
vk::DeviceMemory memory { nullptr };
};
- GpuMemoryDefaultAllocator( GpuMemoryManager& manager )
+ explicit GpuMemoryDefaultAllocator( GpuMemoryManager& manager )
: GpuMemoryAllocator(), mGpuManager( manager ),
mGraphics(manager.GetGraphics())
{
*/
virtual RefCountedGpuMemoryBlock Allocate( const Handle<Buffer>& buffer, vk::MemoryPropertyFlags memoryProperties ) override
{
- return Allocate( mGraphics.GetDevice().getBufferMemoryRequirements(buffer->GetVkHandle() ),
+ vk::Buffer handle = buffer->GetVkHandle();
+ vk::MemoryRequirements memReqs = mGraphics.GetDevice().getBufferMemoryRequirements( handle );
+ return Allocate( memReqs,
memoryProperties );
}
void CommandBuffer::ExecuteCommands( std::vector< Dali::Graphics::Vulkan::Handle< CommandBuffer>> commandBuffers )
{
+ assert( mAllocateInfo.level == vk::CommandBufferLevel::ePrimary
+ && "Cannot record command: ExecuteCommands\tReason: The command buffer recording this command is not primary" );
+
auto vkBuffers = std::vector< vk::CommandBuffer >{};
vkBuffers.reserve( commandBuffers.size());
for( auto&& buf : commandBuffers )
{
- assert( mAllocateInfo.level == vk::CommandBufferLevel::eSecondary &&
- "Cannot Execute Commands. Command buffer level not secondary" );
+ assert(buf->mAllocateInfo.level == vk::CommandBufferLevel::eSecondary &&
+ "Cannot record command: Execute Commands\tReason: A command buffer provided for execution is not secondary" );
+
vkBuffers.emplace_back( buf->GetVkHandle());
}
.setSharingMode( vk::SharingMode::eExclusive )
.setSize( size ));
- buffer->BindMemory( allocator.Allocate( buffer, vk::MemoryPropertyFlagBits::eHostVisible ) );
+ buffer->BindMemory( allocator.Allocate( buffer, vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent ) );
// copy pixels to the buffer
auto ptr = buffer->GetMemoryHandle()->MapTyped<char>();
std::copy( reinterpret_cast<const char*>(data),
reinterpret_cast<const char*>(data) + sizeInBytes,
ptr );
+
buffer->GetMemoryHandle()->Unmap();
// record copy and layout change
// submit and wait till image is uploaded so temporary buffer can be destroyed safely
auto fence = mGraphics.CreateFence({});
- mGraphics.Submit( mGraphics.GetGraphicsQueue( 0u ), { SubmissionData{}.SetCommandBuffers( { mCommandBuffer } ) }, fence );
- VkAssert(mGraphics.WaitForFence(fence));
+ VkAssert(mGraphics.Submit( mGraphics.GetGraphicsQueue( 0u ), { SubmissionData{}.SetCommandBuffers( { mCommandBuffer } ) }, fence ));
+ VkAssert(mGraphics.WaitForFence(fence, std::numeric_limits<uint32_t>::max()));
return true;
}
if( image->GetUsageFlags() & vk::ImageUsageFlagBits::eColorAttachment )
{
aspectFlags |= vk::ImageAspectFlagBits::eColor;
- //componentsMapping = { vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eB,vk::ComponentSwizzle::eA };
}
if( image->GetUsageFlags() & vk::ImageUsageFlagBits::eDepthStencilAttachment )
{
}
if( image->GetUsageFlags() & vk::ImageUsageFlagBits::eSampled )
{
- aspectFlags |= ( vk::ImageAspectFlagBits::eColor );
- //componentsMapping = { vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eR,vk::ComponentSwizzle::eA };
+ aspectFlags |= vk::ImageAspectFlagBits::eColor;
}
auto subresourceRange = vk::ImageSubresourceRange{}
vk::Result Graphics::Submit( Queue& queue, const std::vector< SubmissionData >& submissionData, RefCountedFence fence )
{
std::vector< vk::SubmitInfo > submitInfos;
+ std::vector< vk::CommandBuffer > commandBufferHandles;
// Transform SubmissionData to vk::SubmitInfo
std::transform(submissionData.begin(),
submissionData.end(),
std::back_inserter( submitInfos ),
- []( SubmissionData subData )
+ [&]( SubmissionData subData )
{
- std::vector< vk::CommandBuffer > commandBufferHandles;
+
//Extract the command buffer handles
std::transform(subData.commandBuffers.begin(),
subData.commandBuffers.end(),
std::back_inserter(commandBufferHandles),
- []( RefCountedCommandBuffer& entry )
+ [&]( RefCountedCommandBuffer& entry )
{
return entry->GetVkHandle();
});
#include <mutex>
#include <map>
#include <functional>
-#include "vulkan-queue.h"
+#include <dali/graphics/vulkan/vulkan-queue.h>
namespace Dali
{