Skip to content

Commit 1e9ebfb

Browse files
committed
Use plain integers for Vulkan handle types in auto-generated bindings
1 parent a78828e commit 1e9ebfb

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

sdl2-sys/sdl_bindings.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -29283,13 +29283,11 @@ extern "C" {
2928329283
pub struct VkInstance_T {
2928429284
_unused: [u8; 0],
2928529285
}
29286-
pub type VkInstance = *mut VkInstance_T;
2928729286
#[repr(C)]
2928829287
#[derive(Debug, Copy, Clone)]
2928929288
pub struct VkSurfaceKHR_T {
2929029289
_unused: [u8; 0],
2929129290
}
29292-
pub type VkSurfaceKHR = *mut VkSurfaceKHR_T;
2929329291
pub type SDL_vulkanInstance = VkInstance;
2929429292
pub type SDL_vulkanSurface = VkSurfaceKHR;
2929529293
extern "C" {
@@ -29488,6 +29486,10 @@ extern "C" {
2948829486
h: *mut ::std::os::raw::c_int,
2948929487
);
2949029488
}
29489+
/// <div rustbindgen replaces="VkInstance"></div>
29490+
pub type VkInstance = usize;
29491+
/// <div rustbindgen replaces="VkSurfaceKHR"></div>
29492+
pub type VkSurfaceKHR = u64;
2949129493
pub type __builtin_va_list = [__va_list_tag; 1usize];
2949229494
#[repr(C)]
2949329495
#[derive(Debug, Copy, Clone)]

sdl2-sys/wrapper.h

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
#include <SDL.h>
22
#include <SDL_syswm.h>
33
#include <SDL_vulkan.h>
4+
5+
/**
6+
* <div rustbindgen replaces="VkInstance"></div>
7+
*/
8+
typedef uintptr_t VkInstance_int;
9+
10+
/**
11+
* <div rustbindgen replaces="VkSurfaceKHR"></div>
12+
*/
13+
typedef uint64_t VkSurfaceKHR_int;

src/sdl2/video.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ use get_error;
1818

1919
use sys;
2020

21+
pub use sys::{VkInstance, VkSurfaceKHR};
2122

22-
type VkInstance = usize;
23-
type VkSurfaceKHR = u64;
2423

2524
pub struct WindowSurfaceRef<'a>(&'a mut SurfaceRef, &'a Window);
2625

@@ -1147,11 +1146,11 @@ impl Window {
11471146
/// [`vkCreateInstance`](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateInstance.html)
11481147
/// function in the Vulkan library.
11491148
pub fn vulkan_create_surface(&self, instance: VkInstance) -> Result<VkSurfaceKHR, String> {
1150-
let mut surface: sys::VkSurfaceKHR = ptr::null_mut();
1151-
if unsafe { sys::SDL_Vulkan_CreateSurface(self.context.raw, instance as *mut _, &mut surface) } == sys::SDL_bool::SDL_FALSE {
1149+
let mut surface: VkSurfaceKHR = 0;
1150+
if unsafe { sys::SDL_Vulkan_CreateSurface(self.context.raw, instance, &mut surface) } == sys::SDL_bool::SDL_FALSE {
11521151
Err(get_error())
11531152
} else {
1154-
Ok(surface as VkSurfaceKHR)
1153+
Ok(surface)
11551154
}
11561155
}
11571156

0 commit comments

Comments
 (0)