Skip to content

Commit c5efc89

Browse files
committed
hal/vulkan: add debug names to all swapchain semaphores
1 parent f5d8a0a commit c5efc89

3 files changed

Lines changed: 29 additions & 10 deletions

File tree

wgpu-hal/src/vulkan/device.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,8 @@ impl super::Device {
577577
// semaphores, since we prospectively need to provide the call to
578578
// acquire the next image with an unsignaled semaphore.
579579
let surface_semaphores = (0..=images.len())
580-
.map(|_| {
581-
super::SwapchainImageSemaphores::new(&self.shared)
580+
.map(|i| {
581+
super::SwapchainImageSemaphores::new(&self.shared, i)
582582
.map(Mutex::new)
583583
.map(Arc::new)
584584
})
@@ -3018,11 +3018,19 @@ impl crate::Device for super::Device {
30183018
}
30193019

30203020
impl super::DeviceShared {
3021-
pub(super) fn new_binary_semaphore(&self) -> Result<vk::Semaphore, crate::DeviceError> {
3021+
pub(super) fn new_binary_semaphore(
3022+
&self,
3023+
name: &str,
3024+
) -> Result<vk::Semaphore, crate::DeviceError> {
30223025
unsafe {
3023-
self.raw
3026+
let semaphore = self
3027+
.raw
30243028
.create_semaphore(&vk::SemaphoreCreateInfo::default(), None)
3025-
.map_err(super::map_host_device_oom_err)
3029+
.map_err(super::map_host_device_oom_err)?;
3030+
3031+
self.set_object_name(semaphore, name);
3032+
3033+
Ok(semaphore)
30263034
}
30273035
}
30283036

wgpu-hal/src/vulkan/instance.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,8 @@ impl crate::Surface for super::Surface {
11291129
}
11301130
};
11311131

1132+
log::error!("Got swapchain image {index}");
1133+
11321134
drop(locked_swapchain_semaphores);
11331135
// We only advance the surface semaphores if we successfully acquired an image, otherwise
11341136
// we should try to re-acquire using the same semaphores.

wgpu-hal/src/vulkan/mod.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,16 +262,22 @@ struct SwapchainImageSemaphores {
262262
///
263263
/// [`acquire`]: SwapchainImageSemaphores::acquire
264264
previously_used_submission_index: crate::FenceValue,
265+
266+
/// Which image this semaphore set is used for.
267+
frame_index: usize,
265268
}
266269

267270
impl SwapchainImageSemaphores {
268-
fn new(device: &DeviceShared) -> Result<Self, crate::DeviceError> {
271+
fn new(device: &DeviceShared, frame_index: usize) -> Result<Self, crate::DeviceError> {
269272
Ok(Self {
270-
acquire: device.new_binary_semaphore()?,
273+
acquire: device.new_binary_semaphore(&format!(
274+
"SwapchainImageSemaphore: Image {frame_index} acquire"
275+
))?,
271276
should_wait_for_acquire: true,
272277
present: Vec::new(),
273278
present_index: 0,
274279
previously_used_submission_index: 0,
280+
frame_index,
275281
})
276282
}
277283

@@ -304,7 +310,10 @@ impl SwapchainImageSemaphores {
304310
let sem = match self.present.get(self.present_index) {
305311
Some(sem) => *sem,
306312
None => {
307-
let sem = device.new_binary_semaphore()?;
313+
let sem = device.new_binary_semaphore(&format!(
314+
"SwapchainImageSemaphore: Image {} present semaphore {}",
315+
self.frame_index, self.present_index
316+
))?;
308317
self.present.push(sem);
309318
sem
310319
}
@@ -729,7 +738,7 @@ impl RelaySemaphores {
729738
fn new(device: &DeviceShared) -> Result<Self, crate::DeviceError> {
730739
Ok(Self {
731740
wait: None,
732-
signal: device.new_binary_semaphore()?,
741+
signal: device.new_binary_semaphore("RelaySemaphores: 1")?,
733742
})
734743
}
735744

@@ -744,7 +753,7 @@ impl RelaySemaphores {
744753
// The second submission should wait on `old.signal`, and then
745754
// signal a new semaphore which we'll create now.
746755
self.wait = Some(old.signal);
747-
self.signal = device.new_binary_semaphore()?;
756+
self.signal = device.new_binary_semaphore("RelaySemaphores: 2")?;
748757
}
749758
Some(ref mut wait) => {
750759
// What this submission signals, the next should wait.

0 commit comments

Comments
 (0)