Skip to content

Commit 4f18c26

Browse files
committed
hal/vulkan: add debug names to all swapchain semaphores
1 parent 91a711d commit 4f18c26

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

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
@@ -260,16 +260,22 @@ struct SwapchainImageSemaphores {
260260
///
261261
/// [`acquire`]: SwapchainImageSemaphores::acquire
262262
previously_used_submission_index: crate::FenceValue,
263+
264+
/// Which image this semaphore set is used for.
265+
frame_index: usize,
263266
}
264267

265268
impl SwapchainImageSemaphores {
266-
fn new(device: &DeviceShared) -> Result<Self, crate::DeviceError> {
269+
fn new(device: &DeviceShared, frame_index: usize) -> Result<Self, crate::DeviceError> {
267270
Ok(Self {
268-
acquire: device.new_binary_semaphore()?,
271+
acquire: device.new_binary_semaphore(&format!(
272+
"SwapchainImageSemaphore: Image {frame_index} acquire"
273+
))?,
269274
should_wait_for_acquire: true,
270275
present: Vec::new(),
271276
present_index: 0,
272277
previously_used_submission_index: 0,
278+
frame_index,
273279
})
274280
}
275281

@@ -302,7 +308,10 @@ impl SwapchainImageSemaphores {
302308
let sem = match self.present.get(self.present_index) {
303309
Some(sem) => *sem,
304310
None => {
305-
let sem = device.new_binary_semaphore()?;
311+
let sem = device.new_binary_semaphore(&format!(
312+
"SwapchainImageSemaphore: Image {} present semaphore {}",
313+
self.frame_index, self.present_index
314+
))?;
306315
self.present.push(sem);
307316
sem
308317
}
@@ -727,7 +736,7 @@ impl RelaySemaphores {
727736
fn new(device: &DeviceShared) -> Result<Self, crate::DeviceError> {
728737
Ok(Self {
729738
wait: None,
730-
signal: device.new_binary_semaphore()?,
739+
signal: device.new_binary_semaphore("RelaySemaphores: 1")?,
731740
})
732741
}
733742

@@ -742,7 +751,7 @@ impl RelaySemaphores {
742751
// The second submission should wait on `old.signal`, and then
743752
// signal a new semaphore which we'll create now.
744753
self.wait = Some(old.signal);
745-
self.signal = device.new_binary_semaphore()?;
754+
self.signal = device.new_binary_semaphore("RelaySemaphores: 2")?;
746755
}
747756
Some(ref mut wait) => {
748757
// What this submission signals, the next should wait.

0 commit comments

Comments
 (0)