fix(agc): non-homogeneous positions with all viewport transforms enabled

This commit is contained in:
boykopovar
2026-09-16 07:11:00 +03:00
parent f73834ce2f
commit 05ec432f75
2 changed files with 14 additions and 3 deletions
@@ -155,7 +155,12 @@ State DecodeState(const QueueState& queue) {
Require(read(cx, 0x2f9) == 0x2du, "nonstandard pixel center or vertex quantization is unsupported");
Require(read(cx, 0x313) == 0x6000u, "conservative rasterization is unsupported");
Require(read(cx, 0x30e) == 0xffffffffu && read(cx, 0x30f) == 0xffffffffu, "sample masks are unsupported");
Require(read(cx, 0x206) == 0x3fu, "only homogeneous positions with all viewport transforms enabled are supported");
const auto viewportControl = read(cx, 0x206);
if (viewportControl != 0x43fu) {
std::ostringstream message;
message << "AGC graphics: PA_CL_VTE_CNTL=0x" << std::hex << viewportControl << ": expected 0x43f for homogeneous positions and all viewport transforms; pre-divided coordinates, reciprocal W or disabled transforms are unsupported";
throw std::runtime_error(message.str());
}
Require(read(cx, 0x204) == 0x80000u, "only standard zero-to-one depth clipping is supported");
const auto raster = read(cx, 0x205);
Require((raster & ~0x7u) == 0 || (raster & ~0x7u) == 0x240u, "polygon mode, depth bias, provoking vertex or nonstandard rasterization is unsupported");
@@ -19,7 +19,7 @@ AgcDriver::QueueState makeState() {
{0x2dc, 0xaa00}, {0x2f8, 0}, {0x292, 2}, {0x293, 0},
{0x80, 0}, {0x8d, 0}, {0x83, 0xffff}, {0x8c, 0xa},
{0x2f9, 0x2d}, {0x313, 0x6000}, {0x30e, 0xffffffff}, {0x30f, 0xffffffff},
{0x206, 0x3f}, {0x204, 0x80000}, {0x205, 0x240},
{0x206, 0x43f}, {0x204, 0x80000}, {0x205, 0x240},
{0x8e, 0xf}, {0x8f, 0xf}, {0x202, 0xcc0010},
{0x1c4, 0}, {0x1c5, 9}, {0x1c3, 4}, {0x31c, 0x28028},
{0x31b, 0}, {0x31d, 0}, {0x3b0, (63u << 14u) | 3u},
@@ -169,9 +169,15 @@ void InitialContextTests() {
Require(queue.context.at(0x2dc) == 0xaa00 && queue.context.at(0x313) == 0x6000 && queue.context.at(0x2f9) == 0x2d, "initial raster controls are incomplete");
Require(queue.context.at(0x30e) == 0xffffffff && queue.context.at(0x30f) == 0xffffffff, "initial sample mask excludes samples");
queue.userConfig[0x242] = 4;
for (const auto offset : {0x2d5u, 0x204u, 0x206u, 0x8eu, 0x8fu, 0x1c3u, 0x1c5u, 0x31cu, 0x3b0u, 0x3b8u, 0x318u, 0x390u, 0x10fu, 0x110u, 0x111u, 0x112u, 0x113u, 0x114u, 0xb4u, 0xb5u}) queue.context.at(offset) = configured.context.at(offset);
for (const auto offset : {0x2d5u, 0x204u, 0x8eu, 0x8fu, 0x1c3u, 0x1c5u, 0x31cu, 0x3b0u, 0x3b8u, 0x318u, 0x390u, 0x10fu, 0x110u, 0x111u, 0x112u, 0x113u, 0x114u, 0xb4u, 0xb5u}) queue.context.at(offset) = configured.context.at(offset);
const auto state = AgcDriver::Graphics::DecodeState(queue);
Require(state.color.address == reinterpret_cast<std::uintptr_t>(colorMemory.data()) && state.color.bytes == colorMemory.size(), "sparse guest setup lost its render target");
Require(queue.context.at(0x206) == 0x43f, "initial homogeneous viewport mode changed");
for (const auto control : {0x3fu, 0x43eu, 0x53fu, 0x63fu, 0x8000043fu}) {
queue.context[0x206] = control;
expectFailure([&] { AgcDriver::Graphics::DecodeState(queue); }, "PA_CL_VTE_CNTL=0x");
}
queue.context[0x206] = 0x43f;
queue.context[0x2dc] |= 1;
expectFailure([&] { AgcDriver::Graphics::DecodeState(queue); }, "alpha-to-coverage");
queue.context.erase(0x2dc);