Skip to content

Commit 4cbf8cf

Browse files
authored
Fix opening of renderdoc lib (#2930)
* Fix opening renderdoc lib Renderdoc needs to not be opened by us, but instead open the existing copy. Unfortunately this requires OS specific flags for opening, plus `libloading` doesn't have full API coverage currently. * Added changelog entry for #2930 * Hide RTLD_NOLOAD behind a cfg for unix Co-authored-by: ABuffSeagull <reecevanatta@hey.com>
1 parent a05c8dc commit 4cbf8cf

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ the same every time it is rendered, we now warn if it is missing.
6060

6161
#### General
6262
- Improve the validation and error reporting of buffer mappings by @nical in [#2848](https://github.com/gfx-rs/wgpu/pull/2848)
63+
- Fixed opening of RenderDoc library by @abuffseagull in [#2930](https://github.com/gfx-rs/wgpu/pull/2930)
6364

6465
### Changes
6566

wgpu-hal/src/auxil/renderdoc.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ pub enum RenderDoc {
2828
},
2929
}
3030

31+
// TODO: replace with libloading API once supported
32+
#[cfg(unix)]
33+
const RTLD_NOLOAD: i32 = 0x4;
34+
3135
impl RenderDoc {
3236
pub unsafe fn new() -> Self {
3337
type GetApiFn = unsafe extern "C" fn(version: u32, out: *mut *mut ffi::c_void) -> i32;
@@ -39,7 +43,20 @@ impl RenderDoc {
3943
#[cfg(target_os = "android")]
4044
let renderdoc_filename = "libVkLayer_GLES_RenderDoc.so";
4145

42-
let renderdoc_lib = match libloading::Library::new(renderdoc_filename) {
46+
#[cfg(unix)]
47+
let renderdoc_result: Result<libloading::Library, libloading::Error> =
48+
libloading::os::unix::Library::open(
49+
Some(renderdoc_filename),
50+
libloading::os::unix::RTLD_NOW | RTLD_NOLOAD,
51+
)
52+
.map(|lib| lib.into());
53+
54+
#[cfg(windows)]
55+
let renderdoc_result: Result<libloading::Library, libloading::Error> =
56+
libloading::os::windows::Library::open_already_loaded(renderdoc_filename)
57+
.map(|lib| lib.into());
58+
59+
let renderdoc_lib = match renderdoc_result {
4360
Ok(lib) => lib,
4461
Err(e) => {
4562
return RenderDoc::NotAvailable {

0 commit comments

Comments
 (0)