From 05ec432f756db11c8acc37998022c798db7e2121 Mon Sep 17 00:00:00 2001 From: boykopovar Date: Wed, 16 Sep 2026 07:11:00 +0300 Subject: [PATCH] fix(agc): non-homogeneous positions with all viewport transforms enabled --- core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp | 7 ++++++- core/libs/prx/libSceAgcDriver/tests/Graphics.cpp | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp b/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp index 46ceb0705..c921c24cc 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp @@ -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"); diff --git a/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp b/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp index 825295868..85a3a45bf 100644 --- a/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp @@ -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(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);