Add debug names to some buffers

This commit is contained in:
Magnus Norddahl 2022-06-14 01:01:54 +02:00 committed by Christoph Oelckers
parent 5cc21c5a4a
commit 5446e37874
4 changed files with 26 additions and 4 deletions

View file

@ -454,7 +454,7 @@ void VkRenderState::ApplyHWBufferSet()
auto descriptors = fb->GetDescriptorSetManager();
uint32_t offsets[3] = { mViewpointOffset, matrixOffset, streamDataOffset };
mCommandBuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, fb->GetRenderPassManager()->GetPipelineLayout(mPipelineKey.NumTextureLayers), 0, fb->GetDescriptorSetManager()->GetFixedDescriptorSet());
mCommandBuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, passManager->GetPipelineLayout(mPipelineKey.NumTextureLayers), 0, fb->GetDescriptorSetManager()->GetFixedDescriptorSet());
mCommandBuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, passManager->GetPipelineLayout(mPipelineKey.NumTextureLayers), 1, descriptors->GetHWBufferDescriptorSet(), 3, offsets);
mLastViewpointOffset = mViewpointOffset;

View file

@ -349,6 +349,7 @@ void VulkanFrameBuffer::CopyScreenToBuffer(int w, int h, uint8_t *data)
bufbuilder.setSize(w * h * 4);
bufbuilder.setUsage(VK_BUFFER_USAGE_TRANSFER_DST_BIT, VMA_MEMORY_USAGE_GPU_TO_CPU);
auto staging = bufbuilder.create(device);
staging->SetDebugName("CopyScreenToBuffer");
// Copy from image to buffer
VkBufferImageCopy region = {};

View file

@ -82,11 +82,13 @@ void VkHardwareBuffer::SetData(size_t size, const void *data, BufferUsageType us
builder.setUsage(VK_BUFFER_USAGE_TRANSFER_DST_BIT | mBufferType, VMA_MEMORY_USAGE_GPU_ONLY);
builder.setSize(bufsize);
mBuffer = builder.create(fb->device);
mBuffer->SetDebugName(usage == BufferUsageType::Static ? "VkHardwareBuffer.Static" : "VkHardwareBuffer.Stream");
BufferBuilder builder2;
builder2.setUsage(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VMA_MEMORY_USAGE_CPU_ONLY);
builder2.setSize(bufsize);
mStaging = builder2.create(fb->device);
mStaging->SetDebugName(usage == BufferUsageType::Static ? "VkHardwareBuffer.Staging.Static" : "VkHardwareBuffer.Staging.Stream");
if (data)
{
@ -108,6 +110,7 @@ void VkHardwareBuffer::SetData(size_t size, const void *data, BufferUsageType us
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
builder.setSize(bufsize);
mBuffer = builder.create(fb->device);
mBuffer->SetDebugName("VkHardwareBuffer.Persistent");
map = mBuffer->Map(0, bufsize);
if (data)
@ -124,6 +127,7 @@ void VkHardwareBuffer::SetData(size_t size, const void *data, BufferUsageType us
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
builder.setSize(bufsize);
mBuffer = builder.create(fb->device);
mBuffer->SetDebugName("VkHardwareBuffer.Mappable");
if (data)
{
@ -174,10 +178,12 @@ void VkHardwareBuffer::Resize(size_t newsize)
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
builder.setSize(newsize);
mBuffer = builder.create(fb->device);
mBuffer->SetDebugName("VkHardwareBuffer.Resized");
buffersize = newsize;
// Transfer data from old to new
fb->GetCommands()->GetTransferCommands()->copyBuffer(oldBuffer.get(), mBuffer.get(), 0, 0, oldsize);
fb->GetCommands()->TransferDeleteList->Add(std::move(oldBuffer));
fb->GetCommands()->WaitForCommands(false);
fb->GetDescriptorSetManager()->UpdateHWBufferSet(); // Old buffer may be part of the bound descriptor set

View file

@ -44,7 +44,12 @@ public:
VulkanBuffer(VulkanDevice *device, VkBuffer buffer, VmaAllocation allocation, size_t size);
~VulkanBuffer();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER); }
#ifdef _DEBUG
void SetDebugName(const char* name) { debugName = name; device->SetDebugObjectName(name, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER); }
std::string debugName;
#else
void SetDebugName(const char* name) { device->SetDebugObjectName(name, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER); }
#endif
VulkanDevice *device = nullptr;
@ -174,7 +179,12 @@ public:
VulkanDescriptorSet(VulkanDevice *device, VulkanDescriptorPool *pool, VkDescriptorSet set);
~VulkanDescriptorSet();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)set, VK_OBJECT_TYPE_DESCRIPTOR_SET); }
#ifdef _DEBUG
void SetDebugName(const char* name) { debugName = name; device->SetDebugObjectName(name, (uint64_t)set, VK_OBJECT_TYPE_DESCRIPTOR_SET); }
std::string debugName;
#else
void SetDebugName(const char* name) { device->SetDebugObjectName(name, (uint64_t)set, VK_OBJECT_TYPE_DESCRIPTOR_SET); }
#endif
VulkanDevice *device;
VulkanDescriptorPool *pool;
@ -191,7 +201,12 @@ public:
VulkanDescriptorPool(VulkanDevice *device, VkDescriptorPool pool);
~VulkanDescriptorPool();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)pool, VK_OBJECT_TYPE_DESCRIPTOR_POOL); }
#ifdef _DEBUG
void SetDebugName(const char* name) { debugName = name; device->SetDebugObjectName(name, (uint64_t)pool, VK_OBJECT_TYPE_DESCRIPTOR_POOL); }
std::string debugName;
#else
void SetDebugName(const char* name) { device->SetDebugObjectName(name, (uint64_t)pool, VK_OBJECT_TYPE_DESCRIPTOR_POOL); }
#endif
std::unique_ptr<VulkanDescriptorSet> tryAllocate(VulkanDescriptorSetLayout *layout);
std::unique_ptr<VulkanDescriptorSet> allocate(VulkanDescriptorSetLayout *layout);