Cemu/dependencies/ih264d/decoder/arm/ih264d_function_selector.c
rhemf 2dcaac317c Add native Windows ARM64 (AArch64) support
Enables building and running Cemu natively on Windows on ARM (e.g.
Snapdragon devices) with clang-cl. The existing AArch64 recompiler
backend is used, so no x64 emulation is involved.

Build system (CMakeLists.txt, dependencies/ih264d, src/Cafe):
- Auto-select the arm64-windows-static vcpkg triplet and detect the
  AArch64 architecture even when the emulated host shell misreports it.
- Disable IPO for clang-cl (LTO would force lld-link, which cannot read
  vcpkg's MSVC /GL objects) and link clang_rt.builtins for the
  compiler-rt calls (e.g. __udivti3) that lld-link does not add.
- Set the static CRT on the xbyak_aarch64 target.
- Locate pkgconf under the actual vcpkg host triplet instead of a
  hardcoded x64-windows path.
- Build the bundled ih264d decoder as portable C on ARM64/Windows; its
  NEON .s files use ELF-only :got: relocations that do not assemble for
  COFF targets.

Source (precompiled.h, ExceptionHandler_win32, Debugger, LatteTextureCache):
- Guard x86-only intrinsics/paths behind ARCH_X86_64. clang-cl defines
  _MSC_VER but not __GNUC__, so several `#if defined(_MSC_VER)` branches
  wrongly selected x86 intrinsics on ARM64. Adds AArch64 register
  dumping to the crash handler.

Manifest: use processorArchitecture="*" for Common-Controls so it
resolves on ARM64.

See BUILD.md for the build steps (Ninja + clang-cl + -DCMAKE_LINKER_TYPE=MSVC).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 14:05:33 +01:00

103 lines
2.9 KiB
C

/******************************************************************************
*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*****************************************************************************
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
*/
/**
*******************************************************************************
* @file
* ihevcd_function_selector.c
*
* @brief
* Contains functions to initialize function pointers used in hevc
*
* @author
* Naveen
*
* @par List of Functions:
* @remarks
* None
*
*******************************************************************************
*/
/*****************************************************************************/
/* File Includes */
/*****************************************************************************/
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "ih264_typedefs.h"
#include "iv.h"
#include "ivd.h"
#include "ih264_defs.h"
#include "ih264_size_defs.h"
#include "ih264_error.h"
#include "ih264_trans_quant_itrans_iquant.h"
#include "ih264_inter_pred_filters.h"
#include "ih264d_structs.h"
#include "ih264d_function_selector.h"
void ih264d_init_function_ptr(dec_struct_t *ps_codec)
{
IVD_ARCH_T e_proc_arch = ps_codec->e_processor_arch;
ih264d_init_function_ptr_generic(ps_codec);
switch(e_proc_arch)
{
#if defined(ARMV8) && !defined(DISABLE_NEON)
case ARCH_ARMV8_GENERIC:
default:
ih264d_init_function_ptr_av8(ps_codec);
break;
#elif !defined(DISABLE_NEON)
case ARCH_ARM_A5:
case ARCH_ARM_A7:
case ARCH_ARM_A9:
case ARCH_ARM_A15:
case ARCH_ARM_A9Q:
default:
ih264d_init_function_ptr_a9q(ps_codec);
break;
#else
default:
#endif
case ARCH_ARM_NONEON:
break;
}
}
void ih264d_init_arch(dec_struct_t *ps_codec)
{
#ifdef DEFAULT_ARCH
#if DEFAULT_ARCH == D_ARCH_ARM_NONEON
ps_codec->e_processor_arch = ARCH_ARM_NONEON;
#elif DEFAULT_ARCH == D_ARCH_ARMV8_GENERIC
ps_codec->e_processor_arch = ARCH_ARMV8_GENERIC;
#elif DEFAULT_ARCH == D_ARCH_ARM_NEONINTR
ps_codec->e_processor_arch = ARCH_ARM_NEONINTR;
#else
ps_codec->e_processor_arch = ARCH_ARM_A9Q;
#endif
#else
ps_codec->e_processor_arch = ARCH_ARM_A9Q;
#endif
}