From da1a7393685e9cdf2e70ae5df3de75ca442a1d68 Mon Sep 17 00:00:00 2001 From: MarcZX100 Date: Wed, 14 Oct 2026 07:35:19 +0000 Subject: [PATCH 1/3] test(agc): cover repeated untracked storage writes after sampling --- .../tests/execution/StoreOverUntracked.cpp | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp index 3431424ec109..f98e62ee553f 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp @@ -60,6 +60,10 @@ alignas(256) constexpr std::array FillCode{ 0xd7460004, 0x04010c08, 0x7e000204, 0x7e020205, 0x7e040206, 0x7e060207, 0xe01c2000, 0x80000004, 0xbf810000, }; +alignas(256) constexpr std::array ReadCode{ + 0x7e020280, 0x7e04020c, 0xf0001108, 0x00010300, 0xbf8c3f70, 0x34080082, 0xe0701000, 0x80000304, 0xbf810000, +}; + std::uint64_t AddressOf(const void* data) { return static_cast(reinterpret_cast(data)); } @@ -120,6 +124,20 @@ void Fill(const std::uint32_t* texels) { Dispatch(FillCode, 64, (static_cast(userData.size()) << 1u) | 0x80u, userData, static_cast(SurfaceBytes / 1024u)); } +std::array BufferDescriptor(const void* data, std::size_t bytes) { + const auto address = AddressOf(data); + return {static_cast(address), static_cast((address >> 32u) & 0xffffu), static_cast(bytes), 0x31016facu}; +} + +void ReadImage(const std::uint32_t* texels, std::uint32_t* output) { + std::array userData{}; + const auto buffer = BufferDescriptor(output, SurfaceBytes); + const auto texture = TextureDescriptor(texels); + std::copy(buffer.begin(), buffer.end(), userData.begin()); + std::copy(texture.begin(), texture.end(), userData.begin() + 4); + Dispatch(ReadCode, 32, static_cast(userData.size()) << 1u, userData, 1); +} + class Surface { public: explicit Surface(bool watched = false, std::size_t lead = 0) : watched(watched), regionBytes(lead == 0 ? SurfaceBytes : SurfaceBytes + Block) { @@ -217,7 +235,7 @@ void Settle(THold& hold, const Surface& surface, std::uint32_t result) { hold.unlock(); } -enum class Kind { ReadAfter, ReadBefore, Filled, Copied, LeftWatch, WrittenThenLeftWatch, ImportLeftWatch, NeighbourCopied, NeighbourLeftWatch }; +enum class Kind { ReadAfter, ReadBefore, Filled, Copied, LeftWatch, WrittenThenLeftWatch, ImportLeftWatch, NeighbourCopied, NeighbourLeftWatch, UntrackedRepeat }; // One 64 KiB block of the surface: the image of its last block, and the source copied into it. constexpr std::uint32_t BlockSide = 128; @@ -313,6 +331,16 @@ Outcome Run(const Case& test) { Settle(hold, *source, Filled); } Store(surface.Texels()); + if (test.kind == Kind::UntrackedRepeat) { + Settle(hold, surface, Stored); + Surface output; + ReadImage(surface.Texels(), output.Texels()); + hold.lock(); + const auto image = StorageTexture::FindLive(surface.Address(), SurfaceBytes); + Require(image != nullptr, "store over untracked: the sampled surface has no live storage image"); + image->MarkDirty(); + hold.unlock(); + } if (test.kind == Kind::Filled || leaves) { Settle(hold, surface, Stored); if (leaves) { @@ -438,6 +466,7 @@ int main() { {"a surface whose import left the write watch", Kind::ImportLeftWatch, 0xe000}, {"an image copy into another block of the surface", Kind::NeighbourCopied, 0xe000}, {"a surface whose first block left the write watch with the page before it", Kind::NeighbourLeftWatch, 0xe000}, + {"untracked storage results written again after an image read", Kind::UntrackedRepeat, 0xe000}, }}; bool kept = true; for (const auto& test : cases) { From 9c765fa0fa7a2cde10042d13f16e80d2ca14df9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Thu, 15 Oct 2026 14:11:00 +0200 Subject: [PATCH 2/3] test(agc): keep the sampled output surface alive until the queued read finishes --- .../libSceAgcDriver/tests/execution/StoreOverUntracked.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp index f98e62ee553f..3ec234022651 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp @@ -312,6 +312,7 @@ Outcome RunSecondStore(const char* name) { } Outcome Run(const Case& test) { + std::optional output; std::optional source; if (test.kind == Kind::Copied || test.kind == Kind::NeighbourCopied) source.emplace(); const bool neighbour = test.kind == Kind::NeighbourLeftWatch; @@ -333,8 +334,8 @@ Outcome Run(const Case& test) { Store(surface.Texels()); if (test.kind == Kind::UntrackedRepeat) { Settle(hold, surface, Stored); - Surface output; - ReadImage(surface.Texels(), output.Texels()); + output.emplace(); + ReadImage(surface.Texels(), output->Texels()); hold.lock(); const auto image = StorageTexture::FindLive(surface.Address(), SurfaceBytes); Require(image != nullptr, "store over untracked: the sampled surface has no live storage image"); From d17895ed846bf1a5804443b1281b60d85e561c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Thu, 15 Oct 2026 14:26:21 +0200 Subject: [PATCH 3/3] test(agc): size the case table for the neighbour case added on main --- .../prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp index 3ec234022651..63fbbb453965 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp @@ -457,7 +457,7 @@ int main() { Surface probe; Require(AgcDriver::Graphics::DescribeSurface(AgcDriver::Graphics::DecodeTextureResource(TextureDescriptor(probe.Texels()))).guestBytes == SurfaceBytes, "store over untracked: unexpected surface size"); } - constexpr std::array cases{{ + constexpr std::array cases{{ {"another block read after the CPU write", Kind::ReadAfter, Block + Page}, {"another block read before the CPU write", Kind::ReadBefore, 0xe000}, {"a fill of the surface", Kind::Filled, 0xe000},