Skip to content

Commit 4ce1d58

Browse files
authored
Merge pull request #9 from aosoft/aosoft/#7
Add new interfaces
2 parents 84f4cd6 + f2d716e commit 4ce1d58

File tree

17 files changed

+28889
-13867
lines changed

17 files changed

+28889
-13867
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "unity-native-plugin-sample-profiler"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
authors = ["Yasuhiro Taniuchi"]
55
edition = "2018"
66
publish = false
@@ -11,8 +11,8 @@ crate-type = ["cdylib"]
1111
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1212

1313
[dependencies]
14-
unity-native-plugin = { version = "0.5.0", path = "../unity-native-plugin", features = ["profiler_callbacks"] }
15-
unity-native-plugin-sys = { version = "0.5.0", path = "../unity-native-plugin-sys" }
14+
unity-native-plugin = { version = "0.6.0", path = "../unity-native-plugin", features = ["profiler_callbacks"] }
15+
unity-native-plugin-sys = { version = "0.6.0", path = "../unity-native-plugin-sys" }
1616
log = "0.4"
1717
env_logger = "0.8"
1818
flume = "0.10"

unity-native-plugin-sample/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "unity-native-plugin-sample"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
authors = ["Yasuhiro Taniuchi"]
55
edition = "2018"
66
publish = false
@@ -11,10 +11,10 @@ crate-type = ["cdylib"]
1111
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1212

1313
[dependencies]
14-
unity-native-plugin = { version = "0.5.0", path = "../unity-native-plugin", features = ["d3d11", "d3d12", "profiler"] }
15-
unity-native-plugin-vulkan = { version = "0.5.0", path = "../unity-native-plugin-vulkan" }
14+
unity-native-plugin = { version = "0.6.0", path = "../unity-native-plugin", features = ["d3d11", "d3d12", "profiler"] }
15+
unity-native-plugin-vulkan = { version = "0.6.0", path = "../unity-native-plugin-vulkan" }
1616
winapi = { version = "0.3.9", features = ["winuser", "d3d11", "dxgiformat"] }
1717
wio = "0.2.2"
1818

1919
[dev-dependencies]
20-
unity-native-plugin-tester = { version = "0.5.0", path = "../unity-native-plugin-tester", features = ["d3d11"] }
20+
unity-native-plugin-tester = { version = "0.6.0", path = "../unity-native-plugin-tester", features = ["d3d11"] }

unity-native-plugin-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "unity-native-plugin-sys"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
authors = ["Yasuhiro Taniuchi"]
55
edition = "2018"
66
license = "MIT"

unity-native-plugin-sys/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
unity-native-plugin-rs
22
====
33

4-
* based on Unity 6000.0.5f1
5-
* Vulkan SDK 1.3.268.1
4+
* based on Unity 6000.0.10f1
5+
* Vulkan SDK 1.3.283.0
66
* bindgen 0.69.4
7-
* clang version 10.0.0-4ubuntu1
7+
* clang version 14.0.0-1ubuntu1.1

unity-native-plugin-sys/src/plugin_api.rs

Lines changed: 28697 additions & 13806 deletions
Large diffs are not rendered by default.

unity-native-plugin-sys/wrapper.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ struct ID3D12CommandQueue {};
3636
#include <IUnityProfilerCallbacks.h>
3737

3838
#include <IUnityMemoryManager.h>
39-
Assert(bool);
39+
40+
#define Assert(x)
41+
4042
#include <IUnityEventQueue.h>
4143
#include <IUnityLog.h>

unity-native-plugin-tester/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "unity-native-plugin-tester"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
authors = ["Yasuhiro Taniuchi"]
55
edition = "2018"
66
license = "MIT"
@@ -25,8 +25,8 @@ d3d11 = []
2525
d3d12 = []
2626

