From 635abed98c4fc94a357d58c508249e2211759582 Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 5 Nov 2026 20:08:56 +0100 Subject: [PATCH 1/6] fix(agc): preserve authoritative stencil plane ownership --- .../Graphics/src/DepthSurface.cpp | 10 +- ...driver_stencil_plane_ownership_tests.cmake | 10 + .../tests/execution/StencilPlaneOwnership.cpp | 181 ++++++++++++++++++ docs/dev/debt/libSceAgcDriver.md | 2 + 4 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_stencil_plane_ownership_tests.cmake create mode 100644 core/libs/prx/libSceAgcDriver/tests/execution/StencilPlaneOwnership.cpp diff --git a/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp b/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp index 845c78735e31..934c5c43d62c 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp @@ -657,6 +657,7 @@ std::optional decodeOverwrite(const StorageImageClear& clea class DepthSurface; std::pair staleStencilRange(const DepthSurface& surface); void noteStalePlane(std::uint64_t begin, std::uint64_t end); +void retireStencil(DepthSurface& surface); std::uint64_t nextPlaneSerial(); class DepthSurface { @@ -2503,19 +2504,26 @@ PlaneOwners& stencilOwners() { void takePlane(DepthSurface& surface, PlaneOwners& owners, std::uint64_t address, VkImageAspectFlagBits aspect, bool created, VkImageAspectFlags clearAspects) { auto& entry = owners[{surface.context.device, address}]; auto* owner = entry.surface; - if (owner != nullptr && owner->active->load(std::memory_order_acquire) && owner != &surface && owner->target.format == surface.target.format && owner->target.samples == surface.target.samples && owner->target.extent.width == surface.target.extent.width && owner->target.extent.height == surface.target.extent.height && (!created || (clearAspects & aspect) == 0)) { + const bool compatible = owner != nullptr && owner->active->load(std::memory_order_acquire) && owner != &surface && owner->target.format == surface.target.format && owner->target.samples == surface.target.samples && owner->target.extent.width == surface.target.extent.width && owner->target.extent.height == surface.target.extent.height; + if (compatible && (!created || (clearAspects & aspect) == 0)) { if ((owner->pendingClear & aspect) != 0) { if (aspect == VK_IMAGE_ASPECT_DEPTH_BIT) { surface.depthFill = owner->depthFill; surface.depthMark = std::max(surface.depthMark, owner->depthMark); } else { surface.stencilFill = owner->stencilFill; + if (surface.target.samples == 1u && !surface.stencilFill.has_value()) surface.stencilFill = owner->clearStencil; surface.stencilMark = std::max(surface.stencilMark, owner->stencilMark); } if (!created || (aspect == VK_IMAGE_ASPECT_DEPTH_BIT ? surface.depthFill.has_value() : surface.stencilFill.has_value())) surface.pendingClear |= aspect; } else { surface.CopyAspectFrom(*owner, aspect); } + if (aspect == VK_IMAGE_ASPECT_STENCIL_BIT && surface.StencilMirrorable() && owner->StencilMirrorable()) surface.stencilGeneration = owner->stencilGeneration; + } + if (compatible && aspect == VK_IMAGE_ASPECT_STENCIL_BIT && surface.StencilMirrorable() && owner->stencilStale) { + surface.MarkStencilStale(); + retireStencil(*owner); } entry = {&surface, ++planeBinds}; } diff --git a/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_stencil_plane_ownership_tests.cmake b/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_stencil_plane_ownership_tests.cmake new file mode 100644 index 000000000000..3e10fd5bec50 --- /dev/null +++ b/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_stencil_plane_ownership_tests.cmake @@ -0,0 +1,10 @@ +if(BUILD_TESTING) + set_tests_properties(agc_driver_stencil_plane_ownership PROPERTIES TIMEOUT 30) + foreach(case d16 readonly cpu cpu_fresh clear independent) + add_test(NAME agc_driver_stencil_plane_ownership_${case} COMMAND agc_driver_stencil_plane_ownership_tests ${case}) + set_tests_properties(agc_driver_stencil_plane_ownership_${case} PROPERTIES ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1;APS5_NO_PIPELINE_JOURNAL=1" TIMEOUT 30 SKIP_RETURN_CODE 77 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") + if(WIN32) + set_tests_properties(agc_driver_stencil_plane_ownership_${case} PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$") + endif() + endforeach() +endif() diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/StencilPlaneOwnership.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/StencilPlaneOwnership.cpp new file mode 100644 index 000000000000..be8abe7c0143 --- /dev/null +++ b/core/libs/prx/libSceAgcDriver/tests/execution/StencilPlaneOwnership.cpp @@ -0,0 +1,181 @@ +#include "prx/libSceAgcDriver/Execution/include/GuestMemory.hpp" +#include "prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp" +#include "prx/libSceAgcDriver/Graphics/include/TextureTiling.hpp" +#include "prx/libc/include/GuestAllocations.hpp" +#include "prx/libc/include/GuestArena.hpp" +#include "prx/libc/include/GuestWriteWatch.hpp" +#include "DepthFastClearHarness.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + +using DepthFastClearHarness::Require; +constexpr VkExtent2D Extent{256u, 256u}; +constexpr std::size_t Block = 65536u; +constexpr std::size_t DepthBytes = 4u * Block; +constexpr std::size_t Texels = 256u * 256u; +alignas(256) std::array Colors{}; + +struct Fixture { + AgcDriver::VulkanDevice& device; + DepthFastClearHarness::Shaders shaders; + std::uintptr_t base; + VkFormat format; + + Fixture(AgcDriver::VulkanDevice& device, VkFormat format) : device(device), shaders(DepthFastClearHarness::Compile(device)), format(format) { + constexpr std::size_t bytes = 3u * DepthBytes + 4u * Block; + auto* memory = GuestArena::GuestArenaAllocate_nid_postfix(bytes, Block); + Require(memory != nullptr, "cannot allocate stencil ownership fixture"); + GuestArena::GuestArenaCommit_nid_postfix(memory, bytes, 0x04, bytes); + GuestAllocations::Mutation().Add(memory, bytes, true, true, true); + GuestWriteWatch::GuestWriteWatchRegister_nid_postfix(memory, bytes); + base = reinterpret_cast(memory); + std::fill_n(static_cast(memory), 3u * DepthBytes / sizeof(float), 1.0f); + std::memset(reinterpret_cast(Stencil()), 0, 4u * Block); + AgcDriver::GuestMemory::BumpCollectEpoch(); + } + + std::uintptr_t Depth(unsigned index) const { return base + index * DepthBytes; } + std::uintptr_t Stencil(unsigned index = 0u) const { return base + 3u * DepthBytes + index * Block; } + + DepthFastClearHarness::Surface Surface(unsigned depth, unsigned stencil = 0u) const { + return {Depth(depth), Stencil(stencil), 0u, false, format, 0u, 0u, AgcDriver::Graphics::XorSwizzleMode(AgcDriver::Graphics::TextureTileMode::kZ64KBX)}; + } + + static DepthFastClearHarness::DrawOptions Options(std::uint8_t value, bool write) { + DepthFastClearHarness::DrawOptions options; + options.depthTest = write; + options.depthWrite = write; + options.depthCompare = VK_COMPARE_OP_ALWAYS; + options.minDepth = options.maxDepth = 0.5f; + options.stencilTest = true; + options.stencil = {VK_STENCIL_OP_KEEP, write ? VK_STENCIL_OP_REPLACE : VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, + write ? VK_COMPARE_OP_ALWAYS : VK_COMPARE_OP_EQUAL, 255u, write ? 255u : 0u, value}; + return options; + } + + std::uint32_t Draw(const DepthFastClearHarness::Surface& surface, const DepthFastClearHarness::DrawOptions& options) { + return DepthFastClearHarness::Draw(device, shaders, surface, options, Extent, Colors); + } + + void Write(unsigned index, std::uint8_t value, unsigned stencil = 0u) { + Require(Draw(Surface(index, stencil), Options(value, true)) == Texels, "source stencil draw did not cover the plane"); + } + + void CheckStencil(std::uint8_t value, unsigned stencil = 0u) { + const auto address = Stencil(stencil); + const auto ranges = AgcDriver::Graphics::FlushDepthPlanes(address, Block); + device.WaitIdle(); + std::vector bytes(Block); + AgcDriver::GuestMemory::ReadCommitted(address, bytes); + Require(ranges.size() == 1u, "a superseded stencil replica was also published"); + Require(std::ranges::all_of(bytes, [&](std::byte byte) { return byte == static_cast(value); }), "guest stencil bytes do not hold the current owner's value"); + Require(AgcDriver::Graphics::FlushDepthPlanes(address, Block).empty(), "a clean stencil plane was published twice"); + } + + void CheckDepth(unsigned index) { + static_cast(AgcDriver::Graphics::FlushDepthPlanes(Depth(index), DepthBytes)); + device.WaitIdle(); + std::array values{}; + AgcDriver::GuestMemory::ReadCommitted(Depth(index), std::as_writable_bytes(std::span(values))); + Require(std::ranges::all_of(values, [](std::uint32_t value) { return value == std::bit_cast(0.5f); }), "stencil handoff discarded an independently owned depth plane"); + } +}; + +void SharedWrites(Fixture& fixture) { + fixture.Write(0u, 37u); + fixture.Write(1u, 203u); + fixture.Write(2u, 91u); + fixture.CheckStencil(91u); + if (fixture.format == VK_FORMAT_D32_SFLOAT_S8_UINT) { + for (unsigned index = 0; index != 3u; ++index) fixture.CheckDepth(index); + } +} + +void ReadOnly(Fixture& fixture) { + fixture.Write(0u, 37u); + fixture.Write(1u, 203u); + Require(fixture.Draw(fixture.Surface(0u), Fixture::Options(203u, false)) == Texels, "a read-only rebind lost the newest stencil value"); + auto masked = Fixture::Options(73u, true); + masked.depthWrite = false; + masked.stencil.writeMask = 0u; + Require(fixture.Draw(fixture.Surface(0u), masked) == Texels, "a masked stencil draw failed"); + fixture.CheckStencil(203u); + fixture.CheckDepth(0u); + fixture.CheckDepth(1u); +} + +void CpuStore(Fixture& fixture, bool fresh) { + fixture.Write(0u, 37u); + fixture.Write(1u, 203u); + std::memset(reinterpret_cast(fixture.Stencil()), 5, Block); + AgcDriver::GuestMemory::BumpCollectEpoch(); + const auto destination = fixture.Surface(fresh ? 2u : 0u); + Require(fixture.Draw(destination, Fixture::Options(5u, false)) == Texels, "the new stencil owner did not consume the CPU store"); + Require(fixture.Draw(destination, Fixture::Options(203u, false)) == 0u, "the old GPU stencil value survived the CPU store"); + fixture.CheckStencil(5u); + fixture.CheckDepth(0u); + fixture.CheckDepth(1u); +} + +void PendingClear(Fixture& fixture) { + auto surface = fixture.Surface(0u); + surface.htile = fixture.Stencil(3u); + surface.htileStencil = true; + surface.clearStencil = 90u; + const auto bytes = AgcDriver::Graphics::HtileMetadataBytes(Extent); + Require(bytes <= Block, "HTILE does not fit its fixture allocation"); + std::memset(reinterpret_cast(surface.htile), 255, bytes); + AgcDriver::GuestMemory::BumpCollectEpoch(); + Require(fixture.Draw(surface, Fixture::Options(37u, true)) == Texels, "stencil clear source draw failed"); + std::memset(reinterpret_cast(surface.htile), 0, bytes); + AgcDriver::GuestMemory::BumpCollectEpoch(); + AgcDriver::Graphics::NoteDepthMetadataFill(surface.htile, bytes, 0u); + auto target = fixture.Surface(1u); + target.clearStencil = 165u; + Require(fixture.Draw(target, Fixture::Options(90u, false)) == Texels, "a new stencil owner replaced the pending clear with its clear-register value"); + fixture.CheckStencil(90u); +} + +void Independent(Fixture& fixture) { + constexpr std::array values{37u, 203u, 91u}; + for (unsigned index = 0; index != values.size(); ++index) fixture.Write(index, values[index], index); + for (unsigned index = 0; index != values.size(); ++index) { + fixture.CheckStencil(values[index], index); + fixture.CheckDepth(index); + } +} + +} + +int main(int argc, char** argv) { + try { + const std::string_view mode = argc == 1 ? "write" : argc == 2 ? argv[1] : "invalid"; + auto device = OpenVulkanTestDevice(); + if (!device) return VulkanTestSkipped; + Fixture fixture(*device, mode == "d16" ? VK_FORMAT_D16_UNORM_S8_UINT : VK_FORMAT_D32_SFLOAT_S8_UINT); + if (mode == "write" || mode == "d16") SharedWrites(fixture); + else if (mode == "readonly") ReadOnly(fixture); + else if (mode == "cpu" || mode == "cpu_fresh") { + if (!AgcDriver::GuestMemory::WriteWatched() || !AgcDriver::GuestMemory::Watched(fixture.Stencil(), Block)) { + std::puts("skipped, guest write watch unavailable"); + return VulkanTestSkipped; + } + CpuStore(fixture, mode == "cpu_fresh"); + } else if (mode == "clear") PendingClear(fixture); + else if (mode == "independent") Independent(fixture); + else throw std::runtime_error("unknown stencil ownership test arguments"); + } catch (const std::exception& error) { + std::fprintf(stderr, "%s\n", error.what()); + return 1; + } + std::puts("stencil plane ownership tests passed"); +} diff --git a/docs/dev/debt/libSceAgcDriver.md b/docs/dev/debt/libSceAgcDriver.md index fe5812b1e576..d62793273ee4 100644 --- a/docs/dev/debt/libSceAgcDriver.md +++ b/docs/dev/debt/libSceAgcDriver.md @@ -147,6 +147,8 @@ Eligible single-sample draws retain native finite bounds inside [0, 1] and use a ### Functional +- [Stencil ownership handoff](../../../core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp) (libSceAgcDriver) - stencil transfers across different extents or formats have no full-plane preservation proof. Publication and CPU-write generation transfer cover compatible single-sample mirrored planes; multisample and nonmirrorable publication retain their existing paths. Later CPU stores that no rebinding read consumes, including unwatched mappings, can still be overwritten at publication (#14969). Console behavior and commercial titles were not measured. + - [Native multisampled depth import](../../../core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp) (libSceAgcDriver) - refuses a depth HTILE that is not pipe-aligned (`0x2af` bit 18 is zero). Sonic Superstars (PPSA06888) uses a layout with iterate-256 also off (`DB_Z_INFO` bit 20 is zero) on its 2x depth targets, and the refusal stops presentation before its title screen. Not verified: whether the clear-proof is correct for a non-pipe-aligned layout, since the import reads the HTILE words as a flat array. - [Written staging window on discrete GPUs](../../../core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp) (libSceAgcDriver) - a written buffer element of a dispatch that is not swept is staged device-local up to 8 MiB on a discrete GPU (`Context::discreteGpu`) and up to 2 MiB otherwise; `APS5_WRITTEN_SHADOW_MAX_KIB` replaces either bound. The 8 MiB figure comes from one title on one NVIDIA Windows system (PPSA09911: a 2.5 and a 3.3 MiB skin-cache output written in place cost 55 ms of GPU time per frame, 1.8 ms of extra staging copies once staged); the point where the two copies of a larger element cost more than its in-place stores, and whether AMD or Linux drivers move it, has not been measured. The window is per element and per use, so a kernel that streams once through an element inside the window pays the copy-in and the copy-back on every dispatch. - [FS table calls on macOS](../../../core/libs/prx/libSceAgcDriver/Execution/include/Driver/DriverMemory.hpp) (libSceAgcDriver) - macOS keeps the console's 0xfe0000000 for itself, so the driver block, and the FS table at 0xfe0040000 inside it, moves to 0xee0000000 there; `sceAgc*StaticBuffer` and `AgcDriverStaticTable_nid_postfix` use the moved address. A shader that builds the table address from two `s_mov_b32` literals still loads from 0xfe0040000: `ReadTableCallees` (`Driver/Shaders/ShaderRegistry.cpp`) reads that address unchanged, and the shader also loads from it at run time, so those dispatches cannot link on macOS. #6160 lists titles that build this address. `ComputeFsTableCalls` is skipped on macOS as it is under `ANYPS5_ENABLE_ASAN`. Closes when: the driver rewrites that pointer in the shader code for both the callee lookup and the code the GPU runs, or the console address can be mapped on macOS. From 922835da2d7bffa23f031055382c52e8714e0664 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 13 Nov 2026 11:00:01 +0100 Subject: [PATCH 2/6] test(agc): preserve stencil publication after copy failure --- ...driver_stencil_plane_ownership_tests.cmake | 2 +- .../tests/execution/StencilPlaneOwnership.cpp | 70 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_stencil_plane_ownership_tests.cmake b/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_stencil_plane_ownership_tests.cmake index 3e10fd5bec50..82c3c76822cc 100644 --- a/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_stencil_plane_ownership_tests.cmake +++ b/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_stencil_plane_ownership_tests.cmake @@ -1,6 +1,6 @@ if(BUILD_TESTING) set_tests_properties(agc_driver_stencil_plane_ownership PROPERTIES TIMEOUT 30) - foreach(case d16 readonly cpu cpu_fresh clear independent) + foreach(case d16 readonly cpu cpu_fresh clear independent copy_failure) add_test(NAME agc_driver_stencil_plane_ownership_${case} COMMAND agc_driver_stencil_plane_ownership_tests ${case}) set_tests_properties(agc_driver_stencil_plane_ownership_${case} PROPERTIES ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1;APS5_NO_PIPELINE_JOURNAL=1" TIMEOUT 30 SKIP_RETURN_CODE 77 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") if(WIN32) diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/StencilPlaneOwnership.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/StencilPlaneOwnership.cpp index be8abe7c0143..1be7cea298a8 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/StencilPlaneOwnership.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/StencilPlaneOwnership.cpp @@ -1,4 +1,5 @@ #include "prx/libSceAgcDriver/Execution/include/GuestMemory.hpp" +#include "prx/libSceAgcDriver/Graphics/include/Context.hpp" #include "prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp" #include "prx/libSceAgcDriver/Graphics/include/TextureTiling.hpp" #include "prx/libc/include/GuestAllocations.hpp" @@ -90,6 +91,74 @@ struct Fixture { } }; +struct CopyFailureProbe { + explicit CopyFailureProbe(AgcDriver::Graphics::Context& context) : original(context.deviceProc) { + Require(active == nullptr, "a stencil copy failure probe is already active"); + fallback = original; + active = this; + context.deviceProc = Resolve; + } + + ~CopyFailureProbe() { active = nullptr; } + + static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL Resolve(VkDevice device, const char* name) { + if (active != nullptr && active->failNext && std::strcmp(name, "vkCmdCopyImage") == 0) { + active->failNext = false; + ++active->refused; + return nullptr; + } + return (active != nullptr ? active->original : fallback)(device, name); + } + + inline static CopyFailureProbe* active = nullptr; + inline static PFN_vkGetDeviceProcAddr fallback = nullptr; + PFN_vkGetDeviceProcAddr original; + bool failNext = false; + unsigned refused = 0; +}; + +void CopyFailure(Fixture& fixture) { + auto context = fixture.device.graphicsContext(); + CopyFailureProbe probe(context); + const auto destination = fixture.Surface(1u); + AgcDriver::Graphics::DepthTarget target{destination.depth, destination.stencil, Extent, destination.format, 1.0f, destination.clearStencil, destination.htile, destination.htileStencil}; + target.depthSwizzle = destination.swizzle; + try { + Require(AgcDriver::Graphics::DepthSurfaceViewWithStencilWriteIntent(context, target, false, true, false) != VK_NULL_HANDLE, "cannot prime the stencil copy destination"); + fixture.Write(1u, 37u); + fixture.Write(0u, 203u); + std::vector before(Block); + AgcDriver::GuestMemory::ReadCommittedUnsynced(fixture.Stencil(), before); + Require(!std::ranges::all_of(before, [](std::byte byte) { return byte == std::byte{203}; }), "the source stencil was published before the failed handoff"); + const auto nativeCopy = probe.original(context.device, "vkCmdCopyImage"); + Require(nativeCopy != nullptr, "the native image copy callback is unavailable"); + probe.failNext = true; + bool rejected = false; + try { + static_cast(AgcDriver::Graphics::DepthSurfaceViewWithStencilWriteIntent(context, target, false, true, false)); + } catch (const std::runtime_error& error) { + rejected = std::string_view(error.what()) == "AGC graphics: missing Vulkan function: vkCmdCopyImage"; + } + probe.failNext = false; + Require(rejected && probe.refused == 1u, "the stencil inheritance copy did not reach its injected resolver failure"); + Require(context.deviceProc(context.device, "vkCmdCopyImage") == nativeCopy, "the native image copy callback was not restored after the failure"); + std::printf("stencil copy failure injected=%u source=203 previous destination=37\n", probe.refused); + fixture.device.WaitIdle(); + fixture.CheckStencil(203u); + Require(fixture.Draw(destination, Fixture::Options(203u, false)) == Texels, "stencil inheritance did not recover after its copy failed"); + fixture.CheckStencil(203u); + fixture.CheckDepth(0u); + fixture.CheckDepth(1u); + fixture.device.WaitIdle(); + AgcDriver::Graphics::ClearDepthSurfaces(context.device); + } catch (...) { + probe.failNext = false; + fixture.device.WaitIdle(); + AgcDriver::Graphics::ClearDepthSurfaces(context.device); + throw; + } +} + void SharedWrites(Fixture& fixture) { fixture.Write(0u, 37u); fixture.Write(1u, 203u); @@ -172,6 +241,7 @@ int main(int argc, char** argv) { CpuStore(fixture, mode == "cpu_fresh"); } else if (mode == "clear") PendingClear(fixture); else if (mode == "independent") Independent(fixture); + else if (mode == "copy_failure") CopyFailure(fixture); else throw std::runtime_error("unknown stencil ownership test arguments"); } catch (const std::exception& error) { std::fprintf(stderr, "%s\n", error.what()); From 338a4e9540ef0ef3f718a61a9bef7b10397cdc63 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 15 Nov 2026 03:17:50 +0100 Subject: [PATCH 3/6] fix(docs): disambiguate ICU list debt update --- docs/dev/debt/changes/feat-icu-ulist.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/debt/changes/feat-icu-ulist.md b/docs/dev/debt/changes/feat-icu-ulist.md index 35137bccf52c..57a5ac41d1fa 100644 --- a/docs/dev/debt/changes/feat-icu-ulist.md +++ b/docs/dev/debt/changes/feat-icu-ulist.md @@ -1,6 +1,6 @@ # libSceIcu -## change [Older callable exports] +## change `uloc_getLCID`, `uloc_getLocaleForLCID`, - [Older callable exports](../../../core/libs/prx/libSceIcu/LegacyExports.cpp) - 1689 of the 2347 3.20 callable NIDs use ICU 68 names (hashes of `libicuuc`/`libicui18n`/`libicuio` symbols in [ICU 68.2 Ubuntu 20.04](https://github.com/unicode-org/icu/releases/download/release-68-2/icu4c-68_2-Ubuntu20.04-x64.tgz), stripping `_68`; 1293 C++ in `icu_68`); a name match does not show ICU 68's prototype or behavior. `ubidi_getClass`, ten `unorm2_*`, `unorm_compare`, `u_terminateChars`, `u_terminateUChar32s`, `uloc_isRightToLeft`, `uloc_getLCID`, `uloc_getLocaleForLCID`, `uprv_int32Comparator`, `uprv_uint32Comparator`, `uprv_uint16Comparator` (in [ArrayComparators.cpp](../../../core/libs/prx/libSceIcu/ArrayComparators.cpp)), `ulist_*` and [Script.cpp](../../../core/libs/prx/libSceIcu/Script.cpp) are implemented; the rest throw. The other 654 keep placeholder names (650 match no ICU 68.2 symbol). None appears in the later version-labelled inventory; no cross-version compatibility is claimed. From 35c736b1fbdaae5a8f50822a4c4d3b9d0a72df58 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 15 Nov 2026 03:23:52 +0100 Subject: [PATCH 4/6] test(agc): cover unwatched stencil ownership baselines --- ...driver_stencil_plane_ownership_tests.cmake | 5 ++- .../tests/execution/StencilPlaneOwnership.cpp | 41 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_stencil_plane_ownership_tests.cmake b/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_stencil_plane_ownership_tests.cmake index 82c3c76822cc..5f665a4357a0 100644 --- a/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_stencil_plane_ownership_tests.cmake +++ b/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_stencil_plane_ownership_tests.cmake @@ -1,8 +1,11 @@ if(BUILD_TESTING) set_tests_properties(agc_driver_stencil_plane_ownership PROPERTIES TIMEOUT 30) - foreach(case d16 readonly cpu cpu_fresh clear independent copy_failure) + foreach(case d16 readonly cpu cpu_fresh clear independent copy_failure unwatched_cpu_fresh unwatched_cpu_reused unwatched_cpu_after unwatched_gpu_after) add_test(NAME agc_driver_stencil_plane_ownership_${case} COMMAND agc_driver_stencil_plane_ownership_tests ${case}) set_tests_properties(agc_driver_stencil_plane_ownership_${case} PROPERTIES ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1;APS5_NO_PIPELINE_JOURNAL=1" TIMEOUT 30 SKIP_RETURN_CODE 77 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") + if(case MATCHES "^unwatched_") + set_property(TEST agc_driver_stencil_plane_ownership_${case} APPEND PROPERTY ENVIRONMENT "APS5_NO_WRITE_WATCH=1") + endif() if(WIN32) set_tests_properties(agc_driver_stencil_plane_ownership_${case} PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$") endif() diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/StencilPlaneOwnership.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/StencilPlaneOwnership.cpp index 1be7cea298a8..119883cc2e36 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/StencilPlaneOwnership.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/StencilPlaneOwnership.cpp @@ -195,6 +195,45 @@ void CpuStore(Fixture& fixture, bool fresh) { fixture.CheckDepth(1u); } +void CheckHandoffBytes(Fixture& fixture, std::uint8_t value, bool published) { + const auto ranges = AgcDriver::Graphics::FlushDepthPlanes(fixture.Stencil(), Block); + fixture.device.WaitIdle(); + std::array bytes{}; + AgcDriver::GuestMemory::ReadCommitted(fixture.Stencil(), bytes); + Require(std::ranges::all_of(bytes, [&](std::byte byte) { return byte == static_cast(value); }), "read-only stencil handoff did not preserve CPU/GPU write order"); + Require(ranges.size() == (published ? 1u : 0u), "read-only stencil handoff published an unexpected number of replicas"); + Require(AgcDriver::Graphics::FlushDepthPlanes(fixture.Stencil(), Block).empty(), "a discarded or clean stencil plane was published again"); +} + +void UnwatchedHandoff(Fixture& fixture, std::string_view mode) { + Require(!AgcDriver::GuestMemory::Watched(fixture.Stencil(), Block), "the unwatched handoff fixture must not use write watch"); + const bool reused = mode == "unwatched_cpu_reused"; + const bool after = mode == "unwatched_cpu_after"; + const bool gpuAfter = mode == "unwatched_gpu_after"; + fixture.Write(0u, 37u); + if (reused) { + fixture.CheckStencil(37u); + std::memset(reinterpret_cast(fixture.Stencil()), 5, Block); + AgcDriver::GuestMemory::BumpCollectEpoch(); + } + fixture.Write(1u, 203u); + if (!reused && !after) { + std::memset(reinterpret_cast(fixture.Stencil()), 5, Block); + AgcDriver::GuestMemory::BumpCollectEpoch(); + } + const auto destination = fixture.Surface(reused ? 0u : 2u); + Require(fixture.Draw(destination, Fixture::Options(203u, false)) == Texels, "a read-only handoff lost the latest GPU stencil"); + if (after) { + std::memset(reinterpret_cast(fixture.Stencil()), 5, Block); + AgcDriver::GuestMemory::BumpCollectEpoch(); + } + if (gpuAfter) fixture.Write(2u, 91u); + CheckHandoffBytes(fixture, reused ? 203u : gpuAfter ? 91u : 5u, reused || gpuAfter); + fixture.CheckDepth(0u); + fixture.CheckDepth(1u); + if (gpuAfter) fixture.CheckDepth(2u); +} + void PendingClear(Fixture& fixture) { auto surface = fixture.Surface(0u); surface.htile = fixture.Stencil(3u); @@ -239,6 +278,8 @@ int main(int argc, char** argv) { return VulkanTestSkipped; } CpuStore(fixture, mode == "cpu_fresh"); + } else if (mode == "unwatched_cpu_fresh" || mode == "unwatched_cpu_reused" || mode == "unwatched_cpu_after" || mode == "unwatched_gpu_after") { + UnwatchedHandoff(fixture, mode); } else if (mode == "clear") PendingClear(fixture); else if (mode == "independent") Independent(fixture); else if (mode == "copy_failure") CopyFailure(fixture); From fbbadbcc82d8b9c4d16fead4c76cc0e2ce7f1203 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 15 Nov 2026 03:27:02 +0100 Subject: [PATCH 5/6] fix(agc): preserve stencil baseline through ownership handoff --- core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp b/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp index c214c9f69fea..2481c1f43af2 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp @@ -2558,7 +2558,10 @@ void takePlane(DepthSurface& surface, PlaneOwners& owners, std::uint64_t address } else { surface.CopyAspectFrom(*owner, aspect); } - if (aspect == VK_IMAGE_ASPECT_STENCIL_BIT && surface.StencilMirrorable() && owner->StencilMirrorable()) surface.stencilGeneration = owner->stencilGeneration; + if (aspect == VK_IMAGE_ASPECT_STENCIL_BIT && surface.StencilMirrorable() && owner->StencilMirrorable()) { + surface.stencilBaseline = owner->stencilBaseline; + surface.stencilGeneration = owner->stencilGeneration; + } } if (compatible && aspect == VK_IMAGE_ASPECT_STENCIL_BIT && surface.StencilMirrorable() && owner->stencilStale) { surface.MarkStencilStale(); From b6e08256c086798fef7cb07fd09117efff0e58e0 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 15 Nov 2026 06:38:26 +0100 Subject: [PATCH 6/6] docs: retain upstream ICU list debt correction --- docs/dev/debt/changes/feat-icu-ulist.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/debt/changes/feat-icu-ulist.md b/docs/dev/debt/changes/feat-icu-ulist.md index 028440fb0357..fbcab0f32601 100644 --- a/docs/dev/debt/changes/feat-icu-ulist.md +++ b/docs/dev/debt/changes/feat-icu-ulist.md @@ -1,6 +1,6 @@ # libSceIcu -## change `uloc_getLCID`, `uloc_getLocaleForLCID`, +## change [Older callable exports] - [Older callable exports](../../../core/libs/prx/libSceIcu/LegacyExports.cpp) - 1689 of the 2347 3.20 callable NIDs use ICU 68 names (hashes of `libicuuc`/`libicui18n`/`libicuio` symbols in [ICU 68.2 Ubuntu 20.04](https://github.com/unicode-org/icu/releases/download/release-68-2/icu4c-68_2-Ubuntu20.04-x64.tgz), stripping `_68`; 1293 C++ in `icu_68`); a name match does not show ICU 68's prototype or behavior. `ubidi_getClass`, ten `unorm2_*`, `unorm_compare`, `u_terminateChars`, `u_terminateUChar32s`, `uloc_isRightToLeft`, `uloc_getLCID`, `uloc_getLocaleForLCID`, `uprv_int32Comparator`, `uprv_uint32Comparator`, `uprv_uint16Comparator` (in [ArrayComparators.cpp](../../../core/libs/prx/libSceIcu/ArrayComparators.cpp)), the 12 `ucase_*` exports, `ulist_*` and [Script.cpp](../../../core/libs/prx/libSceIcu/Script.cpp) are implemented; the rest throw. The other 654 keep placeholder names (650 match no ICU 68.2 symbol). None appears in the later version-labelled inventory; no cross-version compatibility is claimed.