Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
79340b2
fix runtime and translator correctness
patchzyy Nov 17, 2026
f3c8fea
limit memory fault test to supported hosts
patchzyy Nov 17, 2026
2f96f91
build all registered macos tests
patchzyy Nov 17, 2026
73bada9
fix config recovery and constructor exceptions
patchzyy Nov 17, 2026
2b9a6e6
draft performance improvements
patchzyy Nov 17, 2026
1242f8e
keep the existing shader renderer
patchzyy Nov 18, 2026
542e4ad
update aurora correctness fixes
patchzyy Nov 18, 2026
b2e68cc
update aurora performance fixes
patchzyy Nov 18, 2026
d8d8ae6
update controller save fixes
patchzyy Nov 18, 2026
c1a069f
sync updated aurora fixes
patchzyy Nov 18, 2026
dc2885e
reject stale linux aurora packages
patchzyy Nov 18, 2026
a21a345
sync linux package validation
patchzyy Nov 18, 2026
01a4f95
update aurora linux test linkage
patchzyy Nov 18, 2026
cf7de85
fix gx cache validation and translator flags
patchzyy Nov 18, 2026
f2b0e6a
sync aurora test fixes
patchzyy Nov 18, 2026
be4dc84
handle literal paths in package checks
patchzyy Nov 18, 2026
f04649a
run audio tests on supported cpus
patchzyy Nov 18, 2026
a710713
sync package and controller fixes
patchzyy Nov 18, 2026
03fa7c6
match linux package sources
patchzyy Nov 18, 2026
df86d5c
fix translator options and gx recovery
patchzyy Nov 18, 2026
57a3f82
sync linux package fixes
patchzyy Nov 18, 2026
9d4df40
reject empty aurora checkouts
patchzyy Nov 18, 2026
a38420e
sync aurora checkout check
patchzyy Nov 18, 2026
51d8978
point aurora at merged main
patchzyy Nov 18, 2026
a4cae1c
merge main after #420
patchzyy Nov 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,20 @@ jobs:
mkw_macos_context_abi_tests \
mkw_macos_host_context_tests \
mkw_macos_guest_flat_memory_tests \
mkw_macos_external_audio_tests
mkw_macos_external_audio_tests \
mkw_ax_mix_kernels_tests

- name: Test execution substrate
shell: bash
run: ctest --test-dir build-macos --output-on-failure

- name: Check ARM audio kernels with sanitizers
shell: bash
run: |
clang++ -std=c++17 -O2 -fno-fast-math \
-fsanitize=address,undefined -fno-sanitize-recover=all \
-DMKW_AX_MIX_REQUIRE_NEON=1 \
-Iruntime/include -Iruntime/src/hle/audio \
runtime/tests/ax_mix_kernels_tests.cpp -o build-macos/ax-mix-sanitized
build-macos/ax-mix-sanitized
build-macos/mkw_ax_mix_kernels_tests --benchmark 20000
12 changes: 12 additions & 0 deletions .github/workflows/recomp-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ jobs:
shell: pwsh
run: ./Launcher/Test-Recompilation.ps1 -Parallel 4

- name: Test GX performance paths
shell: pwsh
run: |
$tools = Join-Path $PWD 'Launcher/artifacts/portable-tools'
$build = Join-Path $PWD 'build/recomp-test/native-build'
$env:PATH = "$build;$tools/llvm-mingw/bin;$tools/CMake/bin;$tools/Ninja;$env:PATH"
cmake -S build/recomp-test/runtime -B $build -DMKW_BUILD_AURORA_TESTS=ON -DFETCHCONTENT_FULLY_DISCONNECTED=OFF
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
cmake --build $build --parallel 3 --target gx_fifo_tests shader_module_cache_tests mkw_gx_texture_binding_tests mkw_gx_sync_tests mkw_gx_dl_cache_tests
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
ctest --test-dir $build --output-on-failure --no-tests=error -R '^(GXFifoTest|RuntimeDirectDrawTest|ShaderModuleCacheTest|mkw_gx_(texture_binding|sync|dl_cache)_tests)'

# Print cache results (even if the build fails)
- name: Show sccache stats
if: always()
Expand Down
9 changes: 9 additions & 0 deletions Launcher/macos/macos-x86_64-toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ set(CMAKE_SYSTEM_NAME Darwin)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_OSX_ARCHITECTURES x86_64 CACHE STRING
"Target macOS architectures" FORCE)

