Skip to content

fix(runtime): isolate host worker MXCSR - #7622

Open
MarcZX10 wants to merge 12 commits into
boykopovar:mainfrom
MarcZX10:codex/host-worker-mxcsr
Open

MarcZX10 wants to merge 12 commits into
boykopovar:mainfrom
MarcZX10:codex/host-worker-mxcsr

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Starts AnyPS5-owned native workers with host MXCSR 0x1f80 before their tasks. Linux threads created from guest execution contexts can otherwise inherit guest MXCSR 0x9fc0 and its FTZ/DAZ settings. The change covers current-main std::thread and std::jthread workers across runtime, AGC, VideoOut, shader cache, AvPlayer and libkernel code, the shader-registration pthread trampoline, and both Windows crash-diagnostic thread entrypoints. The focused helpers preserve the caller's MXCSR. Guest pthread execution remains governed by its separate guest-entry logic in #7565; this follows up on the host-worker question in #7594.

Tested

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt (https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 10749 core/libs/prx/libc/src/Process.cpp L2-3
PR 10760 core/libs/prx/libSceAgcDriver/Execution/include/CaptureTrace.hpp L60-61
PR 10957 core/libs/prx/libSceAvPlayer/src/Source.cpp L4
PR 11048 core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp L15

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 674 core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 1601 core/libs/prx/libSceAvPlayer/src/Source.cpp
PR 1896 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp
PR 2434 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 3986 core/libs/prx/libkernel/System/src/Signals.cpp
PR 4040 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 4449 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 5021 core/libs/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp
core/libs/prx/libkernel/Equeue/src/FileEvent.cpp
PR 5115 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 5372 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 5441 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineLibrary.cpp
core/shader/recompiler/CMakeLists.txt
core/shader/recompiler/ShaderDiskCache.cpp
PR 6146 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6280 core/shader/recompiler/ShaderDiskCache.cpp
PR 6412 core/shader/recompiler/ShaderDiskCache.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6488 core/shader/recompiler/ShaderDiskCache.cpp
PR 6548 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6918 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6924 core/shader/recompiler/ShaderDiskCache.cpp
PR 6960 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6977 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7088 core/libs/prx/libkernel/Equeue/src/FileEvent.cpp
PR 7121 core/libs/prx/libkernel/Equeue/src/FileEvent.cpp
PR 7192 core/libs/prx/libc/src/specifics/windows/CrashReport.cpp
PR 7201 core/libs/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAvPlayer/src/Player.cpp
core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp
core/libs/prx/libkernel/System/src/Signals.cpp
core/shader/recompiler/CMakeLists.txt
PR 7275 core/libs/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7369 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7412 core/libs/prx/libSceAvPlayer/src/Source.cpp
PR 7449 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7457 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7484 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineLibrary.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/shader/recompiler/CMakeLists.txt
core/shader/recompiler/ShaderDiskCache.cpp
PR 7682 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 7684 core/shader/recompiler/ShaderDiskCache.cpp
PR 8004 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/shader/recompiler/CMakeLists.txt
PR 8014 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 8542 core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
PR 8592 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 8650 core/libs/CMakeLists.txt
PR 9012 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 9019 core/libs/CMakeLists.txt
PR 9156 core/libs/CMakeLists.txt
PR 9176 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 9284 core/libs/CMakeLists.txt
PR 9287 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 9289 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 9293 core/libs/CMakeLists.txt
PR 9297 core/libs/CMakeLists.txt
PR 9302 core/libs/CMakeLists.txt
PR 9356 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/shader/recompiler/CMakeLists.txt
core/shader/recompiler/ShaderDiskCache.cpp
PR 9383 core/libs/CMakeLists.txt
PR 9387 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/shader/recompiler/CMakeLists.txt
core/shader/recompiler/ShaderDiskCache.cpp
PR 9389 core/libs/prx/libkernel/System/src/Signals.cpp
PR 9402 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 9431 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9432 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9489 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineLibrary.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/shader/recompiler/CMakeLists.txt
core/shader/recompiler/ShaderDiskCache.cpp
PR 9536 core/libs/CMakeLists.txt
PR 9571 core/libs/CMakeLists.txt
PR 9672 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9673 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9674 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9675 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9676 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9748 core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
PR 9772 core/libs/CMakeLists.txt
PR 9842 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9852 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 9947 core/libs/prx/libkernel/Apr/src/Apr.cpp
PR 10049 core/shader/recompiler/ShaderDiskCache.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineLibrary.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/shader/recompiler/CMakeLists.txt
core/shader/recompiler/ShaderDiskCache.cpp
PR 10249 core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp
PR 10435 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 10442 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 10547 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11446 core/libs/prx/libkernel/Apr/src/Apr.cpp

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Latest hosted run: conventions, eligibility, report, Linux/macOS Debug+Release register-context, Linux/macOS/Windows relinker, relinker ASAN, and both macOS write-watch jobs pass. The workflow skipped the full Linux and Windows app suites, so those results are not covered by this run.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks for the jthread coverage, that part looks right. Full CI on f2a3f97 fails to build on Linux and Windows at the shader disk cache key check:

core/shader/recompiler/ShaderDiskCache.cpp includes core/libs/prx/libc/include/HostThread.hpp, which the shader disk cache key does not hash: add it to shaderCacheKeySources in core/shader/recompiler/ShaderCacheVersion.cmake

Could you add HostThread.hpp to shaderCacheKeySources (ShaderCacheVersion.cmake)?

Two small optional extras while you're there: the RefreshPool mirror-refresh helpers (GuestBufferMemory.cpp) still start without the reset (no float math, so not required), and a debt line noting that threads started by third-party code while on a guest thread (SDL audio, driver-internal threads) still inherit guest MXCSR on Linux would make the boundary explicit.

@LeandroLP23

Copy link
Copy Markdown
Contributor

Windows build of f2a3f9702 on main c3591adf9 (clean merge), WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. It fails in two places:

  1. The shader cache key check stops the build:

    Shader disk cache key check failed:
      core/shader/recompiler/ShaderDiskCache.cpp includes core/libs/prx/libc/include/HostThread.hpp, which the shader disk cache key does not hash: add it to shaderCacheKeySources in core/shader/recompiler/CMakeLists.txt
    

    This check runs on every host, so it probably fails on Linux as well once the project is configured.

  2. host_thread_mxcsr_tests does not link with MinGW:

    HostThreadMxcsr.cpp.obj:HostThreadMxcsr.cpp:(.data+0x0): undefined reference to `__gxx_personality_v0'
    

    The other executables in that block link a target that brings the runtime in. host_thread_local_tests links host_thread_local_test_library, and windows_backtrace_report_tests links libc. The new one links nothing.

I didn't get further, so the MXCSR test itself has not run on Windows.

AI-assisted

@LeandroLP23

Copy link
Copy Markdown
Contributor

@MarcZX100 I followed up on both Windows failures. With the two changes below on f2a3f9702 (merged onto main c3591adf9, together with #7629, #7630 and #7627), the full build succeeds and the new test passes.

  • Cache key check: HostThread.hpp added to shaderCacheKeySources, next to HostThreadLocal.hpp.
  • Link: this toolchain uses DWARF exceptions (ANYPS5_MINGW_DWARF_EXCEPTIONS). __gxx_personality_v0 then comes from AnyPS5's libc (exception/Personality.cpp), not from MinGW's libstdc++. A manual g++ link of the two objects with the default -lstdc++ fails the same way. So the test links libc, as windows_backtrace_report_tests does, and on Windows gets the PATH to it like the other libc tests.
diff --git a/core/libs/CMakeLists.txt b/core/libs/CMakeLists.txt
index 1fe93b670..8e6a0576d 100644
--- a/core/libs/CMakeLists.txt
+++ b/core/libs/CMakeLists.txt
@@ -469,7 +469,11 @@ if(BUILD_TESTING)
     set_tests_properties(host_thread_local PROPERTIES TIMEOUT 15)
     add_test_executable(host_thread_mxcsr_tests tests/HostThreadMxcsr.cpp)
     target_include_directories(host_thread_mxcsr_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+    target_link_libraries(host_thread_mxcsr_tests PRIVATE libc)
     add_test(NAME host_thread_mxcsr COMMAND host_thread_mxcsr_tests)
+    if(WIN32)
+        set_tests_properties(host_thread_mxcsr PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
+    endif()
     if(MINGW)
         add_test(NAME prx_thread_local_destructors COMMAND ${CMAKE_COMMAND} -DNM=${CMAKE_NM} -DOBJDUMP=${CMAKE_OBJDUMP}
             -DMODULES=$<TARGET_FILE_DIR:libc> -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/ThreadLocalDestructors.cmake)
diff --git a/core/shader/recompiler/CMakeLists.txt b/core/shader/recompiler/CMakeLists.txt
index e4bcac3e9..7aed6fe08 100644
--- a/core/shader/recompiler/CMakeLists.txt
+++ b/core/shader/recompiler/CMakeLists.txt
@@ -178,7 +178,7 @@ function(add_shader_recompiler target runtimeTarget)
             "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/*.cmake"
             "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/CMakeLists.txt"
     )
-    set(shaderCacheKeySources "${PROJECT_SOURCE_DIR}/core/libs/prx/libc/include/HostThreadLocal.hpp")
+    set(shaderCacheKeySources "${PROJECT_SOURCE_DIR}/core/libs/prx/libc/include/HostThread.hpp" "${PROJECT_SOURCE_DIR}/core/libs/prx/libc/include/HostThreadLocal.hpp")
     foreach(source IN LISTS shaderCacheKeySources)
         if(NOT EXISTS "${source}")
             message(FATAL_ERROR "Shader disk cache key source does not exist: ${source}")

Results, Radeon 860M, Windows 11 26300, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON:

  • host_thread_mxcsr and host_thread_local pass, 3 runs of 3.
  • Every agc_* test on that build: 719 of 722 pass. The 3 failures don't come from this PR: agc_driver_depth_bounds_state is fix(agc): preserve infinite depth bounds #7627's missing Windows PATH, and agc_driver_quad_pixel_mask and agc_driver_layered_volume_vertex_no_gpl fail the same way on main here.

AI-assisted

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Pushed 7aec3f58f to address the two reported build failures:

  • Add HostThread.hpp to the shader disk cache key inputs.
  • Link host_thread_mxcsr_tests with libc and prepend its directory to PATH on Windows.

The changes match the focused patch reported by LeandroLP23. Their independent Windows 11 26300 / Radeon 860M / WinLibs GCC 15.2.0 Release run reports host_thread_mxcsr and host_thread_local passing 3/3 each, and the full build succeeding. That run was on an equivalent merged tree before this commit; it has not yet run against this exact head.

Local git diff --check passes. The local conventions checker reports seven pre-existing baseline findings (one silent stub and six old revert subjects); no finding points to these two CMake edits. This host's full build remains blocked by the unrelated GCC dependent-template error in SrtDescriptorEvaluation.cpp. The prior PR CI had full Linux and Windows jobs skipped, so those are not presented as validation of this head.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

The updated head 7aec3f58f now has green conventions, eligibility, report, register-context (Ubuntu Debug/Release and macOS Intel Debug/Release), relinker (Linux, Windows, macOS arm64/x86_64, ASan), and write-watch (macOS arm64/Intel) checks. Full Linux/Windows builds were skipped by path policy. The independent Radeon 860M run remains evidence from an equivalent merged tree before this exact head, as described above.

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the new test on macOS (x86-64 under Rosetta 2), head 7aec3f58f. Apple M2 Max, macOS 27.2, Apple clang 21. The full x86-64 tree from this head configures on macOS but libc does not compile there (CLOCK_REALTIME_COARSE, st_mtim in General.cpp; #7332 covers that), so I built core/libs/tests/HostThreadMxcsr.cpp with the PR's HostThread.hpp on its own (clang++ -arch x86_64 -std=c++20 -O2). The arm64 build does not include core/libs.

On macOS the test does not catch a missing reset:

  • As in the PR: passes 5/5.
  • With both SetHostMxcsr() calls removed from StartHostThread and StartHostJThread: also passes 5/5.
  • Control: with the helper setting 0x9fc0 instead of 0x1f80, it throws as expected, so the check itself works.

Under Rosetta 2 a new thread starts with the default MXCSR and does not inherit the creator's FTZ/DAZ. A plain probe shows the same for std::thread and pthread_create: the caller is at 0x9fc0, the new thread reads 0x1f80 (3/3). I have no Intel Mac to check native x86-64.

So the inheritance this PR fixes does not happen here. On macOS the reset changes nothing for new threads, and host_thread_mxcsr only works as a regression test on Linux. It may be worth saying that in Tested, or showing it failing on Linux without the reset.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux follow-up to my macOS note above: a full Linux build and suite run of 7aec3f58f, plus the mutation I suggested there. The hosted run skipped the Linux app suite, and the Linux runs so far covered only the focused test. On Linux the test does catch a missing reset.

Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release, BUILD_TESTING=ON, full build.
Head 7aec3f58f merged onto main a373e85e5 (clean merge). Same commands on plain main for the baseline.

  • Builds, including the shader cache key check that failed on f2a3f9702.
  • host_thread_mxcsr and host_thread_local pass 20/20 with --repeat until-fail:20. The 28 tests matching host_thread|pthread|mxcsr pass.
  • Non-GPU suite (ctest -E "^agc|gpu|vulkan|video_out" -j7): 745/746. The new test brings the count to 746, and main is 745/745. The one failure was pr_overlap_tools. That test only exercises tools/pr_overlap.py, which this PR doesn't touch. It passed 3/3 on its own in the same merged tree, so I read it as a flake under -j7.
  • AGC suite on lavapipe (Mesa 26.0.3, VK_DRIVER_FILES pointing only at lvp_icd.json; ctest -R "^agc" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64" -j4): 732/732 with 50 skipped, the same as main.
  • Mutation: with SetHostMxcsr() emptied, host_thread_mxcsr fails 3/3 with a host worker inherited guest MXCSR. So on Linux a plain std::thread started from a thread at 0x9fc0 really starts at 0x9fc0, unlike under Rosetta 2, and the test catches it.
  • Coverage check: in the merged tree, I grepped core (without tests, 3rdparty and the relinker) for workers that are still started directly. There is one: RefreshPool in libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp (threads.emplace_back([this](std::stop_token token) { ... }), the mirror refresh helpers, std::vector<std::jthread>). It is created lazily by RefreshPool::Get(), so it inherits whatever MXCSR the first caller has. Its helpers only memcmp/memcpy blocks, so FTZ/DAZ has no effect on them today. It is the only launch I found outside the helpers, in case you want the coverage to be complete.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@blawesom

Copy link
Copy Markdown
Contributor

Rebase handoff, with one test-fixture extension — rebased onto current main (all three commits, authorship unchanged). The conflict in the recompiler CMakeLists kept main's dedup machinery plus your HostThread.hpp key source — and the shader_cache_runtime_sources test fixture needed the matching HostThread.hpp stub added (it only created HostThreadLocal.hpp, so the new key source made its configure step fail). Both included.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; conventions pass; the shader-cache runtime-sources test passes; full suite green apart from the four known main regressions (agc_driver_tessellation — Mesa #5444; agc_driver_bda_device — #7584; agc_driver_image_table_vouched_lookups — #7766; agc_driver_guest_memory_lifetime — #7784, which I bisected today to 16473dbbe in the #6499 family), none from this PR.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/7622
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 398b2576c.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@blawesom thanks for carrying this across the conflict. The CMake resolution is the right one: it keeps main's compiled-sources dedup and appends HostThread.hpp to shaderCacheKeySources, which ShaderCacheVersion.cmake still requires because ShaderDiskCache.cpp includes it. The first two commits come through unchanged.

One thing is missing from the pushed branch: rebase/7622 at 398b2576c doesn't contain the shader_cache_runtime_sources fixture stub. The last commit only touches the two CMakeLists files, and tools/tests/test_shader_cache_runtime_sources.py still only writes HostThreadLocal.hpp. On 398b2576c that test fails at the fixture configure ("Shader disk cache key source does not exist", 11 failures). With this line added after the HostThreadLocal.hpp write, it passes:

        (header.parent / 'HostThread.hpp').write_text('struct FixtureThread {};\n', encoding='utf-8')

My guess is that it's still uncommitted on your side. Could you push it to rebase/7622?

@MarcZX10 the --ff-only pickup won't work because this is a real rebase: 398b2576c doesn't contain your current head 7aec3f58f. Once the stub is on blawesom's branch, adopting it would be:

git fetch https://github.com/blawesom/AnyPS5 rebase/7622
git checkout codex/host-worker-mxcsr
git reset --hard FETCH_HEAD
git push --force-with-lease

If you'd rather not force-push, merging main into your branch works too: it's the same single conflict in core/shader/recompiler/CMakeLists.txt, resolved the same way, plus the fixture line above. Either way, we'll run full CI on the new head before it goes on.

@MarcZX10
MarcZX10 force-pushed the codex/host-worker-mxcsr branch from 7aec3f5 to 70e3144 Compare October 19, 2026 14:50
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 22, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 23, 2026
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 23, 2026
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants