From 133f08ed14feb6b8770a1ff5d2f7b7a5e0d1fa73 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 30 Oct 2022 16:39:19 +0000 Subject: [PATCH] Stash new register value before executing deferred draws/updates Since the register writes technically happen after the draw, issues can occur if they happen before: e.g. skyrim updates ctSelect and disables all RTs after a draw, but this would happen before it previously and crash the driver. --- app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp index 7ee54526..7eead087 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp @@ -93,6 +93,7 @@ namespace skyline::soc::gm20b::engine::maxwell3d { bool redundant{registers.raw[method] == argument}; + u32 origRegisterValue{registers.raw[method]}; registers.raw[method] = argument; if (batchEnableState.raw) { @@ -111,10 +112,12 @@ namespace skyline::soc::gm20b::engine::maxwell3d { #undef LOAD_CONSTANT_BUFFER_CALLBACKS default: // When a method other than constant buffer update is called submit our submit the previously built-up update as a batch + registers.raw[method] = origRegisterValue; interconnect.DisableQuickConstantBufferBind(); interconnect.LoadConstantBuffer(batchLoadConstantBuffer.buffer, batchLoadConstantBuffer.startOffset); batchEnableState.constantBufferActive = false; batchLoadConstantBuffer.Reset(); + registers.raw[method] = argument; break; // Continue on here to handle the actual method } } else if (batchEnableState.drawActive) { // See DeferredDrawState comment for full details @@ -171,7 +174,9 @@ namespace skyline::soc::gm20b::engine::maxwell3d { // Once we stop calling draw methods flush the current draw since drawing is dependent on the register state not changing default: + registers.raw[method] = origRegisterValue; FlushDeferredDraw(); + registers.raw[method] = argument; break; } }