Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/libs/prx/libSceAgc/Command/src/Packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void ValidatePacket(const std::uint32_t* packet, std::uint32_t opcode, std::uint
}

std::uint32_t* WriteNop(CommandBuffer* buffer, std::uint32_t count, const char* function) {
const auto header = Header(0x10u, count);
const auto header = count == 1 ? 0xffff1000u : Header(0x10u, count);
auto* packet = Allocate(buffer, count, function);
packet[0] = header;
std::fill_n(packet + 1, count - 1u, 0u);
Expand Down
17 changes: 17 additions & 0 deletions core/libs/prx/libSceAgc/tests/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ extern "C" std::uint32_t* APS5_VABI sceAgcAcbPushMarker(CommandBuffer* buf, cons
extern "C" std::uint32_t* APS5_VABI sceAgcAcbPopMarker(CommandBuffer* buf);
extern "C" std::uint32_t* APS5_VABI sceAgcAcbSetMarker(CommandBuffer* buf, const char* str, std::uint32_t color);
extern "C" std::uint32_t* APS5_VABI sceAgcDcbSetIndexBuffer(CommandBuffer* buf, std::uint64_t indexAddress);
extern "C" std::uint32_t* APS5_VABI sceAgcSetNop(CommandBuffer* buf, std::uint32_t sizeDw);

namespace {

Expand Down Expand Up @@ -109,6 +110,21 @@ void testPackets() {
check(noDown.cursor_up == scratch.data() + 6, "allocation past the top of a buffer without a down cursor advanced its cursor");
}

void testNop() {
Storage storage;
storage.words.fill(0xdeadbeefu);
auto* single = sceAgcSetNop(&storage.buffer, 1);
auto* pair = sceAgcSetNop(&storage.buffer, 2);
auto* triple = sceAgcSetNop(&storage.buffer, 3);
const std::array<std::uint32_t, 7> expected{0xffff1000u, 0xc0001000u, 0, 0xc0011000u, 0, 0, 0xdeadbeefu};
check(single == storage.words.data() && pair == single + 1 && triple == pair + 2, "incorrect NOP placement");
check(std::equal(expected.begin(), expected.end(), storage.words.begin()), "incorrect NOP packet");
check(storage.buffer.cursor_up == storage.words.data() + 6, "incorrect NOP cursor advance");
expectFailure([&] { sceAgcSetNop(&storage.buffer, 0); });
expectFailure([&] { sceAgcSetNop(&storage.buffer, 0x4002u); });
check(storage.buffer.cursor_up == storage.words.data() + 6, "invalid NOP advanced the cursor");
}

void testClearState() {
Storage storage;
storage.words.fill(0xdeadbeefu);
Expand Down Expand Up @@ -404,6 +420,7 @@ int main(int argc, char** argv) {
return 0;
}
testPackets();
testNop();
testClearState();
testIndexedIndirectDraws();
testMarkers();
Expand Down
Loading