2727
[dependencies]
28-
unity-native-plugin-sys = { version = "0.5.0", path = "../unity-native-plugin-sys" }
29-
unity-native-plugin = { version = "0.5.0", path = "../unity-native-plugin", features = ["d3d11", "d3d12"] }
28+
unity-native-plugin-sys = { version = "0.6.0", path = "../unity-native-plugin-sys" }
29+
unity-native-plugin = { version = "0.6.0", path = "../unity-native-plugin", features = ["d3d11", "d3d12"] }
3030
winapi = { version = "0.3.9", features = ["winuser", "dxgi", "d3d11", "dxgiformat", "dxgitype", "d3dcommon"] }
3131
winit = "0.23.0"
3232
wio = "0.2.2"

unity-native-plugin-vulkan/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "unity-native-plugin-vulkan"
3-
version = "0.5.1"
3+
version = "0.6.0"
44
authors = ["Yasuhiro Taniuchi"]
55
license = "MIT"
66
description = "Unity Native Plugin API (Vulkan) for Rust"
@@ -19,6 +19,6 @@ include = [
1919
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
2020

2121
[dependencies]
22-
unity-native-plugin = { version = "0.5.0", path = "../unity-native-plugin" }
23-
unity-native-plugin-sys = { version = "0.5.0", path = "../unity-native-plugin-sys" }
24-
ash = "0.33.1"
22+
unity-native-plugin = { version = "0.6.0", path = "../unity-native-plugin" }
23+
unity-native-plugin-sys = { version = "0.6.0", path = "../unity-native-plugin-sys" }
24+
ash = "0.38.0+1.3.281.1"

unity-native-plugin/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "unity-native-plugin"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
authors = ["Yasuhiro Taniuchi"]
55
license = "MIT"
66
description = "Unity Native Plugin API for Rust"
@@ -26,4 +26,4 @@ profiler = []
2626
profiler_callbacks = ["profiler"]
2727

2828
[dependencies]
29-
unity-native-plugin-sys = { version = "0.5.0", path = "../unity-native-plugin-sys" }
29+
unity-native-plugin-sys = { version = "0.6.0", path = "../unity-native-plugin-sys" }

unity-native-plugin/src/d3d11.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,24 @@ impl UnityGraphicsD3D11 {
3939
.SRVFromNativeTexture
4040
.expect("SRVFromNativeTexture")(texture) as ComPtr
4141
}
42+
43+
pub unsafe fn swap_chain(&self) -> ComPtr {
44+
self.interface().GetSwapChain.expect("GetSwapChain")() as ComPtr
45+
}
46+
47+
pub fn sync_interval(&self) -> u32 {
48+
unsafe {
49+
self.interface()
50+
.GetSyncInterval
51+
.expect("GetSyncInterval")()
52+
}
53+
}
54+
55+
pub fn present_flags(&self) -> u32 {
56+
unsafe {
57+
self.interface()
58+
.GetPresentFlags
59+
.expect("GetPresentFlags")()
60+
}
61+
}
4262
}

unity-native-plugin/src/d3d12.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl UnityGraphicsD3D12 {
2929
unsafe {
3030
self.interface()
3131
.GetNextFrameFenceValue
32-
.expect("GetNextFrameFenceValue")()
32+
.expect("GetNextFrameFenceValue")() as u64
3333
}
3434
}
3535

@@ -79,7 +79,7 @@ impl UnityGraphicsD3D12v2 {
7979
unsafe {
8080
self.interface()
8181
.GetNextFrameFenceValue
82-
.expect("GetNextFrameFenceValue")()
82+
.expect("GetNextFrameFenceValue")() as u64
8383
}
8484
}
8585

@@ -94,7 +94,7 @@ impl UnityGraphicsD3D12v2 {
9494
command_list as *mut ID3D12GraphicsCommandList,
9595
states.len() as ::std::os::raw::c_int,
9696
states.as_ptr() as *mut UnityGraphicsD3D12ResourceState,
97-
)
97+
) as u64
9898
}
9999
}
100100