if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND NOT DEFINED CMAKE_CROSSCOMPILING_EMULATOR
AND NOT DEFINED ENV{CMAKE_CROSSCOMPILING_EMULATOR})
execute_process(COMMAND /usr/bin/arch -x86_64 /usr/bin/true
RESULT_VARIABLE _mkw_can_run_x86_64 OUTPUT_QUIET ERROR_QUIET)
if(_mkw_can_run_x86_64 EQUAL 0)
set(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/arch -x86_64)
endif()
endif()
70 changes: 70 additions & 0 deletions runtime/cmake/PlatformTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ endif()
if(TARGET gx_fifo_tests)
target_sources(gx_fifo_tests PRIVATE
"${MKW_TEST_RUNTIME_DIR}/tests/gx_fifo_invalidation_tests.cpp"
"${MKW_TEST_RUNTIME_DIR}/tests/gx_direct_draw_tests.cpp"
"${MKW_TEST_RUNTIME_DIR}/src/hle/gx/gx_fifo.cpp")
target_include_directories(gx_fifo_tests PRIVATE
"${MKW_AURORA_DIR}/tests" "${MKW_TEST_RUNTIME_DIR}/include"
Expand All @@ -164,6 +165,70 @@ if(TARGET gx_fifo_tests)
if(MKW_PLATFORM_WINDOWS)
target_link_libraries(gx_fifo_tests PRIVATE advapi32)
endif()

get_target_property(_mkw_gx_sources gx_fifo_tests SOURCES)
get_target_property(_mkw_gx_source_dir gx_fifo_tests SOURCE_DIR)
get_target_property(_mkw_gx_includes gx_fifo_tests INCLUDE_DIRECTORIES)
get_target_property(_mkw_gx_links gx_fifo_tests LINK_LIBRARIES)
set(_mkw_gx_encoder_sources)
foreach(_mkw_gx_source IN LISTS _mkw_gx_sources)
if(_mkw_gx_source MATCHES "(^|/)lib/")
get_filename_component(_mkw_gx_absolute "${_mkw_gx_source}" ABSOLUTE
BASE_DIR "${_mkw_gx_source_dir}")
list(APPEND _mkw_gx_encoder_sources "${_mkw_gx_absolute}")
endif()
endforeach()

add_executable(mkw_gx_texture_binding_tests
"${MKW_TEST_RUNTIME_DIR}/tests/gx_texture_binding_tests.cpp"
"${MKW_AURORA_DIR}/tests/gx_test_stubs.cpp"
${_mkw_gx_encoder_sources})
add_executable(mkw_gx_sync_tests
"${MKW_TEST_RUNTIME_DIR}/tests/gx_worker_tests.cpp"
"${MKW_TEST_RUNTIME_DIR}/tests/gx_copy_tests.cpp"
"${MKW_AURORA_DIR}/tests/gx_test_stubs.cpp"
${_mkw_gx_encoder_sources})
target_compile_definitions(mkw_gx_sync_tests PRIVATE MKW_GX_COPY_TESTING=1)
foreach(_mkw_gx_test IN ITEMS mkw_gx_texture_binding_tests mkw_gx_sync_tests)
target_include_directories(${_mkw_gx_test} PRIVATE
${_mkw_gx_includes} "${MKW_TEST_RUNTIME_DIR}/tests")
target_compile_definitions(${_mkw_gx_test} PRIVATE AURORA TARGET_PC=1)
target_compile_features(${_mkw_gx_test} PRIVATE cxx_std_20)
target_link_libraries(${_mkw_gx_test} PRIVATE ${_mkw_gx_links} Threads::Threads)
set_target_properties(${_mkw_gx_test} PROPERTIES UNITY_BUILD OFF)
aurora_copy_runtime_dlls(${_mkw_gx_test})
add_test(NAME ${_mkw_gx_test} COMMAND ${_mkw_gx_test})
set_tests_properties(${_mkw_gx_test} PROPERTIES TIMEOUT 120)
endforeach()

add_executable(mkw_gx_dl_cache_tests "${MKW_TEST_RUNTIME_DIR}/tests/gx_dl_cache_tests.cpp")
target_include_directories(mkw_gx_dl_cache_tests PRIVATE
"${MKW_TEST_RUNTIME_DIR}/include"
"${MKW_TEST_RUNTIME_DIR}/third_party/toml11"
"${MKW_AURORA_DIR}/include")
target_compile_features(mkw_gx_dl_cache_tests PRIVATE cxx_std_20)
target_compile_definitions(mkw_gx_dl_cache_tests PRIVATE AURORA TARGET_PC=1 NOMINMAX)
target_link_libraries(mkw_gx_dl_cache_tests PRIVATE xxHash::xxhash ${AURORA_SDL3_TARGET})
set_target_properties(mkw_gx_dl_cache_tests PROPERTIES UNITY_BUILD OFF)
add_test(NAME mkw_gx_dl_cache_tests COMMAND mkw_gx_dl_cache_tests)
endif()

function(mkw_add_ax_mix_test target)
add_executable(${target} "${MKW_TEST_RUNTIME_DIR}/tests/ax_mix_kernels_tests.cpp")
target_include_directories(${target} PRIVATE
"${MKW_TEST_RUNTIME_DIR}/include" "${MKW_TEST_RUNTIME_DIR}/src/hle/audio")
target_compile_features(${target} PRIVATE cxx_std_17)
set_target_properties(${target} PROPERTIES UNITY_BUILD OFF)
if(NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR)
add_test(NAME ${target} COMMAND ${target})
endif()
endfunction()

mkw_add_ax_mix_test(mkw_ax_mix_kernels_tests)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64|ARM64)$")
target_compile_definitions(mkw_ax_mix_kernels_tests PRIVATE MKW_AX_MIX_REQUIRE_NEON=1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(AMD64|amd64|x86_64|X86_64)$")
target_compile_options(mkw_ax_mix_kernels_tests PRIVATE -march=x86-64-v2)
endif()

add_executable(mkw_fiber_manager_tests
Expand Down Expand Up @@ -297,6 +362,11 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(AMD64|amd64|x86_64|X86_64)$")
]=] MKW_HOST_SUPPORTS_X86_V3)
cmake_pop_check_state()
endif()
if((NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR) AND MKW_HOST_SUPPORTS_X86_V3)
mkw_add_ax_mix_test(mkw_ax_mix_kernels_v3_tests)
target_compile_options(mkw_ax_mix_kernels_v3_tests PRIVATE -march=x86-64-v3)
endif()

