From 24ecfdd94f3dc68270e40e615b78db3f758fed37 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 21 Sep 2026 13:20:46 +1000 Subject: [PATCH] Misc: Use C++23 elifdef/elifndef And drop macros for platforms not supported in the public repo. --- src/common/CMakeLists.txt | 9 +-- src/common/common.vcxproj | 1 + src/common/common.vcxproj.filters | 1 + src/common/dynamic_library.cpp | 10 +-- src/common/log.cpp | 27 +------ src/common/platform_strings.h | 31 ++++++++ src/common/threading.h | 9 +-- src/common/timer.cpp | 5 +- src/common/types.h | 49 ++---------- src/core/achievements.cpp | 20 +---- src/core/bus.cpp | 10 +-- src/core/core.cpp | 21 +----- src/core/cpu_code_cache.cpp | 5 +- src/core/cpu_recompiler_x64.cpp | 8 +- src/core/discord_presence.cpp | 4 - src/core/discord_presence.h | 9 --- src/core/fullscreenui_widgets.cpp | 26 +------ src/core/game_database.cpp | 8 -- src/core/game_list.cpp | 4 - src/core/gdb_server.cpp | 4 - src/core/gdb_server.h | 9 --- src/core/gpu_dump.cpp | 1 + src/core/gte.cpp | 54 +------------- src/core/guncon.cpp | 8 -- src/core/hotkeys.cpp | 16 ---- src/core/imgui_overlays.cpp | 26 ------- src/core/justifier.cpp | 8 -- src/core/settings.cpp | 26 +------ src/core/settings.h | 20 ----- src/core/spu.cpp | 2 - src/core/system.cpp | 26 +------ src/core/video_thread.cpp | 15 +--- src/util/CMakeLists.txt | 44 +++-------- src/util/audio_stream.cpp | 26 ------- src/util/audio_stream.h | 19 ----- src/util/cd_image_device.cpp | 19 +---- src/util/core_audio_stream.h | 5 -- src/util/dyn_libs.cpp | 120 +++++++++++++++--------------- src/util/imgui_manager.cpp | 9 --- src/util/imgui_manager.h | 12 --- src/util/input_manager.cpp | 35 +-------- src/util/input_manager.h | 5 -- src/util/input_source.h | 4 - src/util/media_capture.cpp | 28 ------- src/util/media_capture.h | 2 - src/util/opengl_context.cpp | 4 - src/util/page_fault_handler.cpp | 59 ++++++--------- src/util/util.props | 2 +- src/util/vulkan_device.cpp | 2 +- src/util/vulkan_entry_points.inl | 4 - src/util/vulkan_headers.h | 16 ++-- src/util/vulkan_loader.cpp | 22 +----- src/util/vulkan_swap_chain.cpp | 27 +------ 53 files changed, 187 insertions(+), 749 deletions(-) create mode 100644 src/common/platform_strings.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 8d3c6e68c..431ea7bf1 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -50,6 +50,7 @@ add_library(common path.h perf_scope.cpp perf_scope.h + platform_strings.h progress_callback.cpp progress_callback.h ryml_helpers.h @@ -97,16 +98,10 @@ if(APPLE) find_library(COCOA_LIBRARY Cocoa REQUIRED) find_library(QUARTZCORE_LIBRARY QuartzCore) target_link_libraries(common PRIVATE ${COCOA_LIBRARY} ${QUARTZCORE_LIBRARY}) -endif() - -if(NOT ANDROID AND NOT APPLE) +else() target_link_libraries(common PRIVATE libbacktrace::libbacktrace) endif() -if(ANDROID) - target_link_libraries(common PRIVATE log) -endif() - if(LINUX) # We need -lrt for shm_unlink target_link_libraries(common PRIVATE rt) diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj index 38785de09..788fede72 100644 --- a/src/common/common.vcxproj +++ b/src/common/common.vcxproj @@ -26,6 +26,7 @@ + diff --git a/src/common/common.vcxproj.filters b/src/common/common.vcxproj.filters index 67fccce75..29a92d5e0 100644 --- a/src/common/common.vcxproj.filters +++ b/src/common/common.vcxproj.filters @@ -61,6 +61,7 @@ + diff --git a/src/common/dynamic_library.cpp b/src/common/dynamic_library.cpp index 949771e1f..8e00c16b4 100644 --- a/src/common/dynamic_library.cpp +++ b/src/common/dynamic_library.cpp @@ -45,9 +45,9 @@ DynamicLibrary::~DynamicLibrary() std::string DynamicLibrary::GetUnprefixedFilename(const char* filename) { -#if defined(_WIN32) +#ifdef _WIN32 return std::string(filename) + ".dll"; -#elif defined(__APPLE__) +#elifdef __APPLE__ return std::string(filename) + ".dylib"; #else return std::string(filename) + ".so"; @@ -56,7 +56,7 @@ std::string DynamicLibrary::GetUnprefixedFilename(const char* filename) std::string DynamicLibrary::GetVersionedFilename(const char* libname, int major, int minor, int patch) { -#if defined(_WIN32) +#ifdef _WIN32 if (major >= 0 && minor >= 0 && patch >= 0) return fmt::format("{}-{}-{}-{}.dll", libname, major, minor, patch); else if (major >= 0 && minor >= 0) @@ -65,7 +65,7 @@ std::string DynamicLibrary::GetVersionedFilename(const char* libname, int major, return fmt::format("{}-{}.dll", libname, major); else return fmt::format("{}.dll", libname); -#elif defined(__APPLE__) +#elifdef __APPLE__ const char* prefix = std::strncmp(libname, "lib", 3) ? "lib" : ""; if (major >= 0 && minor >= 0 && patch >= 0) return fmt::format("{}{}.{}.{}.{}.dylib", prefix, libname, major, minor, patch); @@ -108,7 +108,7 @@ bool DynamicLibrary::Open(const char* filename, Error* error) return false; } -#if defined(__linux__) && !defined(__ANDROID__) +#ifdef __linux__ struct link_map* map; if (dlinfo(m_handle, RTLD_DI_LINKMAP, &map) == 0) DEV_LOG("{} loaded as {}", filename, map->l_name); diff --git a/src/common/log.cpp b/src/common/log.cpp index adf09a520..c9438ff3a 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -18,8 +18,6 @@ #if defined(_WIN32) #include "windows_headers.h" -#elif defined(__ANDROID__) -#include #else #include #include @@ -169,8 +167,6 @@ bool Log::IsConsoleOutputCurrentlyAvailable() #ifdef _WIN32 const HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); return (h != NULL && h != INVALID_HANDLE_VALUE); -#elif defined(__ANDROID__) - return false; #else // standard output isn't really reliable because it could be redirected to a file. check standard input for tty. struct termios attr; @@ -357,14 +353,14 @@ void Log::ConsoleOutputLogCallback(void* pUserParam, MessageCategory cat, const if (!s_state.console_output_enabled) return; -#if defined(_WIN32) +#ifdef _WIN32 FormatLogMessageAndPrintW( cat, function_name, message, s_state.console_output_timestamps, true, [cat](const std::wstring_view& message) { HANDLE hOutput = (UnpackLevel(cat) <= Level::Warning) ? s_state.hConsoleStdErr : s_state.hConsoleStdOut; DWORD chars_written; WriteConsoleW(hOutput, message.data(), static_cast(message.length()), &chars_written, nullptr); }); -#elif !defined(__ANDROID__) +#else FormatLogMessageAndPrint( cat, function_name, message, s_state.console_output_timestamps, true, [cat](std::string_view message) { const int outputFd = (UnpackLevel(cat) <= Log::Level::Warning) ? STDERR_FILENO : STDOUT_FILENO; @@ -379,26 +375,9 @@ void Log::DebugOutputLogCallback(void* pUserParam, MessageCategory cat, const ch if (!s_state.debug_output_enabled) return; -#if defined(_WIN32) +#ifdef _WIN32 FormatLogMessageAndPrintW(cat, function_name, message, false, false, [](const std::wstring_view& message) { OutputDebugStringW(message.data()); }); -#elif defined(__ANDROID__) - if (message.empty()) - return; - - static constexpr int logPriority[static_cast(Level::MaxCount)] = { - ANDROID_LOG_INFO, // None - ANDROID_LOG_ERROR, // Error - ANDROID_LOG_WARN, // Warning - ANDROID_LOG_INFO, // Info - ANDROID_LOG_INFO, // Verbose - ANDROID_LOG_DEBUG, // Dev - ANDROID_LOG_DEBUG, // Debug - ANDROID_LOG_DEBUG, // Trace - }; - - __android_log_print(logPriority[static_cast(UnpackLevel(cat))], GetChannelName(UnpackChannel(cat)), "%.*s", - static_cast(message.length()), message.data()); #endif } diff --git a/src/common/platform_strings.h b/src/common/platform_strings.h new file mode 100644 index 000000000..8020788eb --- /dev/null +++ b/src/common/platform_strings.h @@ -0,0 +1,31 @@ +// SPDX-FileCopyrightText: 2019-2026 Connor McLaughlin +// SPDX-License-Identifier: CC-BY-NC-ND-4.0 + +#pragma once + +#include "common/types.h" + +#ifdef CPU_ARCH_X64 +#define CPU_ARCH_STR "x64" +#elifdef CPU_ARCH_ARM32 +#define CPU_ARCH_STR "arm32" +#elifdef CPU_ARCH_ARM64 +#define CPU_ARCH_STR "arm64" +#elifdef CPU_ARCH_RISCV64 +#define CPU_ARCH_STR "riscv64" +#elifdef CPU_ARCH_LOONGARCH64 +#define CPU_ARCH_STR "loongarch64" +#else +#error Unknown architecture. +#endif + +// OS detection. +#ifdef _WIN32 +#define TARGET_OS_STR "Windows" +#elifdef __linux__ +#define TARGET_OS_STR "Linux" +#elifdef __APPLE__ +#define TARGET_OS_STR "macOS" +#else +#error Unknown OS. +#endif diff --git a/src/common/threading.h b/src/common/threading.h index 2309fbb4e..1215ed552 100644 --- a/src/common/threading.h +++ b/src/common/threading.h @@ -144,8 +144,6 @@ private: void* m_data = nullptr; #elif defined(__APPLE__) static constexpr u32 NATIVE_STORAGE_SIZE = 64; -#elif defined(__ANDROID__) - static constexpr u32 NATIVE_STORAGE_SIZE = (sizeof(void*) == 8) ? 40 : 4; #elif defined(__linux__) && defined(CPU_ARCH_ARM64) static constexpr u32 NATIVE_STORAGE_SIZE = 48; #elif defined(__linux__) @@ -199,12 +197,9 @@ private: #if defined(_WIN32) void* m_data = nullptr; -#elif defined(__APPLE__) || (defined(__linux__) && !defined(__ANDROID__)) +#elif defined(__APPLE__) || defined(__linux__) static constexpr u32 NATIVE_STORAGE_SIZE = 48; static constexpr u32 NATIVE_STORAGE_ALIGNMENT = 8; -#elif defined(__ANDROID__) - static constexpr u32 NATIVE_STORAGE_SIZE = (sizeof(void*) == 8) ? 48 : 4; - static constexpr u32 NATIVE_STORAGE_ALIGNMENT = alignof(void*); #else #error Unsupported platform. #endif @@ -231,8 +226,6 @@ public: private: #if defined(_WIN32) || defined(__APPLE__) void* m_data = nullptr; -#elif defined(__ANDROID__) - static constexpr u32 NATIVE_STORAGE_SIZE = (sizeof(void*) == 8) ? 16 : 4; #elif defined(__linux__) static constexpr u32 NATIVE_STORAGE_SIZE = (sizeof(void*) == 8) ? 32 : 16; #else diff --git a/src/common/timer.cpp b/src/common/timer.cpp index 38939389f..958c29298 100644 --- a/src/common/timer.cpp +++ b/src/common/timer.cpp @@ -374,7 +374,7 @@ void Timer::HybridSleep(std::uint64_t ns, std::uint64_t min_sleep_time) void Timer::NanoSleep(std::uint64_t ns) { -#if defined(_WIN32) +#ifdef _WIN32 HANDLE timer = GetSleepTimer(); if (timer) { @@ -389,9 +389,6 @@ void Timer::NanoSleep(std::uint64_t ns) { Sleep(static_cast(ns / 1000000)); } -#elif defined(__ANDROID__) - // Round down to the next millisecond. - usleep(static_cast((ns / 1000000) * 1000)); #else const struct timespec ts = {static_cast(ns / 1000000000ULL), static_cast(ns % 1000000000ULL)}; nanosleep(&ts, nullptr); diff --git a/src/common/types.h b/src/common/types.h index 88511a912..ac3a9a8a7 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -138,31 +138,25 @@ struct dependent_int_false : std::false_type // Architecture detection. #if defined(_MSC_VER) -#if defined(_M_X64) +#ifdef _M_X64 #define CPU_ARCH_X64 1 -#elif defined(_M_IX86) -#define CPU_ARCH_X86 1 -#elif defined(_M_ARM64) +#elifdef _M_ARM64 #define CPU_ARCH_ARM64 1 -#elif defined(_M_ARM) -#define CPU_ARCH_ARM32 1 #else #error Unknown architecture. #endif #elif defined(__GNUC__) || defined(__clang__) -#if defined(__x86_64__) +#ifdef __x86_64__ #define CPU_ARCH_X64 1 -#elif defined(__i386__) -#define CPU_ARCH_X86 1 -#elif defined(__aarch64__) +#elifdef __aarch64__ #define CPU_ARCH_ARM64 1 -#elif defined(__arm__) +#elifdef __arm__ #define CPU_ARCH_ARM32 1 #elif defined(__riscv) && __riscv_xlen == 64 #define CPU_ARCH_RISCV64 1 -#elif defined(__loongarch64) +#elifdef __loongarch64 #define CPU_ARCH_LOONGARCH64 1 #else #error Unknown architecture. @@ -174,37 +168,6 @@ struct dependent_int_false : std::false_type #endif -#if defined(CPU_ARCH_X64) -#define CPU_ARCH_STR "x64" -#elif defined(CPU_ARCH_X86) -#define CPU_ARCH_STR "x86" -#elif defined(CPU_ARCH_ARM32) -#define CPU_ARCH_STR "arm32" -#elif defined(CPU_ARCH_ARM64) -#define CPU_ARCH_STR "arm64" -#elif defined(CPU_ARCH_RISCV64) -#define CPU_ARCH_STR "riscv64" -#elif defined(CPU_ARCH_LOONGARCH64) -#define CPU_ARCH_STR "loongarch64" -#else -#define CPU_ARCH_STR "Unknown" -#endif - -// OS detection. -#if defined(_WIN32) -#define TARGET_OS_STR "Windows" -#elif defined(__ANDROID__) -#define TARGET_OS_STR "Android" -#elif defined(__linux__) -#define TARGET_OS_STR "Linux" -#elif defined(__FreeBSD__) -#define TARGET_OS_STR "FreeBSD" -#elif defined(__APPLE__) -#define TARGET_OS_STR "macOS" -#else -#define TARGET_OS_STR "Unknown" -#endif - // Host page sizes. #if defined(MIN_HOST_PAGE_SIZE) || defined(MAX_HOST_PAGE_SIZE) #if !defined(MIN_HOST_PAGE_SIZE) || !defined(MAX_HOST_PAGE_SIZE) diff --git a/src/core/achievements.cpp b/src/core/achievements.cpp index 18a85cf05..c49be63a4 100644 --- a/src/core/achievements.cpp +++ b/src/core/achievements.cpp @@ -1032,9 +1032,7 @@ void Achievements::UpdateRichPresence(std::unique_lock& lo INFO_LOG("Rich presence updated: {}", s_state.rich_presence_string); -#ifdef ENABLE_DISCORD_PRESENCE DiscordPresence::UpdateDetails(GetCurrentGameBadgeURL(), s_state.rich_presence_string); -#endif } void Achievements::OnSystemStarting(bool disable_hardcore_mode) @@ -1267,9 +1265,7 @@ void Achievements::ClientLoadGameCallback(int result, const char* error_message, // but the progress is fine since that's just game IDs UpdateProgressDatabaseFromCurrentGame(); -#ifdef ENABLE_DISCORD_PRESENCE DiscordPresence::UpdateDetails(s_state.game_badge_url, s_state.rich_presence_string); -#endif if (g_settings.achievements_prefetch_badges) Achievements::PrefetchAllAchievementBadges(); @@ -1287,9 +1283,7 @@ void Achievements::ClientLoadGameCallback(int result, const char* error_message, void Achievements::ClearGameInfo() { -#ifdef ENABLE_DISCORD_PRESENCE DiscordPresence::UpdateDetails({}, {}); -#endif FullscreenUI::ClearAchievementsState(); @@ -2268,17 +2262,15 @@ void Achievements::ConfirmHardcoreModeDisableAsync(std::string_view trigger, std }); } -#if defined(_WIN32) +#ifdef _WIN32 #include "common/windows_headers.h" -#elif !defined(__ANDROID__) +#else #include #endif #include "common/thirdparty/SmallVector.h" #include "common/thirdparty/aes.h" -#ifndef __ANDROID__ - static TinyString GetLoginEncryptionMachineKey() { TinyString ret; @@ -2316,12 +2308,12 @@ static TinyString GetLoginEncryptionMachineKey() ret.resize(machine_guid_length); RegCloseKey(hKey); #else -#if defined(__linux__) +#ifdef __linux__ // use /etc/machine-id on Linux std::optional machine_id = FileSystem::ReadFileToString("/etc/machine-id"); if (machine_id.has_value()) ret = std::string_view(machine_id.value()); -#elif defined(__APPLE__) +#elifdef __APPLE__ // use gethostuuid(2) on macOS const struct timespec ts{}; uuid_t uuid{}; @@ -2342,8 +2334,6 @@ static TinyString GetLoginEncryptionMachineKey() return ret; } -#endif - static std::array GetLoginEncryptionKey(std::string_view username) { // super basic key stretching @@ -2351,7 +2341,6 @@ static std::array GetLoginEncryptionKey(std::string_view username) SHA256Digest digest; -#ifndef __ANDROID__ // Only use machine key if we're not running in portable mode. if (!EmuFolders::IsRunningInPortableMode()) { @@ -2361,7 +2350,6 @@ static std::array GetLoginEncryptionKey(std::string_view username) else WARNING_LOG("Failed to get machine key, token will be decipherable."); } -#endif // salt with username digest.Update(username.data(), username.length()); diff --git a/src/core/bus.cpp b/src/core/bus.cpp index 2f5a5c5f5..834fd899f 100644 --- a/src/core/bus.cpp +++ b/src/core/bus.cpp @@ -45,7 +45,6 @@ LOG_CHANNEL(Bus); // Exports for external debugger access -#ifndef __ANDROID__ namespace Exports { extern "C" { @@ -59,7 +58,6 @@ __attribute__((visibility("default"), used)) u32 RAM_SIZE, RAM_MASK; } } // namespace Exports -#endif namespace Bus { @@ -249,20 +247,16 @@ bool Bus::AllocateMemoryMap(bool export_shared_memory, Error* error) g_bus.ram_mapped_size = RAM_8MB_SIZE; SetHandlers(); -#ifndef __ANDROID__ Exports::RAM = reinterpret_cast(g_bus.unprotected_ram); -#endif return true; } void Bus::ReleaseMemoryMap() { -#ifndef __ANDROID__ Exports::RAM = 0; Exports::RAM_SIZE = 0; Exports::RAM_MASK = 0; -#endif g_bus.memory_handlers_isc = nullptr; if (g_bus.memory_handlers) @@ -368,7 +362,7 @@ bool Bus::ReallocateMemoryMap(bool export_shared_memory, Error* error) void Bus::CleanupMemoryMap() { -#if !defined(_WIN32) && !defined(__ANDROID__) +#ifndef _WIN32 // This is only needed on Linux. if (!s_locals.shmem_name.empty()) MemMap::DeleteSharedMemory(s_locals.shmem_name.c_str()); @@ -386,10 +380,8 @@ void Bus::SetRAMSize(bool enable_8mb_ram) g_bus.ram_size = enable_8mb_ram ? RAM_8MB_SIZE : RAM_2MB_SIZE; g_bus.ram_mask = enable_8mb_ram ? RAM_8MB_MASK : RAM_2MB_MASK; -#ifndef __ANDROID__ Exports::RAM_SIZE = g_bus.ram_size; Exports::RAM_MASK = g_bus.ram_mask; -#endif } void Bus::Shutdown() diff --git a/src/core/core.cpp b/src/core/core.cpp index 3416f3041..f694ca915 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -30,6 +30,7 @@ #include "common/log.h" #include "common/memmap.h" #include "common/path.h" +#include "common/platform_strings.h" #include "common/ryml_helpers.h" #include "common/string_util.h" #include "common/task_queue.h" @@ -139,7 +140,6 @@ bool Core::SetAppRootAndResources(Error* error) bool Core::SetDataRoot(Error* error) { -#ifndef __ANDROID__ // This bullshit here because AppImage mounts in /tmp, so we need to check the "real" appimage location. std::string_view real_approot = EmuFolders::AppRoot; @@ -156,9 +156,8 @@ bool Core::SetDataRoot(Error* error) EmuFolders::DataRoot = std::string(real_approot); return true; } -#endif // __ANDROID__ -#if defined(_WIN32) +#ifdef _WIN32 // On Windows, we want to use %APPDATA%\DuckStation for data, and %LOCALAPPDATA%\DuckStation for cache. // Old installs use Documents\DuckStation for everything. Check this first. @@ -195,7 +194,7 @@ bool Core::SetDataRoot(Error* error) } } -#elif (defined(__linux__) || defined(__FreeBSD__)) && !defined(__ANDROID__) +#elifdef __linux__ // Use $XDG_CONFIG_HOME/duckstation if it exists. const char* xdg_config_home = getenv("XDG_CONFIG_HOME"); @@ -222,7 +221,7 @@ bool Core::SetDataRoot(Error* error) } } -#elif defined(__APPLE__) +#elifdef __APPLE__ static constexpr char MAC_DATA_DIR[] = "Library/Application Support/DuckStation"; const char* home_dir = getenv("HOME"); @@ -257,8 +256,6 @@ bool Core::SetDataRoot(Error* error) return true; } -#ifndef __ANDROID__ - std::string Core::GetBaseSettingsPath() { return Path::Combine(EmuFolders::DataRoot, "settings.ini"); @@ -349,8 +346,6 @@ void Core::SetDefaultSettings(SettingsInterface& si, bool host, bool system, boo } } -#endif // __ANDROID__ - std::unique_lock Core::GetSettingsLock() { return std::unique_lock(s_locals.settings_mutex); @@ -758,10 +753,8 @@ bool Core::CoreThreadInitialize(bool disable_worker_threads, Error* error) Achievements::Initialize(); -#ifdef ENABLE_DISCORD_PRESENCE if (g_settings.enable_discord_presence) DiscordPresence::Initialize(); -#endif return true; } @@ -770,9 +763,7 @@ void Core::CoreThreadShutdown() { s_locals.async_task_queue.SetWorkerCount(0, 0); -#ifdef ENABLE_DISCORD_PRESENCE DiscordPresence::Shutdown(); -#endif Achievements::Shutdown(); @@ -824,15 +815,11 @@ void Core::IdleUpdate(u64 max_poll_time) { InputManager::PollSources(); -#ifdef ENABLE_DISCORD_PRESENCE DiscordPresence::Poll(); -#endif HTTPDownloader::PollRequests(); Achievements::IdleUpdate(); -#ifdef ENABLE_GDB_SERVER GDBServer::PollUntil(max_poll_time); -#endif } diff --git a/src/core/cpu_code_cache.cpp b/src/core/cpu_code_cache.cpp index a7faf5ee2..929292ad1 100644 --- a/src/core/cpu_code_cache.cpp +++ b/src/core/cpu_code_cache.cpp @@ -68,9 +68,8 @@ static constexpr u32 RECOMPILER_FAR_CODE_CACHE_SIZE = 16 * 1024 * 1024; // On Linux ARM32/ARM64, we use a dedicated section in the ELF for storing code. This is because without // ASLR, or on certain ASLR offsets, the sbrk() heap ends up immediately following the text/data sections, -// which means there isn't a large enough gap to fit within range on ARM32. Also enable it for Android, -// because MAP_FIXED_NOREPLACE may not exist on older kernels. -#if (defined(__linux__) && (defined(CPU_ARCH_ARM32) || defined(CPU_ARCH_ARM64))) || defined(__ANDROID__) +// which means there isn't a large enough gap to fit within range on ARM32. +#if defined(__linux__) && (defined(CPU_ARCH_ARM32) || defined(CPU_ARCH_ARM64)) #define USE_CODE_BUFFER_SECTION 1 #endif diff --git a/src/core/cpu_recompiler_x64.cpp b/src/core/cpu_recompiler_x64.cpp index 4bf4c5854..8b9f267d2 100644 --- a/src/core/cpu_recompiler_x64.cpp +++ b/src/core/cpu_recompiler_x64.cpp @@ -42,7 +42,7 @@ static constexpr u32 BACKPATCH_JMP_SIZE = 5; static bool IsCallerSavedRegister(u32 id); // ABI selection -#if defined(_WIN32) +#ifdef _WIN32 #define RWRET Xbyak::Reg32(Xbyak::Operand::EAX) #define RWARG1 Xbyak::Reg32(Xbyak::Operand::RCX) @@ -58,7 +58,7 @@ static bool IsCallerSavedRegister(u32 id); // on win32, we need to reserve an additional 32 bytes shadow space when calling out to C static constexpr u32 STACK_SHADOW_SIZE = 32; -#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__) || defined(__FreeBSD__) +#else #define RWRET Xbyak::Reg32(Xbyak::Operand::EAX) #define RWARG1 Xbyak::Reg32(Xbyak::Operand::EDI) @@ -73,10 +73,6 @@ static constexpr u32 STACK_SHADOW_SIZE = 32; static constexpr u32 STACK_SHADOW_SIZE = 0; -#else - -#error Unknown ABI. - #endif namespace CPU { diff --git a/src/core/discord_presence.cpp b/src/core/discord_presence.cpp index a268111a8..89e9b8196 100644 --- a/src/core/discord_presence.cpp +++ b/src/core/discord_presence.cpp @@ -3,8 +3,6 @@ #include "discord_presence.h" -#ifdef ENABLE_DISCORD_PRESENCE - #include "achievements.h" #include "game_database.h" #include "system.h" @@ -193,5 +191,3 @@ void DiscordPresence::UpdateDetails(std::string_view badge_url, std::string_view Update(false); } - -#endif // ENABLE_DISCORD_PRESENCE \ No newline at end of file diff --git a/src/core/discord_presence.h b/src/core/discord_presence.h index 9d14234b7..94b181e36 100644 --- a/src/core/discord_presence.h +++ b/src/core/discord_presence.h @@ -7,13 +7,6 @@ #include -// Discord presence is available on all platforms except Android. -#ifndef __ANDROID__ -#define ENABLE_DISCORD_PRESENCE -#endif - -#ifdef ENABLE_DISCORD_PRESENCE - namespace DiscordPresence { bool Initialize(); @@ -26,5 +19,3 @@ void Update(bool is_new_session); void UpdateDetails(std::string_view badge_url, std::string_view state); } // namespace DiscordPresence - -#endif // ENABLE_DISCORD_PRESENCE diff --git a/src/core/fullscreenui_widgets.cpp b/src/core/fullscreenui_widgets.cpp index 52ef9c744..920a43434 100644 --- a/src/core/fullscreenui_widgets.cpp +++ b/src/core/fullscreenui_widgets.cpp @@ -1717,7 +1717,6 @@ void FullscreenUI::DrawWithBlurTexture(const ImDrawList* parent_list, const ImDr bool FullscreenUI::UpdateLayoutScale() { -#ifndef __ANDROID__ static constexpr float LAYOUT_RATIO = LAYOUT_SCREEN_WIDTH / LAYOUT_SCREEN_HEIGHT; const ImGuiIO& io = ImGui::GetIO(); @@ -1748,21 +1747,6 @@ bool FullscreenUI::UpdateLayoutScale() UIStyle.MediumSmallFontSize = LayoutScale(LAYOUT_MEDIUM_SMALL_FONT_SIZE); return (UIStyle.LayoutScale != old_scale); - -#else - // On Android, treat a rotated display as always being in landscape mode for FSUI scaling. - // Makes achievement popups readable regardless of the device's orientation, and avoids layout changes. - const ImGuiIO& io = ImGui::GetIO(); - const float old_scale = UIStyle.LayoutScale; - UIStyle.LayoutScale = std::max(io.DisplaySize.x, io.DisplaySize.y) / LAYOUT_SCREEN_WIDTH; - UIStyle.RcpLayoutScale = 1.0f / UIStyle.LayoutScale; - UIStyle.LargeFontSize = LayoutScale(LAYOUT_LARGE_FONT_SIZE); - UIStyle.MediumFontSize = LayoutScale(LAYOUT_MEDIUM_FONT_SIZE); - UIStyle.MediumLargeFontSize = LayoutScale(LAYOUT_MEDIUM_LARGE_FONT_SIZE); - UIStyle.MediumSmallFontSize = LayoutScale(LAYOUT_MEDIUM_SMALL_FONT_SIZE); - return (UIStyle.LayoutScale != old_scale); - -#endif } FullscreenUI::IconStackString::IconStackString(std::string_view icon, std::string_view str) @@ -7084,15 +7068,7 @@ FullscreenUI::NotificationLayout::NotificationLayout(NotificationLocation locati : m_spacing(LayoutScale(10.0f)), m_location(location) { const float screen_margin = ImGuiManager::GetScreenMargin(); - - // android goes a little lower due to on-screen buttons -#ifndef __ANDROID__ - static constexpr float top_start_pct = 0.1f; -#else - static constexpr float top_start_pct = 0.15f; -#endif - - const float top_margin = ImFloor(top_start_pct * ImGui::GetIO().DisplaySize.y); + const float top_margin = ImFloor(0.1f * ImGui::GetIO().DisplaySize.y); CalcStartPosition(screen_margin, top_margin); } diff --git a/src/core/game_database.cpp b/src/core/game_database.cpp index 56e238a4e..7359d7b1c 100644 --- a/src/core/game_database.cpp +++ b/src/core/game_database.cpp @@ -883,15 +883,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes if (HasTrait(Trait::ForcePGXPCPUMode)) { if (display_osd_messages && settings.gpu_pgxp_enable && !settings.gpu_pgxp_cpu) - { -#ifndef __ANDROID__ append_message(TRANSLATE_SV("GameDatabase", "PGXP CPU mode enabled.")); -#else - Host::AddIconOSDMessage(OSDMessageType::Warning, "gamedb_force_pgxp_cpu", ICON_EMOJI_WARNING, - "This game requires PGXP CPU mode, which increases system requirements." - "If the game runs too slow, disable PGXP for this game."); -#endif - } settings.gpu_pgxp_cpu = settings.gpu_pgxp_enable; } diff --git a/src/core/game_list.cpp b/src/core/game_list.cpp index bba2ea208..b77627bde 100644 --- a/src/core/game_list.cpp +++ b/src/core/game_list.cpp @@ -1133,10 +1133,6 @@ void GameList::Refresh(std::unique_lock& lock, bool invali if (!achievements_progress.Load(&error)) WARNING_LOG("Failed to load achievements progress: {}", error.GetDescription()); -#ifdef __ANDROID__ - recursive_dirs.push_back(Path::Combine(EmuFolders::DataRoot, "games")); -#endif - if (!dirs.empty() || !recursive_dirs.empty()) { progress->SetState(0, static_cast(dirs.size() + recursive_dirs.size())); diff --git a/src/core/gdb_server.cpp b/src/core/gdb_server.cpp index ca4588952..4c4bb1f58 100644 --- a/src/core/gdb_server.cpp +++ b/src/core/gdb_server.cpp @@ -3,8 +3,6 @@ #include "gdb_server.h" -#ifdef ENABLE_GDB_SERVER - #include "bus.h" #include "cpu_code_cache.h" #include "cpu_core.h" @@ -1546,5 +1544,3 @@ void GDBServer::OnSystemResumed() for (size_t i = 0; i < s_locals.clients.size(); i++) s_locals.clients[i]->OnSystemResumed(); } - -#endif // ENABLE_GDB_SERVER diff --git a/src/core/gdb_server.h b/src/core/gdb_server.h index 9927f11e4..bdcba3da0 100644 --- a/src/core/gdb_server.h +++ b/src/core/gdb_server.h @@ -5,13 +5,6 @@ #include "common/types.h" -// GDB server is available on all platforms except Android. -#ifndef __ANDROID__ -#define ENABLE_GDB_SERVER -#endif - -#ifdef ENABLE_GDB_SERVER - namespace GDBServer { bool Initialize(u16 port); @@ -30,5 +23,3 @@ namespace Host { void OnGDBServerActiveClientsChanged(bool has_clients); } // namespace Host - -#endif // ENABLE_GDB_SERVER diff --git a/src/core/gpu_dump.cpp b/src/core/gpu_dump.cpp index 2687d1335..e89dd2cf1 100644 --- a/src/core/gpu_dump.cpp +++ b/src/core/gpu_dump.cpp @@ -19,6 +19,7 @@ #include "common/file_system.h" #include "common/log.h" #include "common/path.h" +#include "common/platform_strings.h" #include "common/string_util.h" #include "common/timer.h" diff --git a/src/core/gte.cpp b/src/core/gte.cpp index 424afe51b..e94bc1e79 100644 --- a/src/core/gte.cpp +++ b/src/core/gte.cpp @@ -26,12 +26,6 @@ LOG_CHANNEL(CPU); -// Freecam is disabled on Android because there's no windowed UI for it. -// And because users can't be trusted to not crash games and complain. -#ifndef __ANDROID__ -#define ENABLE_FREECAM 1 -#endif - namespace GTE { static constexpr s64 MAC0_MIN_VALUE = -(INT64_C(1) << 31); @@ -71,8 +65,6 @@ struct ALIGN_TO_CACHE_LINE Config u32 custom_aspect_ratio_denominator = 0; float custom_aspect_ratio_f = 1.0f; -#ifdef ENABLE_FREECAM - Timer::Value freecam_update_time = 0; std::atomic_bool freecam_transform_changed{false}; bool freecam_enabled = false; @@ -89,7 +81,6 @@ struct ALIGN_TO_CACHE_LINE Config ALIGN_TO_CACHE_LINE GSMatrix4x4 freecam_matrix = GSMatrix4x4::Identity(); GSMatrix4x4 freecam_inverted_rotation_matrix = GSMatrix4x4::Identity(); -#endif }; } // namespace @@ -240,10 +231,6 @@ static void NCCS(const s16 V[3], u8 shift, bool lm); static void NCDS(const s16 V[3], u8 shift, bool lm); static void DPCS(const u8 color[3], u8 shift, bool lm); -#ifdef ENABLE_FREECAM -static void ApplyFreecam(s64& x, s64& y, s64& z); -#endif - static void Execute_MVMVA(Instruction inst); static void Execute_SQR(Instruction inst); static void Execute_OP(Instruction inst); @@ -268,6 +255,8 @@ static void Execute_INTPL(Instruction inst); static void Execute_GPL(Instruction inst); static void Execute_GPF(Instruction inst); +static void ApplyFreecam(s64& x, s64& y, s64& z); + } // namespace GTE void GTE::Reset() @@ -728,10 +717,8 @@ void GTE::RTPS(const s16 V[3], u8 shift, bool lm, bool last) s64 y = dot3(1); s64 z = dot3(2); -#ifdef ENABLE_FREECAM if (s_config.freecam_active) ApplyFreecam(x, y, z); -#endif TruncateAndSetMAC<1>(x, shift); TruncateAndSetMAC<2>(y, shift); @@ -805,7 +792,6 @@ void GTE::RTPS(const s16 V[3], u8 shift, bool lm, bool last) precise_y = RT1.dot(FV) + static_cast(REGS.TR[1]); precise_z = RT2.dot(FV) + static_cast(REGS.TR[2]); -#ifdef ENABLE_FREECAM if (s_config.freecam_active) { const GSVector4 offset_pos = s_config.freecam_matrix * GSVector4(precise_x, precise_y, precise_z, 1.0f); @@ -813,7 +799,6 @@ void GTE::RTPS(const s16 V[3], u8 shift, bool lm, bool last) precise_y = offset_pos.extract32<1>(); precise_z = offset_pos.extract32<2>(); } -#endif } else { @@ -1501,8 +1486,6 @@ GTE::InstructionImpl GTE::GetInstructionImpl(u32 inst_bits, TickCount* ticks) } } -#ifdef ENABLE_FREECAM - bool GTE::IsFreecamEnabled() { return s_config.freecam_enabled; @@ -1808,36 +1791,3 @@ void GTE::DrawFreecamWindow(float scale) if (changed) s_config.freecam_transform_changed.store(true, std::memory_order_release); } - -#else // ENABLE_FREECAM - -bool GTE::IsFreecamEnabled() -{ - return false; -} - -void GTE::SetFreecamEnabled(bool enabled) -{ -} - -void GTE::SetFreecamMoveAxis(u32 axis, float x) -{ -} - -void GTE::SetFreecamRotateAxis(u32 axis, float x) -{ -} - -void GTE::UpdateFreecam(u64 current_time) -{ -} - -void GTE::ResetFreecam() -{ -} - -void GTE::DrawFreecamWindow(float scale) -{ -} - -#endif // ENABLE_FREECAM diff --git a/src/core/guncon.cpp b/src/core/guncon.cpp index 5176cdd98..5106e97fc 100644 --- a/src/core/guncon.cpp +++ b/src/core/guncon.cpp @@ -289,11 +289,7 @@ static const Controller::ControllerBindingInfo s_binding_info[] = { #undef BUTTON }; -#ifndef __ANDROID__ static constexpr const char* DEFAULT_CROSSHAIR_PATH = "images" FS_OSPATH_SEPARATOR_STR "crosshair.png"; -#else -static constexpr const char* DEFAULT_CROSSHAIR_PATH = ""; -#endif static const SettingInfo s_settings[] = { {SettingInfo::Type::Path, "CrosshairImagePath", TRANSLATE_NOOP("GunCon", "Crosshair Image Path"), @@ -373,14 +369,10 @@ void GunCon::LoadSettings(const SettingsInterface& si, const char* section, bool if (!m_cursor_path.empty()) { std::string image_path; -#ifndef __ANDROID__ if (!Path::IsAbsolute(m_cursor_path)) image_path = Path::Combine(EmuFolders::Resources, m_cursor_path); else image_path = m_cursor_path; -#else - image_path = m_cursor_path; -#endif ImGuiManager::SetSoftwareCursor(new_pointer_index, std::move(image_path), m_cursor_scale, m_cursor_color); if (m_has_relative_binds) diff --git a/src/core/hotkeys.cpp b/src/core/hotkeys.cpp index 7edf9658d..cb539f579 100644 --- a/src/core/hotkeys.cpp +++ b/src/core/hotkeys.cpp @@ -39,7 +39,6 @@ void Settings::SetDefaultHotkeyConfig(SettingsInterface& si) { si.ClearSection("Hotkeys"); -#ifndef __ANDROID__ si.SetStringValue("Hotkeys", "FastForward", "Keyboard/Tab"); si.SetStringValue("Hotkeys", "TogglePause", "Keyboard/Space"); si.SetStringValue("Hotkeys", "Screenshot", "Keyboard/F10"); @@ -50,7 +49,6 @@ void Settings::SetDefaultHotkeyConfig(SettingsInterface& si) si.SetStringValue("Hotkeys", "SaveSelectedSaveState", "Keyboard/F2"); si.SetStringValue("Hotkeys", "SelectPreviousSaveStateSlot", "Keyboard/F3"); si.SetStringValue("Hotkeys", "SelectNextSaveStateSlot", "Keyboard/F4"); -#endif } static void HotkeyModifyResolutionScale(s32 increment) @@ -128,8 +126,6 @@ static bool HotkeyCheckRewindAvailability(bool enabled) static constexpr const HotkeyInfo s_hotkey_list[] = { -#ifndef __ANDROID__ - {"OpenPauseMenu", TRANSLATE_NOOP("Hotkeys", "Interface"), TRANSLATE_NOOP("Hotkeys", "Open Pause Menu"), [](InputButtonEvent event) { if (event == InputButtonEvent::Released && System::CanPauseSystem(true)) @@ -182,8 +178,6 @@ static constexpr const HotkeyInfo s_hotkey_list[] = { VideoThread::SetFullscreen(!VideoThread::IsFullscreen()); }}, -#endif // __ANDROID__ - {"FastForward", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP("Hotkeys", "Fast Forward (Hold)"), [](InputButtonEvent event) { System::SetFastForwardEnabled(event == InputButtonEvent::Pressed); }}, @@ -214,13 +208,11 @@ static constexpr const HotkeyInfo s_hotkey_list[] = { Host::RunOnCoreThread(System::ResetSystem); }}, -#ifndef __ANDROID__ {"ChangeDisc", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP("Hotkeys", "Change Disc"), [](InputButtonEvent event) { if (event == InputButtonEvent::Released) FullscreenUI::OpenDiscChangeMenu(); }}, -#endif // __ANDROID__ {"SwitchToPreviousDisc", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP("Hotkeys", "Switch to Previous Disc"), [](InputButtonEvent event) { @@ -243,7 +235,6 @@ static constexpr const HotkeyInfo s_hotkey_list[] = { System::SetRewindState(enabled); }}, -#ifndef __ANDROID__ {"FrameStep", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP("Hotkeys", "Frame Step"), [](InputButtonEvent event) { if (event == InputButtonEvent::Released) @@ -283,8 +274,6 @@ static constexpr const HotkeyInfo s_hotkey_list[] = { } }}, -#endif // __ANDROID__ - {"SwapMemoryCards", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP("Hotkeys", "Swap Memory Card Slots"), [](InputButtonEvent event) { if (event == InputButtonEvent::Released) @@ -517,9 +506,6 @@ static constexpr const HotkeyInfo s_hotkey_list[] = { System::StopRecordingGPUDump(); }}, -// See gte.cpp. -#ifndef __ANDROID__ - {"FreecamToggle", TRANSLATE_NOOP("Hotkeys", "Free Camera"), TRANSLATE_NOOP("Hotkeys", "Freecam Toggle"), [](InputButtonEvent event) { if (event == InputButtonEvent::Released && !Achievements::IsHardcoreModeActive()) @@ -630,8 +616,6 @@ static constexpr const HotkeyInfo s_hotkey_list[] = { GTE::SetFreecamRotateAxis(2, (event == InputButtonEvent::Pressed) ? 1.0f : 0.0f); }}, -#endif // __ANDROID__ - {"AudioMute", TRANSLATE_NOOP("Hotkeys", "Audio"), TRANSLATE_NOOP("Hotkeys", "Toggle Mute"), [](InputButtonEvent event) { if (event == InputButtonEvent::Released && System::IsValid()) diff --git a/src/core/imgui_overlays.cpp b/src/core/imgui_overlays.cpp index f72c1c186..ee5fc2ef6 100644 --- a/src/core/imgui_overlays.cpp +++ b/src/core/imgui_overlays.cpp @@ -86,8 +86,6 @@ struct InputOverlayStateUpdateBuffer InputOverlayState::PadState pads[0]; }; -#ifndef __ANDROID__ - struct DebugWindowInfo { const char* name; @@ -98,8 +96,6 @@ struct DebugWindowInfo u32 default_height; }; -#endif - } // namespace static void FormatProcessorStat(SmallStringBase& text, double usage, double time); @@ -114,8 +110,6 @@ static void DrawEnhancementsOverlay(const GPUBackend* gpu); static void DrawInputsOverlay(); static void UpdateInputOverlay(void* buffer); -#ifndef __ANDROID__ - static constexpr size_t NUM_DEBUG_WINDOWS = 7; static constexpr const char* DEBUG_WINDOW_CONFIG_SECTION = "DebugWindows"; static constexpr const std::array s_debug_window_info = {{ @@ -129,15 +123,12 @@ static constexpr const std::array s_debug_wi }}; static std::array s_debug_window_state = {}; -#endif - static InputOverlayState s_input_overlay_state = {}; } // namespace ImGuiManager bool ImGuiManager::AreAnyDebugWindowsEnabled(const SettingsInterface& si) { -#ifndef __ANDROID__ const bool block_all = Achievements::IsHardcoreModeActive(); if (block_all) return false; @@ -148,23 +139,17 @@ bool ImGuiManager::AreAnyDebugWindowsEnabled(const SettingsInterface& si) if (si.GetBoolValue(DEBUG_WINDOW_CONFIG_SECTION, info.name, false)) return true; } -#endif return false; } bool ImGuiManager::IsSPUDebugWindowEnabled() { -#ifndef __ANDROID__ return (s_debug_window_state[1].window_handle != nullptr); -#else - return false; -#endif } bool ImGuiManager::UpdateDebugWindowConfig() { -#ifndef __ANDROID__ const bool block_all = Achievements::IsHardcoreModeActive(); bool was_changed = false; @@ -198,14 +183,10 @@ bool ImGuiManager::UpdateDebugWindowConfig() } return was_changed; -#else - return false; -#endif } void ImGuiManager::RenderDebugWindows() { -#ifndef __ANDROID__ for (size_t i = 0; i < NUM_DEBUG_WINDOWS; i++) { AuxiliaryRenderWindowState& state = s_debug_window_state[i]; @@ -221,12 +202,10 @@ void ImGuiManager::RenderDebugWindows() Host::CommitBaseSettingChanges(); } } -#endif } void ImGuiManager::DestroyAllDebugWindows() { -#ifndef __ANDROID__ for (size_t i = 0; i < NUM_DEBUG_WINDOWS; i++) { AuxiliaryRenderWindowState& state = s_debug_window_state[i]; @@ -235,7 +214,6 @@ void ImGuiManager::DestroyAllDebugWindows() ImGuiManager::DestroyAuxiliaryRenderWindow(&state, DEBUG_WINDOW_CONFIG_SECTION, s_debug_window_info[i].name); } -#endif } void ImGuiManager::RenderTextOverlays(const GPUBackend* gpu) @@ -539,7 +517,6 @@ void ImGuiManager::DrawPerformanceOverlay(const GPUBackend* gpu, float& position position_y += spacing; } -#ifndef __ANDROID__ if (MediaCapture* cap = System::GetMediaCapture()) { text.assign(BOLD("CAP:") " "); @@ -547,7 +524,6 @@ void ImGuiManager::DrawPerformanceOverlay(const GPUBackend* gpu, float& position DrawPerformanceStat(dl, position_y, fixed_font, fixed_font_size, FIXED_BOLD_WEIGHT, 0, rbound, text); position_y += spacing; } -#endif } if (g_gpu_settings.display_show_gpu_usage && g_gpu_device->IsGPUTimingEnabled()) @@ -659,7 +635,6 @@ void ImGuiManager::DrawEnhancementsOverlay(const GPUBackend* gpu) void ImGuiManager::DrawMediaCaptureOverlay(float& position_y, float scale, float margin, float spacing) { -#ifndef __ANDROID__ MediaCapture* const cap = System::GetMediaCapture(); if (!cap) return; @@ -701,7 +676,6 @@ void ImGuiManager::DrawMediaCaptureOverlay(float& position_y, float scale, float IM_COL32(255, 255, 255, 255), text_msg.c_str(), text_msg.end_ptr()); position_y += box_size.y + spacing; -#endif } void ImGuiManager::DrawFrameTimeOverlay(float& position_y, float scale, float margin, float spacing) diff --git a/src/core/justifier.cpp b/src/core/justifier.cpp index 0813125c5..ae65af301 100644 --- a/src/core/justifier.cpp +++ b/src/core/justifier.cpp @@ -354,11 +354,7 @@ static const Controller::ControllerBindingInfo s_binding_info[] = { #undef BUTTON }; -#ifndef __ANDROID__ static constexpr const char* DEFAULT_CROSSHAIR_PATH = "images" FS_OSPATH_SEPARATOR_STR "crosshair.png"; -#else -static constexpr const char* DEFAULT_CROSSHAIR_PATH = ""; -#endif static const SettingInfo s_settings[] = { {SettingInfo::Type::Path, "CrosshairImagePath", TRANSLATE_NOOP("Justifier", "Crosshair Image Path"), @@ -453,14 +449,10 @@ void Justifier::LoadSettings(const SettingsInterface& si, const char* section, b if (!m_cursor_path.empty()) { std::string image_path; -#ifndef __ANDROID__ if (!Path::IsAbsolute(m_cursor_path)) image_path = Path::Combine(EmuFolders::Resources, m_cursor_path); else image_path = m_cursor_path; -#else - image_path = m_cursor_path; -#endif ImGuiManager::SetSoftwareCursor(new_pointer_index, std::move(image_path), m_cursor_scale, m_cursor_color); if (m_has_relative_binds) diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 4752b008e..8fe929835 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -150,10 +150,8 @@ const CPUFastmemMode Settings::DEFAULT_CPU_FASTMEM_MODE = #if defined(_WIN32) const MediaCaptureBackend Settings::DEFAULT_MEDIA_CAPTURE_BACKEND = MediaCaptureBackend::MediaFoundation; -#elif !defined(__ANDROID__) -const MediaCaptureBackend Settings::DEFAULT_MEDIA_CAPTURE_BACKEND = MediaCaptureBackend::FFmpeg; #else -const MediaCaptureBackend Settings::DEFAULT_MEDIA_CAPTURE_BACKEND = MediaCaptureBackend::MaxCount; +const MediaCaptureBackend Settings::DEFAULT_MEDIA_CAPTURE_BACKEND = MediaCaptureBackend::FFmpeg; #endif std::span Settings::GetSectionSaveOrder() @@ -184,9 +182,7 @@ std::span Settings::GetSectionSaveOrder() "PostProcessing", "BorderOverlay", "InputSources", -#ifdef ENABLE_SDL "SDLExtra", -#endif "ControllerPorts", "Pad1", "Pad2", @@ -577,10 +573,8 @@ void Settings::Load(const SettingsInterface& si, const SettingsInterface& contro gpu_dump_cpu_to_vram_copies = si.GetBoolValue("Debug", "DumpCPUToVRAMCopies"); gpu_dump_vram_to_cpu_copies = si.GetBoolValue("Debug", "DumpVRAMToCPUCopies"); -#ifndef __ANDROID__ enable_gdb_server = si.GetBoolValue("Debug", "EnableGDBServer"); gdb_server_port = static_cast(si.GetUIntValue("Debug", "GDBServerPort", DEFAULT_GDB_SERVER_PORT)); -#endif sio_redirect_to_tty = si.GetBoolValue("SIO", "RedirectToTTY", false); @@ -644,12 +638,6 @@ void Settings::Load(const SettingsInterface& si, const SettingsInterface& contro pio_flash_image_path = si.GetStringViewValue("PIO", "FlashImagePath"); pio_flash_write_enable = si.GetBoolValue("PIO", "FlashImageWriteEnable", false); pio_switch_active = si.GetBoolValue("PIO", "SwitchActive", true); - -#ifdef __ANDROID__ - // Android users are incredibly silly and don't understand that stretch is in the aspect ratio list... - if (si.GetBoolValue("Display", "Stretch", false)) - display_aspect_ratio = DisplayAspectRatio::MatchWindow; -#endif } void Settings::LoadPGXPSettings(const SettingsInterface& si) @@ -923,10 +911,8 @@ void Settings::Save(SettingsInterface& si, bool for_copy) const si.SetBoolValue("Debug", "DumpCPUToVRAMCopies", gpu_dump_cpu_to_vram_copies); si.SetBoolValue("Debug", "DumpVRAMToCPUCopies", gpu_dump_vram_to_cpu_copies); -#ifndef __ANDROID__ si.SetBoolValue("Debug", "EnableGDBServer", enable_gdb_server); si.SetUIntValue("Debug", "GDBServerPort", gdb_server_port); -#endif si.SetBoolValue("SIO", "RedirectToTTY", sio_redirect_to_tty); @@ -1214,9 +1200,7 @@ void Settings::ApplySettingRestrictions() UpdateOverclockActive(); } -#ifndef __ANDROID__ enable_gdb_server = false; -#endif gpu_show_vram = false; gpu_dump_cpu_to_vram_copies = false; @@ -1332,7 +1316,7 @@ void Settings::SetDefaultLogConfig(SettingsInterface& si) si.SetStringValue("Logging", "LogLevel", GetLogLevelName(Log::DEFAULT_LOG_LEVEL)); si.SetBoolValue("Logging", "LogTimestamps", true); -#if !defined(_WIN32) && !defined(__ANDROID__) +#ifndef _WIN32 // On Linux, default the console to whether standard input is currently available. si.SetBoolValue("Logging", "LogToConsole", Log::IsConsoleOutputCurrentlyAvailable()); #else @@ -1395,10 +1379,8 @@ void Settings::SetDefaultControllerConfig(SettingsInterface& si) si.SetStringValue(section.c_str(), "Type", Controller::GetControllerInfo(GetDefaultControllerType(i)).name); } -#ifndef __ANDROID__ // Use the automapper to set this up. InputManager::MapController(si, 0, InputManager::GetGenericBindingMapping("Keyboard"), true); -#endif } static constexpr const std::array s_log_level_names = { @@ -2069,11 +2051,7 @@ const char* Settings::GetDisplayFineCropModeDisplayName(DisplayFineCropMode mode static constexpr const std::string_view s_auto_aspect_ratio_name = TRANSLATE_DISAMBIG_NOOP("Settings", "Auto (Game Native)", "DisplayAspectRatio"); static constexpr const std::string_view s_stretch_aspect_ratio_name = -#ifndef __ANDROID__ TRANSLATE_DISAMBIG_NOOP("Settings", "Stretch To Fill", "DisplayAspectRatio"); -#else - "Auto (Match Window)"; -#endif static constexpr const std::string_view s_par_1_1_aspect_ratio_name = TRANSLATE_DISAMBIG_NOOP("Settings", "PAR 1:1", "DisplayAspectRatio"); diff --git a/src/core/settings.h b/src/core/settings.h index fd707420f..be86e739b 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -264,20 +264,9 @@ struct GPUSettings static constexpr s16 ACHIEVEMENT_NOTIFICATION_SCALE_OSD_SCALE = -1; static constexpr s16 ACHIEVEMENT_NOTIFICATION_SCALE_AUTO = 0; -#ifndef __ANDROID__ static constexpr u8 DEFAULT_GPU_MAX_QUEUED_FRAMES = 2; static constexpr bool DEFAULT_GPU_PREFER_GLES_CONTEXT = false; -#else - static constexpr u8 DEFAULT_GPU_MAX_QUEUED_FRAMES = 3; - static constexpr bool DEFAULT_GPU_PREFER_GLES_CONTEXT = true; -#endif - - // Prefer optimal frame pacing everywhere except ARM64 Linux because potatoes. -#if defined(__ANDROID__) || (defined(__linux__) && defined(__aarch64__)) - static constexpr bool DEFAULT_OPTIMAL_FRAME_PACING = false; -#else static constexpr bool DEFAULT_OPTIMAL_FRAME_PACING = true; -#endif }; struct Settings : public GPUSettings @@ -413,10 +402,8 @@ struct Settings : public GPUSettings std::string pcdrv_root; -#ifndef __ANDROID__ u16 gdb_server_port = DEFAULT_GDB_SERVER_PORT; bool enable_gdb_server = false; -#endif ALWAYS_INLINE bool IsRunaheadEnabled() const { return (runahead_frames > 0); } @@ -654,17 +641,10 @@ struct Settings : public GPUSettings static constexpr CaptureFileNameFormat DEFAULT_MEDIA_CAPTURE_FILENAME_FORMAT = CaptureFileNameFormat::TitleAndTimestamp; - // Android doesn't create settings until they're first opened, so we have to override the defaults here. -#ifndef __ANDROID__ static constexpr bool DEFAULT_SAVE_STATE_BACKUPS = true; static constexpr bool DEFAULT_FAST_BOOT_VALUE = false; static constexpr u16 DEFAULT_GDB_SERVER_PORT = 2345; static constexpr bool DEFAULT_ACHIEVEMENT_BADGE_PREFETCH = true; -#else - static constexpr bool DEFAULT_SAVE_STATE_BACKUPS = false; - static constexpr bool DEFAULT_FAST_BOOT_VALUE = true; - static constexpr bool DEFAULT_ACHIEVEMENT_BADGE_PREFETCH = false; -#endif }; ALIGN_TO_CACHE_LINE extern Settings g_settings; // CPU thread copy. diff --git a/src/core/spu.cpp b/src/core/spu.cpp index f35a84abc..a902b6204 100644 --- a/src/core/spu.cpp +++ b/src/core/spu.cpp @@ -2573,13 +2573,11 @@ void SPU::Execute(void* param, TickCount ticks) } } -#ifndef __ANDROID__ if (MediaCapture* cap = System::GetMediaCapture()) [[unlikely]] { if (!cap->DeliverAudioFrames(output_frame_start, frames_in_this_batch)) System::StopMediaCapture(); } -#endif if (!s_state.audio_output_muted) [[likely]] s_state.audio_stream.EndWrite(frames_in_this_batch); diff --git a/src/core/system.cpp b/src/core/system.cpp index d5fa76ac2..2afe7e755 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -1177,7 +1177,6 @@ void System::SetDefaultSettings(SettingsInterface& si, bool ignore_user_prefs) PostProcessing::Config::ClearStages(si, PostProcessing::Config::INTERNAL_CHAIN_SECTION); si.ClearSection("BorderOverlay"); -#ifndef __ANDROID__ si.SetStringValue("MediaCapture", "Backend", MediaCapture::GetBackendName(Settings::DEFAULT_MEDIA_CAPTURE_BACKEND)); si.SetStringValue("MediaCapture", "FileNameFormat", Settings::GetCaptureFileNameFormatName(Settings::DEFAULT_MEDIA_CAPTURE_FILENAME_FORMAT)); @@ -1194,7 +1193,6 @@ void System::SetDefaultSettings(SettingsInterface& si, bool ignore_user_prefs) si.SetStringValue("MediaCapture", "AudioCodec", ""); si.SetBoolValue("MediaCapture", "AudioCodecUseArgs", false); si.SetStringValue("MediaCapture", "AudioCodecArgs", ""); -#endif } void System::ApplySettings(bool display_osd_messages) @@ -1607,9 +1605,7 @@ void System::PauseSystem(bool paused) if (g_settings.inhibit_screensaver) InhibitScreensaver(false); -#ifdef ENABLE_GDB_SERVER GDBServer::OnSystemPaused(); -#endif Host::OnSystemPaused(); UpdateDisplayVSync(); @@ -1624,9 +1620,7 @@ void System::PauseSystem(bool paused) if (g_settings.inhibit_screensaver) InhibitScreensaver(true); -#ifdef ENABLE_GDB_SERVER GDBServer::OnSystemResumed(); -#endif Host::OnSystemResumed(); UpdateDisplayVSync(); @@ -1899,10 +1893,8 @@ System::BootResult System::BootSystem(SystemBootParameters parameters, Error* er if (g_settings.inhibit_screensaver) InhibitScreensaver(true); -#ifdef ENABLE_GDB_SERVER if (g_settings.enable_gdb_server) GDBServer::Initialize(g_settings.gdb_server_port); -#endif Host::OnSystemStarted(); @@ -2017,9 +2009,7 @@ void System::DestroySystem() s_state.undo_load_state.reset(); -#ifdef ENABLE_GDB_SERVER GDBServer::Shutdown(); -#endif VideoThread::RunOnThread([]() { VideoThread::SetRunIdleReason(VideoThread::RunIdleReason::SystemPaused, false); @@ -2107,9 +2097,7 @@ void System::ClearRunningGame() Host::OnSystemGameChanged(s_state.running_game_path, s_state.running_game_serial, s_state.running_game_title, s_state.running_game_hash); -#ifdef ENABLE_DISCORD_PRESENCE DiscordPresence::Update(true); -#endif } void System::Execute() @@ -2166,13 +2154,9 @@ void System::FrameDone() Achievements::FrameUpdate(); } -#ifdef ENABLE_DISCORD_PRESENCE DiscordPresence::Poll(); -#endif -#ifdef ENABLE_GDB_SERVER GDBServer::PollUntil(0); -#endif // Save states for rewind and runahead. if (s_state.rewind_save_counter >= 0) @@ -2383,7 +2367,6 @@ void System::Throttle(Timer::Value current_time, Timer::Value sleep_until) return; } -#ifdef ENABLE_GDB_SERVER // If we are running the GDB server and have clients, then use it to sleep instead. // That way in a query->response->query->response chain, we don't process only one message per frame. if (GDBServer::HasAnyClients()) @@ -2391,11 +2374,10 @@ void System::Throttle(Timer::Value current_time, Timer::Value sleep_until) GDBServer::PollUntil(sleep_until); } else -#endif { // Use a spinwait if we undersleep for all platforms except android.. don't want to burn battery. // Linux also seems to do a much better job of waking up at the requested time. -#if !defined(__linux__) && !defined(__ANDROID__) +#ifndef __linux__ Timer::SleepUntil(sleep_until, g_settings.display_optimal_frame_pacing); #else Timer::SleepUntil(sleep_until, false); @@ -4282,9 +4264,7 @@ void System::UpdateRunningGame(const std::string& path, CDImage* image, bool boo if (s_state.running_game_serial != prev_serial) UpdateSessionTime(prev_serial); -#ifdef ENABLE_DISCORD_PRESENCE DiscordPresence::Update(booting); -#endif if (!s_state.running_game_title.empty()) { @@ -4868,7 +4848,6 @@ void System::CheckForSettingsChanges(const Settings& old_settings) if (g_settings.inhibit_screensaver != old_settings.inhibit_screensaver) InhibitScreensaver(!IsPaused() && g_settings.inhibit_screensaver); -#ifdef ENABLE_GDB_SERVER if (g_settings.enable_gdb_server != old_settings.enable_gdb_server || g_settings.gdb_server_port != old_settings.gdb_server_port) { @@ -4876,7 +4855,6 @@ void System::CheckForSettingsChanges(const Settings& old_settings) if (g_settings.enable_gdb_server) GDBServer::Initialize(g_settings.gdb_server_port); } -#endif } else { @@ -4909,7 +4887,6 @@ void System::CheckForSettingsChanges(const Settings& old_settings) Achievements::UpdateSettings(old_settings); -#ifdef ENABLE_DISCORD_PRESENCE if (g_settings.enable_discord_presence != old_settings.enable_discord_presence) { if (g_settings.enable_discord_presence) @@ -4917,7 +4894,6 @@ void System::CheckForSettingsChanges(const Settings& old_settings) else DiscordPresence::Shutdown(); } -#endif if (g_settings.export_shared_memory != old_settings.export_shared_memory) [[unlikely]] { diff --git a/src/core/video_thread.cpp b/src/core/video_thread.cpp index 5a8547483..d133cb9b7 100644 --- a/src/core/video_thread.cpp +++ b/src/core/video_thread.cpp @@ -725,18 +725,11 @@ bool VideoThread::CreateDeviceOnThread(RenderAPI api, bool fullscreen, bool star if (g_gpu_settings.gpu_disable_compressed_textures) create_flags |= GPUDevice::CreateFlags::DisableCompressedTextures; - // Only dump shaders on debug builds for Android, users will complain about storage... -#if !defined(__ANDROID__) || defined(_DEBUG) - const std::string_view shader_dump_directory(EmuFolders::DataRoot); -#else - const std::string_view shader_dump_directory; -#endif - Error create_error; std::optional wi; if (!g_gpu_device || !(wi = Host::AcquireRenderWindow(api, fullscreen, fullscreen_mode.has_value(), &create_error)).has_value() || - !g_gpu_device->Create(Core::GetStringSettingValue("GPU", "Adapter"), create_flags, shader_dump_directory, + !g_gpu_device->Create(Core::GetStringSettingValue("GPU", "Adapter"), create_flags, EmuFolders::DataRoot, EmuFolders::Cache, SHADER_CACHE_VERSION, wi.value(), s_state.requested_vsync, fullscreen_mode.has_value() ? &fullscreen_mode.value() : nullptr, exclusive_fullscreen_control, &create_error)) @@ -862,9 +855,7 @@ bool VideoThread::CreateGPUBackendOnThread(bool hardware_renderer, bool upload_v } } -#ifndef __ANDROID__ ImGuiManager::UpdateDebugWindowConfig(); -#endif if (hardware_renderer) s_state.gpu_backend = GPUBackend::CreateHardwareBackend(); @@ -1264,8 +1255,7 @@ void VideoThread::UpdateSettings(bool gpu_settings_changed, bool device_settings } else { -#ifndef __ANDROID__ - // Not needed on Android, debug windows are not used. + // still need to update debug window visibility RunOnThread([]() { if (s_state.gpu_backend) { @@ -1273,7 +1263,6 @@ void VideoThread::UpdateSettings(bool gpu_settings_changed, bool device_settings PresentFrameAndRestoreContext(); } }); -#endif } } diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 7c188705a..fc6c1b539 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -26,6 +26,7 @@ add_library(util compress_helpers.h core_audio_stream.cpp core_audio_stream.h + cubeb_audio_stream.cpp cue_parser.cpp cue_parser.h dyn_libjpeg.h @@ -78,6 +79,9 @@ add_library(util postprocessing_shader_glsl.h postprocessing_shader_slang.cpp postprocessing_shader_slang.h + sdl_audio_stream.cpp + sdl_input_source.cpp + sdl_input_source.h shadergen.cpp shadergen.h shiftjis.cpp @@ -110,7 +114,8 @@ get_target_property(WEBP_INCLUDE_DIRS WebP::webp INTERFACE_INCLUDE_DIRECTORIES) get_target_property(LIBZIP_INCLUDE_DIRS libzip::zip INTERFACE_INCLUDE_DIRECTORIES) target_include_directories(util PRIVATE ${JPEG_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS} ${WEBP_INCLUDE_DIRS} ${LIBZIP_INCLUDE_DIRS}) target_link_libraries(util PUBLIC common imgui) -target_link_libraries(util PRIVATE libchdr lzma ZLIB::ZLIB SoundTouch::SoundTouchDLL xxhash zstd::libzstd_shared reshadefx) +target_link_libraries(util PRIVATE libchdr lzma reshadefx cubeb xxhash) +target_link_libraries(util PRIVATE CURL::libcurl SDL3::Headers SoundTouch::SoundTouchDLL ZLIB::ZLIB zstd::libzstd_shared) if(ENABLE_X11) target_sources(util PRIVATE @@ -142,7 +147,7 @@ if(ENABLE_OPENGL) target_compile_definitions(util PUBLIC "ENABLE_OPENGL=1") target_link_libraries(util PRIVATE glad) - if(LINUX OR BSD OR ANDROID) + if(LINUX OR BSD) target_sources(util PRIVATE opengl_context_egl.cpp opengl_context_egl.h @@ -166,9 +171,6 @@ if(ENABLE_OPENGL) "${Wayland_INCLUDE_DIRS}" # For wayland-egl ) endif() - if(ANDROID) - target_include_directories(util PRIVATE "${CMAKE_SOURCE_DIR}/android") - endif() endif() if(APPLE) @@ -203,7 +205,7 @@ if(ENABLE_VULKAN) target_link_libraries(util PUBLIC vulkan-headers) endif() -# shaderc/spirv-cross is loaded dynamically to reduce module loads on startup. +# freetype/plutosvg/shaderc/spirv-cross/ffmpeg is loaded dynamically to reduce module loads on startup. get_target_property(FREETYPE_INCLUDE_DIRS freetype INTERFACE_INCLUDE_DIRECTORIES) get_target_property(PLUTOSVG_INCLUDE_DIRS plutosvg::plutosvg INTERFACE_INCLUDE_DIRECTORIES) get_target_property(SHADERC_INCLUDE_DIR Shaderc::shaderc_shared INTERFACE_INCLUDE_DIRECTORIES) @@ -213,27 +215,9 @@ target_include_directories(util PUBLIC ${PLUTOSVG_INCLUDE_DIRS} ${SHADERC_INCLUDE_DIR} ${SPIRV_CROSS_INCLUDE_DIR} + ${FFMPEG_INCLUDE_DIRS} ) -if(NOT ANDROID) - target_sources(util PRIVATE - cubeb_audio_stream.cpp - sdl_audio_stream.cpp - sdl_input_source.cpp - sdl_input_source.h - ) - target_compile_definitions(util PUBLIC - ENABLE_SDL - ) - target_link_libraries(util PUBLIC - cubeb - SDL3::Headers - ) - - # FFmpeg loaded dynamically on demand. - target_include_directories(util PUBLIC ${FFMPEG_INCLUDE_DIRS}) -endif() - if(APPLE) set(MAC_SOURCES metal_device.h @@ -251,14 +235,8 @@ if(APPLE) find_library(QUARTZCORE_LIBRARY QuartzCore) target_link_libraries(util PRIVATE ${METAL_LIBRARY} ${QUARTZCORE_LIBRARY} ${IOK_LIBRARY}) set_source_files_properties(${MAC_SOURCES} PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE) -elseif(NOT ANDROID) - if(LINUX) - target_link_libraries(util PRIVATE UDEV::UDEV) - endif() -endif() - -if(NOT ANDROID) - target_link_libraries(util PRIVATE CURL::libcurl) +elseif(LINUX) + target_link_libraries(util PRIVATE UDEV::UDEV) endif() function(add_util_resources target) diff --git a/src/util/audio_stream.cpp b/src/util/audio_stream.cpp index 92b727944..24f668863 100644 --- a/src/util/audio_stream.cpp +++ b/src/util/audio_stream.cpp @@ -20,31 +20,20 @@ AudioStream::DeviceInfo::~DeviceInfo() = default; static constexpr const std::array s_backend_names = { // clang-format off "Null", -#ifndef __ANDROID__ "Cubeb", "SDL", -#endif #ifdef _WIN32 "XAudio2", -#endif -#ifdef __ANDROID__ - "AAudio", "OpenSLES", #endif // clang-format on }; static constexpr const std::array s_backend_display_names = { // clang-format off TRANSLATE_DISAMBIG_NOOP("Settings", "Null (No Output)", "AudioBackend"), -#ifndef __ANDROID__ TRANSLATE_DISAMBIG_NOOP("Settings", "Cubeb", "AudioBackend"), TRANSLATE_DISAMBIG_NOOP("Settings", "SDL", "AudioBackend"), -#endif #ifdef _WIN32 TRANSLATE_DISAMBIG_NOOP("Settings", "XAudio2", "AudioBackend"), -#endif -#ifdef __ANDROID__ - "AAudio", - "OpenSL ES", #endif // clang-format on }; @@ -83,11 +72,9 @@ std::vector> AudioStream::GetDriverNames(Aud std::vector> ret; switch (backend) { -#ifndef __ANDROID__ case AudioBackend::Cubeb: ret = GetCubebDriverNames(); break; -#endif default: break; @@ -102,11 +89,9 @@ std::vector AudioStream::GetOutputDevices(AudioBackend std::vector ret; switch (backend) { -#ifndef __ANDROID__ case AudioBackend::Cubeb: ret = GetCubebOutputDevices(driver, sample_rate); break; -#endif #ifdef _WIN32 case AudioBackend::XAudio2: ret = GetXAudio2OutputDevices(sample_rate); @@ -127,7 +112,6 @@ std::unique_ptr AudioStream::CreateStream(AudioBackend backend, u32 { switch (backend) { -#ifndef __ANDROID__ case AudioBackend::Cubeb: return CreateCubebAudioStream(sample_rate, channels, output_latency_frames, output_latency_minimal, driver_name, device_name, source, auto_start, error); @@ -135,21 +119,11 @@ std::unique_ptr AudioStream::CreateStream(AudioBackend backend, u32 case AudioBackend::SDL: return CreateSDLAudioStream(sample_rate, channels, output_latency_frames, output_latency_minimal, source, auto_start, error); -#endif #ifdef _WIN32 case AudioBackend::XAudio2: return CreateXAudio2AudioStream(sample_rate, channels, output_latency_frames, output_latency_minimal, device_name, source, auto_start, error); #endif -#ifdef __ANDROID__ - case AudioBackend::AAudio: - return CreateAAudioAudioStream(sample_rate, channels, output_latency_frames, output_latency_minimal, source, - auto_start, error); - - case AudioBackend::OpenSLES: - return CreateOpenSLESAudioStream(sample_rate, channels, output_latency_frames, output_latency_minimal, source, - auto_start, error); -#endif default: Error::SetStringView(error, "Unknown audio backend."); diff --git a/src/util/audio_stream.h b/src/util/audio_stream.h index 8acee21aa..8653fd0c4 100644 --- a/src/util/audio_stream.h +++ b/src/util/audio_stream.h @@ -15,15 +15,10 @@ class Error; enum class AudioBackend : u8 { Null, -#ifndef __ANDROID__ Cubeb, SDL, #ifdef _WIN32 XAudio2, -#endif -#else - AAudio, - OpenSLES, #endif Count }; @@ -41,11 +36,7 @@ class AudioStream public: using SampleType = AudioStreamSource::SampleType; -#ifndef __ANDROID__ static constexpr AudioBackend DEFAULT_BACKEND = AudioBackend::Cubeb; -#else - static constexpr AudioBackend DEFAULT_BACKEND = AudioBackend::AAudio; -#endif struct DeviceInfo { @@ -87,7 +78,6 @@ protected: AudioStream(); private: -#ifndef __ANDROID__ static std::vector> GetCubebDriverNames(); static std::vector GetCubebOutputDevices(std::string_view driver, u32 sample_rate); static std::unique_ptr CreateCubebAudioStream(u32 sample_rate, u32 channels, u32 output_latency_frames, @@ -104,13 +94,4 @@ private: std::string_view device_name, AudioStreamSource* source, bool auto_start, Error* error); #endif -#else - static std::unique_ptr CreateAAudioAudioStream(u32 sample_rate, u32 channels, u32 output_latency_frames, - bool output_latency_minimal, AudioStreamSource* source, - bool auto_start, Error* error); - static std::unique_ptr CreateOpenSLESAudioStream(u32 sample_rate, u32 channels, - u32 output_latency_frames, bool output_latency_minimal, - AudioStreamSource* source, bool auto_start, - Error* error); -#endif }; diff --git a/src/util/cd_image_device.cpp b/src/util/cd_image_device.cpp index 66ea0c104..e62da5b42 100644 --- a/src/util/cd_image_device.cpp +++ b/src/util/cd_image_device.cpp @@ -685,7 +685,7 @@ bool CDImage::IsDeviceName(const char* path) return std::string_view(path).starts_with("\\\\.\\"); } -#elif defined(__linux__) && !defined(__ANDROID__) +#elif defined(__linux__) #include #include @@ -1618,21 +1618,4 @@ bool CDImage::IsDeviceName(const char* path) return valid; } -#else - -std::unique_ptr CDImage::OpenDeviceImage(const char* path, Error* error) -{ - return {}; -} - -std::vector> CDImage::GetDeviceList() -{ - return {}; -} - -bool CDImage::IsDeviceName(const char* path) -{ - return false; -} - #endif diff --git a/src/util/core_audio_stream.h b/src/util/core_audio_stream.h index 6aa85fdb8..0b9d2d616 100644 --- a/src/util/core_audio_stream.h +++ b/src/util/core_audio_stream.h @@ -37,13 +37,8 @@ struct AudioStreamParameters bool stretch_use_aa_filter = DEFAULT_STRETCH_USE_AA_FILTER; static constexpr AudioStretchMode DEFAULT_STRETCH_MODE = AudioStretchMode::TimeStretch; -#ifndef __ANDROID__ static constexpr u16 DEFAULT_BUFFER_MS = 50; static constexpr u16 DEFAULT_OUTPUT_LATENCY_MS = 20; -#else - static constexpr u16 DEFAULT_BUFFER_MS = 100; - static constexpr u16 DEFAULT_OUTPUT_LATENCY_MS = 20; -#endif static constexpr bool DEFAULT_OUTPUT_LATENCY_MINIMAL = false; static constexpr u16 DEFAULT_STRETCH_SEQUENCE_LENGTH = 30; diff --git a/src/util/dyn_libs.cpp b/src/util/dyn_libs.cpp index f3d5a1948..c91c8123d 100644 --- a/src/util/dyn_libs.cpp +++ b/src/util/dyn_libs.cpp @@ -70,9 +70,6 @@ struct Locals std::once_flag libwebp_init_flag; DynamicLibrary libzip_library; std::once_flag libzip_init_flag; - DynamicLibrary sdl_library; - std::once_flag sdl_init_flag; - std::atomic sdl_init_subsystems{0}; DynamicLibrary sqlite_library; std::once_flag sqlite_init_flag; DynamicLibrary shaderc_library; @@ -80,6 +77,9 @@ struct Locals shaderc_compiler_t shaderc_compiler; DynamicLibrary spirv_cross_library; std::once_flag spirv_cross_init_flag; + DynamicLibrary sdl_library; + std::once_flag sdl_init_flag; + std::atomic sdl_init_subsystems{0}; }; } // namespace @@ -89,10 +89,10 @@ DynLibJPEG g_dyn_libjpeg; DynLibWebP g_dyn_libwebp; DynLibPNG g_dyn_libpng; DynLibZip g_dyn_libzip; -DynSDL g_dyn_sdl; DynSqlite g_dyn_sqlite; DynShaderc g_dyn_shaderc; DynSpirvCross g_dyn_spirv_cross; +DynSDL g_dyn_sdl; static Locals s_locals; Locals::~Locals() @@ -237,12 +237,6 @@ bool DynLibZip::Open(Error* const error) error); } -static const DynamicLibrary::SymbolTable s_sdl_symbols[] = { -#define RESOLVE_SYMBOL(F) {#F, (void**)&g_dyn_sdl.F}, - DYN_SDL_FUNCTIONS(RESOLVE_SYMBOL) -#undef RESOLVE_SYMBOL -}; - static const DynamicLibrary::SymbolTable s_sqlite_symbols[] = { #define RESOLVE_SYMBOL(F) {#F, (void**)&g_dyn_sqlite.F}, DYN_SQLITE_FUNCTIONS(RESOLVE_SYMBOL) @@ -258,6 +252,62 @@ bool DynSqlite::Open(Error* error) s_sqlite_symbols, error); } +static const DynamicLibrary::SymbolTable s_shaderc_symbols[] = { +#define RESOLVE_SYMBOL(F) {#F, (void**)&g_dyn_shaderc.F}, + DYN_SHADERC_FUNCTIONS(RESOLVE_SYMBOL) +#undef RESOLVE_SYMBOL +}; + +bool DynShaderc::Open(Error* const error) +{ + if (s_locals.shaderc_library.IsOpen()) [[likely]] + return true; + + return LoadDynLib("shaderc_shared", -1, s_locals.shaderc_library, s_locals.shaderc_init_flag, s_shaderc_symbols, + error, [](Error* const error) { + g_dyn_shaderc.compiler = g_dyn_shaderc.shaderc_compiler_initialize(); + if (!g_dyn_shaderc.compiler) + { + ERROR_LOG("shaderc_compiler_initialize() failed"); + Error::SetStringView(error, "shaderc_compiler_initialize() failed"); + return false; + } + + return true; + }); +} + +void DynShaderc::Close() +{ + if (compiler) + shaderc_compiler_release(std::exchange(compiler, nullptr)); +} + +// clang-format off +static const DynamicLibrary::SymbolTable s_spirv_cross_symbols[] = { +#define RESOLVE_SYMBOL(F) {#F, (void**)&g_dyn_spirv_cross.F}, + DYN_SPIRV_CROSS_FUNCTIONS(RESOLVE_SYMBOL) + DYN_SPIRV_CROSS_HLSL_FUNCTIONS(RESOLVE_SYMBOL) + DYN_SPIRV_CROSS_MSL_FUNCTIONS(RESOLVE_SYMBOL) +#undef RESOLVE_SYMBOL +}; +// clang-format on + +bool DynSpirvCross::Open(Error* const error) +{ + if (s_locals.spirv_cross_library.IsOpen()) [[likely]] + return true; + + return LoadDynLib("spirv-cross-c-shared", SPIRV_CROSS_MAJOR_VERSION, s_locals.spirv_cross_library, + s_locals.spirv_cross_init_flag, s_spirv_cross_symbols, error); +} + +static const DynamicLibrary::SymbolTable s_sdl_symbols[] = { +#define RESOLVE_SYMBOL(F) {#F, (void**)&g_dyn_sdl.F}, + DYN_SDL_FUNCTIONS(RESOLVE_SYMBOL) +#undef RESOLVE_SYMBOL +}; + static void SDLLogCallback(void* userdata, int category, SDL_LogPriority priority, const char* message) { static constexpr Log::Level priority_map[SDL_LOG_PRIORITY_COUNT] = { @@ -318,53 +368,3 @@ void DynSDL::QuitSubSystem(SDL_InitFlags flags) if (subsystems_to_release != 0) SDL_QuitSubSystem(subsystems_to_release); } - -static const DynamicLibrary::SymbolTable s_shaderc_symbols[] = { -#define RESOLVE_SYMBOL(F) {#F, (void**)&g_dyn_shaderc.F}, - DYN_SHADERC_FUNCTIONS(RESOLVE_SYMBOL) -#undef RESOLVE_SYMBOL -}; - -bool DynShaderc::Open(Error* const error) -{ - if (s_locals.shaderc_library.IsOpen()) [[likely]] - return true; - - return LoadDynLib("shaderc_shared", -1, s_locals.shaderc_library, s_locals.shaderc_init_flag, s_shaderc_symbols, - error, [](Error* const error) { - g_dyn_shaderc.compiler = g_dyn_shaderc.shaderc_compiler_initialize(); - if (!g_dyn_shaderc.compiler) - { - ERROR_LOG("shaderc_compiler_initialize() failed"); - Error::SetStringView(error, "shaderc_compiler_initialize() failed"); - return false; - } - - return true; - }); -} - -void DynShaderc::Close() -{ - if (compiler) - shaderc_compiler_release(std::exchange(compiler, nullptr)); -} - -// clang-format off -static const DynamicLibrary::SymbolTable s_spirv_cross_symbols[] = { -#define RESOLVE_SYMBOL(F) {#F, (void**)&g_dyn_spirv_cross.F}, - DYN_SPIRV_CROSS_FUNCTIONS(RESOLVE_SYMBOL) - DYN_SPIRV_CROSS_HLSL_FUNCTIONS(RESOLVE_SYMBOL) - DYN_SPIRV_CROSS_MSL_FUNCTIONS(RESOLVE_SYMBOL) -#undef RESOLVE_SYMBOL -}; -// clang-format on - -bool DynSpirvCross::Open(Error* const error) -{ - if (s_locals.spirv_cross_library.IsOpen()) [[likely]] - return true; - - return LoadDynLib("spirv-cross-c-shared", SPIRV_CROSS_MAJOR_VERSION, s_locals.spirv_cross_library, - s_locals.spirv_cross_init_flag, s_spirv_cross_symbols, error); -} diff --git a/src/util/imgui_manager.cpp b/src/util/imgui_manager.cpp index ed7f716a4..a4f3ad359 100644 --- a/src/util/imgui_manager.cpp +++ b/src/util/imgui_manager.cpp @@ -394,13 +394,8 @@ bool ImGuiManager::Initialize(Error* error) io.IniFilename = nullptr; io.BackendFlags |= ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures; -#ifndef __ANDROID__ - // Android has no keyboard, nor are we using ImGui for any actual user-interactable windows. io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard | ImGuiConfigFlags_NavEnableGamepad | ImGuiConfigFlags_NoMouseCursorChange; -#else - io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard | ImGuiConfigFlags_NavEnableGamepad; -#endif SetCommonIOOptions(io, s_state.imgui_context->PlatformIO); s_state.last_render_time = Timer::GetCurrentValue(); @@ -2097,8 +2092,6 @@ std::optional ImGuiManager::MapHostKeyEventToImGuiKey(u32 key) std::nullopt; } -#ifndef __ANDROID__ - bool ImGuiManager::CreateAuxiliaryRenderWindow(AuxiliaryRenderWindowState* state, std::string_view title, std::string_view icon_name, const char* config_section, const char* config_prefix, u32 default_width, u32 default_height, @@ -2313,5 +2306,3 @@ void ImGuiManager::ProcessAuxiliaryRenderWindowInputEvent(Host::AuxiliaryRenderW break; } } - -#endif // __ANDROID__ diff --git a/src/util/imgui_manager.h b/src/util/imgui_manager.h index 2af211f54..49433002d 100644 --- a/src/util/imgui_manager.h +++ b/src/util/imgui_manager.h @@ -96,11 +96,7 @@ enum class LanguageFont : u8 using LanguageFontOrder = std::array(LanguageFont::MaxCount)>; /// Default size for screen margins. -#ifndef __ANDROID__ inline constexpr float DEFAULT_SCREEN_MARGIN = 10.0f; -#else -inline constexpr float DEFAULT_SCREEN_MARGIN = 16.0f; -#endif /// Initializes ImGui, creates fonts, etc. bool Initialize(Error* error); @@ -232,8 +228,6 @@ float GetOSDMessageDuration(OSDMessageType type); /// Returns the ending position of OSD messages from the last frame. float GetOSDMessageEndPosition(); -#ifndef __ANDROID__ - /// Auxiliary imgui windows. struct AuxiliaryRenderWindowState { @@ -264,8 +258,6 @@ void ProcessAuxiliaryRenderWindowInputEvent(Host::AuxiliaryRenderWindowUserData Host::AuxiliaryRenderWindowEventParam param2, Host::AuxiliaryRenderWindowEventParam param3); -#endif - } // namespace ImGuiManager namespace Host { @@ -281,8 +273,6 @@ void AddIconOSDMessage(OSDMessageType type, std::string key, OSDMessageIconType void RemoveKeyedOSDMessage(std::string key); void ClearOSDMessages(); -#ifndef __ANDROID__ - /// Auxiliary window management. bool CreateAuxiliaryRenderWindow(s32 x, s32 y, u32 width, u32 height, std::string_view title, std::string_view icon_name, AuxiliaryRenderWindowUserData userdata, @@ -290,6 +280,4 @@ bool CreateAuxiliaryRenderWindow(s32 x, s32 y, u32 width, u32 height, std::strin void DestroyAuxiliaryRenderWindow(AuxiliaryRenderWindowHandle handle, s32* pos_x = nullptr, s32* pos_y = nullptr, u32* width = nullptr, u32* height = nullptr); -#endif - } // namespace Host diff --git a/src/util/input_manager.cpp b/src/util/input_manager.cpp index fea2c4820..d9f1eb963 100644 --- a/src/util/input_manager.cpp +++ b/src/util/input_manager.cpp @@ -269,13 +269,11 @@ struct State ALIGN_TO_CACHE_LINE static State s_state; static constexpr const std::array s_key_code_data = { -#if defined(_WIN32) +#ifdef _WIN32 #define KEY_ENTRY(ename, usb, evdev, xkb, win, mac, name, icon_name) KeyCodeData{usb, win, name, icon_name}, -#elif defined(__APPLE__) +#elifdef __APPLE__ #define KEY_ENTRY(ename, usb, evdev, xkb, win, mac, name, icon_name) KeyCodeData{usb, mac, name, icon_name}, -#elif defined(__ANDROID__) -#define KEY_ENTRY(ename, usb, evdev, xkb, win, mac, name, icon_name) KeyCodeData{usb, evdev, name, icon_name}, -#else +#elifdef __linux__ #define KEY_ENTRY(ename, usb, evdev, xkb, win, mac, name, icon_name) KeyCodeData{usb, xkb, name, icon_name}, #endif #include "common/thirdparty/usb_key_code_data.inl" @@ -795,12 +793,7 @@ static std::array(InputSourceType::Count)> s_input "XInput", "RawInput", #endif -#ifdef ENABLE_SDL "SDL", -#endif -#ifdef __ANDROID__ - "Android", -#endif }}; InputSource* InputManager::GetInputSourceInterface(InputSourceType type) @@ -832,15 +825,8 @@ bool InputManager::GetInputSourceDefaultEnabled(InputSourceType type) return false; #endif -#ifdef ENABLE_SDL case InputSourceType::SDL: return true; -#endif - -#ifdef __ANDROID__ - case InputSourceType::Android: - return true; -#endif default: return false; @@ -1609,10 +1595,8 @@ void InputManager::UpdateRelativeMouseMode() if (s_state.relative_mouse_mode == has_relative_mode_bindings && s_state.hide_host_mouse_cursor == hide_mouse_cursor) return; -#ifndef __ANDROID__ s_state.relative_mouse_mode = has_relative_mode_bindings; s_state.hide_host_mouse_cursor = hide_mouse_cursor; -#endif UpdateHostMouseMode(); } @@ -1713,11 +1697,9 @@ void InputManager::CopyConfiguration(SettingsInterface* dest_si, const SettingsI InputManager::InputSourceToString(static_cast(type))); } -#ifdef ENABLE_SDL // I hate this, but there isn't a better location for it... if (dest_si->GetBoolValue("InputSources", "SDL")) InputSource::CopySDLSourceSettings(dest_si, src_si); -#endif } const MultitapMode mtap_mode = @@ -2555,12 +2537,6 @@ GenericInputBindingMapping InputManager::GetGenericBindingMapping(std::string_vi bool InputManager::IsInputSourceEnabled(const SettingsInterface& si, InputSourceType type) { -#ifdef __ANDROID__ - // Force Android source to always be enabled so nobody accidentally breaks it via ini. - if (type == InputSourceType::Android) - return true; -#endif - return si.GetBoolValue("InputSources", InputSourceToString(type), GetInputSourceDefaultEnabled(type)); } @@ -2622,12 +2598,7 @@ void InputManager::ReloadSources(const SettingsInterface& sources_si, std::uniqu UnregisterDeviceNotificationHandle(); } #endif -#ifdef ENABLE_SDL UpdateInputSourceState(sources_si, settings_lock, InputSourceType::SDL, &InputSource::CreateSDLSource); -#endif -#ifdef __ANDROID__ - UpdateInputSourceState(sources_si, settings_lock, InputSourceType::Android, &InputSource::CreateAndroidSource); -#endif UpdatePointerCount(); } diff --git a/src/util/input_manager.h b/src/util/input_manager.h index a340e6475..70bc5aadb 100644 --- a/src/util/input_manager.h +++ b/src/util/input_manager.h @@ -34,12 +34,7 @@ enum class InputSourceType : u32 XInput, RawInput, #endif -#ifdef ENABLE_SDL SDL, -#endif -#ifdef __ANDROID__ - Android, -#endif Count, }; diff --git a/src/util/input_source.h b/src/util/input_source.h index 714be0109..49f13a4fc 100644 --- a/src/util/input_source.h +++ b/src/util/input_source.h @@ -121,10 +121,6 @@ public: static std::unique_ptr CreateXInputSource(); static std::unique_ptr CreateWin32RawInputSource(); #endif -#ifndef __ANDROID__ static std::unique_ptr CreateSDLSource(); static void CopySDLSourceSettings(SettingsInterface* dest_si, const SettingsInterface& src_si); -#else - static std::unique_ptr CreateAndroidSource(); -#endif }; diff --git a/src/util/media_capture.cpp b/src/util/media_capture.cpp index 8aa41a78a..b9e55b2d4 100644 --- a/src/util/media_capture.cpp +++ b/src/util/media_capture.cpp @@ -42,8 +42,6 @@ #pragma comment(lib, "mfuuid") #endif -#ifndef __ANDROID__ - #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4244) // warning C4244: 'return': conversion from 'int' to 'uint8_t', possible loss of data @@ -71,12 +69,8 @@ extern "C" { #pragma warning(pop) #endif -#endif - LOG_CHANNEL(MediaCapture); -#if defined(_WIN32) || !defined(__ANDROID__) - namespace { struct Locals { @@ -87,21 +81,17 @@ struct Locals std::once_flag mf_library_once_flag; #endif -#ifndef __ANDROID__ static inline DynamicLibrary avcodec_library; static inline DynamicLibrary avformat_library; static inline DynamicLibrary avutil_library; static inline DynamicLibrary swscale_library; static inline DynamicLibrary swresample_library; std::once_flag ffmpeg_once_flag; -#endif }; } // namespace static Locals s_locals; -#endif - namespace { static constexpr u32 VIDEO_WIDTH_ALIGNMENT = 8; @@ -2080,8 +2070,6 @@ bool MediaCaptureMF::ProcessAudioPackets(s64 video_pts, Error* error) #endif -#ifndef __ANDROID__ - #define VISIT_AVCODEC_IMPORTS(X) \ X(avcodec_get_supported_config) \ X(avcodec_find_encoder_by_name) \ @@ -3638,26 +3626,20 @@ MediaCapture::CodecList MediaCaptureFFmpeg::GetAudioCodecList(const char* contai return GetCodecListForContainer(container, AVMEDIA_TYPE_AUDIO); } -#endif - } // namespace static constexpr const std::array(MediaCaptureBackend::MaxCount)> s_backend_names = { #ifdef _WIN32 "MediaFoundation", #endif -#ifndef __ANDROID__ "FFmpeg", -#endif }; static constexpr const std::array(MediaCaptureBackend::MaxCount)> s_backend_display_names = { #ifdef _WIN32 TRANSLATE_DISAMBIG_NOOP("MediaCapture", "Media Foundation", "MediaCaptureBackend"), #endif -#ifndef __ANDROID__ TRANSLATE_DISAMBIG_NOOP("MediaCapture", "FFmpeg", "MediaCaptureBackend"), -#endif }; static_assert(s_backend_names.size() == static_cast(MediaCaptureBackend::MaxCount)); static_assert(s_backend_display_names.size() == static_cast(MediaCaptureBackend::MaxCount)); @@ -3705,11 +3687,9 @@ MediaCapture::ContainerList MediaCapture::GetAudioContainerList(MediaCaptureBack ret = MediaCaptureMF::GetAudioContainerList(); break; #endif -#ifndef __ANDROID__ case MediaCaptureBackend::FFmpeg: ret = MediaCaptureFFmpeg::GetAudioContainerList(); break; -#endif default: break; } @@ -3726,11 +3706,9 @@ MediaCapture::CodecList MediaCapture::GetAudioCodecList(MediaCaptureBackend back ret = MediaCaptureMF::GetAudioCodecList(container); break; #endif -#ifndef __ANDROID__ case MediaCaptureBackend::FFmpeg: ret = MediaCaptureFFmpeg::GetAudioCodecList(container); break; -#endif default: break; } @@ -3747,11 +3725,9 @@ MediaCapture::ContainerList MediaCapture::GetVideoContainerList(MediaCaptureBack ret = MediaCaptureMF::GetVideoContainerList(); break; #endif -#ifndef __ANDROID__ case MediaCaptureBackend::FFmpeg: ret = MediaCaptureFFmpeg::GetVideoContainerList(); break; -#endif default: break; } @@ -3768,11 +3744,9 @@ MediaCapture::CodecList MediaCapture::GetVideoCodecList(MediaCaptureBackend back ret = MediaCaptureMF::GetVideoCodecList(container); break; #endif -#ifndef __ANDROID__ case MediaCaptureBackend::FFmpeg: ret = MediaCaptureFFmpeg::GetVideoCodecList(container); break; -#endif default: break; } @@ -3787,10 +3761,8 @@ std::unique_ptr MediaCapture::Create(MediaCaptureBackend backend, case MediaCaptureBackend::MediaFoundation: return MediaCaptureMF::Create(error); #endif -#ifndef __ANDROID__ case MediaCaptureBackend::FFmpeg: return MediaCaptureFFmpeg::Create(error); -#endif default: return nullptr; } diff --git a/src/util/media_capture.h b/src/util/media_capture.h index 4e8dd9381..13029f21a 100644 --- a/src/util/media_capture.h +++ b/src/util/media_capture.h @@ -19,9 +19,7 @@ enum class MediaCaptureBackend : u8 #ifdef _WIN32 MediaFoundation, #endif -#ifndef __ANDROID__ FFmpeg, -#endif MaxCount, }; diff --git a/src/util/opengl_context.cpp b/src/util/opengl_context.cpp index cb4b4fe8e..15d48d093 100644 --- a/src/util/opengl_context.cpp +++ b/src/util/opengl_context.cpp @@ -19,8 +19,6 @@ #include "opengl_context_wgl.h" #elif defined(__APPLE__) #include "opengl_context_agl.h" -#elif defined(__ANDROID__) -#include "opengl_context_egl_android.h" #else #ifdef ENABLE_EGL #ifdef ENABLE_WAYLAND @@ -145,8 +143,6 @@ std::unique_ptr OpenGLContext::Create(WindowInfo& wi, SurfaceHand context = OpenGLContextWGL::Create(wi, surface, versions_to_try, error); #elif defined(__APPLE__) context = OpenGLContextAGL::Create(wi, surface, versions_to_try, error); -#elif defined(__ANDROID__) - context = OpenGLContextEGLAndroid::Create(wi, surface, versions_to_try, error); #else #if defined(ENABLE_X11) if (wi.type == WindowInfoType::Xlib) diff --git a/src/util/page_fault_handler.cpp b/src/util/page_fault_handler.cpp index e49b3e625..45841f1c7 100644 --- a/src/util/page_fault_handler.cpp +++ b/src/util/page_fault_handler.cpp @@ -16,9 +16,11 @@ #include #include #include -#elif defined(__APPLE__) || defined(__FreeBSD__) +#elif defined(__APPLE__) #include #include +#else +#error Unsupported platform. #endif #ifdef __APPLE__ @@ -27,7 +29,7 @@ #include #endif -#if defined(CPU_ARCH_ARM64) +#ifdef CPU_ARCH_ARM64 static constexpr u64 ARM64_ESR_ISS_DA_WNR = (1u << 6); [[maybe_unused]] static bool IsStoreInstruction(const void* ptr) @@ -65,7 +67,7 @@ static constexpr u64 ARM64_ESR_ISS_DA_WNR = (1u << 6); } } -#ifdef __linux__ +#if defined(__linux__) && !defined(__ANDROID__) static std::optional GetLinuxAArch64ESR(const ucontext_t* context) { @@ -111,7 +113,7 @@ static std::optional GetLinuxAArch64ESR(const ucontext_t* context) #endif // __linux__ -#elif defined(CPU_ARCH_RISCV64) +#elifdef CPU_ARCH_RISCV64 [[maybe_unused]] static bool IsStoreInstruction(const void* ptr) { u32 bits; @@ -119,7 +121,7 @@ static std::optional GetLinuxAArch64ESR(const ucontext_t* context) return ((bits & 0x7Fu) == 0b0100011u); } -#elif defined(CPU_ARCH_LOONGARCH64) +#elifdef CPU_ARCH_LOONGARCH64 [[maybe_unused]] static bool IsStoreInstruction(const void* ptr) { u32 bits; @@ -224,7 +226,7 @@ static std::optional GetLinuxAArch64ESR(const ucontext_t* context) } #endif -#if defined(_WIN32) +#ifdef _WIN32 namespace PageFaultHandler { static LONG ExceptionHandler(PEXCEPTION_POINTERS exi); @@ -236,9 +238,9 @@ LONG PageFaultHandler::ExceptionHandler(PEXCEPTION_POINTERS exi) if (exi->ExceptionRecord->ExceptionCode != EXCEPTION_ACCESS_VIOLATION) return EXCEPTION_CONTINUE_SEARCH; -#if defined(_M_AMD64) +#ifdef _M_AMD64 void* const exception_pc = reinterpret_cast(exi->ContextRecord->Rip); -#elif defined(_M_ARM64) +#elifdef _M_ARM64 void* const exception_pc = reinterpret_cast(exi->ContextRecord->Pc); #else void* const exception_pc = nullptr; @@ -271,65 +273,50 @@ static void SignalHandler(int sig, siginfo_t* info, void* ctx); void PageFaultHandler::SignalHandler(int sig, siginfo_t* info, void* ctx) { -#if defined(__linux__) +#ifdef __linux__ void* const exception_address = reinterpret_cast(info->si_addr); -#if defined(CPU_ARCH_X64) +#ifdef CPU_ARCH_X64 void* const exception_pc = reinterpret_cast(static_cast(ctx)->uc_mcontext.gregs[REG_RIP]); const bool is_write = (static_cast(ctx)->uc_mcontext.gregs[REG_ERR] & 2) != 0; -#elif defined(CPU_ARCH_ARM32) +#elifdef CPU_ARCH_ARM32 void* const exception_pc = reinterpret_cast(static_cast(ctx)->uc_mcontext.arm_pc); const bool is_write = (static_cast(ctx)->uc_mcontext.error_code & (1 << 11)) != 0; // DFSR.WnR -#elif defined(CPU_ARCH_ARM64) +#elifdef CPU_ARCH_ARM64 ucontext_t* const context = static_cast(ctx); void* const exception_pc = reinterpret_cast(context->uc_mcontext.pc); const std::optional esr = GetLinuxAArch64ESR(context); // NOTE: Must not read instruction unless ESR check fails. const bool is_write = esr.has_value() ? ((esr.value() & ARM64_ESR_ISS_DA_WNR) != 0) : IsStoreInstruction(exception_pc); -#elif defined(CPU_ARCH_RISCV64) +#elifdef CPU_ARCH_RISCV64 void* const exception_pc = reinterpret_cast(static_cast(ctx)->uc_mcontext.__gregs[REG_PC]); const bool is_write = IsStoreInstruction(exception_pc); -#elif defined(CPU_ARCH_LOONGARCH64) +#elifdef CPU_ARCH_LOONGARCH64 void* const exception_pc = reinterpret_cast(static_cast(ctx)->uc_mcontext.__pc); const bool is_write = IsStoreInstruction(exception_pc); #else - void* const exception_pc = nullptr; - const bool is_write = false; +#error Unsupported architecture. #endif -#elif defined(__APPLE__) +#elifdef __APPLE__ -#if defined(CPU_ARCH_X64) +#ifdef CPU_ARCH_X64 void* const exception_address = reinterpret_cast(static_cast(ctx)->uc_mcontext->__es.__faultvaddr); void* const exception_pc = reinterpret_cast(static_cast(ctx)->uc_mcontext->__ss.__rip); const bool is_write = (static_cast(ctx)->uc_mcontext->__es.__err & 2) != 0; -#elif defined(CPU_ARCH_ARM64) +#elifdef CPU_ARCH_ARM64 ucontext_t* const context = static_cast(ctx); void* const exception_address = reinterpret_cast(context->uc_mcontext->__es.__far); void* const exception_pc = reinterpret_cast(context->uc_mcontext->__ss.__pc); const bool is_write = (context->uc_mcontext->__es.__esr & ARM64_ESR_ISS_DA_WNR) != 0; #else - void* const exception_address = reinterpret_cast(info->si_addr); - void* const exception_pc = nullptr; - const bool is_write = false; +#error Unsupported architecture. #endif -#elif defined(__FreeBSD__) - -#if defined(CPU_ARCH_X64) - void* const exception_address = reinterpret_cast(static_cast(ctx)->uc_mcontext.mc_addr); - void* const exception_pc = reinterpret_cast(static_cast(ctx)->uc_mcontext.mc_rip); - const bool is_write = (static_cast(ctx)->uc_mcontext.mc_err & 2) != 0; -#elif defined(CPU_ARCH_ARM64) - void* const exception_address = reinterpret_cast(static_cast(ctx)->uc_mcontext->__es.__far); - void* const exception_pc = reinterpret_cast(static_cast(ctx)->uc_mcontext->__ss.__pc); - const bool is_write = IsStoreInstruction(exception_pc); #else - void* const exception_address = reinterpret_cast(info->si_addr); - void* const exception_pc = nullptr; - const bool is_write = false; -#endif + +#error Unsupported platform. #endif diff --git a/src/util/util.props b/src/util/util.props index 9de62fd22..82ac66f36 100644 --- a/src/util/util.props +++ b/src/util/util.props @@ -4,7 +4,7 @@ - %(PreprocessorDefinitions);CPUINFO_SHARED=1;ENABLE_VULKAN=1;ENABLE_SDL=1 + %(PreprocessorDefinitions);CPUINFO_SHARED=1;ENABLE_VULKAN=1 %(PreprocessorDefinitions);ENABLE_OPENGL=1 %(AdditionalIncludeDirectories);$(SolutionDir)dep\xxhash\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\libchdr\include;$(SolutionDir)dep\cubeb\include;$(SolutionDir)dep\d3d12ma\include;$(SolutionDir)dep\vulkan\include;$(SolutionDir)dep\ffmpeg\include;$(DepsIncludeDir)plutosvg; %(AdditionalIncludeDirectories);$(SolutionDir)dep\glad\include diff --git a/src/util/vulkan_device.cpp b/src/util/vulkan_device.cpp index fefbc144e..b010a1a8a 100644 --- a/src/util/vulkan_device.cpp +++ b/src/util/vulkan_device.cpp @@ -333,7 +333,7 @@ bool VulkanDevice::EnableOptionalDeviceExtensions(VkPhysicalDevice physical_devi // VK_KHR_dynamic_rendering_local_read appears to be broken on RDNA3, like everything else... // Just causes GPU resets when you actually use a feedback loop. Assume Mesa is fine. // VK_EXT_fragment_shader_interlock is similar, random GPU hangs. -#if defined(_WIN32) || defined(__ANDROID__) +#if defined(_WIN32) m_optional_extensions.vk_ext_fragment_shader_interlock = false; m_optional_extensions.vk_khr_dynamic_rendering_local_read = false; WARNING_LOG( diff --git a/src/util/vulkan_entry_points.inl b/src/util/vulkan_entry_points.inl index a1131f277..5eecc1ce8 100644 --- a/src/util/vulkan_entry_points.inl +++ b/src/util/vulkan_entry_points.inl @@ -54,10 +54,6 @@ VULKAN_INSTANCE_ENTRY_POINT(vkCreateWaylandSurfaceKHR, false) VULKAN_INSTANCE_ENTRY_POINT(vkCreateMetalSurfaceEXT, false) #endif -#if defined(VK_USE_PLATFORM_ANDROID_KHR) -VULKAN_INSTANCE_ENTRY_POINT(vkCreateAndroidSurfaceKHR, false) -#endif - // VK_EXT_debug_utils VULKAN_INSTANCE_ENTRY_POINT(vkCmdBeginDebugUtilsLabelEXT, false) VULKAN_INSTANCE_ENTRY_POINT(vkCmdEndDebugUtilsLabelEXT, false) diff --git a/src/util/vulkan_headers.h b/src/util/vulkan_headers.h index aaeaae7e2..1f14d0ea2 100644 --- a/src/util/vulkan_headers.h +++ b/src/util/vulkan_headers.h @@ -12,10 +12,8 @@ class Error; // vulkan.h pulls in windows.h on Windows, so we need to include our replacement header first #include "common/windows_headers.h" -#elif defined(__APPLE__) +#elifdef __APPLE__ #define VK_USE_PLATFORM_METAL_EXT -#elif defined(__ANDROID__) -#define VK_USE_PLATFORM_ANDROID_KHR #else #ifdef ENABLE_X11 #define VK_USE_PLATFORM_XCB_KHR @@ -45,17 +43,17 @@ extern "C" { #endif // We include vk_mem_alloc globally, so we don't accidentally include it before the vulkan header somewhere. -#if defined(__clang__) +#ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" #pragma clang diagnostic ignored "-Wunused-variable" #pragma clang diagnostic ignored "-Wmissing-field-initializers" #pragma clang diagnostic ignored "-Wunused-function" -#elif defined(__GNUC__) +#elifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wunused-function" -#elif defined(_MSC_VER) +#elifdef _MSC_VER #pragma warning(push, 0) #endif @@ -64,10 +62,10 @@ extern "C" { #define VMA_STATS_STRING_ENABLED 0 #include "vulkan/vk_mem_alloc.h" -#if defined(__clang__) +#ifdef __clang__ #pragma clang diagnostic pop -#elif defined(__GNUC__) +#elifdef __GNUC__ #pragma GCC diagnostic pop -#elif defined(_MSC_VER) +#elifdef _MSC_VER #pragma warning(pop) #endif diff --git a/src/util/vulkan_loader.cpp b/src/util/vulkan_loader.cpp index 6bf1c98c8..fe17b7e58 100644 --- a/src/util/vulkan_loader.cpp +++ b/src/util/vulkan_loader.cpp @@ -378,41 +378,34 @@ bool VulkanLoader::SelectInstanceExtensions(VulkanDevice::ExtensionList* extensi return false; }; -#if defined(VK_USE_PLATFORM_WIN32_KHR) +#ifdef VK_USE_PLATFORM_WIN32_KHR if (wtype == WindowInfoType::Win32 && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) || !SupportsExtension(VK_KHR_WIN32_SURFACE_EXTENSION_NAME, true))) { return false; } #endif -#if defined(VK_USE_PLATFORM_XCB_KHR) +#ifdef VK_USE_PLATFORM_XCB_KHR if (wtype == WindowInfoType::XCB && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) || !SupportsExtension(VK_KHR_XCB_SURFACE_EXTENSION_NAME, true))) { return false; } #endif -#if defined(VK_USE_PLATFORM_WAYLAND_KHR) +#ifdef VK_USE_PLATFORM_WAYLAND_KHR if (wtype == WindowInfoType::Wayland && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) || !SupportsExtension(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, true))) { return false; } #endif -#if defined(VK_USE_PLATFORM_METAL_EXT) +#ifdef VK_USE_PLATFORM_METAL_EXT if (wtype == WindowInfoType::MacOS && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) || !SupportsExtension(VK_EXT_METAL_SURFACE_EXTENSION_NAME, true))) { return false; } #endif -#if defined(VK_USE_PLATFORM_ANDROID_KHR) - if (wtype == WindowInfoType::Android && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) || - !SupportsExtension(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, true))) - { - return false; - } -#endif // VK_EXT_debug_utils if (debug_instance && !SupportsExtension(VK_EXT_DEBUG_UTILS_EXTENSION_NAME, false)) @@ -589,10 +582,6 @@ VulkanLoader::GPUList VulkanLoader::EnumerateGPUs(Error* error) bool VulkanLoader::IsSuitableDefaultRenderer(WindowInfoType window_type) { -#ifdef __ANDROID__ - // No way in hell. - return false; -#else const std::optional adapter_list = GetAdapterList(window_type, nullptr); if (!adapter_list.has_value() || adapter_list->empty()) { @@ -622,9 +611,7 @@ bool VulkanLoader::IsSuitableDefaultRenderer(WindowInfoType window_type) INFO_LOG("Not using Vulkan for Intel GPU with incomplete driver."); return false; } -#endif -#if defined(__linux__) || defined(__ANDROID__) // V3D is buggy, image copies with larger textures are broken. if (ainfo.driver_type == GPUDriverType::BroadcomMesa) { @@ -635,7 +622,6 @@ bool VulkanLoader::IsSuitableDefaultRenderer(WindowInfoType window_type) INFO_LOG("Allowing Vulkan as default renderer."); return true; -#endif } GPUDriverType VulkanLoader::GuessDriverType(const VkPhysicalDeviceProperties& device_properties, diff --git a/src/util/vulkan_swap_chain.cpp b/src/util/vulkan_swap_chain.cpp index 3e2413683..d696e1bfd 100644 --- a/src/util/vulkan_swap_chain.cpp +++ b/src/util/vulkan_swap_chain.cpp @@ -103,26 +103,6 @@ bool VulkanSwapChain::CreateSurface(VkPhysicalDevice physical_device, Error* err } #endif -#if defined(VK_USE_PLATFORM_ANDROID_KHR) - if (m_window_info.type == WindowInfoType::Android) - { - const VkAndroidSurfaceCreateInfoKHR surface_create_info = { - .sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR, - .pNext = nullptr, - .flags = 0, - .window = static_cast(m_window_info.window_handle)}; - const VkResult res = - vkCreateAndroidSurfaceKHR(VulkanLoader::GetVulkanInstance(), &surface_create_info, nullptr, &m_surface); - if (res != VK_SUCCESS) - { - Vulkan::SetErrorObject(error, "vkCreateAndroidSurfaceKHR failed: ", res); - return false; - } - - return true; - } -#endif - #if defined(VK_USE_PLATFORM_XCB_KHR) if (m_window_info.type == WindowInfoType::XCB) { @@ -359,11 +339,10 @@ bool VulkanSwapChain::CreateSwapChain(VulkanDevice& dev, Error* error) DEV_LOG("Creating a swap chain with {} images in present mode {}", image_count, PresentModeToString(present_mode.value())); - // Determine the dimensions of the swap chain. Values of -1 indicate the size we specify here - // determines window size? Android sometimes lags updating currentExtent, so don't use it. - // We want to avoid the system-level downsampling with fractional scaling on MacOS too. + // Determine the dimensions of the swap chain. Values of -1 indicate the size we specify here determines + // window size? We want to avoid the system-level downsampling with fractional scaling on MacOS too. VkExtent2D size = surface_caps.surfaceCapabilities.currentExtent; -#if !defined(__ANDROID__) && !defined(__APPLE__) +#ifndef __APPLE__ if (size.width == UINT32_MAX) #endif {