hal/vulkan: add debug names to all swapchain semaphores

This commit is contained in:
Connor Fitzgerald 2025-07-19 17:13:21 -04:00
parent f5d8a0a06a
commit c5efc89b08
3 changed files with 29 additions and 10 deletions

View File

@ -577,8 +577,8 @@ impl super::Device {
// semaphores, since we prospectively need to provide the call to // semaphores, since we prospectively need to provide the call to
// acquire the next image with an unsignaled semaphore. // acquire the next image with an unsignaled semaphore.
let surface_semaphores = (0..=images.len()) let surface_semaphores = (0..=images.len())
.map(|_| { .map(|i| {
super::SwapchainImageSemaphores::new(&self.shared) super::SwapchainImageSemaphores::new(&self.shared, i)
.map(Mutex::new) .map(Mutex::new)
.map(Arc::new) .map(Arc::new)
}) })
@ -3018,11 +3018,19 @@ impl crate::Device for super::Device {
} }
impl super::DeviceShared { impl super::DeviceShared {
pub(super) fn new_binary_semaphore(&self) -> Result<vk::Semaphore, crate::DeviceError> { pub(super) fn new_binary_semaphore(
&self,
name: &str,
) -> Result<vk::Semaphore, crate::DeviceError> {
unsafe { unsafe {
self.raw let semaphore = self
.raw
.create_semaphore(&vk::SemaphoreCreateInfo::default(), None) .create_semaphore(&vk::SemaphoreCreateInfo::default(), None)
.map_err(super::map_host_device_oom_err) .map_err(super::map_host_device_oom_err)?;
self.set_object_name(semaphore, name);
Ok(semaphore)
} }
} }

View File

@ -1129,6 +1129,8 @@ impl crate::Surface for super::Surface {
} }
}; };
log::error!("Got swapchain image {index}");
drop(locked_swapchain_semaphores); drop(locked_swapchain_semaphores);
// We only advance the surface semaphores if we successfully acquired an image, otherwise // We only advance the surface semaphores if we successfully acquired an image, otherwise
// we should try to re-acquire using the same semaphores. // we should try to re-acquire using the same semaphores.

View File

@ -262,16 +262,22 @@ struct SwapchainImageSemaphores {
/// ///
/// [`acquire`]: SwapchainImageSemaphores::acquire /// [`acquire`]: SwapchainImageSemaphores::acquire
previously_used_submission_index: crate::FenceValue, previously_used_submission_index: crate::FenceValue,
/// Which image this semaphore set is used for.
frame_index: usize,
} }
impl SwapchainImageSemaphores { impl SwapchainImageSemaphores {
fn new(device: &DeviceShared) -> Result<Self, crate::DeviceError> { fn new(device: &DeviceShared, frame_index: usize) -> Result<Self, crate::DeviceError> {
Ok(Self { Ok(Self {
acquire: device.new_binary_semaphore()?, acquire: device.new_binary_semaphore(&format!(
"SwapchainImageSemaphore: Image {frame_index} acquire"
))?,
should_wait_for_acquire: true, should_wait_for_acquire: true,
present: Vec::new(), present: Vec::new(),
present_index: 0, present_index: 0,
previously_used_submission_index: 0, previously_used_submission_index: 0,
frame_index,
}) })
} }
@ -304,7 +310,10 @@ impl SwapchainImageSemaphores {
let sem = match self.present.get(self.present_index) { let sem = match self.present.get(self.present_index) {
Some(sem) => *sem, Some(sem) => *sem,
None => { None => {
let sem = device.new_binary_semaphore()?; let sem = device.new_binary_semaphore(&format!(
"SwapchainImageSemaphore: Image {} present semaphore {}",
self.frame_index, self.present_index
))?;
self.present.push(sem); self.present.push(sem);
sem sem
} }
@ -729,7 +738,7 @@ impl RelaySemaphores {
fn new(device: &DeviceShared) -> Result<Self, crate::DeviceError> { fn new(device: &DeviceShared) -> Result<Self, crate::DeviceError> {
Ok(Self { Ok(Self {
wait: None, wait: None,
signal: device.new_binary_semaphore()?, signal: device.new_binary_semaphore("RelaySemaphores: 1")?,
}) })
} }
@ -744,7 +753,7 @@ impl RelaySemaphores {
// The second submission should wait on `old.signal`, and then // The second submission should wait on `old.signal`, and then
// signal a new semaphore which we'll create now. // signal a new semaphore which we'll create now.
self.wait = Some(old.signal); self.wait = Some(old.signal);
self.signal = device.new_binary_semaphore()?; self.signal = device.new_binary_semaphore("RelaySemaphores: 2")?;
} }
Some(ref mut wait) => { Some(ref mut wait) => {
// What this submission signals, the next should wait. // What this submission signals, the next should wait.