Skip to content

Commit c59bd17

Browse files
committed
Implement vulkan.rs
1 parent 5875ba0 commit c59bd17

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

unity-native-plugin-vulkan/src/vulkan.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,15 +298,21 @@ impl UnityGraphicsVulkan {
298298
}
299299
}
300300

301-
//pub fn access_queue
301+
pub unsafe fn access_queue(
302+
&self,
303+
callback: UnityRenderingEventAndData,
304+
event_id: ::std::os::raw::c_int,
305+
user_data: *mut ::std::os::raw::c_void,
306+
flush: bool,
307+
) {
308+
self.interface().AccessQueue.expect("AccessQueue")(callback, event_id, user_data, flush);
309+
}
302310

303311
pub fn config_swapchain(&self, swapchain_config: &VulkanSwapchainConfiguration) -> bool {
304312
unsafe {
305313
self.interface()
306314
.ConfigureSwapchain
307-
.expect("ConfigureSwapchain")(
308-
std::mem::transmute(swapchain_config),
309-
)
315+
.expect("ConfigureSwapchain")(std::mem::transmute(swapchain_config))
310316
}
311317
}
312318

@@ -320,7 +326,10 @@ impl UnityGraphicsVulkan {
320326
access_mode: VulkanResourceAccessMode,
321327
) -> Option<VulkanImage> {
322328
let mut ret = std::mem::zeroed::<VulkanImage>();
323-
if self.interface().AccessTextureByID.expect("AccessTextureByID")(
329+
if self
330+
.interface()
331+
.AccessTextureByID
332+
.expect("AccessTextureByID")(
324333
texture_id,
325334
match sub_resource {
326335
Some(t) => std::mem::transmute(t),

unity-native-plugin/src/graphics.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use unity_native_plugin_sys::*;
44

55
pub type RenderBuffer = unity_native_plugin_sys::UnityRenderBuffer;
66
pub type TextureID = unity_native_plugin_sys::UnityTextureID;
7+
pub type RenderingEvent = unsafe extern "system" fn(eventId: ::std::os::raw::c_int);
8+
pub type RenderingEventAndData =
9+
unsafe extern "system" fn(eventId: ::std::os::raw::c_int, data: *mut ::std::os::raw::c_void);
710

811
#[repr(u32)]
912
#[derive(Copy, Clone)]
@@ -38,7 +41,7 @@ define_unity_interface!(
3841
0x8C5AD4926EB17B11_u64
3942
);
4043

41-
pub type UnityGraphicsDeviceEventCallback = extern "system" fn(eventType: GfxDeviceEventType);
44+
pub type GraphicsDeviceEventCallback = extern "system" fn(eventType: GfxDeviceEventType);
4245

4346
impl UnityGraphics {
4447
pub fn get_renderer(&self) -> GfxRenderer {
@@ -52,7 +55,7 @@ impl UnityGraphics {
5255

5356
pub fn register_device_event_callback(
5457
&self,
55-
callback: Option<UnityGraphicsDeviceEventCallback>,
58+
callback: Option<GraphicsDeviceEventCallback>,
5659
) {
5760
unsafe {
5861
if let Some(intf) = self.interface().RegisterDeviceEventCallback {
@@ -63,7 +66,7 @@ impl UnityGraphics {
6366

6467
pub fn unregister_device_event_callback(
6568
&self,
66-
callback: Option<UnityGraphicsDeviceEventCallback>,
69+
callback: Option<GraphicsDeviceEventCallback>,
6770
) {
6871
unsafe {
6972
if let Some(intf) = self.interface().UnregisterDeviceEventCallback {

0 commit comments

Comments
 (0)