@@ -23,7 +23,7 @@ void Buffer::alloc() {
2323 allocInfo.usage = vmaUsage;
2424 allocInfo.flags = flags;
2525
26- VkBuffer vkBuffer;
26+ VkBuffer vkBuffer = VK_NULL_HANDLE ;
2727
2828 VkResult res;
2929 if (alignment != 0 ) {
@@ -36,18 +36,24 @@ void Buffer::alloc() {
3636 throw std::runtime_error (" Failed to create buffer" );
3737 }
3838 buffer = vk::Buffer (vkBuffer);
39+
40+ if (context->validationLayersEnabled ) {
41+ context->device ->setDebugUtilsObjectNameEXT (
42+ vk::DebugUtilsObjectNameInfoEXT {vk::ObjectType::eBuffer, reinterpret_cast <uint64_t >(static_cast <VkBuffer>(buffer)), debugName.c_str ()});
43+ }
3944}
4045
4146Buffer::Buffer (const std::shared_ptr<VulkanContext>& _context, uint32_t size, vk::BufferUsageFlags usage,
42- VmaMemoryUsage vmaUsage, VmaAllocationCreateFlags flags, bool shared, vk::DeviceSize alignment)
47+ VmaMemoryUsage vmaUsage, VmaAllocationCreateFlags flags, bool shared, vk::DeviceSize alignment, std::string debugName )
4348 : context(_context),
4449 size(size),
4550 alignment(alignment),
4651 shared(shared),
4752 usage(usage),
4853 vmaUsage(vmaUsage),
4954 flags(flags),
50- allocation(nullptr ) {
55+ allocation(nullptr ),
56+ debugName(std::move(debugName)) {
5157 alloc ();
5258}
5359
@@ -159,12 +165,12 @@ std::shared_ptr<Buffer> Buffer::staging(std::shared_ptr<VulkanContext> context,
159165}
160166
161167std::shared_ptr<Buffer> Buffer::storage (std::shared_ptr<VulkanContext> context, uint64_t size, bool concurrentSharing,
162- vk::DeviceSize alignment) {
168+ vk::DeviceSize alignment, std::string debugName ) {
163169 return std::make_shared<Buffer>(context, size,
164170 vk::BufferUsageFlagBits::eStorageBuffer | vk::BufferUsageFlagBits::eTransferDst |
165171 vk::BufferUsageFlagBits::eTransferSrc,
166172 VMA_MEMORY_USAGE_GPU_ONLY, VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT,
167- concurrentSharing, alignment);
173+ concurrentSharing, alignment, debugName );
168174}
169175
170176void Buffer::assertEquals (char * data, size_t length) {
0 commit comments