@@ -120,7 +120,7 @@ impl UnityGraphicsD3D12v3 {
120120
unsafe {
121121
self.interface()
122122
.GetNextFrameFenceValue
123-
.expect("GetNextFrameFenceValue")()
123+
.expect("GetNextFrameFenceValue")() as u64
124124
}
125125
}
126126

@@ -135,7 +135,7 @@ impl UnityGraphicsD3D12v3 {
135135
command_list as *mut ID3D12GraphicsCommandList,
136136
states.len() as ::std::os::raw::c_int,
137137
states.as_ptr() as *mut UnityGraphicsD3D12ResourceState,
138-
)
138+
) as u64
139139
}
140140

141141
pub fn set_physical_video_memory_control_values(
@@ -172,7 +172,7 @@ impl UnityGraphicsD3D12v4 {
172172
unsafe {
173173
self.interface()
174174
.GetNextFrameFenceValue
175-
.expect("GetNextFrameFenceValue")()
175+
.expect("GetNextFrameFenceValue")() as u64
176176
}
177177
}
178178

@@ -187,7 +187,7 @@ impl UnityGraphicsD3D12v4 {
187187
command_list as *mut ID3D12GraphicsCommandList,
188188
states.len() as ::std::os::raw::c_int,
189189
states.as_ptr() as *mut UnityGraphicsD3D12ResourceState,
190-
)
190+
) as u64
191191
}
192192

193193
pub fn set_physical_video_memory_control_values(
@@ -228,7 +228,7 @@ impl UnityGraphicsD3D12v5 {
228228
unsafe {
229229
self.interface()
230230
.GetNextFrameFenceValue
231-
.expect("GetNextFrameFenceValue")()
231+
.expect("GetNextFrameFenceValue")() as u64
232232
}
233233
}
234234

@@ -243,7 +243,7 @@ impl UnityGraphicsD3D12v5 {
243243
command_list as *mut ID3D12GraphicsCommandList,
244244
states.len() as ::std::os::raw::c_int,
245245
states.as_ptr() as *mut UnityGraphicsD3D12ResourceState,
246-
)
246+
) as u64
247247
}
248248

