diff --git a/src/common/emulatorConfig.cpp b/src/common/emulatorConfig.cpp index fb79c79..136a4a9 100644 --- a/src/common/emulatorConfig.cpp +++ b/src/common/emulatorConfig.cpp @@ -101,6 +101,10 @@ bool ReadbackLinearImagesEnabled() { return g_config->readback_linear_images; } +bool PlayGoHackEnabled() { + return g_config->playgo_hack_enabled; +} + #if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS bool RedZoneProtectionEnabled() { return g_config->red_zone_protection_enabled; diff --git a/src/common/emulatorConfig.h b/src/common/emulatorConfig.h index 77e3926..c0a8f27 100644 --- a/src/common/emulatorConfig.h +++ b/src/common/emulatorConfig.h @@ -51,6 +51,7 @@ struct ConfigOptions { bool spirv_debug_printf_enabled = false; bool renderdoc_enabled = false; bool readback_linear_images = false; + bool playgo_hack_enabled = false; #if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS bool red_zone_protection_enabled = false; #endif @@ -85,6 +86,7 @@ bool SpirvDebugPrintfEnabled(); bool RenderDocEnabled(); bool ReadbackLinearImagesEnabled(); +bool PlayGoHackEnabled(); #if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS bool RedZoneProtectionEnabled(); #endif diff --git a/src/libs/libPlayGo.cpp b/src/libs/libPlayGo.cpp index 113cd00..94f0093 100644 --- a/src/libs/libPlayGo.cpp +++ b/src/libs/libPlayGo.cpp @@ -1,6 +1,7 @@ #include "common/abi.h" #include "common/assert.h" #include "common/common.h" +#include "common/emulatorConfig.h" #include "common/logging/log.h" #include "common/stringUtils.h" #include "libs/errno.h" @@ -23,6 +24,7 @@ static constexpr int8_t PLAYGO_LOCUS_LOCAL_FAST = 3; static constexpr int32_t PLAYGO_INSTALL_SPEED_FULL = 2; static constexpr int32_t PLAYGO_OPTIONAL_TYPE_LANGUAGE = 0; static constexpr int32_t PLAYGO_OPTIONAL_TYPE_SCENARIO = 1; +static constexpr uint32_t PLAYGO_DEFAULT_CHUNKS_NUM = 1000; static constexpr uint64_t PLAYGO_LANGUAGE_MASK_ALL = 0xffffffffffffffffull; static constexpr uint64_t PLAYGO_SCENARIO_MASK_ALL = 0x1full; @@ -96,6 +98,11 @@ int KYTY_SYSV_ABI PlayGoInitialize(const PlayGoInitParams* init) { "\t reserved = %" PRId32 "\n", reinterpret_cast(init->buf_addr), init->buf_size, init->reserved); + if (Config::PlayGoHackEnabled() && !ensure_chunks_loaded()) { + g_chunks_num = PLAYGO_DEFAULT_CHUNKS_NUM; + LOGF("\t playgo_hack chunks = %" PRIu32 "\n", g_chunks_num); + } + return OK; } diff --git a/src/main.cpp b/src/main.cpp index b731620..5272b1f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -64,6 +64,7 @@ static void PrintUsage() { ::printf(" --spirv-debug-printf Enable SPIR-V debug printf.\n"); ::printf( " --readback-linear-images Read back writable linear images on submit.\n"); + ::printf(" --playgo-hack Use the supplied PlayGo stub fallback.\n"); #if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS ::printf(" --redzone Protect the guest SysV red zone.\n"); #endif @@ -141,6 +142,11 @@ static bool ParseArgs(int argc, char* argv[], RunOptions& options, bool& show_he continue; } + if (arg == "--playgo-hack") { + options.config.playgo_hack_enabled = true; + continue; + } + #if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS if (arg == "--redzone") { options.config.red_zone_protection_enabled = true;