Skip to content

Commit

Permalink
Merge pull request #12917 from fwcd/sse-wasm-fixes
Browse files Browse the repository at this point in the history
SSE: Check `!defined(__EMSCRIPTEN__)` where intrinsics are unavailable on WASM
  • Loading branch information
daschuer authored Apr 7, 2024
2 parents 6dcdb35 + 8c62564 commit 0416ba6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/soundio/sounddevicenetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,18 @@ void SoundDeviceNetwork::callbackProcessClkRef() {

if (!m_denormals) {
m_denormals = true;

// This disables the denormals calculations, to avoid a
// performance penalty of ~20
// https://github.com/mixxxdj/mixxx/issues/7747
#ifdef __SSE__

// On Emscripten (WebAssembly) denormals-as-zero/flush-as-zero are
// neither supported nor configurable. This may lead to degraded
// performance compared to other platforms and may be addressed in the
// future if/when WebAssembly adds support for DAZ/FTZ. For further
// discussion and links see https://github.com/mixxxdj/mixxx/pull/12917

#if defined(__SSE__) && !defined(__EMSCRIPTEN__)
if (!_MM_GET_DENORMALS_ZERO_MODE()) {
qDebug() << "SSE: Enabling denormals to zero mode";
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
Expand Down
9 changes: 8 additions & 1 deletion src/soundio/sounddeviceportaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,10 +906,17 @@ int SoundDevicePortAudio::callbackProcessClkRef(
#endif
m_bSetThreadPriority = true;

#ifdef __SSE__
// This disables the denormals calculations, to avoid a
// performance penalty of ~20
// https://github.com/mixxxdj/mixxx/issues/7747

// On Emscripten (WebAssembly) denormals-as-zero/flush-as-zero are
// neither supported nor configurable. This may lead to degraded
// performance compared to other platforms and may be addressed in the
// future if/when WebAssembly adds support for DAZ/FTZ. For further
// discussion and links see https://github.com/mixxxdj/mixxx/pull/12917

#if defined(__SSE__) && !defined(__EMSCRIPTEN__)
if (!_MM_GET_DENORMALS_ZERO_MODE()) {
qDebug() << "SSE: Enabling denormals to zero mode";
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
Expand Down
2 changes: 1 addition & 1 deletion src/util/denormalsarezero.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define _MM_DENORMALS_ZERO_OFF 0x0000
#endif

#ifdef __SSE__
#if defined(__SSE__) && !defined(__EMSCRIPTEN__)

#include <xmmintrin.h>

Expand Down

0 comments on commit 0416ba6

Please sign in to comment.