diff --git a/core/libs/prx/libSceAgcDriver/Execution/src/Driver.cpp b/core/libs/prx/libSceAgcDriver/Execution/src/Driver.cpp index b3f2cd3b1..55d762667 100644 --- a/core/libs/prx/libSceAgcDriver/Execution/src/Driver.cpp +++ b/core/libs/prx/libSceAgcDriver/Execution/src/Driver.cpp @@ -3840,8 +3840,15 @@ private: const bool colorWrites = targetMask != queue.context.end() && shaderMask != queue.context.end() && (targetMask->second & shaderMask->second) != 0; if (!colorWrites && !queue.shader.contains(0x8)) return DrawVerdict::Nothing; } + if (drawParameters.indexed) { + const auto restart = queue.userConfig.find(0x24b); + if (restart != queue.userConfig.end() && restart->second != 0) { + rejected = "AGC graphics: primitive restart (GE_MULTI_PRIM_IB_RESET_EN) is unsupported for indexed draws"; + return DrawVerdict::Rejected; + } + } if (DrawPrecheck()) { - rejected = Graphics::DrawRejection(queue); + rejected = Graphics::DrawRejection(queue, drawParameters.indexed); if (!rejected.empty()) return DrawVerdict::Rejected; } phase(DrawRowPrecheck); diff --git a/core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp b/core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp index fb84496c9..fd90957c3 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp @@ -67,7 +67,7 @@ State DecodeState(const QueueState& queue); // The message DecodeState (or the pixel stage decode after it) would throw for the register rules // this precheck covers, evaluated without exceptions before the draw is decoded; empty when they // pass (DecodeState still checks everything). A register a rule needs that is absent is no verdict. -std::string DrawRejection(const QueueState& queue); +std::string DrawRejection(const QueueState& queue, bool indexed); // The recording facade of the draw decoders (design_cpu_final M8, step 8a): every register read // of DecodeShaderStages, DecodeState, DrawRejection, DecodePixelStageInfo and Driver::draw's diff --git a/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp b/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp index 8d214688f..dcc5a608e 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp @@ -293,7 +293,7 @@ State DecodeState(const QueueState& queue) { default: throw std::runtime_error("AGC graphics: unsupported primitive type " + std::to_string(primitive)); } APS5_LOG_OUT_DEBUG("Topology=%u", static_cast(result.topology)); - zero(queue.userConfig, 0x24b, ~0u, "primitive restart (GE_MULTI_PRIM_IB_RESET_EN)", RegisterBank::UserConfig); + (void)read(queue.userConfig, 0x24b, RegisterBank::UserConfig); if ((read(cx, 0x207) & LayerExports) != 0) { static bool reported = false; if (!reported) { @@ -498,7 +498,7 @@ State DecodeState(const QueueState& queue) { return result; } -std::string DrawRejection(const QueueState& queue) { +std::string DrawRejection(const QueueState& queue, bool indexed) { const auto& cx = queue.context; // A register a rule needs that is absent gives no verdict here: DecodeState reports it. const auto value = [&](const Registers& registers, std::uint32_t offset, std::uint32_t& out) { @@ -514,7 +514,7 @@ std::string DrawRejection(const QueueState& queue) { const auto require = [&](bool condition, const char* reason) { return condition ? std::string() : "AGC graphics: " + std::string(reason); }; - if (auto reason = nonzero(queue.userConfig, 0x24b, ~0u, "primitive restart (GE_MULTI_PRIM_IB_RESET_EN)"); !reason.empty()) return reason; + if (auto reason = indexed ? nonzero(queue.userConfig, 0x24b, ~0u, "primitive restart (GE_MULTI_PRIM_IB_RESET_EN)") : std::string(); !reason.empty()) return reason; if (auto reason = nonzero(cx, 0x207, ~LayerExports, "clip distances, layer, viewport or auxiliary vertex exports"); !reason.empty()) return reason; if (value(cx, 0x200, word)) { if (!depthPassThrough(word) && !IgnoreDepthTest() && (word & DepthControlMask) != 0) return zeroMessage(0x200, word, "depth, stencil or conditional color writes"); diff --git a/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp b/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp index a96f0b446..dacf921c2 100644 --- a/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp @@ -85,7 +85,11 @@ void stateTests() { Require(state.viewport.y == 4 && state.viewport.height == -4, "negative viewport height was lost"); Require(state.color.format == VK_FORMAT_R8G8B8A8_UNORM, "RGBA format changed"); queue.userConfig[0x24b] = 1; - expectFailure([&] { AgcDriver::Graphics::DecodeState(queue); }, "GE_MULTI_PRIM_IB_RESET_EN"); + queue.context[0x1b3] = 2; + queue.context[0x1b4] = 2; + (void)AgcDriver::Graphics::DecodeState(queue); + Require(AgcDriver::Graphics::DrawRejection(queue, false).empty(), "primitive restart rejected a non-indexed draw"); + Require(AgcDriver::Graphics::DrawRejection(queue, true).find("GE_MULTI_PRIM_IB_RESET_EN") != std::string::npos, "primitive restart was accepted for an indexed draw"); queue = makeState(); queue.userConfig.erase(0x24b); queue.context[0x2a5] = 0; @@ -123,7 +127,7 @@ void stateTests() { queue.context[0x1b3] = 2; queue.context[0x1b4] = 2; state = AgcDriver::Graphics::DecodeState(queue); - Require(AgcDriver::Graphics::DrawRejection(queue).empty(), "precheck rejected the reference state"); + Require(AgcDriver::Graphics::DrawRejection(queue, true).empty(), "precheck rejected the reference state"); static_cast(AgcDriver::Graphics::DecodePixelStageInfo(queue.context, state.hasColorTarget, state.color.componentMapping)); AgcDriver::Graphics::RegisterReadLog() = nullptr; Require(!log.empty(), "the register facade recorded nothing");