Xlib loader
This commit is contained in:
parent
601f5573cf
commit
b83e6802c5
|
@ -19,10 +19,32 @@ pub struct Instance {
|
||||||
pub instance_fn: vk::InstanceFn,
|
pub instance_fn: vk::InstanceFn,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct XlibSurface {
|
||||||
|
pub handle: vk::Instance,
|
||||||
|
pub xlib_surface_fn: vk::XlibSurfaceFn,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl XlibSurface {
|
||||||
|
pub fn create_xlib_surface_khr(&self,
|
||||||
|
create_info: &vk::XlibSurfaceCreateInfoKHR)
|
||||||
|
-> VkResult<vk::SurfaceKHR> {
|
||||||
|
unsafe {
|
||||||
|
let mut surface = mem::uninitialized();
|
||||||
|
let err_code = self.xlib_surface_fn
|
||||||
|
.create_xlib_surface_khr(self.handle, create_info, ptr::null(), &mut surface);
|
||||||
|
match err_code {
|
||||||
|
vk::Result::Success => Ok(surface),
|
||||||
|
_ => Err(err_code),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Surface {
|
pub struct Surface {
|
||||||
pub handle: vk::Instance,
|
pub handle: vk::Instance,
|
||||||
pub surface_fn: vk::SurfaceFn,
|
pub surface_fn: vk::SurfaceFn,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Surface {
|
impl Surface {
|
||||||
pub fn get_physical_device_surface_support_khr(&self,
|
pub fn get_physical_device_surface_support_khr(&self,
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
|
@ -112,6 +134,19 @@ impl Surface {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Instance {
|
impl Instance {
|
||||||
|
pub fn load_xlib_surface(&self, entry: &Entry) -> XlibSurface {
|
||||||
|
let surface_fn = vk::XlibSurfaceFn::load(|name| {
|
||||||
|
unsafe {
|
||||||
|
mem::transmute(entry.static_fn
|
||||||
|
.get_instance_proc_addr(self.handle, name.as_ptr()))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
XlibSurface {
|
||||||
|
handle: self.handle,
|
||||||
|
xlib_surface_fn: surface_fn,
|
||||||
|
}
|
||||||
|
}
|
||||||
pub fn load_surface(&self, entry: &Entry) -> Surface {
|
pub fn load_surface(&self, entry: &Entry) -> Surface {
|
||||||
let surface_fn = vk::SurfaceFn::load(|name| {
|
let surface_fn = vk::SurfaceFn::load(|name| {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -201,22 +236,6 @@ impl Instance {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_xlib_surface_khr(&self,
|
|
||||||
create_info: &vk::XlibSurfaceCreateInfoKHR)
|
|
||||||
-> VkResult<vk::SurfaceKHR> {
|
|
||||||
unsafe {
|
|
||||||
let mut surface = mem::uninitialized();
|
|
||||||
let err_code = self.instance_fn
|
|
||||||
.create_xlib_surface_khr(self.handle, create_info, ptr::null(), &mut surface);
|
|
||||||
match err_code {
|
|
||||||
vk::Result::Success => Ok(surface),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
pub fn get_physical_device_queue_family_properties(&self,
|
pub fn get_physical_device_queue_family_properties(&self,
|
||||||
physical_device: vk::PhysicalDevice)
|
physical_device: vk::PhysicalDevice)
|
||||||
-> Vec<vk::QueueFamilyProperties> {
|
-> Vec<vk::QueueFamilyProperties> {
|
||||||
|
|
16
src/vk.rs
16
src/vk.rs
|
@ -3839,13 +3839,6 @@ vk_functions!{
|
||||||
visual_id: VisualID,
|
visual_id: VisualID,
|
||||||
) -> Bool32;
|
) -> Bool32;
|
||||||
|
|
||||||
"vkCreateXlibSurfaceKHR", create_xlib_surface_khr(
|
|
||||||
instance: Instance,
|
|
||||||
p_create_info: *const XlibSurfaceCreateInfoKHR,
|
|
||||||
p_allocator: *const AllocationCallbacks,
|
|
||||||
p_surface: *mut SurfaceKHR,
|
|
||||||
) -> Result;
|
|
||||||
|
|
||||||
"vkCreateXcbSurfaceKHR", create_xcb_surface_khr(
|
"vkCreateXcbSurfaceKHR", create_xcb_surface_khr(
|
||||||
instance: Instance,
|
instance: Instance,
|
||||||
p_create_info: *const XcbSurfaceCreateInfoKHR,
|
p_create_info: *const XcbSurfaceCreateInfoKHR,
|
||||||
|
@ -4890,4 +4883,13 @@ vk_functions!{
|
||||||
p_present_modes: *mut PresentModeKHR,
|
p_present_modes: *mut PresentModeKHR,
|
||||||
) -> Result;
|
) -> Result;
|
||||||
}
|
}
|
||||||
|
vk_functions!{
|
||||||
|
XlibSurfaceFn,
|
||||||
|
"vkCreateXlibSurfaceKHR", create_xlib_surface_khr(
|
||||||
|
instance: Instance,
|
||||||
|
p_create_info: *const XlibSurfaceCreateInfoKHR,
|
||||||
|
p_allocator: *const AllocationCallbacks,
|
||||||
|
p_surface: *mut SurfaceKHR,
|
||||||
|
) -> Result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue