Skip to content

Commit 88e2159

Browse files
committed
Split Globals into Globals and GlobalsWasm to account for alignment differences
1 parent 5606893 commit 88e2159

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/mesh_view/globals.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
pub trait WasmPadding {}
2-
3-
/// No WASM padding
4-
impl WasmPadding for () {}
5-
6-
/// Single float WASM padding
7-
impl WasmPadding for f32 {}
1+
#[repr(C)]
2+
pub struct Globals {
3+
// The time since startup in seconds
4+
// Wraps to 0 after 1 hour.
5+
pub time: f32,
6+
// The delta time since the previous frame in seconds
7+
pub delta_time: f32,
8+
// Frame count since the start of the app.
9+
// It wraps to zero when it reaches the maximum value of a u32.
10+
pub frame_count: u32,
11+
}
812

913
#[repr(C)]
10-
pub struct Globals<P: WasmPadding = ()> {
14+
pub struct GlobalsWasm {
1115
// The time since startup in seconds
1216
// Wraps to 0 after 1 hour.
1317
pub time: f32,
@@ -18,5 +22,5 @@ pub struct Globals<P: WasmPadding = ()> {
1822
pub frame_count: u32,
1923

2024
// WebGL2 structs must be 16 byte aligned.
21-
_wasm_padding: P,
25+
_wasm_padding: f32,
2226
}

0 commit comments

Comments
 (0)