Skip to content

Commit da94465

Browse files
fix: temp disable XP SIMD until crash resolved (#611)
1 parent ce69550 commit da94465

File tree

5 files changed

+36
-49
lines changed

5 files changed

+36
-49
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,6 @@ version = '0.10.6'
204204
[workspace.dependencies.sha2]
205205
version = '0.10.8'
206206

207-
[workspace.dependencies.simd-utils]
208-
path = 'crates/simd-utils'
209-
210207
[workspace.dependencies.tokio-util]
211208
features = ['full']
212209
version = '0.7.12'

crates/hyperion/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ anyhow = {workspace = true}
2323
base64 = {workspace = true}
2424
geometry = {workspace = true}
2525
bitfield-struct = {workspace = true}
26-
simd-utils = {workspace = true}
2726
bitvec = {workspace = true}
2827
papaya = {workspace = true}
2928
bumpalo = {workspace = true}

crates/hyperion/src/egress/sync_entity_state.rs

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ impl Module for EntityStateSyncModule {
5656
const _: () = assert!(size_of::<Xp>() == size_of::<u16>());
5757
const _: () = assert!(align_of::<Xp>() == align_of::<u16>());
5858

59-
/// Number of lanes in the SIMD vector
60-
const LANES: usize = 64; // up to AVX512
61-
6259
let compose = table.field_unchecked::<Compose>(0);
6360
let compose = compose.first().unwrap();
6461

@@ -70,41 +67,39 @@ impl Module for EntityStateSyncModule {
7067
let prev_xp: &mut [u16] =
7168
core::slice::from_raw_parts_mut(prev_xp.as_mut_ptr().cast(), count);
7269

73-
debug_assert_eq!(
74-
prev_xp.as_ptr() as usize & 63,
75-
0,
76-
"prev_xp is not 64-byte aligned"
77-
);
70+
// debug_assert_eq!(
71+
// prev_xp.as_ptr() as usize & 63,
72+
// 0,
73+
// "prev_xp is not 64-byte aligned"
74+
// );
7875

7976
let mut xp = table.field_unchecked::<Xp>(3);
8077
let xp = xp.get_mut(..).unwrap();
8178
let xp: &mut [u16] =
8279
core::slice::from_raw_parts_mut(xp.as_mut_ptr().cast(), count);
8380

84-
debug_assert_eq!(xp.as_ptr() as usize & 63, 0, "xp is not 64-byte aligned");
81+
// debug_assert_eq!(xp.as_ptr() as usize & 63, 0, "xp is not 64-byte aligned");
8582

86-
simd_utils::copy_and_get_diff::<_, LANES>(
87-
prev_xp,
88-
xp,
89-
|idx, prev, current| {
90-
debug_assert!(prev != current);
83+
for (idx, (prev, current)) in itertools::zip_eq(prev_xp, xp).enumerate() {
84+
if prev != current {
85+
continue;
86+
}
9187

92-
let net = net.get(idx).unwrap();
88+
let net = net.get(idx).unwrap();
9389

94-
let current = Xp::from(*current);
95-
let visual = current.get_visual();
90+
let current = Xp::from(*current);
91+
let visual = current.get_visual();
9692

97-
let packet = play::ExperienceBarUpdateS2c {
98-
bar: visual.prop,
99-
level: VarInt(i32::from(visual.level)),
100-
total_xp: VarInt::default(),
101-
};
93+
let packet = play::ExperienceBarUpdateS2c {
94+
bar: visual.prop,
95+
level: VarInt(i32::from(visual.level)),
96+
total_xp: VarInt::default(),
97+
};
10298

103-
compose
104-
.unicast(&packet, *net, SystemId(100), &world)
105-
.unwrap();
106-
},
107-
);
99+
compose
100+
.unicast(&packet, *net, SystemId(100), &world)
101+
.unwrap();
102+
}
108103
}
109104
}
110105
});

crates/hyperion/src/lib.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ use std::{
3838
use anyhow::{Context, bail};
3939
use derive_more::{Deref, DerefMut};
4040
use egress::EgressModule;
41-
use flecs_ecs::{
42-
prelude::*,
43-
sys::{ecs_os_get_api, ecs_os_set_api, ecs_os_set_api_defaults},
44-
};
41+
use flecs_ecs::prelude::*;
4542
pub use glam;
4643
use glam::IVec2;
4744
use ingress::IngressModule;
@@ -202,19 +199,19 @@ impl Hyperion {
202199
.map_err(|_| anyhow::anyhow!("failed to create compression level"))?,
203200
});
204201

205-
unsafe {
206-
ecs_os_set_api_defaults();
207-
let mut os_api = ecs_os_get_api();
208-
209-
let (malloc, calloc, realloc, free) = alloc::setup_custom_allocators();
210-
211-
os_api.malloc_ = malloc;
212-
os_api.calloc_ = calloc;
213-
os_api.realloc_ = realloc;
214-
os_api.free_ = free;
215-
216-
ecs_os_set_api(&mut os_api);
217-
}
202+
// unsafe {
203+
// ecs_os_set_api_defaults();
204+
// let mut os_api = ecs_os_get_api();
205+
//
206+
// let (malloc, calloc, realloc, free) = alloc::setup_custom_allocators();
207+
//
208+
// os_api.malloc_ = malloc;
209+
// os_api.calloc_ = calloc;
210+
// os_api.realloc_ = realloc;
211+
// os_api.free_ = free;
212+
//
213+
// ecs_os_set_api(&mut os_api);
214+
// }
218215

219216
let world = World::new();
220217

0 commit comments

Comments
 (0)