ANDROID -> __ANDROID__

This commit is contained in:
lizzie 2026-06-01 19:07:58 +00:00 • committed by crueter
parent 9ae4915e9c
commit 48945f7082
32 changed files with 88 additions and 80 deletions

View file

@ -303,7 +303,7 @@ namespace {
} }
[[nodiscard]] s64 GetHostCNTFRQ() noexcept { [[nodiscard]] s64 GetHostCNTFRQ() noexcept {
u64 cntfrq_el0 = 0; u64 cntfrq_el0 = 0;
#ifdef ANDROID #ifdef __ANDROID__
std::string_view board{""}; std::string_view board{""};
char buffer[PROP_VALUE_MAX]; char buffer[PROP_VALUE_MAX];
int len{__system_property_get("ro.product.board", buffer)}; int len{__system_property_get("ro.product.board", buffer)};

View file

@ -30,7 +30,7 @@ std::string NativeErrorToString(int e) {
return ret; return ret;
#else #else
char err_str[255]; char err_str[255];
#if defined(ANDROID) || \ #if defined(__ANDROID__) || \
(defined(__GLIBC__) && (_GNU_SOURCE || (_POSIX_C_SOURCE < 200112L && _XOPEN_SOURCE < 600))) (defined(__GLIBC__) && (_GNU_SOURCE || (_POSIX_C_SOURCE < 200112L && _XOPEN_SOURCE < 600)))
// Thread safe (GNU-specific) // Thread safe (GNU-specific)
const char* str = strerror_r(e, err_str, sizeof(err_str)); const char* str = strerror_r(e, err_str, sizeof(err_str));

View file

@ -9,7 +9,7 @@
#include "common/assert.h" #include "common/assert.h"
#include "common/fs/file.h" #include "common/fs/file.h"
#include "common/fs/fs.h" #include "common/fs/fs.h"
#ifdef ANDROID #ifdef __ANDROID__
#include "common/fs/fs_android.h" #include "common/fs/fs_android.h"
#endif #endif
#include "common/logging.h" #include "common/logging.h"
@ -259,7 +259,7 @@ void IOFile::Open(const fs::path& path, FileAccessMode mode, FileType type, File
} else { } else {
_wfopen_s(&file, path.c_str(), AccessModeToWStr(mode, type)); _wfopen_s(&file, path.c_str(), AccessModeToWStr(mode, type));
} }
#elif ANDROID #elif __ANDROID__
if (Android::IsContentUri(path)) { if (Android::IsContentUri(path)) {
ASSERT_MSG(mode == FileAccessMode::Read, "Content URI file access is for read-only!"); ASSERT_MSG(mode == FileAccessMode::Read, "Content URI file access is for read-only!");
const auto fd = Android::OpenContentUri(path, Android::OpenMode::Read); const auto fd = Android::OpenContentUri(path, Android::OpenMode::Read);
@ -396,7 +396,7 @@ u64 IOFile::GetSize() const {
// Flush any unwritten buffered data into the file prior to retrieving the file size. // Flush any unwritten buffered data into the file prior to retrieving the file size.
std::fflush(file); std::fflush(file);
#if ANDROID #ifdef __ANDROID__
u64 file_size = 0; u64 file_size = 0;
if (Android::IsContentUri(file_path)) { if (Android::IsContentUri(file_path)) {
file_size = Android::GetSize(file_path); file_size = Android::GetSize(file_path);

View file

@ -6,7 +6,7 @@
#include "common/fs/file.h" #include "common/fs/file.h"
#include "common/fs/fs.h" #include "common/fs/fs.h"
#ifdef ANDROID #ifdef __ANDROID__
#include "common/fs/fs_android.h" #include "common/fs/fs_android.h"
#endif #endif
#include "common/fs/path_util.h" #include "common/fs/path_util.h"
@ -532,7 +532,7 @@ void IterateDirEntriesRecursively(const std::filesystem::path& path,
bool Exists(const fs::path& path) { bool Exists(const fs::path& path) {
std::error_code ec; std::error_code ec;
#ifdef ANDROID #ifdef __ANDROID__
if (Android::IsContentUri(path)) { if (Android::IsContentUri(path)) {
return Android::Exists(path); return Android::Exists(path);
} else { } else {
@ -545,7 +545,7 @@ bool Exists(const fs::path& path) {
bool IsFile(const fs::path& path) { bool IsFile(const fs::path& path) {
std::error_code ec; std::error_code ec;
#ifdef ANDROID #ifdef __ANDROID__
if (Android::IsContentUri(path)) { if (Android::IsContentUri(path)) {
return !Android::IsDirectory(path); return !Android::IsDirectory(path);
} else { } else {
@ -558,7 +558,7 @@ bool IsFile(const fs::path& path) {
bool IsDir(const fs::path& path) { bool IsDir(const fs::path& path) {
std::error_code ec; std::error_code ec;
#ifdef ANDROID #ifdef __ANDROID__
if (Android::IsContentUri(path)) { if (Android::IsContentUri(path)) {
return Android::IsDirectory(path); return Android::IsDirectory(path);
} else { } else {
@ -611,7 +611,7 @@ fs::file_type GetEntryType(const fs::path& path) {
} }
u64 GetSize(const fs::path& path) { u64 GetSize(const fs::path& path) {
#ifdef ANDROID #ifdef __ANDROID__
if (Android::IsContentUri(path)) { if (Android::IsContentUri(path)) {
return Android::GetSize(path); return Android::GetSize(path);
} }

View file

@ -11,7 +11,7 @@
#include "common/assert.h" #include "common/assert.h"
#include "common/fs/fs.h" #include "common/fs/fs.h"
#ifdef ANDROID #ifdef __ANDROID__
#include "common/fs/fs_android.h" #include "common/fs/fs_android.h"
#endif #endif
#include "common/fs/fs_paths.h" #include "common/fs/fs_paths.h"
@ -126,7 +126,7 @@ public:
LEGACY_PATH(Yuzu, YUZU) LEGACY_PATH(Yuzu, YUZU)
LEGACY_PATH(Suyu, SUYU) LEGACY_PATH(Suyu, SUYU)
#undef LEGACY_PATH #undef LEGACY_PATH
#elif ANDROID #elif __ANDROID__
ASSERT(!eden_path.empty()); ASSERT(!eden_path.empty());
eden_path_cache = eden_path / CACHE_DIR; eden_path_cache = eden_path / CACHE_DIR;
eden_path_config = eden_path / CONFIG_DIR; eden_path_config = eden_path / CONFIG_DIR;
@ -447,11 +447,11 @@ std::vector<std::string> SplitPathComponentsCopy(std::string_view filename) {
std::string SanitizePath(std::string_view path_, DirectorySeparator directory_separator) { std::string SanitizePath(std::string_view path_, DirectorySeparator directory_separator) {
std::string path(path_); std::string path(path_);
#ifdef ANDROID #ifdef __ANDROID__
if (Android::IsContentUri(path)) { if (Android::IsContentUri(path)) {
return path; return path;
} }
#endif // ANDROID #endif // __ANDROID__
char type1 = directory_separator == DirectorySeparator::BackwardSlash ? '/' : '\\'; char type1 = directory_separator == DirectorySeparator::BackwardSlash ? '/' : '\\';
char type2 = directory_separator == DirectorySeparator::BackwardSlash ? '\\' : '/'; char type2 = directory_separator == DirectorySeparator::BackwardSlash ? '\\' : '/';
@ -482,7 +482,7 @@ std::string GetParentPath(std::string_view path) {
return std::string(path); return std::string(path);
} }
#ifdef ANDROID #ifdef __ANDROID__
if (path[0] != '/') { if (path[0] != '/') {
std::string path_string{path}; std::string path_string{path};
return FS::Android::GetParentDirectory(path_string); return FS::Android::GetParentDirectory(path_string);

View file

@ -320,7 +320,7 @@ struct DebuggerBackend final : public Backend {
void Flush() noexcept override {} void Flush() noexcept override {}
}; };
#endif #endif
#ifdef ANDROID #ifdef __ANDROID__
/// @brief Backend that writes to the Android logcat /// @brief Backend that writes to the Android logcat
struct LogcatBackend : public Backend { struct LogcatBackend : public Backend {
explicit LogcatBackend() noexcept = default; explicit LogcatBackend() noexcept = default;
@ -359,7 +359,7 @@ struct Impl {
#ifdef _WIN32 #ifdef _WIN32
lambda(static_cast<Backend&>(debugger_backend)); lambda(static_cast<Backend&>(debugger_backend));
#endif #endif
#ifdef ANDROID #ifdef __ANDROID__
lambda(static_cast<Backend&>(lc_backend)); lambda(static_cast<Backend&>(lc_backend));
#endif #endif
} }
@ -372,7 +372,7 @@ struct Impl {
#ifdef _WIN32 #ifdef _WIN32
DebuggerBackend debugger_backend{}; DebuggerBackend debugger_backend{};
#endif #endif
#ifdef ANDROID #ifdef __ANDROID__
LogcatBackend lc_backend{}; LogcatBackend lc_backend{};
#endif #endif
std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()}; std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};

View file

@ -359,7 +359,7 @@ struct Values {
true, true,
true}; true};
SwitchableSetting<int, true> fsr_sharpening_slider{linkage, SwitchableSetting<int, true> fsr_sharpening_slider{linkage,
#ifdef ANDROID #ifdef __ANDROID__
0, 0,
#else #else
25, 25,
@ -417,7 +417,7 @@ struct Values {
linkage, 0, "bg_blue", Category::Renderer, Specialization::Default, true, true}; linkage, 0, "bg_blue", Category::Renderer, Specialization::Default, true, true};
SwitchableSetting<GpuAccuracy, true> gpu_accuracy{linkage, SwitchableSetting<GpuAccuracy, true> gpu_accuracy{linkage,
#ifdef ANDROID #ifdef __ANDROID__
GpuAccuracy::Low, GpuAccuracy::Low,
#else #else
GpuAccuracy::Medium, GpuAccuracy::Medium,
@ -447,7 +447,7 @@ struct Values {
"nvdec_emulation", Category::RendererAdvanced}; "nvdec_emulation", Category::RendererAdvanced};
SwitchableSetting<AnisotropyMode, true> max_anisotropy{linkage, SwitchableSetting<AnisotropyMode, true> max_anisotropy{linkage,
#ifdef ANDROID #ifdef __ANDROID__
AnisotropyMode::Default, AnisotropyMode::Default,
#else #else
AnisotropyMode::Automatic, AnisotropyMode::Automatic,
@ -500,7 +500,7 @@ struct Values {
Category::RendererAdvanced}; Category::RendererAdvanced};
SwitchableSetting<bool> use_reactive_flushing{linkage, SwitchableSetting<bool> use_reactive_flushing{linkage,
#ifdef ANDROID #ifdef __ANDROID__
false, false,
#else #else
true, true,
@ -519,7 +519,7 @@ struct Values {
true, true,
true}; true};
#ifdef ANDROID #ifdef __ANDROID__
SwitchableSetting<bool> use_optimized_vertex_buffers{linkage, SwitchableSetting<bool> use_optimized_vertex_buffers{linkage,
false, false,
"use_optimized_vertex_buffers", "use_optimized_vertex_buffers",
@ -553,7 +553,7 @@ struct Values {
true, true,
true}; true};
SwitchableSetting<bool> async_presentation{linkage, SwitchableSetting<bool> async_presentation{linkage,
#ifdef ANDROID #ifdef __ANDROID__
false, false,
#else #else
false, false,
@ -599,7 +599,7 @@ struct Values {
Category::RendererHacks}; Category::RendererHacks};
SwitchableSetting<ExtendedDynamicState> dyna_state{linkage, SwitchableSetting<ExtendedDynamicState> dyna_state{linkage,
#if defined(ANDROID) #if defined(__ANDROID__)
ExtendedDynamicState::Disabled, ExtendedDynamicState::Disabled,
#elif defined(__APPLE__) #elif defined(__APPLE__)
ExtendedDynamicState::Disabled, ExtendedDynamicState::Disabled,
@ -618,7 +618,7 @@ struct Values {
Specialization::Scalar}; Specialization::Scalar};
SwitchableSetting<bool> vertex_input_dynamic_state{linkage, SwitchableSetting<bool> vertex_input_dynamic_state{linkage,
#if defined (ANDROID) #ifdef __ANDROID__
false, false,
#else #else
true, true,
@ -634,7 +634,7 @@ struct Values {
linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug}; linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug};
Setting<bool> enable_renderdoc_hotkey{linkage, false, "renderdoc_hotkey", Setting<bool> enable_renderdoc_hotkey{linkage, false, "renderdoc_hotkey",
Category::RendererDebug}; Category::RendererDebug};
#if defined(ANDROID) && defined(ARCHITECTURE_arm64) #if defined(__ANDROID__) && defined(ARCHITECTURE_arm64)
// Debug override for automatic BCn patching detection // Debug override for automatic BCn patching detection
Setting<bool> patch_old_qcom_drivers{linkage, false, "patch_old_qcom_drivers", Setting<bool> patch_old_qcom_drivers{linkage, false, "patch_old_qcom_drivers",
Category::RendererDebug}; Category::RendererDebug};
@ -679,7 +679,7 @@ struct Values {
Setting<s32> current_user{linkage, 0, "current_user", Category::System}; Setting<s32> current_user{linkage, 0, "current_user", Category::System};
SwitchableSetting<ConsoleMode> use_docked_mode{linkage, SwitchableSetting<ConsoleMode> use_docked_mode{linkage,
#ifdef ANDROID #ifdef __ANDROID__
ConsoleMode::Handheld, ConsoleMode::Handheld,
#else #else
ConsoleMode::Docked, ConsoleMode::Docked,

View file

@ -18,7 +18,7 @@
#include <windows.h> #include <windows.h>
#endif #endif
#ifdef ANDROID #ifdef __ANDROID__
#include <common/fs/fs_android.h> #include <common/fs/fs_android.h>
#endif #endif
@ -45,7 +45,7 @@ bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _
if (full_path.empty()) if (full_path.empty())
return false; return false;
#ifdef ANDROID #ifdef __ANDROID__
if (full_path[0] != '/') { if (full_path[0] != '/') {
*_pPath = Common::FS::Android::GetParentDirectory(full_path); *_pPath = Common::FS::Android::GetParentDirectory(full_path);
*_pFilename = Common::FS::Android::GetFilename(full_path); *_pFilename = Common::FS::Android::GetFilename(full_path);

View file

@ -9,7 +9,7 @@
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <boost/version.hpp> #include <boost/version.hpp>
#if BOOST_VERSION > 108400 && (!defined(_WINDOWS) && !defined(ANDROID)) || defined(YUZU_BOOST_v1) #if BOOST_VERSION > 108400 && (!defined(_WINDOWS) && !defined(__ANDROID__)) || defined(YUZU_BOOST_v1)
#define USE_BOOST_v1 #define USE_BOOST_v1
#endif #endif

View file

@ -23,7 +23,7 @@
#define stat _stat64 #define stat _stat64
#endif #endif
#ifdef ANDROID #ifdef __ANDROID__
#include "common/fs/fs_android.h" #include "common/fs/fs_android.h"
#endif #endif
@ -288,7 +288,7 @@ RealVfsFile::~RealVfsFile() {
} }
std::string RealVfsFile::GetName() const { std::string RealVfsFile::GetName() const {
#ifdef ANDROID #ifdef __ANDROID__
if (path[0] != '/') { if (path[0] != '/') {
return FS::Android::GetFilename(path); return FS::Android::GetFilename(path);
} }

View file

@ -31,7 +31,7 @@ RenderdocAPI::RenderdocAPI() {
#elif defined(__HAIKU__) #elif defined(__HAIKU__)
// no rtld on haiku // no rtld on haiku
#else #else
#ifdef ANDROID #ifdef __ANDROID__
static constexpr const char RENDERDOC_LIB[] = "libVkLayer_GLES_RenderDoc.so"; static constexpr const char RENDERDOC_LIB[] = "libVkLayer_GLES_RenderDoc.so";
#else #else
static constexpr const char RENDERDOC_LIB[] = "librenderdoc.so"; static constexpr const char RENDERDOC_LIB[] = "librenderdoc.so";

View file

@ -1009,7 +1009,7 @@ std::string Config::AdjustOutputString(const std::string& string) {
// Windows requires that two forward slashes are used at the start of a path for unmapped // Windows requires that two forward slashes are used at the start of a path for unmapped
// network drives so we have to watch for that here // network drives so we have to watch for that here
#ifndef ANDROID #ifndef __ANDROID__
if (string.substr(0, 2) == "//") { if (string.substr(0, 2) == "//") {
boost::replace_all(adjusted_string, "//", "/"); boost::replace_all(adjusted_string, "//", "/");
adjusted_string.insert(0, "/"); adjusted_string.insert(0, "/");

View file

@ -13,7 +13,7 @@
#include "core/crypto/key_manager.h" #include "core/crypto/key_manager.h"
#include "frontend_common/content_manager.h" #include "frontend_common/content_manager.h"
#ifdef ANDROID #ifdef __ANDROID__
#include <jni.h> #include <jni.h>
#include <common/android/id_cache.h> #include <common/android/id_cache.h>
#include <common/android/android_common.h> #include <common/android/android_common.h>
@ -25,7 +25,7 @@ FirmwareManager::InstallKeys(std::string location, std::string extension) {
const auto keys_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::KeysDir); const auto keys_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::KeysDir);
#ifdef ANDROID #ifdef __ANDROID__
JNIEnv *env = Common::Android::GetEnvForThread(); JNIEnv *env = Common::Android::GetEnvForThread();
jstring jsrc = Common::Android::ToJString(env, location); jstring jsrc = Common::Android::ToJString(env, location);

View file

@ -179,7 +179,7 @@ void EmulatedController::LoadDevices() {
if (npad_id_type == NpadIdType::Player1 || npad_id_type == NpadIdType::Handheld) { if (npad_id_type == NpadIdType::Player1 || npad_id_type == NpadIdType::Handheld) {
camera_params[1] = Common::ParamPackage{"engine:camera,camera:1"}; camera_params[1] = Common::ParamPackage{"engine:camera,camera:1"};
nfc_params[0] = Common::ParamPackage{"engine:virtual_amiibo,nfc:1"}; nfc_params[0] = Common::ParamPackage{"engine:virtual_amiibo,nfc:1"};
#ifndef ANDROID #ifndef __ANDROID__
ring_params[1] = Common::ParamPackage{"engine:joycon,axis_x:100,axis_y:101"}; ring_params[1] = Common::ParamPackage{"engine:joycon,axis_x:100,axis_y:101"};
#else #else
android_params = Common::ParamPackage{"engine:android,port:100"}; android_params = Common::ParamPackage{"engine:android,port:100"};

View file

@ -30,7 +30,7 @@
#include "input_common/drivers/sdl_driver.h" #include "input_common/drivers/sdl_driver.h"
#endif #endif
#ifdef ANDROID #ifdef __ANDROID__
#include "input_common/drivers/android.h" #include "input_common/drivers/android.h"
#endif #endif
@ -85,7 +85,7 @@ struct InputSubsystem::Impl {
RegisterEngine("cemuhookudp", udp_client); RegisterEngine("cemuhookudp", udp_client);
RegisterEngine("tas", tas_input); RegisterEngine("tas", tas_input);
RegisterEngine("camera", camera); RegisterEngine("camera", camera);
#ifdef ANDROID #ifdef __ANDROID__
RegisterEngine("android", android); RegisterEngine("android", android);
#endif #endif
RegisterEngine("virtual_amiibo", virtual_amiibo); RegisterEngine("virtual_amiibo", virtual_amiibo);
@ -119,7 +119,7 @@ struct InputSubsystem::Impl {
UnregisterEngine(udp_client); UnregisterEngine(udp_client);
UnregisterEngine(tas_input); UnregisterEngine(tas_input);
UnregisterEngine(camera); UnregisterEngine(camera);
#ifdef ANDROID #ifdef __ANDROID__
UnregisterEngine(android); UnregisterEngine(android);
#endif #endif
UnregisterEngine(virtual_amiibo); UnregisterEngine(virtual_amiibo);
@ -138,13 +138,13 @@ struct InputSubsystem::Impl {
Common::ParamPackage{{"display", "Any"}, {"engine", "any"}}, Common::ParamPackage{{"display", "Any"}, {"engine", "any"}},
}; };
#ifndef ANDROID #ifndef __ANDROID__
auto keyboard_devices = keyboard->GetInputDevices(); auto keyboard_devices = keyboard->GetInputDevices();
devices.insert(devices.end(), keyboard_devices.begin(), keyboard_devices.end()); devices.insert(devices.end(), keyboard_devices.begin(), keyboard_devices.end());
auto mouse_devices = mouse->GetInputDevices(); auto mouse_devices = mouse->GetInputDevices();
devices.insert(devices.end(), mouse_devices.begin(), mouse_devices.end()); devices.insert(devices.end(), mouse_devices.begin(), mouse_devices.end());
#endif #endif
#ifdef ANDROID #ifdef __ANDROID__
auto android_devices = android->GetInputDevices(); auto android_devices = android->GetInputDevices();
devices.insert(devices.end(), android_devices.begin(), android_devices.end()); devices.insert(devices.end(), android_devices.begin(), android_devices.end());
#endif #endif
@ -176,7 +176,7 @@ struct InputSubsystem::Impl {
if (engine == mouse->GetEngineName()) { if (engine == mouse->GetEngineName()) {
return mouse; return mouse;
} }
#ifdef ANDROID #ifdef __ANDROID__
if (engine == android->GetEngineName()) { if (engine == android->GetEngineName()) {
return android; return android;
} }
@ -261,7 +261,7 @@ struct InputSubsystem::Impl {
if (engine == mouse->GetEngineName()) { if (engine == mouse->GetEngineName()) {
return true; return true;
} }
#ifdef ANDROID #ifdef __ANDROID__
if (engine == android->GetEngineName()) { if (engine == android->GetEngineName()) {
return true; return true;
} }
@ -294,7 +294,7 @@ struct InputSubsystem::Impl {
void BeginConfiguration() { void BeginConfiguration() {
keyboard->BeginConfiguration(); keyboard->BeginConfiguration();
mouse->BeginConfiguration(); mouse->BeginConfiguration();
#ifdef ANDROID #ifdef __ANDROID__
android->BeginConfiguration(); android->BeginConfiguration();
#endif #endif
#ifdef ENABLE_LIBUSB #ifdef ENABLE_LIBUSB
@ -310,7 +310,7 @@ struct InputSubsystem::Impl {
void EndConfiguration() { void EndConfiguration() {
keyboard->EndConfiguration(); keyboard->EndConfiguration();
mouse->EndConfiguration(); mouse->EndConfiguration();
#ifdef ANDROID #ifdef __ANDROID__
android->EndConfiguration(); android->EndConfiguration();
#endif #endif
#ifdef ENABLE_LIBUSB #ifdef ENABLE_LIBUSB
@ -355,7 +355,7 @@ struct InputSubsystem::Impl {
std::shared_ptr<Joycons> joycon; std::shared_ptr<Joycons> joycon;
#endif #endif
#ifdef ANDROID #ifdef __ANDROID__
std::shared_ptr<Android> android; std::shared_ptr<Android> android;
#endif #endif
}; };
@ -412,7 +412,7 @@ const Camera* InputSubsystem::GetCamera() const {
return impl->camera.get(); return impl->camera.get();
} }
#ifdef ANDROID #ifdef __ANDROID__
Android* InputSubsystem::GetAndroid() { Android* InputSubsystem::GetAndroid() {
return impl->android.get(); return impl->android.get();
} }

View file

@ -151,7 +151,7 @@ Id EmitConvertU32U64(EmitContext& ctx, Id value) {
} }
Id EmitConvertF16F32(EmitContext& ctx, Id value) { Id EmitConvertF16F32(EmitContext& ctx, Id value) {
#ifdef ANDROID #ifdef __ANDROID__
return ctx.OpFConvert(ctx.F16[1], value); return ctx.OpFConvert(ctx.F16[1], value);
#else #else
const auto result = ctx.OpFConvert(ctx.F16[1], value); const auto result = ctx.OpFConvert(ctx.F16[1], value);

View file

@ -506,7 +506,7 @@ Id EmitImageSampleExplicitLod(EmitContext& ctx, IR::Inst* inst, const IR::Value&
Id result = Emit(&EmitContext::OpImageSparseSampleExplicitLod, Id result = Emit(&EmitContext::OpImageSparseSampleExplicitLod,
&EmitContext::OpImageSampleExplicitLod, ctx, inst, ctx.F32[4], &EmitContext::OpImageSampleExplicitLod, ctx, inst, ctx.F32[4],
Texture(ctx, info, index), coords, operands.Mask(), operands.Span()); Texture(ctx, info, index), coords, operands.Mask(), operands.Span());
#ifdef ANDROID #ifdef __ANDROID__
if (Settings::values.fix_bloom_effects.GetValue()) { if (Settings::values.fix_bloom_effects.GetValue()) {
result = ctx.OpVectorTimesScalar(ctx.F32[4], result, ctx.Const(0.98f)); result = ctx.OpVectorTimesScalar(ctx.F32[4], result, ctx.Const(0.98f));
} }

View file

@ -801,7 +801,7 @@ void BufferCache<P>::UpdateVertexBufferSlot(u32 index, const Binding& binding) {
template <class P> template <class P>
void BufferCache<P>::BindHostVertexBuffers() { void BufferCache<P>::BindHostVertexBuffers() {
#ifdef ANDROID #ifdef __ANDROID__
const bool use_optimized_vertex_buffers = Settings::values.use_optimized_vertex_buffers.GetValue(); const bool use_optimized_vertex_buffers = Settings::values.use_optimized_vertex_buffers.GetValue();
#else #else
constexpr bool use_optimized_vertex_buffers = true; constexpr bool use_optimized_vertex_buffers = true;

View file

@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
#ifdef ANDROID #ifdef __ANDROID__
#include "video_core/gpu_logging/freedreno_debug.h" #include "video_core/gpu_logging/freedreno_debug.h"
#include "common/logging.h" #include "common/logging.h"
@ -49,4 +49,4 @@ std::string FreedrenoDebugger::GetBreadcrumbs() {
} // namespace GPU::Logging::Freedreno } // namespace GPU::Logging::Freedreno
#endif // ANDROID #endif // __ANDROID__

View file

@ -3,7 +3,7 @@
#pragma once #pragma once
#ifdef ANDROID #ifdef __ANDROID__
#include <string> #include <string>
@ -29,4 +29,4 @@ private:
} // namespace GPU::Logging::Freedreno } // namespace GPU::Logging::Freedreno
#endif // ANDROID #endif // __ANDROID__

View file

@ -28,7 +28,7 @@ namespace {
constexpr AVPixelFormat PreferredGpuFormat = AV_PIX_FMT_NV12; constexpr AVPixelFormat PreferredGpuFormat = AV_PIX_FMT_NV12;
constexpr AVPixelFormat PreferredCpuFormat = AV_PIX_FMT_YUV420P; constexpr AVPixelFormat PreferredCpuFormat = AV_PIX_FMT_YUV420P;
constexpr std::array PreferredGpuDecoders = { constexpr std::array PreferredGpuDecoders = {
#if defined (_WIN32) #if defined(_WIN32)
AV_HWDEVICE_TYPE_CUDA, AV_HWDEVICE_TYPE_CUDA,
AV_HWDEVICE_TYPE_D3D11VA, AV_HWDEVICE_TYPE_D3D11VA,
AV_HWDEVICE_TYPE_DXVA2, AV_HWDEVICE_TYPE_DXVA2,
@ -39,7 +39,7 @@ constexpr std::array PreferredGpuDecoders = {
AV_HWDEVICE_TYPE_DRM, AV_HWDEVICE_TYPE_DRM,
#elif defined(__APPLE__) #elif defined(__APPLE__)
AV_HWDEVICE_TYPE_VIDEOTOOLBOX, AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
#elif defined(ANDROID) #elif defined(__ANDROID__)
AV_HWDEVICE_TYPE_MEDIACODEC, AV_HWDEVICE_TYPE_MEDIACODEC,
#elif defined(__unix__) #elif defined(__unix__)
AV_HWDEVICE_TYPE_CUDA, AV_HWDEVICE_TYPE_CUDA,

View file

@ -45,7 +45,7 @@
#include "video_core/vulkan_common/vulkan_wrapper.h" #include "video_core/vulkan_common/vulkan_wrapper.h"
#include "video_core/gpu_logging/gpu_logging.h" #include "video_core/gpu_logging/gpu_logging.h"
#ifdef ANDROID #ifdef __ANDROID__
#include "../../android/app/src/main/jni/android_settings.h" #include "../../android/app/src/main/jni/android_settings.h"
#endif #endif
@ -328,7 +328,7 @@ Shader::RuntimeInfo MakeRuntimeInfo(std::span<const Shader::IR::Program> program
size_t GetTotalPipelineWorkers() { size_t GetTotalPipelineWorkers() {
const size_t max_core_threads = const size_t max_core_threads =
std::max<size_t>(static_cast<size_t>(std::thread::hardware_concurrency()), 2ULL) - 1ULL; std::max<size_t>(static_cast<size_t>(std::thread::hardware_concurrency()), 2ULL) - 1ULL;
#ifdef ANDROID #ifdef __ANDROID__
const int configured = AndroidSettings::values.pipeline_worker_count.GetValue(); const int configured = AndroidSettings::values.pipeline_worker_count.GetValue();
const int clamped = std::clamp(configured, 4, 8); const int clamped = std::clamp(configured, 4, 8);
const size_t desired = static_cast<size_t>(clamped); const size_t desired = static_cast<size_t>(clamped);

View file

@ -309,7 +309,7 @@ void PresentManager::CopyToSwapchain(Frame* frame) {
try { try {
// Recreate surface and swapchain if needed. // Recreate surface and swapchain if needed.
if (requires_recreation) { if (requires_recreation) {
#ifdef ANDROID #ifdef __ANDROID__
surface = CreateSurface(instance, render_window.GetWindowInfo()); surface = CreateSurface(instance, render_window.GetWindowInfo());
#endif #endif
RecreateSwapchain(frame); RecreateSwapchain(frame);

View file

@ -928,13 +928,13 @@ void RasterizerVulkan::LoadDiskResources(u64 title_id, std::stop_token stop_load
} }
void RasterizerVulkan::FlushWork() { void RasterizerVulkan::FlushWork() {
#ifdef ANDROID #ifdef __ANDROID__
static constexpr u32 DRAWS_TO_DISPATCH = 512; static constexpr u32 DRAWS_TO_DISPATCH = 512;
static constexpr u32 CHECK_MASK = 3; static constexpr u32 CHECK_MASK = 3;
#else #else
static constexpr u32 DRAWS_TO_DISPATCH = 4096; static constexpr u32 DRAWS_TO_DISPATCH = 4096;
static constexpr u32 CHECK_MASK = 7; static constexpr u32 CHECK_MASK = 7;
#endif // ANDROID #endif // __ANDROID__
static_assert(DRAWS_TO_DISPATCH % (CHECK_MASK + 1) == 0); static_assert(DRAWS_TO_DISPATCH % (CHECK_MASK + 1) == 0);
if ((++draw_counter & CHECK_MASK) != CHECK_MASK) { if ((++draw_counter & CHECK_MASK) != CHECK_MASK) {

View file

@ -288,7 +288,7 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities) {
.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE, .imageSharingMode = VK_SHARING_MODE_EXCLUSIVE,
.queueFamilyIndexCount = 0, .queueFamilyIndexCount = 0,
.pQueueFamilyIndices = nullptr, .pQueueFamilyIndices = nullptr,
#ifdef ANDROID #ifdef __ANDROID__
// On Android, do not allow surface rotation to deviate from the frontend. // On Android, do not allow surface rotation to deviate from the frontend.
.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR, .preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR,
#else #else
@ -313,7 +313,7 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities) {
swapchain_ci.imageFormat, // Base format MUST be first swapchain_ci.imageFormat, // Base format MUST be first
VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_UNORM,
VK_FORMAT_B8G8R8A8_SRGB, VK_FORMAT_B8G8R8A8_SRGB,
#ifdef ANDROID #ifdef __ANDROID__
VK_FORMAT_R8G8B8A8_UNORM, // Android may use RGBA VK_FORMAT_R8G8B8A8_UNORM, // Android may use RGBA
VK_FORMAT_R8G8B8A8_SRGB, VK_FORMAT_R8G8B8A8_SRGB,
#endif #endif
@ -338,7 +338,7 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities) {
images = swapchain.GetImages(); images = swapchain.GetImages();
image_count = static_cast<u32>(images.size()); image_count = static_cast<u32>(images.size());
#ifdef ANDROID #ifdef __ANDROID__
// Android is already ordered the same as Switch. // Android is already ordered the same as Switch.
image_view_format = VK_FORMAT_R8G8B8A8_UNORM; image_view_format = VK_FORMAT_R8G8B8A8_UNORM;
#else #else

View file

@ -4,7 +4,7 @@
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#if defined(ANDROID) && defined(ARCHITECTURE_arm64) #if defined(__ANDROID__) && defined(ARCHITECTURE_arm64)
#include <adrenotools/driver.h> #include <adrenotools/driver.h>
#endif #endif
@ -20,7 +20,7 @@ namespace Vulkan {
using namespace Common::Literals; using namespace Common::Literals;
TurboMode::TurboMode(const vk::Instance& instance, const vk::InstanceDispatch& dld) TurboMode::TurboMode(const vk::Instance& instance, const vk::InstanceDispatch& dld)
#ifndef ANDROID #ifndef __ANDROID__
: m_device{CreateDevice(instance, dld, VK_NULL_HANDLE)}, m_allocator{m_device} : m_device{CreateDevice(instance, dld, VK_NULL_HANDLE)}, m_allocator{m_device}
#endif #endif
{ {
@ -40,7 +40,7 @@ void TurboMode::QueueSubmitted() {
} }
void TurboMode::Run(std::stop_token stop_token) { void TurboMode::Run(std::stop_token stop_token) {
#ifndef ANDROID #ifndef __ANDROID__
auto& dld = m_device.GetLogical(); auto& dld = m_device.GetLogical();
// Allocate buffer. 2MiB should be sufficient. // Allocate buffer. 2MiB should be sufficient.
@ -154,7 +154,7 @@ void TurboMode::Run(std::stop_token stop_token) {
#endif #endif
while (!stop_token.stop_requested()) { while (!stop_token.stop_requested()) {
#ifdef ANDROID #ifdef __ANDROID__
#ifdef ARCHITECTURE_arm64 #ifdef ARCHITECTURE_arm64
adrenotools_set_turbo(true); adrenotools_set_turbo(true);
#endif #endif
@ -232,7 +232,7 @@ void TurboMode::Run(std::stop_token stop_token) {
std::chrono::milliseconds{100}; std::chrono::milliseconds{100};
}); });
} }
#if defined(ANDROID) && defined(ARCHITECTURE_arm64) #if defined(__ANDROID__) && defined(ARCHITECTURE_arm64)
adrenotools_set_turbo(false); adrenotools_set_turbo(false);
#endif #endif
} }

View file

@ -23,7 +23,7 @@ public:
private: private:
void Run(std::stop_token stop_token); void Run(std::stop_token stop_token);
#ifndef ANDROID #ifndef __ANDROID__
Device m_device; Device m_device;
MemoryAllocator m_allocator; MemoryAllocator m_allocator;
#endif #endif

View file

@ -27,7 +27,7 @@ VkBool32 DebugUtilCallback(VkDebugUtilsMessageSeverityFlagBitsEXT severity,
[[maybe_unused]] void* user_data) { [[maybe_unused]] void* user_data) {
// Skip logging known false-positive validation errors // Skip logging known false-positive validation errors
switch (static_cast<u32>(data->messageIdNumber)) { switch (static_cast<u32>(data->messageIdNumber)) {
#ifdef ANDROID #ifdef __ANDROID__
case 0xbf9cf353u: // VUID-vkCmdBindVertexBuffers2-pBuffers-04111 case 0xbf9cf353u: // VUID-vkCmdBindVertexBuffers2-pBuffers-04111
// The below are due to incorrect reporting of extendedDynamicState // The below are due to incorrect reporting of extendedDynamicState
case 0x1093bebbu: // VUID-vkCmdSetCullMode-None-03384 case 0x1093bebbu: // VUID-vkCmdSetCullMode-None-03384

View file

@ -26,7 +26,7 @@
#include "video_core/vulkan_common/vulkan_wrapper.h" #include "video_core/vulkan_common/vulkan_wrapper.h"
#include "video_core/gpu_logging/gpu_logging.h" #include "video_core/gpu_logging/gpu_logging.h"
#if defined(ANDROID) && defined(ARCHITECTURE_arm64) #if defined(__ANDROID__) && defined(ARCHITECTURE_arm64)
#include <adrenotools/bcenabler.h> #include <adrenotools/bcenabler.h>
#include <android/api-level.h> #include <android/api-level.h>
#endif #endif
@ -294,7 +294,7 @@ ankerl::unordered_dense::map<VkFormat, VkFormatProperties> GetFormatProperties(v
return format_properties; return format_properties;
} }
#if defined(ANDROID) && defined(ARCHITECTURE_arm64) #if defined(__ANDROID__) && defined(ARCHITECTURE_arm64)
void OverrideBcnFormats(ankerl::unordered_dense::map<VkFormat, VkFormatProperties>& format_properties) { void OverrideBcnFormats(ankerl::unordered_dense::map<VkFormat, VkFormatProperties>& format_properties) {
// These properties are extracted from Adreno driver 512.687.0 // These properties are extracted from Adreno driver 512.687.0
constexpr VkFormatFeatureFlags tiling_features{VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | constexpr VkFormatFeatureFlags tiling_features{VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
@ -504,7 +504,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
features.shader_atomic_int64.shaderSharedInt64Atomics = false; features.shader_atomic_int64.shaderSharedInt64Atomics = false;
features.features.shaderInt64 = false; features.features.shaderInt64 = false;
#if defined(ANDROID) && defined(ARCHITECTURE_arm64) #if defined(__ANDROID__) && defined(ARCHITECTURE_arm64)
// BCn patching only safe on Android 9+ (API 28+). Older versions crash on driver load. // BCn patching only safe on Android 9+ (API 28+). Older versions crash on driver load.
const auto major = (properties.properties.driverVersion >> 24) << 2; const auto major = (properties.properties.driverVersion >> 24) << 2;
const auto minor = (properties.properties.driverVersion >> 12) & 0xFFFU; const auto minor = (properties.properties.driverVersion >> 12) & 0xFFFU;

View file

@ -16,7 +16,7 @@ namespace Vulkan {
std::shared_ptr<Common::DynamicLibrary> OpenLibrary( std::shared_ptr<Common::DynamicLibrary> OpenLibrary(
[[maybe_unused]] Core::Frontend::GraphicsContext* context) { [[maybe_unused]] Core::Frontend::GraphicsContext* context) {
LOG_DEBUG(Render_Vulkan, "Looking for a Vulkan library"); LOG_DEBUG(Render_Vulkan, "Looking for a Vulkan library");
#if defined(ANDROID) && defined(ARCHITECTURE_arm64) #if defined(__ANDROID__) && defined(ARCHITECTURE_arm64)
// Android manages its Vulkan driver from the frontend. // Android manages its Vulkan driver from the frontend.
return context->GetDriverLibrary(); return context->GetDriverLibrary();
#else #else

View file

@ -453,7 +453,7 @@ public:
return handle != Type{}; return handle != Type{};
} }
#ifndef ANDROID #ifndef __ANDROID__
/** /**
* Releases ownership of the managed handle. * Releases ownership of the managed handle.
* The caller is responsible for managing the lifetime of the returned handle. * The caller is responsible for managing the lifetime of the returned handle.
@ -535,7 +535,7 @@ public:
return handle != Type{}; return handle != Type{};
} }
#ifndef ANDROID #ifndef __ANDROID__
/** /**
* Releases ownership of the managed handle. * Releases ownership of the managed handle.
* The caller is responsible for managing the lifetime of the returned handle. * The caller is responsible for managing the lifetime of the returned handle.

View file

@ -19,7 +19,12 @@ Dumb script that serves as a ad-hoc cpp-linter
Commands: Commands:
once Check for #pragma once prescence in header files once Check for #pragma once prescence in header files
osdef Fixes OS defines that are not recommended to use:
ANDROID
_WIN64
linux
__unix__
__unix
EOF EOF
} }
@ -31,6 +36,9 @@ while :; do
;; ;;
osdef) osdef)
find "$ROOTDIR/src" -type f -name "*.h" -exec grep -nw "ANDROID" {} + find "$ROOTDIR/src" -type f -name "*.h" -exec grep -nw "ANDROID" {} +
find "$ROOTDIR/src" -type f -name "*.h" -exec grep -nw "_WIN64" {} +
find "$ROOTDIR/src" -type f -name "*.h" -exec grep -nw "__linux" {} +
find "$ROOTDIR/src" -type f -name "*.h" -exec grep -nw "__unix" {} +
break break
;; ;;
*) usage ;; *) usage ;;