mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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); });
|
||||
|
||||
Reference in New Issue
Block a user