From 99f03daf2358c0b1c3a5dcffd1e4c59dffd5fc8c Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Tue, 21 Sep 2021 17:44:45 -0400 Subject: [PATCH] Fix VK and GL renderdoc captures --- CHANGELOG.md | 4 ++++ wgpu-hal/src/gles/device.rs | 3 +-- wgpu-hal/src/gles/egl.rs | 2 +- wgpu-hal/src/vulkan/device.rs | 23 +++++++++++++++-------- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8abbedbaa..56574ba91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +### Unreleased + - GL & Vulkan: + - Fix renderdoc device pointers. + ### wgpu-hal-0.10.7 (2021-09-14) - Metal: - fix stencil back-face state diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index d6a20c22a..b96f4f61f 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -1041,9 +1041,8 @@ impl crate::Device for super::Device { unsafe fn start_capture(&self) -> bool { #[cfg(feature = "renderdoc")] { - //Note: it doesn't look like the device pointer is used by RD self.render_doc - .start_frame_capture(ptr::null_mut(), ptr::null_mut()) + .start_frame_capture(self.shared.context.egl_context.as_ptr(), ptr::null_mut()) } #[cfg(not(feature = "renderdoc"))] false diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 796e2ac89..d0b33c3fb 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -236,7 +236,7 @@ pub struct AdapterContext { glow_context: Mutex, egl: Arc>, egl_display: egl::Display, - egl_context: egl::Context, + pub(super) egl_context: egl::Context, egl_pbuffer: Option, } diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index c5b95ab7e..5b4762566 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -1535,20 +1535,27 @@ impl crate::Device for super::Device { unsafe fn start_capture(&self) -> bool { #[cfg(feature = "renderdoc")] { - self.render_doc.start_frame_capture( - ash::vk::Handle::as_raw(self.shared.raw.handle()) as *mut _, - ptr::null_mut(), - ) + // Renderdoc requires us to give us the pointer that vkInstance _points to_. + let raw_vk_instance = + ash::vk::Handle::as_raw(self.shared.instance.raw.handle()) as *mut *mut _; + let raw_vk_instance_dispatch_table = *raw_vk_instance; + self.render_doc + .start_frame_capture(raw_vk_instance_dispatch_table, ptr::null_mut()) } #[cfg(not(feature = "renderdoc"))] false } unsafe fn stop_capture(&self) { #[cfg(feature = "renderdoc")] - self.render_doc.end_frame_capture( - ash::vk::Handle::as_raw(self.shared.raw.handle()) as *mut _, - ptr::null_mut(), - ) + { + // Renderdoc requires us to give us the pointer that vkInstance _points to_. + let raw_vk_instance = + ash::vk::Handle::as_raw(self.shared.instance.raw.handle()) as *mut *mut _; + let raw_vk_instance_dispatch_table = *raw_vk_instance; + + self.render_doc + .end_frame_capture(raw_vk_instance_dispatch_table, ptr::null_mut()) + } } }