design icon indicating copy to clipboard operation
design copied to clipboard

Support for Rust 16-bit floating point

Open hisergiorojas opened this issue 4 years ago • 1 comments

Openexr has support for 16-bit floating-point, 32-bit floating-point, and 32-bit integer pixels. Openexr rust uses 16f rgba color value and currently, WasmAbi doesn't support rust f16. I won't be able to build a openexr for webassembly without 16 bit floating point.

error: [E0277]: the trait bound f16: IntoWasmAbi is not satisfied --> src/rgba.rs:9:1 | 9 | #[wasm_bindgen] | ^^^^^^^^^^^^^^^ the trait IntoWasmAbi is not implemented for f16 | = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

hisergiorojas avatar Jun 21 '21 03:06 hisergiorojas

This may be better off as an issue on the wasm-bindgen repo.

Wasm doesn't even have a i16 scalar type (or any scalars <32 bits), so the addition of f16 directly to Wasm sounds highly unlikely to happen any time soon.

That said, 16-bit quantities are typically passed either in memory (and 16-bit loads/stores are supported) or directly in 32-bit types. This can be done for f16 too, and I suspect wasm-bindgen simply needs to support it. There's also SIMD vectors with 8 16-bit quantities that may be applicable to your situation.

aardappel avatar Jun 21 '21 20:06 aardappel

If someone wishes to propose a 16-bit floating-format to WebAssembly, please file a new issue. For f16 support in wasm-bindgen, please file issues in the wasm-bindgen repository.

sunfishcode avatar Oct 29 '22 00:10 sunfishcode