249249
pub fn set_physical_video_memory_control_values(

unity-native-plugin/src/enums.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,5 @@
11
use unity_native_plugin_sys::*;
22

3-
#[repr(u16)]
4-
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
5-
pub enum ProfilerMarkerFlag {
6-
ScriptEnterLeave = UnityProfilerMarkerFlag__kUnityProfilerMarkerFlagScriptEnterLeave as u16,
7-
AvailabilityEditor = UnityProfilerMarkerFlag__kUnityProfilerMarkerFlagAvailabilityEditor as u16,
8-
AvailabilityNonDev = UnityProfilerMarkerFlag__kUnityProfilerMarkerFlagAvailabilityNonDev as u16,
9-
Warning = UnityProfilerMarkerFlag__kUnityProfilerMarkerFlagWarning as u16,
10-
VerbosityDebug = UnityProfilerMarkerFlag__kUnityProfilerMarkerFlagVerbosityDebug as u16,
11-
VerbosityInternal = UnityProfilerMarkerFlag__kUnityProfilerMarkerFlagVerbosityInternal as u16,
12-
VerbosityAdvanced = UnityProfilerMarkerFlag__kUnityProfilerMarkerFlagVerbosityAdvanced as u16,
13-
}
14-
15-
#[allow(dead_code)]
16-
pub struct ProfilerMarkerFlags(u16);
17-
18-
#[repr(u8)]
19-
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
20-
pub enum ProfilerMarkerDataType {
21-
None = UnityProfilerMarkerDataType__kUnityProfilerMarkerDataTypeNone as u8,
22-
InstanceId = UnityProfilerMarkerDataType__kUnityProfilerMarkerDataTypeInstanceId as u8,
23-
Int32 = UnityProfilerMarkerDataType__kUnityProfilerMarkerDataTypeInt32 as u8,
24-
UInt32 = UnityProfilerMarkerDataType__kUnityProfilerMarkerDataTypeUInt32 as u8,
25-
Int64 = UnityProfilerMarkerDataType__kUnityProfilerMarkerDataTypeInt64 as u8,
26-
UInt64 = UnityProfilerMarkerDataType__kUnityProfilerMarkerDataTypeUInt64 as u8,
27-
Float = UnityProfilerMarkerDataType__kUnityProfilerMarkerDataTypeFloat as u8,
28-
Double = UnityProfilerMarkerDataType__kUnityProfilerMarkerDataTypeDouble as u8,
29-
String = UnityProfilerMarkerDataType__kUnityProfilerMarkerDataTypeString as u8,
30-
String16 = UnityProfilerMarkerDataType__kUnityProfilerMarkerDataTypeString16 as u8,
31-
Blob8 = UnityProfilerMarkerDataType__kUnityProfilerMarkerDataTypeBlob8 as u8,
32-
}
33-
343
#[repr(u32)]
354
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
365
pub enum RenderingExtEventType {

unity-native-plugin/src/graphics.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub type RenderingEventAndData = unity_native_plugin_sys::UnityRenderingEventAnd
1212
pub enum GfxRenderer {
1313
D3D11 = UnityGfxRenderer_kUnityGfxRendererD3D11,
1414
Null = UnityGfxRenderer_kUnityGfxRendererNull,
15+
OpenGLES20 = 8, // OpenGL ES 2.0, removed
1516
OpenGLES30 = UnityGfxRenderer_kUnityGfxRendererOpenGLES30,
1617
PS4 = UnityGfxRenderer_kUnityGfxRendererPS4,
1718
XboxOne = UnityGfxRenderer_kUnityGfxRendererXboxOne,
@@ -21,6 +22,11 @@ pub enum GfxRenderer {
2122
Vulkan = UnityGfxRenderer_kUnityGfxRendererVulkan,
2223
Nvn = UnityGfxRenderer_kUnityGfxRendererNvn,
2324
XboxOneD3D12 = UnityGfxRenderer_kUnityGfxRendererXboxOneD3D12,
25+
GameCoreXboxOne = UnityGfxRenderer_kUnityGfxRendererGameCoreXboxOne,
26+
GameCoreXboxSeries = UnityGfxRenderer_kUnityGfxRendererGameCoreXboxSeries,
27+
PS5 = UnityGfxRenderer_kUnityGfxRendererPS5,
28+
PS5NGGC = UnityGfxRenderer_kUnityGfxRendererPS5NGGC,
29+
ReservedCFE = UnityGfxRenderer_kUnityGfxRendererReservedCFE,
2430
}
2531

2632
#[repr(u32)]

unity-native-plugin/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ pub mod profiler_callbacks;
1313
pub mod enums;
1414
pub mod graphics;
1515
pub mod interface;
16+
pub mod log;
17+
pub mod memory_manager;
18+
1619
pub type IUnityInterfaces = unity_native_plugin_sys::IUnityInterfaces;
1720

1821
#[macro_export]

unity-native-plugin/src/log.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use crate::define_unity_interface;
2+
use crate::interface::UnityInterface;
3+
use std::ffi::CStr;
4+
use unity_native_plugin_sys::*;
5+
6+
#[repr(u32)]
7+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
8+
pub enum LogType
9+
{
10+
Error = UnityLogType_kUnityLogTypeError,
11+
Warning = UnityLogType_kUnityLogTypeWarning,
12+
Log = UnityLogType_kUnityLogTypeLog,
13+
Exception = UnityLogType_kUnityLogTypeException,
14+
}
15+
16+
define_unity_interface!(
17+
UnityLog,
18+
IUnityLog,
19+
0x9E7507fA5B444D5D_u64,
20+
0x92FB979515EA83FC_u64
21+
);
22+
23+
impl UnityLog {
24+
pub fn log(&self, log_type: LogType, message: &CStr, file_name: &CStr, file_line: i32) {
25+
unsafe {
26+
self.interface().Log.expect("Log")(log_type as UnityLogType, message.as_ptr(), file_name.as_ptr(), file_line);
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)