Skip to content

Commit d9c1cc4

Browse files
baconpaulPaul Walker (Baconpaul)
and
Paul Walker (Baconpaul)
authored
Changes to allow a lua-free arm64ec build (#7832)
These diffs allow surge to build arm64ec standalone and clap in a way that works. Loads of caveats though which I will outline in #7830 --------- Co-authored-by: Paul Walker (Baconpaul) <[email protected]>
1 parent f76645b commit d9c1cc4

18 files changed

+74
-36
lines changed

.github/workflows/build-pr.yml

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ jobs:
2727
cmakeOpt: DEBUG
2828
runTests: false
2929

30+
- name: "windows msvc arm64ec"
31+
os: windows-latest
32+
target: surge-xt_Standalone
33+
cmakeConfig: -G"Visual Studio 17 2022" -A arm64ec -DCMAKE_SYSTEM_VERSION=10 -DSURGE_SKIP_LUA=TRUE
34+
cmakeOpt: DEBUG
35+
runTests: false
36+
3037
- name: "windows clang"
3138
os: windows-latest
3239
target: surge-xt_Standalone

CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,13 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
160160
endif()
161161

162162
if(MSVC)
163+
if (("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "arm64ec") OR ("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "arm64"))
164+
message(STATUS "Skipping warning as error (-WX) on arm64ec for now")
165+
else()
166+
add_compile_options(-WX)
167+
endif()
168+
163169
add_compile_options(
164-
-WX # treat all warnings as errors
165170

166171
# MSVC-only warnings, Clang-cl silently ignores these
167172
/wd4244 # float to double

src/common/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ elseif(WIN32)
336336
UNICODE
337337
_UNICODE
338338
)
339+
340+
message(STATUS "Adding simde interface library on windows")
341+
target_link_libraries(${PROJECT_NAME} PUBLIC surge::simde)
342+
339343
endif()
340344

341345
option(SURGE_RELIABLE_VERSION_INFO "Update version info on every build (off: generate only at configuration time)" ON)

src/common/Parameter.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -1178,11 +1178,18 @@ void Parameter::set_type(int ctrltype)
11781178
break;
11791179
case ct_ensemble_stages:
11801180
{
1181+
#if defined(_M_ARM64EC)
1182+
valtype = vt_int;
1183+
val_min.i = 0;
1184+
val_max.i = 1;
1185+
val_default.i = 0;
1186+
#else
11811187
extern int ensemble_stage_count();
11821188
valtype = vt_int;
11831189
val_min.i = 0;
11841190
val_max.i = ensemble_stage_count() - 1;
11851191
val_default.i = 0;
1192+
#endif
11861193
break;
11871194
}
11881195
case ct_stringosc_excitation_model:
@@ -4064,8 +4071,12 @@ std::string Parameter::get_display(bool external, float ef) const
40644071
break;
40654072
case ct_ensemble_stages:
40664073
{
4074+
#if defined(_M_ARM64EC)
4075+
txt = "name";
4076+
#else
40674077
extern std::string ensemble_stage_name(int);
40684078
txt = ensemble_stage_name(i);
4079+
#endif
40694080
}
40704081
break;
40714082
case ct_reson_mode:

src/common/dsp/DSPExternalAdapterUtils.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* https://github.com/surge-synthesizer/surge
2121
*/
2222

23+
#include "globals.h"
2324
#include "DSPExternalAdapterUtils.h"
2425
#include "sst/filters/FilterPlotter.h"
2526

src/common/dsp/Effect.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
* All source for Surge XT is available at
2020
* https://github.com/surge-synthesizer/surge
2121
*/
22+
23+
#if !defined(_M_ARM64EC)
2224
#include "BBDEnsembleEffect.h"
25+
#endif
26+
2327
#include "BonsaiEffect.h"
2428
#include "ChorusEffectImpl.h"
2529
#include "CombulatorEffect.h"
@@ -104,7 +108,11 @@ Effect *spawn_effect(int id, SurgeStorage *storage, FxStorage *fxdata, pdata *pd
104108
case fxt_tape:
105109
return new chowdsp::TapeEffect(storage, fxdata, pd);
106110
case fxt_ensemble:
111+
#if defined(_M_ARM64EC)
112+
return nullptr;
113+
#else
107114
return new BBDEnsembleEffect(storage, fxdata, pd);
115+
#endif
108116
case fxt_treemonster:
109117
return new TreemonsterEffect(storage, fxdata, pd);
110118
case fxt_waveshaper:

src/common/dsp/Effect.h

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#ifndef SURGE_SRC_COMMON_DSP_EFFECT_H
2424
#define SURGE_SRC_COMMON_DSP_EFFECT_H
2525

26+
#include "globals.h"
2627
#include "DSPUtils.h"
2728
#include "SurgeStorage.h"
2829
#include "lipol.h"

src/common/dsp/effects/BBDEnsembleEffect.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
* https://github.com/surge-synthesizer/surge
2121
*/
2222

23+
#if !defined(_M_ARM64EC)
24+
2325
#include "BBDEnsembleEffect.h"
2426

2527
#include "sst/basic-blocks/mechanics/block-ops.h"
@@ -568,4 +570,6 @@ void BBDEnsembleEffect::handleStreamingMismatches(int streamingRevision,
568570
fxdata->p[ens_output_filter].val.f = defaultFilterCut;
569571
fxdata->p[ens_output_filter].deactivated = true;
570572
}
571-
}
573+
}
574+
575+
#endif

