Skip to content

Commit 5bdd906

Browse files
committed
Add enumerate_layer_extensions
For enumerating extensions supported by an API layer.
1 parent 27f9aee commit 5bdd906

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

openxr/src/entry.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,29 @@ impl Entry {
300300
.collect())
301301
}
302302
}
303+
304+
/// Determine the set of extensions supported by a given OpenXR API layer
305+
pub fn enumerate_layer_extensions(&self, api_layers: &str) -> Result<ExtensionSet> {
306+
let c_str = CString::new(api_layers).map_err(|_| sys::Result::ERROR_NAME_INVALID)?;
307+
unsafe {
308+
let exts = get_arr_init(
309+
sys::ExtensionProperties::out(ptr::null_mut()),
310+
|cap, count, buf| {
311+
(self.fp().enumerate_instance_extension_properties)(
312+
c_str.as_ptr(),
313+
cap,
314+
count,
315+
buf as _,
316+
)
317+
},
318+
)?;
319+
// https://github.com/rust-lang/rust/issues/63569
320+
Ok(ExtensionSet::from(mem::transmute::<
321+
&[std::mem::MaybeUninit<sys::ExtensionProperties>],
322+
&[sys::ExtensionProperties],
323+
>(&exts[..])))
324+
}
325+
}
303326
}
304327

305328
#[inline]

0 commit comments

Comments
 (0)