mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
fix(agc): apply GE_INDX_OFFSET as the base vertex of direct indexed draws
The GE adds GE_INDX_OFFSET to every index it fetches. The driver applied it to auto draws only, so DRAW_INDEX_2 and DRAW_INDEX_OFFSET_2 fetched from vertex 0 whatever the register held. Both packets now take it as their base vertex, and like an auto draw they refuse a queue state without the register (its reset value, 0, is part of the initial state).
This commit is contained in:
@@ -644,7 +644,9 @@ DrawParameters ResolveDraw(std::span<const std::uint32_t> packet, const QueueSta
|
||||
require(bytes <= std::numeric_limits<std::size_t>::max(), "index range size overflow");
|
||||
GuestMemory::CheckRange(reinterpret_cast<const void*>(address), static_cast<std::size_t>(bytes), indexSize);
|
||||
APS5_LOG_OUT_DEBUG("ResolveDraw context targetMask=0x%x shaderMask=0x%x indexCount=%u indexType=%u instances=%u", queue.context.contains(0x8e) ? queue.context.at(0x8e) : 0u, queue.context.contains(0x8f) ? queue.context.at(0x8f) : 0u, count, queue.indexType, queue.instanceCount);
|
||||
return {address, count, indexSize, queue.instanceCount, packet.back()};
|
||||
const auto indexOffset = queue.userConfig.find(0x24a);
|
||||
require(indexOffset != queue.userConfig.end(), "missing GE_INDX_OFFSET register");
|
||||
return {address, count, indexSize, queue.instanceCount, packet.back(), true, indexOffset->second, 0};
|
||||
}
|
||||
|
||||
void Execute(std::span<const std::uint32_t> packet, QueueState& queue) {
|
||||
|
||||
@@ -171,6 +171,17 @@ void testIndexedDraw() {
|
||||
const auto size = type == 0 ? 2u : type == 1 ? 4u : 1u;
|
||||
check(draw.indexAddress == state.indexBase + 2 * size && draw.indexSize == size && draw.indexCount == 4 && draw.instanceCount == 3 && draw.flags == 0x20, "indexed draw state mismatch");
|
||||
}
|
||||
state.indexType = 0;
|
||||
check(AgcDriver::Pm4::ResolveDraw(packet, state).firstVertex == 0, "indexed draw invented a base vertex");
|
||||
state.userConfig[0x24a] = 0xd4d4;
|
||||
const auto offsetDraw = AgcDriver::Pm4::ResolveDraw(packet, state);
|
||||
check(offsetDraw.indexed && offsetDraw.firstVertex == 0xd4d4, "DRAW_INDEX_OFFSET_2 ignored GE_INDX_OFFSET");
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(indices.data());
|
||||
const auto explicitDraw = AgcDriver::Pm4::ResolveDraw(makePacket(0x27, {4, static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), 4, 0}), state);
|
||||
check(explicitDraw.indexed && explicitDraw.firstVertex == 0xd4d4 && explicitDraw.indexAddress == address, "DRAW_INDEX_2 ignored GE_INDX_OFFSET");
|
||||
state.userConfig.erase(0x24a);
|
||||
expectFailure([&] { AgcDriver::Pm4::ResolveDraw(packet, state); }, "GE_INDX_OFFSET");
|
||||
state.userConfig[0x24a] = 0;
|
||||
expectFailure([&] { AgcDriver::Pm4::Validate(packet, 0x20); }, "compute queue");
|
||||
expectFailure([] { AgcDriver::Pm4::Validate(makePacket(0x35, {3, 0, 4, 0}), 0); }, "maximum index size");
|
||||
expectFailure([] { AgcDriver::Pm4::Validate(makePacket(0x35, {4, 0, 4, 1}), 0); }, "draw flags");
|
||||
|
||||
Reference in New Issue
Block a user