src/common/dsp/effects/BBDEnsembleEffect.h

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
#ifndef SURGE_SRC_COMMON_DSP_EFFECTS_BBDENSEMBLEEFFECT_H
2424
#define SURGE_SRC_COMMON_DSP_EFFECTS_BBDENSEMBLEEFFECT_H
25+
26+
#if !defined(_M_ARM64EC)
27+
2528
#include "Effect.h"
2629
#include "BiquadFilter.h"
2730
#include "DSPUtils.h"
@@ -108,4 +111,6 @@ class BBDEnsembleEffect : public Effect
108111
BiquadFilter sincInputFilter;
109112
};
110113

114+
#endif
115+
111116
#endif // SURGE_SRC_COMMON_DSP_EFFECTS_BBDENSEMBLEEFFECT_H

src/common/dsp/effects/chowdsp/bbd_utils/BBDNonlin.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,12 @@ class BBDNonlin
205205
S2.incident(D1.reflected());
206206
Vp = Cpk->voltage();
207207

208-
return vAdd(vMul(Vp, vLoad1(drive)), vMul(Vg, vLoad1(1.0f - drive)));
208+
auto vd = vLoad1(drive);
209+
auto vdm = vLoad1(1.0f - drive);
210+
auto a1 = vMul(Vp, vd);
211+
auto a2 = vMul(Vg, vdm);
212+
auto res = vAdd(a1, a2);
213+
return res;
209214
}
210215

211216
private:

src/common/dsp/effects/chowdsp/tape/HysteresisOps.h

+4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
#include "globals.h"
2727
#include "sst/basic-blocks/dsp/FastMath.h"
2828

29+
#if defined(_M_ARM64EC)
30+
#define CHOWTAPE_HYSTERESIS_USE_SIMD 0
31+
#else
2932
#define CHOWTAPE_HYSTERESIS_USE_SIMD 1
33+
#endif
3034

