From ce6b26fadbd3b832434e5e65f3ce4c8d29a412ae Mon Sep 17 00:00:00 2001 From: Phi1ow <331962174+Phi1ow@users.noreply.github.com> Date: Sun, 4 Oct 2026 23:12:52 +0200 Subject: [PATCH] feat(razor): implement the libSceRazorCpu CPU profiler stubs libSceRazorCpu is the CPU-side instrumentation for the Razor capture tool. AnyPS5 does not host that tool, so the instrumentation does nothing and succeeds, which is also what shadPS4 does: - sceRazorCpuIsCapturing -> 0 (no capture is in progress, so titles skip their profiling paths) - sceRazorCpuJobManagerDispatch / sceRazorCpuJobManagerJob / sceRazorCpuJobManagerSequence -> 0 These only feed the profiler; they do not affect execution. Adds a CMakeLists.txt so the library can carry its guest test. New test core/libs/tests/GuestRazorCpu.cpp checks the four return values; it fails on main (the functions throw) and passes with the change. --- core/libs/prx/libSceRazorCpu/CMakeLists.txt | 20 ++++++++++++++++++ core/libs/prx/libSceRazorCpu/Export.cpp | 4 ---- core/libs/tests/GuestRazorCpu.cpp | 23 +++++++++++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 core/libs/prx/libSceRazorCpu/CMakeLists.txt create mode 100644 core/libs/tests/GuestRazorCpu.cpp diff --git a/core/libs/prx/libSceRazorCpu/CMakeLists.txt b/core/libs/prx/libSceRazorCpu/CMakeLists.txt new file mode 100644 index 000000000..2576a816d --- /dev/null +++ b/core/libs/prx/libSceRazorCpu/CMakeLists.txt @@ -0,0 +1,20 @@ +add_library(libSceRazorCpu SHARED EXCLUDE_FROM_ALL Export.cpp) +target_include_directories(libSceRazorCpu PRIVATE ${LIBS_INCLUDE_DIR}) +configure_windows_unwind(libSceRazorCpu) + +if(MINGW) + foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static) + string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") + endforeach() +endif() + +if(BUILD_TESTING) + add_test_executable(guest_razor_cpu_tests ${LIBS_INCLUDE_DIR}/tests/GuestRazorCpu.cpp) + target_include_directories(guest_razor_cpu_tests PRIVATE ${LIBS_INCLUDE_DIR}) + target_link_libraries(guest_razor_cpu_tests PRIVATE libSceRazorCpu) + add_test(NAME guest_razor_cpu COMMAND guest_razor_cpu_tests) + if(WIN32) + set_tests_properties(guest_razor_cpu PROPERTIES ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$") + endif() +endif() diff --git a/core/libs/prx/libSceRazorCpu/Export.cpp b/core/libs/prx/libSceRazorCpu/Export.cpp index 27bfe2560..83a295d21 100644 --- a/core/libs/prx/libSceRazorCpu/Export.cpp +++ b/core/libs/prx/libSceRazorCpu/Export.cpp @@ -6,25 +6,21 @@ extern "C" { uint32_t APS5_VABI sceRazorCpuIsCapturing(void) { - NotImplemented_nid_no_patch(__func__); return 0; } int APS5_VABI sceRazorCpuJobManagerDispatch(const void* args) { (void)args; - NotImplemented_nid_no_patch(__func__); return 0; } int APS5_VABI sceRazorCpuJobManagerJob(const void* args) { (void)args; - NotImplemented_nid_no_patch(__func__); return 0; } int APS5_VABI sceRazorCpuJobManagerSequence(const void* args) { (void)args; - NotImplemented_nid_no_patch(__func__); return 0; } diff --git a/core/libs/tests/GuestRazorCpu.cpp b/core/libs/tests/GuestRazorCpu.cpp new file mode 100644 index 000000000..2b966d8a6 --- /dev/null +++ b/core/libs/tests/GuestRazorCpu.cpp @@ -0,0 +1,23 @@ +#include "prx/libc/include/general/VabiMacros.hpp" +#include +#include + +extern "C" { +std::uint32_t APS5_VABI sceRazorCpuIsCapturing(void); +int APS5_VABI sceRazorCpuJobManagerDispatch(const void* args); +int APS5_VABI sceRazorCpuJobManagerJob(const void* args); +int APS5_VABI sceRazorCpuJobManagerSequence(const void* args); +} + +namespace { + +void Require(bool value) { if (!value) std::abort(); } + +} + +int main() { + Require(sceRazorCpuIsCapturing() == 0); + Require(sceRazorCpuJobManagerDispatch(nullptr) == 0); + Require(sceRazorCpuJobManagerJob(nullptr) == 0); + Require(sceRazorCpuJobManagerSequence(nullptr) == 0); +}