diff --git a/client/application.cpp b/client/application.cpp index b0433274..384dee76 100644 --- a/client/application.cpp +++ b/client/application.cpp @@ -902,10 +902,16 @@ void application::initialize_vulkan() pipeline_cache = vk::raii::PipelineCache(vk_device, pipeline_cache_info); allocator.emplace(VmaAllocatorCreateInfo{ - .physicalDevice = *vk_physical_device, - .device = *vk_device, - .instance = *vk_instance, - }); + .physicalDevice = *vk_physical_device, + .device = *vk_device, + .instance = *vk_instance, + }, +#ifndef NDEBUG + debug_utils_found +#else + false +#endif + ); } void application::log_views() diff --git a/client/render/text_rasterizer.cpp b/client/render/text_rasterizer.cpp index d206aa15..ac0f7a83 100644 --- a/client/render/text_rasterizer.cpp +++ b/client/render/text_rasterizer.cpp @@ -139,46 +139,42 @@ text_rasterizer::text_rasterizer(vk::raii::Device & device, vk::raii::PhysicalDe image_allocation text_rasterizer::create_image(vk::Extent2D size) { - image_allocation alloc{device, - vk::ImageCreateInfo{ - .imageType = vk::ImageType::e2D, - .format = text::format, - .extent = { - .width = size.width, - .height = size.height, - .depth = 1, - }, - .mipLevels = 1, - .arrayLayers = 1, - .samples = vk::SampleCountFlagBits::e1, - .tiling = vk::ImageTiling::eOptimal, - .usage = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst, - .sharingMode = vk::SharingMode::eExclusive, - .initialLayout = vk::ImageLayout::eUndefined, - }, - VmaAllocationCreateInfo{ - .flags = 0, - .usage = VMA_MEMORY_USAGE_AUTO, - }}; - - application::set_debug_reports_name(alloc, "text_rasterizer image"); - return alloc; + return {device, + vk::ImageCreateInfo{ + .imageType = vk::ImageType::e2D, + .format = text::format, + .extent = { + .width = size.width, + .height = size.height, + .depth = 1, + }, + .mipLevels = 1, + .arrayLayers = 1, + .samples = vk::SampleCountFlagBits::e1, + .tiling = vk::ImageTiling::eOptimal, + .usage = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst, + .sharingMode = vk::SharingMode::eExclusive, + .initialLayout = vk::ImageLayout::eUndefined, + }, + VmaAllocationCreateInfo{ + .flags = 0, + .usage = VMA_MEMORY_USAGE_AUTO, + }, + "text_rasterizer image"}; } buffer_allocation text_rasterizer::create_buffer(size_t size) { - buffer_allocation alloc{device, - vk::BufferCreateInfo{ - .size = size, - .usage = vk::BufferUsageFlagBits::eTransferSrc, - }, - VmaAllocationCreateInfo{ - .flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, - .usage = VMA_MEMORY_USAGE_AUTO, - }}; - application::set_debug_reports_name(alloc, "text_rasterizer buffer"); - - return alloc; + return {device, + vk::BufferCreateInfo{ + .size = size, + .usage = vk::BufferUsageFlagBits::eTransferSrc, + }, + VmaAllocationCreateInfo{ + .flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, + .usage = VMA_MEMORY_USAGE_AUTO, + }, + "text_rasterizer buffer"}; } text_rasterizer::~text_rasterizer() diff --git a/common/vk/allocation.h b/common/vk/allocation.h index e47242be..91c36d20 100644 --- a/common/vk/allocation.h +++ b/common/vk/allocation.h @@ -131,6 +131,12 @@ public: std::tie(resource, allocation) = traits::create(device, create_info, alloc_info); vmaSetAllocationName(vk_allocator::instance(), allocation, name.c_str()); + if (vk_allocator::instance().has_debug_utils) + device.setDebugUtilsObjectNameEXT(vk::DebugUtilsObjectNameInfoEXT{ + .objectType = T::objectType, + .objectHandle = uint64_t(CType(*resource)), + .pObjectName = name.c_str(), + }); } basic_allocation(const basic_allocation &) = delete; diff --git a/common/vk/vk_allocator.cpp b/common/vk/vk_allocator.cpp index 9ea62e63..27371fcd 100644 --- a/common/vk/vk_allocator.cpp +++ b/common/vk/vk_allocator.cpp @@ -20,7 +20,8 @@ #include "vk_allocator.h" #include "vk/check.h" -vk_allocator::vk_allocator(const VmaAllocatorCreateInfo & info) +vk_allocator::vk_allocator(const VmaAllocatorCreateInfo & info, bool has_debug_utils) : + has_debug_utils(has_debug_utils) { CHECK_VK(vmaCreateAllocator(&info, &handle)); } diff --git a/common/vk/vk_allocator.h b/common/vk/vk_allocator.h index 182ca114..ecb156e3 100644 --- a/common/vk/vk_allocator.h +++ b/common/vk/vk_allocator.h @@ -27,7 +27,8 @@ class vk_allocator : public singleton VmaAllocator handle = nullptr; public: - vk_allocator(const VmaAllocatorCreateInfo &); + const bool has_debug_utils; + vk_allocator(const VmaAllocatorCreateInfo &, bool has_debug_utils); ~vk_allocator(); operator VmaAllocator() diff --git a/server/driver/wivrn_comp_target.cpp b/server/driver/wivrn_comp_target.cpp index 2c0aa5ed..b529e359 100644 --- a/server/driver/wivrn_comp_target.cpp +++ b/server/driver/wivrn_comp_target.cpp @@ -232,9 +232,12 @@ static VkResult create_images(struct wivrn_comp_target * cn, vk::ImageUsageFlags for (uint32_t i = 0; i < cn->image_count; i++) { auto & image = cn->psc.images[i].image; - image = image_allocation(device, image_info.get(), {.usage = VMA_MEMORY_USAGE_AUTO}); + image = image_allocation( + device, + image_info.get(), + {.usage = VMA_MEMORY_USAGE_AUTO}, + std::format("comp target image {}", i)); cn->images[i].handle = image; - cn->wivrn_bundle->name(vk::Image(image), "comp target image"); } for (uint32_t i = 0; i < cn->image_count; i++) diff --git a/server/driver/wivrn_foveation.cpp b/server/driver/wivrn_foveation.cpp index 500605d2..747ef6e5 100644 --- a/server/driver/wivrn_foveation.cpp +++ b/server/driver/wivrn_foveation.cpp @@ -335,7 +335,6 @@ wivrn_foveation::wivrn_foveation(wivrn_vk_bundle & bundle, const xrt_hmd_parts & .usage = VMA_MEMORY_USAGE_AUTO_PREFER_HOST, }, "foveation staging buffer"); - bundle.name(vk::Buffer(host_buffer), "foveation staging buffer"); } bundle.name(command_pool, "foveation command pool"); bundle.name(cmd, "foveation command buffer"); diff --git a/server/encoder/video_encoder_vulkan.cpp b/server/encoder/video_encoder_vulkan.cpp index c18e21a9..9da1bc06 100644 --- a/server/encoder/video_encoder_vulkan.cpp +++ b/server/encoder/video_encoder_vulkan.cpp @@ -176,8 +176,8 @@ void wivrn::video_encoder_vulkan::init(const vk::VideoCapabilitiesKHR & video_ca img_create_info, { .usage = VMA_MEMORY_USAGE_AUTO, - }); - vk.name(vk::Image(dpb_image), "vulkan encoder DPB image"); + }, + "vulkan encoder DPB image"); } // Output buffer @@ -195,8 +195,8 @@ void wivrn::video_encoder_vulkan::init(const vk::VideoCapabilitiesKHR & video_ca { .flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT, .usage = VMA_MEMORY_USAGE_AUTO, - }); - vk.name(vk::Buffer(item.output_buffer), "vulkan encode output buffer"); + }, + "vulkan encode output buffer"); if (not(item.output_buffer.properties() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) { @@ -208,8 +208,8 @@ void wivrn::video_encoder_vulkan::init(const vk::VideoCapabilitiesKHR & video_ca { .flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT, .usage = VMA_MEMORY_USAGE_AUTO, - }); - vk.name(vk::Buffer(item.host_buffer), "vulkan encode host buffer"); + }, + "vulkan encode host buffer"); } } @@ -292,8 +292,8 @@ void wivrn::video_encoder_vulkan::init(const vk::VideoCapabilitiesKHR & video_ca }, { .usage = VMA_MEMORY_USAGE_AUTO, - }); - vk.name(vk::Image(slot_data[i].tmp_image), "vulkan encoder temporary image"); + }, + "vulkan encoder temporary image"); image_view_template.image = vk::Image(slot_data[i].tmp_image); slot_data[i].view = vk.device.createImageView(image_view_template); vk.name(slot_data[i].view, "vulkan encoder temporary image view"); diff --git a/server/encoder/video_encoder_x264.cpp b/server/encoder/video_encoder_x264.cpp index fcb28162..048282df 100644 --- a/server/encoder/video_encoder_x264.cpp +++ b/server/encoder/video_encoder_x264.cpp @@ -168,7 +168,8 @@ video_encoder_x264::video_encoder_x264( { .flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT, .usage = VMA_MEMORY_USAGE_AUTO, - }); + }, + "x264 luma buffer"); i.chroma = buffer_allocation( vk.device, { .size = vk::DeviceSize(settings.video_width * settings.video_height / 2), @@ -177,9 +178,8 @@ video_encoder_x264::video_encoder_x264( { .flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT, .usage = VMA_MEMORY_USAGE_AUTO, - }); - vk.name(vk::Buffer(i.luma), "x264 luma buffer"); - vk.name(vk::Buffer(i.chroma), "x264 chroma buffer"); + }, + "x264 chroma buffer"); auto & pic = i.pic; x264_picture_init(&pic); diff --git a/server/utils/wivrn_vk_bundle.cpp b/server/utils/wivrn_vk_bundle.cpp index 5a01c2a9..5d9b688a 100644 --- a/server/utils/wivrn_vk_bundle.cpp +++ b/server/utils/wivrn_vk_bundle.cpp @@ -83,11 +83,12 @@ wivrn::wivrn_vk_bundle::wivrn_vk_bundle(vk_bundle & vk, std::span physical_device(instance, vk.physical_device), device(physical_device, vk.device), allocator({ - .physicalDevice = vk.physical_device, - .device = vk.device, - .instance = vk.instance, - .vulkanApiVersion = VK_MAKE_VERSION(1, 3, 0), // FIXME: sync with wivrn_session.cpp - }), + .physicalDevice = vk.physical_device, + .device = vk.device, + .instance = vk.instance, + .vulkanApiVersion = VK_MAKE_VERSION(1, 3, 0), // FIXME: sync with wivrn_session.cpp + }, + vk.has_EXT_debug_utils), queue(device, vk.queue_family_index, vk.queue_index), queue_family_index(vk.queue_family_index), #ifdef VK_KHR_video_encode_queue