3135
namespace HysteresisOps
3236
{

src/common/dsp/oscillators/ClassicOscillator.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ template <bool FM> void ClassicOscillator::convolute(int voice, bool stereo)
383383
*/
384384
unsigned int m = ((ipos >> 16) & 0xff) * (FIRipol_N << 1);
385385
unsigned int lipolui16 = (ipos & 0xffff);
386-
__m128 lipol128 = _mm_cvtsi32_ss(lipol128, lipolui16);
386+
__m128 lipol128 = _mm_setzero_ps();
387+
lipol128 = _mm_cvtsi32_ss(lipol128, lipolui16);
387388
lipol128 = _mm_shuffle_ps(lipol128, lipol128, _MM_SHUFFLE(0, 0, 0, 0));
388389

389390
int k;

src/common/dsp/oscillators/SampleAndHoldOscillator.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ void SampleAndHoldOscillator::convolute(int voice, bool FM, bool stereo)
226226

227227
unsigned int m = ((ipos >> 16) & 0xff) * (FIRipol_N << 1);
228228
unsigned int lipolui16 = (ipos & 0xffff);
229-
__m128 lipol128 = _mm_cvtsi32_ss(lipol128, lipolui16);
229+
__m128 lipol128 = _mm_setzero_ps();
230+
lipol128 = _mm_cvtsi32_ss(lipol128, lipolui16);
230231
lipol128 = _mm_shuffle_ps(lipol128, lipol128, _MM_SHUFFLE(0, 0, 0, 0));
231232

232233
int k;

src/common/dsp/oscillators/WavetableOscillator.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ void WavetableOscillator::convolute(int voice, bool FM, bool stereo)
353353

354354
unsigned int m = ((ipos >> 16) & 0xff) * (FIRipol_N << 1);
355355
unsigned int lipolui16 = (ipos & 0xffff);
356-
__m128 lipol128 = _mm_cvtsi32_ss(lipol128, lipolui16);
356+
__m128 lipol128 = _mm_setzero_ps();
357+
lipol128 = _mm_cvtsi32_ss(lipol128, lipolui16);
357358
lipol128 = _mm_shuffle_ps(lipol128, lipol128, _MM_SHUFFLE(0, 0, 0, 0));
358359

359360
float g, gR;

src/common/dsp/oscillators/WindowOscillator.cpp

+1-12
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,7 @@ inline bool _BitScanReverse(unsigned long *result, unsigned long bits)
3838
}
3939
} // anonymous namespace
4040
#endif
41-
int Float2Int(float x)
42-
{
43-
#ifdef ARM_NEON
44-
return int(x + 0.5f);
45-
#else
46-
return _mm_cvt_ss2si(_mm_load_ss(&x));
47-
#endif
48-
}
41+
int Float2Int(float x) { return int(x + 0.5f); }
4942
WindowOscillator::WindowOscillator(SurgeStorage *storage, OscillatorStorage *oscdata,
5043
pdata *localcopy)
5144
: Oscillator(storage, oscdata, localcopy), lp(storage), hp(storage)
@@ -188,11 +181,7 @@ void WindowOscillator::init_default_values()
188181
inline unsigned int BigMULr16(unsigned int a, unsigned int b)
189182
{
190183
// 64-bit unsigned multiply with right shift by 16 bits
191-
#ifdef _MSC_VER
192-
const auto c{__emulu(a, b)};
193-
#else
194184
const auto c{std::uint64_t{a} * std::uint64_t{b}};
195-
#endif
196185
return c >> 16u;
197186
}
198187

src/common/globals.h

+3-17
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,8 @@
3232
// if you hit this on msvc and pass the above, you probably need /Zc:__cplusplus
3333
static_assert(__cplusplus == 201703L, "Surge requires C++17; please update your build");
3434

35-
#if MAC
36-
37-
#if defined(__x86_64__)
38-
#else
39-
#define ARM_NEON 1
40-
#endif
41-
42-
#endif
43-
44-
#if LINUX
45-
#if defined(__aarch64__) || defined(__arm__)
46-
#define ARM_NEON 1
47-
#endif
48-
#endif
49-
50-
#if defined(__SSE2__) || defined(_M_AMD64) || defined(_M_X64) || \
51-
(defined(_M_IX86_FP) && _M_IX86_FP >= 2)
35+
#if (defined(__SSE2__) || defined(_M_AMD64) || defined(_M_X64) || \
36+
(defined(_M_IX86_FP) && _M_IX86_FP >= 2)) //&& !defined(_M_ARM64EC)
5237
#include <emmintrin.h>
5338
#else
5439
// With the upgrade to simde 0.8.2 and subsequent conversations
@@ -58,6 +43,7 @@ static_assert(__cplusplus == 201703L, "Surge requires C++17; please update your
5843
// #if defined(__arm__) || defined(__aarch64__) || defined(__riscv)
5944
//
6045
// and just always include this in the else side
46+
#include <cmath>
6147
#define SIMDE_ENABLE_NATIVE_ALIASES
6248
#include "simde/x86/sse2.h"
6349
#endif

src/surge-xt/gui/overlays/AboutScreen.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ void AboutScreen::populateData()
171171
std::string platform = "macOS";
172172
#elif WINDOWS
173173
std::string platform = "Windows";
174+
#if defined(_M_ARM64EC)
175+
platform += " (arm64ec)";
176+
#elif defined(_M_ARM64)
177+
platform += " (arm64)";
178+
#endif
174179
#elif LINUX
175180
std::string platform = "Linux";
176181
#else

0 commit comments

Comments
 (0)