Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/kyty/cmake/KytyBackend.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ target_compile_definitions(anyps5_kyty_gpu
)
if(WIN32)
target_link_libraries(anyps5_kyty_gpu INTERFACE ${ANYPS5_KYTY_ARCHIVES} $<TARGET_PROPERTY:ANYPS5_KYTY_HOST_RUNTIME> $<TARGET_LINKER_FILE:libkernel> $<TARGET_LINKER_FILE:libc> pthread psapi dbghelp ws2_32 synchronization secur32)
if(MINGW AND ANYPS5_MINGW_DWARF_EXCEPTIONS)
target_sources(anyps5_kyty_gpu INTERFACE $<TARGET_OBJECTS:windows_seh_personalities>)
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()
Expand Down
2 changes: 1 addition & 1 deletion core/kyty/common/fallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool Enabled() {
}

bool Containable() {
#if defined(__cpp_exceptions) && !defined(_WIN32)
#if defined(__cpp_exceptions)
return true;
#else
return false;
Expand Down
10 changes: 6 additions & 4 deletions core/libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
1 change: 1 addition & 0 deletions core/libs/prx/libSceAgcDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ target_include_directories(libSceAgcDriver PRIVATE ${LIBS_INCLUDE_DIR} ${ANYPS5_
${CMAKE_CURRENT_BINARY_DIR}/generated)
target_link_libraries(libSceAgcDriver PRIVATE $<IF:$<TARGET_EXISTS:Kyty::gpu>,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")
Expand Down
21 changes: 7 additions & 14 deletions core/libs/prx/libSceAgcDriver/KytyShim/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion core/libs/prx/libSceAgcDriver/KytyShim/tests/Fallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
9 changes: 5 additions & 4 deletions docs/dev/THIRD_PARTY_KYTY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]`
Expand Down
Loading