# Compile the same oracle cases for both paths. The v2 binary proves the
# scalar fallback stays free of FMA; the v3 binary checks the existing
# vector intrinsic path against the same strict result.
Expand Down
130 changes: 123 additions & 7 deletions runtime/src/hle/audio/ax_mix_kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "isa/big_endian.h"

// AX/DSP fixed-point mix kernels: the inner loops of the AXWii command-list mix in ax_mix.cpp.
// Each exists as a scalar reference (a literal transcription of the loop it replaced) and an AVX2 form.
// Each has a scalar reference and architecture-specific SIMD forms.

#include <cstddef>
#include <cstdint>
Expand All @@ -16,8 +16,23 @@
#define MKW_AX_MIX_AVX2 0
#endif

#if !MKW_AX_MIX_AVX2 && defined(__aarch64__) && defined(__ARM_NEON) && !defined(__AARCH64EB__)
#include <arm_neon.h>
#define MKW_AX_MIX_NEON 1
#else
#define MKW_AX_MIX_NEON 0
#endif

namespace AxMixKernels {

// Mix buses retain the low 32 bits, matching the SIMD adds.
inline int32_t AddWrap32(int32_t value, uint32_t addend) {
const uint32_t bits = static_cast<uint32_t>(value) + addend;
int32_t result;
std::memcpy(&result, &bits, sizeof(result));
return result;
}

inline int16_t ClampToS16(int32_t value) {
if (value < -0x8000) {
return static_cast<int16_t>(-0x8000);
Expand All @@ -39,7 +54,7 @@ inline uint16_t MixAddRampScalar(int32_t* out, const int16_t* input, uint32_t co
const int32_t scaled =
(static_cast<int32_t>(input[i]) * static_cast<int32_t>(volume)) >> 15;
const int16_t sample = ClampToS16(scaled);
out[i] += sample;
out[i] = AddWrap32(out[i], static_cast<uint32_t>(sample));
volume = static_cast<uint16_t>(volume + delta);
last = sample;
}
Expand Down Expand Up @@ -90,7 +105,7 @@ inline uint16_t MixAddRampAvx2(int32_t* out, const int16_t* input, uint32_t coun
const int32_t scaled =
(static_cast<int32_t>(input[i]) * static_cast<int32_t>(volume)) >> 15;
const int16_t sample = ClampToS16(scaled);
out[i] += sample;
out[i] = AddWrap32(out[i], static_cast<uint32_t>(sample));
volume = static_cast<uint16_t>(volume + delta);
last = sample;
}
Expand All @@ -99,10 +114,46 @@ inline uint16_t MixAddRampAvx2(int32_t* out, const int16_t* input, uint32_t coun
}
#endif

#if MKW_AX_MIX_NEON
inline uint16x4_t Ramp4(uint16_t volume, uint16_t delta) {
static constexpr uint16_t lanes[] = {0, 1, 2, 3};
return vmla_n_u16(vdup_n_u16(volume), vld1_u16(lanes), delta);
}

inline int16x4_t ScaleBlock4(int16x4_t samples, uint16x4_t ramp) {
const int32x4_t gain = vreinterpretq_s32_u32(vmovl_u16(ramp));
const int32x4_t product = vmulq_s32(vmovl_s16(samples), gain);
return vqmovn_s32(vshrq_n_s32(product, 15));
}

inline uint16_t MixAddRampNeon(int32_t* out, const int16_t* input, uint32_t count,
uint16_t volume, uint16_t delta, int16_t& dpop) {
uint32_t i = 0;
int16_t last = dpop;
if (count >= 4) {
uint16x4_t ramp = Ramp4(volume, delta);
const uint16x4_t step = vdup_n_u16(static_cast<uint16_t>(delta * 4u));
int16x4_t block = vdup_n_s16(0);
for (; count - i >= 4; i += 4) {
block = ScaleBlock4(vld1_s16(input + i), ramp);
vst1q_s32(out + i, vaddw_s16(vld1q_s32(out + i), block));
ramp = vadd_u16(ramp, step);
}
last = vget_lane_s16(block, 3);
volume = vget_lane_u16(ramp, 0);
}
volume = MixAddRampScalar(out + i, input + i, count - i, volume, delta, last);
dpop = last;
return volume;
}
#endif

inline uint16_t MixAddRamp(int32_t* out, const int16_t* input, uint32_t count,
uint16_t volume, uint16_t delta, int16_t& dpop) {
#if MKW_AX_MIX_AVX2
return MixAddRampAvx2(out, input, count, volume, delta, dpop);
#elif MKW_AX_MIX_NEON
return MixAddRampNeon(out, input, count, volume, delta, dpop);
#else
return MixAddRampScalar(out, input, count, volume, delta, dpop);
#endif
Expand Down Expand Up @@ -162,10 +213,29 @@ inline uint16_t ScaleRampAvx2(int16_t* samples, uint32_t count, uint16_t volume,
}
#endif

#if MKW_AX_MIX_NEON
inline uint16_t ScaleRampNeon(int16_t* samples, uint32_t count, uint16_t volume,
uint16_t delta) {
uint32_t i = 0;
if (count >= 4) {
uint16x4_t ramp = Ramp4(volume, delta);
const uint16x4_t step = vdup_n_u16(static_cast<uint16_t>(delta * 4u));
for (; count - i >= 4; i += 4) {
vst1_s16(samples + i, ScaleBlock4(vld1_s16(samples + i), ramp));
ramp = vadd_u16(ramp, step);
}
volume = vget_lane_u16(ramp, 0);
}
return ScaleRampScalar(samples + i, count - i, volume, delta);
}
#endif

inline uint16_t ScaleRamp(int16_t* samples, uint32_t count, uint16_t volume,
uint16_t delta) {
#if MKW_AX_MIX_AVX2
return ScaleRampAvx2(samples, count, volume, delta);
#elif MKW_AX_MIX_NEON
return ScaleRampNeon(samples, count, volume, delta);
#else
return ScaleRampScalar(samples, count, volume, delta);
#endif
Expand All @@ -179,8 +249,9 @@ inline uint16_t ScaleRamp(int16_t* samples, uint32_t count, uint16_t volume,
inline void MixAccumRamp32Scalar(int32_t* dst, const int32_t* src, const uint16_t* ramp,
uint32_t count) {
for (uint32_t i = 0; i < count; ++i) {
dst[i] += static_cast<int32_t>(
(static_cast<int64_t>(src[i]) * static_cast<int64_t>(ramp[i])) >> 15);
const int64_t product = static_cast<int64_t>(src[i]) * ramp[i];
const uint32_t scaled = static_cast<uint32_t>(static_cast<uint64_t>(product) >> 15);
dst[i] = AddWrap32(dst[i], scaled);
}
}

Expand Down Expand Up @@ -208,16 +279,37 @@ inline void MixAccumRamp32Avx2(int32_t* dst, const int32_t* src, const uint16_t*
_mm256_add_epi32(acc, result));
}
for (; i < count; ++i) {
dst[i] += static_cast<int32_t>(
(static_cast<int64_t>(src[i]) * static_cast<int64_t>(ramp[i])) >> 15);
const int64_t product = static_cast<int64_t>(src[i]) * ramp[i];
const uint32_t scaled = static_cast<uint32_t>(static_cast<uint64_t>(product) >> 15);
dst[i] = AddWrap32(dst[i], scaled);
}
}
#endif

#if MKW_AX_MIX_NEON
inline void MixAccumRamp32Neon(int32_t* dst, const int32_t* src, const uint16_t* ramp,
uint32_t count) {
uint32_t i = 0;
for (; count - i >= 4; i += 4) {
const int32x4_t source = vld1q_s32(src + i);
const int32x4_t gain = vreinterpretq_s32_u32(vmovl_u16(vld1_u16(ramp + i)));
const int64x2_t lowProduct = vmull_s32(vget_low_s32(source), vget_low_s32(gain));
const int64x2_t highProduct = vmull_s32(vget_high_s32(source), vget_high_s32(gain));
// Keep bits 15..46, including products whose shifted value exceeds int32.
const int32x4_t scaled = vcombine_s32(vshrn_n_s64(lowProduct, 15),
vshrn_n_s64(highProduct, 15));
vst1q_s32(dst + i, vaddq_s32(vld1q_s32(dst + i), scaled));
}
MixAccumRamp32Scalar(dst + i, src + i, ramp + i, count - i);
}
#endif

inline void MixAccumRamp32(int32_t* dst, const int32_t* src, const uint16_t* ramp,
uint32_t count) {
#if MKW_AX_MIX_AVX2
MixAccumRamp32Avx2(dst, src, ramp, count);
#elif MKW_AX_MIX_NEON
MixAccumRamp32Neon(dst, src, ramp, count);
#else
MixAccumRamp32Scalar(dst, src, ramp, count);
#endif
Expand Down Expand Up @@ -270,9 +362,31 @@ inline void LoadBigEndian32Avx2(int32_t* dst, const uint8_t* src, size_t count)
}
#endif

#if MKW_AX_MIX_NEON
inline void StoreBigEndian32Neon(uint8_t* dst, const int32_t* src, size_t count) {
size_t i = 0;
for (; count - i >= 4; i += 4) {
const uint8x16_t bytes = vreinterpretq_u8_s32(vld1q_s32(src + i));
vst1q_u8(dst + i * sizeof(uint32_t), vrev32q_u8(bytes));
}
StoreBigEndian32Scalar(dst + i * sizeof(uint32_t), src + i, count - i);
}

inline void LoadBigEndian32Neon(int32_t* dst, const uint8_t* src, size_t count) {
size_t i = 0;
for (; count - i >= 4; i += 4) {
const uint8x16_t bytes = vld1q_u8(src + i * sizeof(uint32_t));
vst1q_s32(dst + i, vreinterpretq_s32_u8(vrev32q_u8(bytes)));
}
LoadBigEndian32Scalar(dst + i, src + i * sizeof(uint32_t), count - i);
}
#endif

inline void StoreBigEndian32(uint8_t* dst, const int32_t* src, size_t count) {
#if MKW_AX_MIX_AVX2
StoreBigEndian32Avx2(dst, src, count);
#elif MKW_AX_MIX_NEON
StoreBigEndian32Neon(dst, src, count);
#else
StoreBigEndian32Scalar(dst, src, count);
#endif
Expand All @@ -281,6 +395,8 @@ inline void StoreBigEndian32(uint8_t* dst, const int32_t* src, size_t count) {
inline void LoadBigEndian32(int32_t* dst, const uint8_t* src, size_t count) {
#if MKW_AX_MIX_AVX2
LoadBigEndian32Avx2(dst, src, count);
#elif MKW_AX_MIX_NEON
LoadBigEndian32Neon(dst, src, count);
#else
LoadBigEndian32Scalar(dst, src, count);
#endif
Expand Down
Loading
Loading