Skip to content

Don't try to use SSE4.2 CRC intrinsics under Emscripten #8213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

slowriot
Copy link
Contributor

@slowriot slowriot commented Dec 6, 2024

A very simple change to avoid enabling SSE4 under Emscripten.

This is a workaround, as the latest changes in this WIP branch don't work with Emscripten when SSE4.2 is enabled.

It is possible to build Emscripten projects with SSE4.2 (see https://emscripten.org/docs/porting/simd.html) by passing flags -msse4.2 and -msimd128, which will define __SSE4_2__. However, symbols used here such as _mm_crc32_u32 are not available. Instead, Emscripten exposes a different set of WebAssembly SIMD intrinsics.

This PR is just a workaround for now - an ideal solution would be to have #ifdef EMSCRIPTEN branches for each place that uses SIMD intrinsics, and provide WASM intrinsic equivalent in those places, as described in the article above.

@slowriot
Copy link
Contributor Author

slowriot commented Dec 6, 2024

A quick update - actually it's just the CRC comparison functions that aren't available (see https://emscripten.org/docs/porting/simd.html#id11), so this PR now only disables those under Emscripten, preserving any other use of SSE.

The affected intrinsics are only _mm_crc32_u32 and _mm_crc32_u8.

@slowriot slowriot changed the title Don't enable SSE4 under Emscripten Don't try to use SSE4.2 CRC intrinsics under Emscripten Dec 6, 2024
@ocornut
Copy link
Owner

ocornut commented Dec 7, 2024

Could it be reworked as a single IMGUI_ENABLE_SSE4_2_CRC defined in imgui_internal.h below IMGUI_ENABLE_SSE4_2 ?

thank you!

@ocornut
Copy link
Owner

ocornut commented Dec 9, 2024

Could it be reworked as a single IMGUI_ENABLE_SSE4_2_CRC defined in imgui_internal.h below IMGUI_ENABLE_SSE4_2 ?

I have reworked your change as 2671f68

@ocornut ocornut closed this Dec 9, 2024
@slowriot slowriot deleted the patch-2 branch December 9, 2024 12:19
@slowriot
Copy link
Contributor Author

slowriot commented Dec 9, 2024

Could it be reworked as a single IMGUI_ENABLE_SSE4_2_CRC defined in imgui_internal.h below IMGUI_ENABLE_SSE4_2 ?

I have reworked your change as 2671f68

Thanks!

matthew-mccall pushed a commit to matthew-mccall/imgui that referenced this pull request Jan 1, 2025
matthew-mccall pushed a commit to matthew-mccall/imgui that referenced this pull request Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants