From d4f7ddaa1af420333acdebbcab4b1c4515453402 Mon Sep 17 00:00:00 2001 From: Chad Date: Mon, 5 Oct 2026 14:49:17 -0500 Subject: [PATCH] fix(agc): count the one-dword NOP pad as one dword in range predication 0xffff1000 is a type-3 NOP whose count field is 0x3fff, which the command processor reads as a single dword. sceAgcSetRangePredication read it as a 16385-dword packet and skipped the packets after it, or threw in a short range. It is now stepped over like a type-2 filler. Co-Authored-By: Claude Opus 5.5 --- core/libs/prx/libSceAgc/Predication/src/Predication.cpp | 2 +- core/libs/prx/libSceAgc/tests/Predication.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/libs/prx/libSceAgc/Predication/src/Predication.cpp b/core/libs/prx/libSceAgc/Predication/src/Predication.cpp index 586b40e41..dcaad59b9 100644 --- a/core/libs/prx/libSceAgc/Predication/src/Predication.cpp +++ b/core/libs/prx/libSceAgc/Predication/src/Predication.cpp @@ -23,7 +23,7 @@ int APS5_VABI sceAgcSetRangePredication(uint32_t* start, const volatile uint32_t auto* packet = start; while (packet < end) { const auto type = packet[0] >> 30u; - if (type == 2u) { + if (type == 2u || (packet[0] & 0x3fffff00u) == 0x3fff1000u) { ++packet; continue; } diff --git a/core/libs/prx/libSceAgc/tests/Predication.cpp b/core/libs/prx/libSceAgc/tests/Predication.cpp index b01d77ad2..32a6619ed 100644 --- a/core/libs/prx/libSceAgc/tests/Predication.cpp +++ b/core/libs/prx/libSceAgc/tests/Predication.cpp @@ -65,12 +65,13 @@ void testRange() { Storage storage; auto* first = sceAgcDcbSetIndexCount(&storage.buffer, 3); *storage.buffer.cursor_up++ = 0x80000000u; + *storage.buffer.cursor_up++ = 0xffff1000u; auto* second = sceAgcDcbSetIndexBuffer(&storage.buffer, 0x1000); auto* third = sceAgcDcbSetIndexCount(&storage.buffer, 5); const std::array headers{first[0], second[0], third[0]}; check(sceAgcSetRangePredication(first, storage.buffer.cursor_up, 1) == 0, "range predication failed"); check(first[0] == (headers[0] | 1u) && second[0] == (headers[1] | 1u) && third[0] == (headers[2] | 1u), "range did not predicate every packet"); - check(first[2] == 0x80000000u && second[1] == 0x1000u && third[1] == 5u, "range predication changed a payload or filler"); + check(first[2] == 0x80000000u && first[3] == 0xffff1000u && second[1] == 0x1000u && third[1] == 5u, "range predication changed a payload, filler or pad"); check(sceAgcSetRangePredication(second, third, 0) == 0 && second[0] == headers[1] && third[0] == (headers[2] | 1u), "range end is not exclusive"); check(sceAgcSetRangePredication(first, first, 0) == 0 && first[0] == (headers[0] | 1u), "empty range changed a packet"); expectFailure([&] { sceAgcSetRangePredication(first, first + 1, 1); });