screen-13 icon indicating copy to clipboard operation
screen-13 copied to clipboard

Passes should have debug labels emitted

Open attackgoat opened this issue 3 years ago • 2 comments

This feature no longer works, should be addressed

attackgoat avatar Jun 04 '22 01:06 attackgoat

Was just curious about this. It would be wonderful to see pass labels in nsight & renderdoc!

DGriffin91 avatar Sep 04 '24 06:09 DGriffin91

Was playing around with trying to get this to work and ran into https://github.com/attackgoat/screen-13/issues/88

Idk if this will be helpful at all or not but here's a diff of what I tried:

diff --git a/src/driver/device.rs b/src/driver/device.rs
index 13ca892..00dc820 100644
--- a/src/driver/device.rs
+++ b/src/driver/device.rs
@@ -43,6 +43,8 @@ pub struct Device {
     /// Vulkan instance pointer, which includes useful functions.
     instance: Instance,
 
+    pub(crate) debug_utils_fn: Option<ext::debug_utils::Device>,
+
     /// The physical device, which contains useful data about features, properties, and limits.
     pub physical_device: PhysicalDevice,
 
@@ -313,10 +315,17 @@ impl Device {
             .ray_tracing_pipeline
             .then(|| khr::ray_tracing_pipeline::Device::new(&instance, &device));
 
+        let debug_utils_fn = if Instance::is_debug(&instance) {
+            Some(ext::debug_utils::Device::new(&instance, &device))
+        } else {
+            None
+        };
+
         Ok(Self {
             accel_struct_ext,
             allocator: ManuallyDrop::new(Mutex::new(allocator)),
             device,
+            debug_utils_fn,
             instance,
             physical_device,
             queues,
diff --git a/src/graph/resolver.rs b/src/graph/resolver.rs
index 2e68a9c..f8a2728 100644
--- a/src/graph/resolver.rs
+++ b/src/graph/resolver.rs
@@ -619,6 +619,14 @@ impl Resolver {
 
             // let start_g = std::time::Instant::now();
             unsafe {
+                if let Some(debug_utils_fn) = &cmd_buf.device.debug_utils_fn {
+                    debug_utils_fn.cmd_begin_debug_utils_label(
+                        **cmd_buf,
+                        &vk::DebugUtilsLabelEXT::default()
+                            .label_name(&std::ffi::CString::new(pass.name.clone()).unwrap()),
+                    )
+                }
+
                 cmd_buf.device.cmd_begin_render_pass(
                     **cmd_buf,
                     &vk::RenderPassBeginInfo::default()
@@ -741,6 +749,9 @@ impl Resolver {
         trace!("  end render pass");
 
         unsafe {
+            if let Some(debug_utils_fn) = &cmd_buf.device.debug_utils_fn {
+                debug_utils_fn.cmd_end_debug_utils_label(**cmd_buf)
+            }
             cmd_buf.device.cmd_end_render_pass(**cmd_buf);
         }
     }

DGriffin91 avatar Sep 19 '24 02:09 DGriffin91