diff --git a/core/libs/prx/libSceAgc/CMakeLists.txt b/core/libs/prx/libSceAgc/CMakeLists.txt index 4e9a781f8..f72bd1472 100644 --- a/core/libs/prx/libSceAgc/CMakeLists.txt +++ b/core/libs/prx/libSceAgc/CMakeLists.txt @@ -30,6 +30,7 @@ add_library(libSceAgc SHARED EXCLUDE_FROM_ALL ${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/Registers.cpp ${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/Workload.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Misc/src/PacketInfo.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Misc/src/Platform.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Misc/src/RegisterDefaults.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Misc/src/ShaderFusion.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Misc/src/Suspend.cpp @@ -69,6 +70,19 @@ target_link_libraries(agc_command_tests PRIVATE libSceAgc libc) configure_windows_unwind(agc_command_tests) configure_windows_unwind(libSceAgc) +add_test_executable(agc_platform_tests EXCLUDE_FROM_ALL tests/Platform.cpp) +target_include_directories(agc_platform_tests PRIVATE ${LIBS_INCLUDE_DIR}) +target_link_libraries(agc_platform_tests PRIVATE libSceAgc libc) +configure_windows_unwind(agc_platform_tests) +if(BUILD_TESTING) + set_target_properties(agc_platform_tests PROPERTIES EXCLUDE_FROM_ALL FALSE) + add_test(NAME agc_platform_tests COMMAND agc_platform_tests) + if(WIN32) + set_tests_properties(agc_platform_tests PROPERTIES ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$") + endif() +endif() + add_test_executable(agc_register_command_tests EXCLUDE_FROM_ALL tests/RegisterCommands.cpp Command/src/Packet.cpp diff --git a/core/libs/prx/libSceAgc/Misc/include/Platform.hpp b/core/libs/prx/libSceAgc/Misc/include/Platform.hpp new file mode 100644 index 000000000..fd07f976a --- /dev/null +++ b/core/libs/prx/libSceAgc/Misc/include/Platform.hpp @@ -0,0 +1,4 @@ +#ifndef CORE_LIBS_PRX_LIBSCEAGC_MISC_INCLUDE_PLATFORM_HPP +#define CORE_LIBS_PRX_LIBSCEAGC_MISC_INCLUDE_PLATFORM_HPP + +#endif diff --git a/core/libs/prx/libSceAgc/Misc/src/Platform.cpp b/core/libs/prx/libSceAgc/Misc/src/Platform.cpp new file mode 100644 index 000000000..de162d3a7 --- /dev/null +++ b/core/libs/prx/libSceAgc/Misc/src/Platform.cpp @@ -0,0 +1,17 @@ +#include "prx/libSceAgc/Misc/include/Platform.hpp" +#include "prx/libSceAgc/Command/include/Packet.hpp" + +#include +#include +#include "SceTypes.hpp" +#include "prx/libc/include/General.hpp" + +extern "C" { + +int APS5_VABI sceAgcGetIsTrinityMode(bool* isTrinityMode) { + Agc::Command::CheckAddress(reinterpret_cast(isTrinityMode), alignof(bool), __func__); + *isTrinityMode = false; + return 0; +} + +} diff --git a/core/libs/prx/libSceAgc/Unimplemented.cpp b/core/libs/prx/libSceAgc/Unimplemented.cpp index 94217d10f..dea38a6a4 100644 --- a/core/libs/prx/libSceAgc/Unimplemented.cpp +++ b/core/libs/prx/libSceAgc/Unimplemented.cpp @@ -70,10 +70,6 @@ int APS5_VABI sceAgcGetGsOversubscription() { return 0; } -int APS5_VABI sceAgcGetIsTrinityMode() { - return 0; -} - int APS5_VABI sceAgcGetSemaphoreLabel() { NotImplemented_nid_no_patch(__func__); return 0; diff --git a/core/libs/prx/libSceAgc/tests/Platform.cpp b/core/libs/prx/libSceAgc/tests/Platform.cpp new file mode 100644 index 000000000..daa0634cf --- /dev/null +++ b/core/libs/prx/libSceAgc/tests/Platform.cpp @@ -0,0 +1,53 @@ +#include "prx/libc/include/general/VabiMacros.hpp" +#include "prx/libc/include/Shutdown.hpp" + +#include +#include +#include + +extern "C" int APS5_VABI sceAgcGetIsTrinityMode(bool* isTrinityMode); + +namespace { + +void check(bool condition, const char* message) { + if (!condition) throw std::runtime_error(message); +} + +template +void expectFailure(TAction action) { + try { + action(); + } catch (const std::runtime_error& error) { + check(error.what()[0] != '\0', "empty exception message"); + return; + } + throw std::runtime_error("expected an exception"); +} + +void testTrinityMode() { + std::array flags{true, true, true}; + check(sceAgcGetIsTrinityMode(&flags[1]) == 0, "Trinity mode query did not return 0"); + check(!flags[1], "base PS5 GPU reported as Trinity"); + check(flags[0] && flags[2], "Trinity mode query wrote past its one-byte flag"); +} + +void testRejections() { + expectFailure([] { sceAgcGetIsTrinityMode(nullptr); }); +} + +} + +int main() { + try { + testTrinityMode(); + testRejections(); + LibcRunShutdown_nid_postfix(); + std::puts("AGC platform tests passed"); + return 0; + } catch (const std::exception& error) { + std::fprintf(stderr, "%s\n", error.what()); + try { LibcRunShutdown_nid_postfix(); } + catch (const std::exception& shutdown) { std::fprintf(stderr, "shutdown: %s\n", shutdown.what()); } + return 1; + } +} diff --git a/docs/dev/TechnicalDebt.md b/docs/dev/TechnicalDebt.md index 02ea84a84..0a78cad2a 100644 --- a/docs/dev/TechnicalDebt.md +++ b/docs/dev/TechnicalDebt.md @@ -32,6 +32,7 @@ Throughout the project, every function at every stage either **does exactly what - [sceFontGetRenderScaledKerning](../../core/libs/prx/libSceFont/src/Render.cpp) (libSceFont) - arguments, the cleared output and the bound renderer check taken from `cellFontGetRenderScaledKerning` in [RPCS3](https://github.com/RPCS3/rpcs3/blob/master/rpcs3/Emu/Cell/Modules/cellFont.cpp) (PS3 predecessor of the library), not confirmed on a title. The kerning is the `sceFontGetKerning` one at the render scale - [sceFontGetPixelResolution](../../core/libs/prx/libSceFont/src/Library.cpp) (libSceFont) - signature taken from the IDA type database of [Orbital](https://github.com/AlexAltea/orbital/blob/master/tools/ida/db_types.json), not confirmed on a title. The value is the one the library's driver reports (64 for FreeType); the argument checks and the cleared output follow `sceFontGetLibrary` - [sceAgcSetSubmitMode](../../core/libs/prx/libSceAgc/Misc/src/Suspend.cpp) (libSceAgc) - mode values unknown; only 0 is accepted +- [sceAgcGetIsTrinityMode](../../core/libs/prx/libSceAgc/Misc/src/Platform.cpp) (libSceAgc) - signature from the only PPSA26344 call (a pointer to a one-byte flag, result ignored); a null pointer throws because its error code is unknown - [zARR5aCmkoY](../../core/libs/prx/libSceAgc/DcbFlow/src/Control.cpp) (libSceAgc) - unknown name, signature - [qj7QZpgr9Uw](../../core/libs/prx/libSceAgc/DcbState/src/ContextState.cpp) (libSceAgc) - unknown name - [fd5Bp5tGTgo](../../core/libs/prx/libSceAgc/Misc/src/ShaderFusion.cpp) (libSceAgc) - unknown name