From e70e81dc4599d6353405db1b8610862a9b183dff Mon Sep 17 00:00:00 2001 From: MathiasDevelopes <25400788+MathiasDevelopes@users.noreply.github.com> Date: Thu, 8 Oct 2026 21:31:10 +0200 Subject: [PATCH] fix(libSceAgcDriver): SPI_PS_INPUT_CNTL registers start at their clear-state value A title that never writes SPI_PS_INPUT_CNTL_0 relies on its clear-state value 0, but the register was absent from the initial context, so every draw of a pixel shader with interpolants was rejected with "missing register at DWORD 0x191". All 32 SPI_PS_INPUT_CNTL registers now start at 0, as in the GFX10 clear state, both initially and after CLEAR_STATE. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../prx/libSceAgcDriver/Execution/include/QueueState.hpp | 1 + core/libs/prx/libSceAgcDriver/tests/Graphics.cpp | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/core/libs/prx/libSceAgcDriver/Execution/include/QueueState.hpp b/core/libs/prx/libSceAgcDriver/Execution/include/QueueState.hpp index ff24be825053..d05c1881a07e 100644 --- a/core/libs/prx/libSceAgcDriver/Execution/include/QueueState.hpp +++ b/core/libs/prx/libSceAgcDriver/Execution/include/QueueState.hpp @@ -156,6 +156,7 @@ inline Registers InitialContextRegisters() { {0x318, 0}, {0x31b, 0}, {0x31c, 0}, {0x31d, 0}, {0x390, 0}, {0x3b0, 0}, {0x3b8, 0} }; + for (std::uint32_t i = 0; i < 32; ++i) result.emplace(0x191 + i, 0); for (std::uint32_t i = 0; i < 8; ++i) { result.emplace(0x1e0 + i, 0x20010001); result.emplace(0x31c + 0xfu * i, 0); diff --git a/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp b/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp index e762ee96f1f1..6f2defad61b2 100644 --- a/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp @@ -221,6 +221,15 @@ void stateTests() { Require(!AgcDriver::Graphics::PixelProgramSkipped(queue), "a pixel program address was read as unset"); Require(AgcDriver::Graphics::DrawRejection(queue, true).find("missing register at DWORD 0x1b3") != std::string::npos, "a real pixel program without SPI_PS_INPUT_ENA was accepted"); expectFailure([&] { AgcDriver::Graphics::DecodePixelStageInfo(queue.context, std::array{0xe4u, 0xe4u, 0xe4u, 0xe4u, 0xe4u, 0xe4u, 0xe4u, 0xe4u}); }, "missing register"); + AgcDriver::QueueState cleared; + cleared.context[0x1b3] = 2; + cleared.context[0x1b4] = 2; + cleared.context[0x1b6] = 2; + cleared.context[0x192] = 7; + const auto clearedPixel = AgcDriver::Graphics::DecodePixelStageInfo(cleared.context, std::array{0xe4u, 0xe4u, 0xe4u, 0xe4u, 0xe4u, 0xe4u, 0xe4u, 0xe4u}); + Require(clearedPixel.interpolatorSettings[0] == 0 && clearedPixel.interpolatorSettings[1] == 7, "an unwritten SPI_PS_INPUT_CNTL_0 did not read as its clear-state value"); + cleared.ClearContext(); + for (std::uint32_t i = 0; i < 32; ++i) Require(cleared.context.at(0x191 + i) == 0, "CLEAR_STATE did not reset SPI_PS_INPUT_CNTL"); queue.shader[0x008] = 0; Require(AgcDriver::Graphics::PixelProgramSkipped(queue), "a zero pixel program address was not read as unset"); Require(AgcDriver::Graphics::DrawRejection(queue, true).find("writes color") != std::string::npos, "a draw without a pixel program that writes color was accepted");