mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
Merge pull request #60 from oneandonlydean/fix/primitive-restart-indexed
fix(agc): reject primitive restart only for indexed draws - `DecodeState` still reads `0x24b` (so it stays in the recorded draw-key registers) but no longer rejects on it. - `DrawRejection` takes an `indexed` flag, and reports restart only for indexed draws. - The driver's draw path rejects an indexed draw with restart enabled before the precheck, so indexed draws with restart are still refused when the precheck is off. Restart itself is still not implemented.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<unsigned>(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");
|
||||
|
||||
@@ -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<void>(AgcDriver::Graphics::DecodePixelStageInfo(queue.context, state.hasColorTarget, state.color.componentMapping));
|
||||
AgcDriver::Graphics::RegisterReadLog() = nullptr;
|
||||
Require(!log.empty(), "the register facade recorded nothing");
|
||||
|
||||
Reference in New Issue
Block a user