diff --git a/core/kyty/cmake/KytyBackend.cmake b/core/kyty/cmake/KytyBackend.cmake index 64562ffa37c..495d322da1c 100644 --- a/core/kyty/cmake/KytyBackend.cmake +++ b/core/kyty/cmake/KytyBackend.cmake @@ -134,6 +134,10 @@ target_compile_definitions(anyps5_kyty_gpu ) if(WIN32) target_link_libraries(anyps5_kyty_gpu INTERFACE ${ANYPS5_KYTY_ARCHIVES} $ $ $ pthread psapi dbghelp ws2_32 synchronization secur32) + if(MINGW AND ANYPS5_MINGW_DWARF_EXCEPTIONS) + target_sources(anyps5_kyty_gpu INTERFACE $) + target_link_options(anyps5_kyty_gpu INTERFACE LINKER:--undefined=LibcSehPersonalities_nid_no_patch) + endif() else() target_link_libraries(anyps5_kyty_gpu INTERFACE ${ANYPS5_KYTY_ARCHIVES} ${CMAKE_DL_LIBS} pthread) endif() diff --git a/core/kyty/common/fallback.cpp b/core/kyty/common/fallback.cpp index 50f59f473c0..541ce6a57fc 100644 --- a/core/kyty/common/fallback.cpp +++ b/core/kyty/common/fallback.cpp @@ -33,7 +33,7 @@ bool Enabled() { } bool Containable() { -#if defined(__cpp_exceptions) && !defined(_WIN32) +#if defined(__cpp_exceptions) return true; #else return false; diff --git a/core/libs/CMakeLists.txt b/core/libs/CMakeLists.txt index eed424c8f4f..d587e1b9a72 100644 --- a/core/libs/CMakeLists.txt +++ b/core/libs/CMakeLists.txt @@ -43,11 +43,13 @@ if(MINGW) if(NOT ANYPS5_MINGW_SYSV_SEH_EXCEPTIONS) message(FATAL_ERROR "The Windows libraries require DWARF exceptions or GCC with System V ABI SEH support. Use the toolchains listed in docs/dev/BUILD.md.") endif() - add_library(windows_seh_personalities OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/prx/libc/src/specifics/windows/SehPersonalities.cpp) - target_link_options(windows_seh_personalities INTERFACE LINKER:--undefined=LibcSehPersonalities_nid_no_patch) - link_libraries(windows_seh_personalities) - else() + endif() + add_library(windows_seh_personalities OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/prx/libc/src/specifics/windows/SehPersonalities.cpp) + target_link_options(windows_seh_personalities INTERFACE LINKER:--undefined=LibcSehPersonalities_nid_no_patch) + if(ANYPS5_MINGW_DWARF_EXCEPTIONS) add_compile_options(-fno-asynchronous-unwind-tables) + else() + link_libraries(windows_seh_personalities) endif() endif() diff --git a/core/libs/prx/libSceAgcDriver/CMakeLists.txt b/core/libs/prx/libSceAgcDriver/CMakeLists.txt index d388ceefa63..028dd5ad297 100644 --- a/core/libs/prx/libSceAgcDriver/CMakeLists.txt +++ b/core/libs/prx/libSceAgcDriver/CMakeLists.txt @@ -38,6 +38,7 @@ target_include_directories(libSceAgcDriver PRIVATE ${LIBS_INCLUDE_DIR} ${ANYPS5_ ${CMAKE_CURRENT_BINARY_DIR}/generated) target_link_libraries(libSceAgcDriver PRIVATE $,Kyty::gpu,kyty_gpu> SDL2-static libc libkernel ${CMAKE_DL_LIBS}) target_link_options(libSceAgcDriver PRIVATE LINKER:--undefined=SDL_ShowMessageBox) +configure_windows_unwind(libSceAgcDriver) if(WIN32) target_link_options(libSceAgcDriver PRIVATE LINKER:--exclude-symbols=__emutls_get_address) set_source_files_properties(${kytyShimSources} PROPERTIES COMPILE_OPTIONS "-march=x86-64-v3;-fno-strict-aliasing;-ffp-contract=off;-fno-extern-tls-init") diff --git a/core/libs/prx/libSceAgcDriver/KytyShim/tests/CMakeLists.txt b/core/libs/prx/libSceAgcDriver/KytyShim/tests/CMakeLists.txt index 38c4cf4fcb9..ac3268b3cc6 100644 --- a/core/libs/prx/libSceAgcDriver/KytyShim/tests/CMakeLists.txt +++ b/core/libs/prx/libSceAgcDriver/KytyShim/tests/CMakeLists.txt @@ -317,11 +317,10 @@ if(NOT ANYPS5_KYTY_DLL) add_test_executable(kyty_shim_fallback_tests ${CMAKE_CURRENT_SOURCE_DIR}/Fallback.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../src/Log.cpp) target_include_directories(kyty_shim_fallback_tests PRIVATE ${LIBS_INCLUDE_DIR}) target_link_libraries(kyty_shim_fallback_tests PRIVATE Kyty::gpu libkernel libc) -if(NOT WIN32) - add_test(NAME kyty_shim_fallback COMMAND kyty_shim_fallback_tests) - set_tests_properties(kyty_shim_fallback PROPERTIES TIMEOUT 20 PASS_REGULAR_EXPRESSION "kyty_shim_fallback: ok" - FAIL_REGULAR_EXPRESSION "terminate called") -endif() +configure_windows_unwind(kyty_shim_fallback_tests) +add_test(NAME kyty_shim_fallback COMMAND kyty_shim_fallback_tests) +set_tests_properties(kyty_shim_fallback PROPERTIES TIMEOUT 20 ENVIRONMENT "KYTY_FALLBACKS=1" + PASS_REGULAR_EXPRESSION "kyty_shim_fallback: ok" FAIL_REGULAR_EXPRESSION "terminate called") add_test(NAME kyty_shim_fallback_off COMMAND kyty_shim_fallback_tests stop) set_tests_properties(kyty_shim_fallback_off PROPERTIES TIMEOUT 20 ENVIRONMENT "KYTY_FALLBACKS=0" PASS_REGULAR_EXPRESSION "shader decode reached the code boundary before S_ENDPGM" @@ -406,15 +405,9 @@ target_sources(libSceAgcDriver PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/SpeculativeCo add_test_executable(kyty_shim_speculative_compile_tests ${CMAKE_CURRENT_SOURCE_DIR}/SpeculativeCompileMain.cpp) configure_host_test_executable(kyty_shim_speculative_compile_tests) target_link_libraries(kyty_shim_speculative_compile_tests PRIVATE libSceAgcDriver libkernel libc) -if(NOT WIN32) - add_test(NAME kyty_shim_speculative_compile COMMAND kyty_shim_speculative_compile_tests) - set_tests_properties(kyty_shim_speculative_compile PROPERTIES TIMEOUT 60 ENVIRONMENT "KYTY_FALLBACKS=0" - PASS_REGULAR_EXPRESSION "kyty_shim_speculative_compile: ok" FAIL_REGULAR_EXPRESSION "terminate called|FAILED") -else() - add_test(NAME kyty_shim_speculative_compile_uncontained COMMAND kyty_shim_speculative_compile_tests uncontained) - set_tests_properties(kyty_shim_speculative_compile_uncontained PROPERTIES TIMEOUT 60 - PASS_REGULAR_EXPRESSION "kyty_shim_speculative_compile_uncontained: ok" FAIL_REGULAR_EXPRESSION "FAILED") -endif() +add_test(NAME kyty_shim_speculative_compile COMMAND kyty_shim_speculative_compile_tests) +set_tests_properties(kyty_shim_speculative_compile PROPERTIES TIMEOUT 60 ENVIRONMENT "KYTY_FALLBACKS=0" + PASS_REGULAR_EXPRESSION "kyty_shim_speculative_compile: ok" FAIL_REGULAR_EXPRESSION "terminate called|FAILED") add_test(NAME kyty_shim_speculative_compile_required COMMAND kyty_shim_speculative_compile_tests required) set_tests_properties(kyty_shim_speculative_compile_required PROPERTIES TIMEOUT 60 ENVIRONMENT "KYTY_FALLBACKS=0" PASS_REGULAR_EXPRESSION "buffer descriptor has reserved dst_sel" FAIL_REGULAR_EXPRESSION "did not stop") diff --git a/core/libs/prx/libSceAgcDriver/KytyShim/tests/Fallback.cpp b/core/libs/prx/libSceAgcDriver/KytyShim/tests/Fallback.cpp index c1b9b96e244..60113171407 100644 --- a/core/libs/prx/libSceAgcDriver/KytyShim/tests/Fallback.cpp +++ b/core/libs/prx/libSceAgcDriver/KytyShim/tests/Fallback.cpp @@ -62,7 +62,7 @@ int main(int argc, char** argv) { std::fprintf(stderr, "kyty_shim_fallback: KYTY_FALLBACKS=0 did not stop\n"); return 0; } - Require(Common::Fallback::Enabled(), "KYTY_FALLBACKS is not on by default"); + Require(Common::Fallback::Enabled(), "the test runs with KYTY_FALLBACKS=1"); Require(Prepare(Ends), "a shader that ends was refused"); Require(!Prepare(RunsOff), "a shader the decoder stops on was not caught"); Require(!Prepare({}), "an empty shader was not caught"); diff --git a/core/libs/prx/libSceAgcDriver/KytyShim/tests/SpeculativeCompile.cpp b/core/libs/prx/libSceAgcDriver/KytyShim/tests/SpeculativeCompile.cpp index 89a7af2e499..801e11f7c04 100644 --- a/core/libs/prx/libSceAgcDriver/KytyShim/tests/SpeculativeCompile.cpp +++ b/core/libs/prx/libSceAgcDriver/KytyShim/tests/SpeculativeCompile.cpp @@ -162,17 +162,6 @@ extern "C" int RunKytySpeculativeCompileTest(int argc, char** argv) { std::fprintf(stderr, "kyty_shim_speculative_compile: a required compile did not stop\n"); return 1; } - if (argc > 1 && std::strcmp(argv[1], "uncontained") == 0) { - Program program; - Check(!Common::Fallback::Containable(), "this platform catches a stop"); - Check(program.JudgeSpeculativeCompile(ShaderType::Compute, valid, Cursor, true) == Speculation::Uncontained, - "a variant from a walk that left a load unread is compiled ahead where a stop cannot be caught"); - Check(program.JudgeSpeculativeCompile(ShaderType::Compute, valid, Cursor, false) == Speculation::Compile, - "a variant from a walk that read everything is not compiled ahead"); - Check(program.JudgeSpeculativeCompile(ShaderType::Compute, reserved, Cursor, false) == Speculation::Refused, - "a reserved dst_sel is not refused before compiling"); - return Finish("kyty_shim_speculative_compile_uncontained"); - } Check(!Common::Fallback::Enabled(), "the test runs with KYTY_FALLBACKS=0"); Check(Common::Fallback::Containable(), "this platform does not catch a stop"); diff --git a/docs/dev/THIRD_PARTY_KYTY.md b/docs/dev/THIRD_PARTY_KYTY.md index 39b675c8a68..0099fc85c99 100644 --- a/docs/dev/THIRD_PARTY_KYTY.md +++ b/docs/dev/THIRD_PARTY_KYTY.md @@ -607,20 +607,21 @@ code is 0 when the survey ran, 2 when the cache cannot be read and 64 for a wron [`tools/rt_survey.py`](../../tools/rt_survey.py) runs the probe and writes the report that players attach to the survey issue; see [the ray tracing survey](../user/ANYKYTY.md#ray-tracing-survey). -Fallbacks instead of stops (`KYTY_FALLBACKS`, on by default on Linux; off on Windows, where the C++ exception that carries a fallback is not caught across the guest libc yet): KytyPS5 stops the emulator (`EXIT`, `EXIT_IF`, +Fallbacks instead of stops (`KYTY_FALLBACKS`, on by default on Linux, off by default on Windows): KytyPS5 stops the emulator (`EXIT`, `EXIT_IF`, `EXIT_NOT_IMPLEMENTED`) on anything it does not handle. Where the stop concerns one draw or one dispatch and nothing else depends on it, the build skips that draw or dispatch instead and writes one `[HACK]` line the first time per shader, naming the stop and its source line: a shader the recompiler cannot decode, translate or emit, and a shader stage whose inputs cannot be prepared. A failed shader is remembered (the whole program when no variant of it ever compiled, otherwise that variant), so it is not translated again for each draw; the other variants of the program keep drawing. A background compile that stops is dropped, and the draw compiles it again. Work done ahead of execution is never -required, so its stops are caught whatever `KYTY_FALLBACKS` says, wherever a stop can be caught (Linux): a compile +required, so its stops are caught whatever `KYTY_FALLBACKS` says: a compile queued by the resolution ahead or by a pipeline chain, and the preparation of a shader stage ahead. A compile ahead that stops is kept for its variant (its resources and push data) and never tried again ahead; the execution thread compiles what its draw needs as before, so a stop it hits itself still follows `KYTY_FALLBACKS`. A variant whose buffer descriptors no program of its stage compiles (`ADD_TID` outside compute, a reserved `dst_sel`) is refused before -compiling and kept the same way, and a program with 64 failed variants is no longer compiled ahead. Where a stop cannot -be caught (Windows), a variant of a resolution ahead that left a GPU-produced load unread is not compiled ahead. +compiling and kept the same way, and a program with 64 failed variants is no longer compiled ahead. In a build without +C++ exceptions, where a stop cannot be caught, a variant of a resolution ahead that left a GPU-produced load unread is +not compiled ahead. `[kyty-spec-compile]` counts these compiles every 10 s while they change. A pipeline manifest record that stops while it is replayed is dropped, as with exceptions enabled. The command processor ignores a write to a register it does not know (direct `SET_*_REG` packets and indirect register lists) and a GPU event type it does not know, with one `[HACK]`