mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
[wgpu-hal] add null terminations to symbols to avoid reallocation
This commit is contained in:
parent
9d24888848
commit
595ae7cb47
@ -62,7 +62,7 @@ impl PresentationTimer {
|
||||
let kernelbase =
|
||||
libloading::os::windows::Library::open_already_loaded("kernelbase.dll").unwrap();
|
||||
// No concerns about lifetimes here as kernelbase is always there.
|
||||
let ptr = unsafe { kernelbase.get(b"QueryInterruptTimePrecise").unwrap() };
|
||||
let ptr = unsafe { kernelbase.get(b"QueryInterruptTimePrecise\0").unwrap() };
|
||||
Self::IPresentationManager {
|
||||
fnQueryInterruptTimePrecise: *ptr,
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ impl D3D12Lib {
|
||||
riid: *const windows_core::GUID,
|
||||
ppdevice: *mut *mut core::ffi::c_void,
|
||||
) -> windows_core::HRESULT;
|
||||
let func: libloading::Symbol<Fun> = unsafe { self.lib.get(b"D3D12CreateDevice") }?;
|
||||
let func: libloading::Symbol<Fun> = unsafe { self.lib.get(b"D3D12CreateDevice\0") }?;
|
||||
|
||||
let mut result__ = None;
|
||||
|
||||
@ -148,7 +148,7 @@ impl D3D12Lib {
|
||||
pperrorblob: *mut *mut core::ffi::c_void,
|
||||
) -> windows_core::HRESULT;
|
||||
let func: libloading::Symbol<Fun> =
|
||||
unsafe { self.lib.get(b"D3D12SerializeRootSignature") }?;
|
||||
unsafe { self.lib.get(b"D3D12SerializeRootSignature\0") }?;
|
||||
|
||||
let desc = Direct3D12::D3D12_ROOT_SIGNATURE_DESC {
|
||||
NumParameters: parameters.len() as _,
|
||||
@ -187,7 +187,7 @@ impl D3D12Lib {
|
||||
riid: *const windows_core::GUID,
|
||||
ppvdebug: *mut *mut core::ffi::c_void,
|
||||
) -> windows_core::HRESULT;
|
||||
let func: libloading::Symbol<Fun> = unsafe { self.lib.get(b"D3D12GetDebugInterface") }?;
|
||||
let func: libloading::Symbol<Fun> = unsafe { self.lib.get(b"D3D12GetDebugInterface\0") }?;
|
||||
|
||||
let mut result__ = None;
|
||||
|
||||
@ -217,7 +217,7 @@ impl DxgiLib {
|
||||
riid: *const windows_core::GUID,
|
||||
pdebug: *mut *mut core::ffi::c_void,
|
||||
) -> windows_core::HRESULT;
|
||||
let func: libloading::Symbol<Fun> = unsafe { self.lib.get(b"DXGIGetDebugInterface1") }?;
|
||||
let func: libloading::Symbol<Fun> = unsafe { self.lib.get(b"DXGIGetDebugInterface1\0") }?;
|
||||
|
||||
let mut result__ = None;
|
||||
|
||||
@ -239,7 +239,7 @@ impl DxgiLib {
|
||||
riid: *const windows_core::GUID,
|
||||
ppfactory: *mut *mut core::ffi::c_void,
|
||||
) -> windows_core::HRESULT;
|
||||
let func: libloading::Symbol<Fun> = unsafe { self.lib.get(b"CreateDXGIFactory2") }?;
|
||||
let func: libloading::Symbol<Fun> = unsafe { self.lib.get(b"CreateDXGIFactory2\0") }?;
|
||||
|
||||
let mut result__ = None;
|
||||
|
||||
@ -261,7 +261,7 @@ impl DxgiLib {
|
||||
riid: *const windows_core::GUID,
|
||||
ppfactory: *mut *mut core::ffi::c_void,
|
||||
) -> windows_core::HRESULT;
|
||||
let func: libloading::Symbol<Fun> = unsafe { self.lib.get(b"CreateDXGIFactory1") }?;
|
||||
let func: libloading::Symbol<Fun> = unsafe { self.lib.get(b"CreateDXGIFactory1\0") }?;
|
||||
|
||||
let mut result__ = None;
|
||||
|
||||
|
@ -143,7 +143,7 @@ impl Drop for DisplayOwner {
|
||||
match self.display {
|
||||
DisplayRef::X11(ptr) => unsafe {
|
||||
let func: libloading::Symbol<XCloseDisplayFun> =
|
||||
self.library.get(b"XCloseDisplay").unwrap();
|
||||
self.library.get(b"XCloseDisplay\0").unwrap();
|
||||
func(ptr.as_ptr());
|
||||
},
|
||||
DisplayRef::Wayland => {}
|
||||
@ -155,7 +155,7 @@ fn open_x_display() -> Option<DisplayOwner> {
|
||||
log::debug!("Loading X11 library to get the current display");
|
||||
unsafe {
|
||||
let library = find_library(&["libX11.so.6", "libX11.so"])?;
|
||||
let func: libloading::Symbol<XOpenDisplayFun> = library.get(b"XOpenDisplay").unwrap();
|
||||
let func: libloading::Symbol<XOpenDisplayFun> = library.get(b"XOpenDisplay\0").unwrap();
|
||||
let result = func(ptr::null());
|
||||
ptr::NonNull::new(result).map(|ptr| DisplayOwner {
|
||||
display: DisplayRef::X11(ptr),
|
||||
@ -182,9 +182,9 @@ fn test_wayland_display() -> Option<DisplayOwner> {
|
||||
let library = unsafe {
|
||||
let client_library = find_library(&["libwayland-client.so.0", "libwayland-client.so"])?;
|
||||
let wl_display_connect: libloading::Symbol<WlDisplayConnectFun> =
|
||||
client_library.get(b"wl_display_connect").unwrap();
|
||||
client_library.get(b"wl_display_connect\0").unwrap();
|
||||
let wl_display_disconnect: libloading::Symbol<WlDisplayDisconnectFun> =
|
||||
client_library.get(b"wl_display_disconnect").unwrap();
|
||||
client_library.get(b"wl_display_disconnect\0").unwrap();
|
||||
let display = ptr::NonNull::new(wl_display_connect(ptr::null()))?;
|
||||
wl_display_disconnect(display.as_ptr());
|
||||
find_library(&["libwayland-egl.so.1", "libwayland-egl.so"])?
|
||||
@ -1294,7 +1294,7 @@ impl crate::Surface for Surface {
|
||||
(WindowKind::Wayland, Rwh::Wayland(handle)) => {
|
||||
let library = &self.wsi.display_owner.as_ref().unwrap().library;
|
||||
let wl_egl_window_create: libloading::Symbol<WlEglWindowCreateFun> =
|
||||
unsafe { library.get(b"wl_egl_window_create") }.unwrap();
|
||||
unsafe { library.get(b"wl_egl_window_create\0") }.unwrap();
|
||||
let window =
|
||||
unsafe { wl_egl_window_create(handle.surface.as_ptr(), 640, 480) }
|
||||
.cast();
|
||||
@ -1403,7 +1403,7 @@ impl crate::Surface for Surface {
|
||||
if let Some(window) = wl_window {
|
||||
let library = &self.wsi.display_owner.as_ref().unwrap().library;
|
||||
let wl_egl_window_resize: libloading::Symbol<WlEglWindowResizeFun> =
|
||||
unsafe { library.get(b"wl_egl_window_resize") }.unwrap();
|
||||
unsafe { library.get(b"wl_egl_window_resize\0") }.unwrap();
|
||||
unsafe {
|
||||
wl_egl_window_resize(
|
||||
window,
|
||||
@ -1475,7 +1475,7 @@ impl crate::Surface for Surface {
|
||||
.expect("unsupported window")
|
||||
.library;
|
||||
let wl_egl_window_destroy: libloading::Symbol<WlEglWindowDestroyFun> =
|
||||
unsafe { library.get(b"wl_egl_window_destroy") }.unwrap();
|
||||
unsafe { library.get(b"wl_egl_window_destroy\0") }.unwrap();
|
||||
unsafe { wl_egl_window_destroy(window) };
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user