tirr-c/jxl-oxide

Cannot compile for wasm with simd enabled

Closed this issue · 2 comments

Hi there, thanks for the library.

The library (version 0.8.0 ) can't be compiled for wasm+simd due to the fact that jxl-grid doesn't have SimdVector for v128 defined in crates.io

Errors look like

error[E0599]: no method named `store` found for struct `std::arch::wasm32::v128` in the current scope
   --> /home/caleb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/jxl-render-0.8.0/src/vardct/wasm32/transform.rs:118:27
    |
118 |             scratch_1[y2].store(row_ptr.add(4));
    |                           ^^^^^ method not found in `v128`

While the methods exist in repository, aka

#[cfg(all(target_arch = "wasm32", target_feature = "simd128"))]
impl SimdVector for std::arch::wasm32::v128 {
const SIZE: usize = 4;
#[inline]
fn available() -> bool {
true
}
#[inline]
unsafe fn zero() -> Self {
std::arch::wasm32::f32x4_splat(0f32)
}
#[inline]
unsafe fn set<const N: usize>(val: [f32; N]) -> Self {
assert_eq!(N, Self::SIZE);
std::arch::wasm32::f32x4(val[0], val[1], val[2], val[3])
}
#[inline]
unsafe fn splat_f32(val: f32) -> Self {
std::arch::wasm32::f32x4_splat(val)
}
#[inline]
unsafe fn load(ptr: *const f32) -> Self {
std::arch::wasm32::v128_load(ptr as *const _)
}
#[inline]
unsafe fn load_aligned(ptr: *const f32) -> Self {
std::arch::wasm32::v128_load(ptr as *const _)
}
#[inline]
unsafe fn extract_f32<const N: i32>(self) -> f32 {
match N {
0 => std::arch::wasm32::f32x4_extract_lane::<0>(self),
1 => std::arch::wasm32::f32x4_extract_lane::<1>(self),
2 => std::arch::wasm32::f32x4_extract_lane::<2>(self),
3 => std::arch::wasm32::f32x4_extract_lane::<3>(self),
_ => panic!(),
}
}
#[inline]
unsafe fn store(self, ptr: *mut f32) {
std::arch::wasm32::v128_store(ptr as *mut _, self)
}
#[inline]
unsafe fn store_aligned(self, ptr: *mut f32) {
std::arch::wasm32::v128_store(ptr as *mut _, self)
}
#[inline]
unsafe fn add(self, lhs: Self) -> Self {
std::arch::wasm32::f32x4_add(self, lhs)
}
#[inline]
unsafe fn sub(self, lhs: Self) -> Self {
std::arch::wasm32::f32x4_sub(self, lhs)
}
#[inline]
unsafe fn mul(self, lhs: Self) -> Self {
std::arch::wasm32::f32x4_mul(self, lhs)
}
#[inline]
unsafe fn div(self, lhs: Self) -> Self {
std::arch::wasm32::f32x4_div(self, lhs)
}
#[inline]
unsafe fn abs(self) -> Self {
std::arch::wasm32::f32x4_abs(self)
}
#[inline]
unsafe fn muladd(self, mul: Self, add: Self) -> Self {
self.mul(mul).add(add)
}
#[inline]
unsafe fn mulsub(self, mul: Self, sub: Self) -> Self {
self.mul(mul).sub(sub)
}
}
,

they do not exist in jxl-grid in crates.io (https://docs.rs/crate/jxl-grid/0.4.1/source/src/simd.rs) causing the errors above

Oops, I forgot to bump version of jxl-grid... I just published jxl-grid 0.4.2 and jxl-render 0.8.1, and yanked jxl-render 0.8.0. Could you check if it's fixed now?

Perfect, it's working