mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-09-20 09:41:14 +02:00
Fix shadow state handling for blend enable updates
Incorrect rendering was observed during loading transitions in Trails in the Sky 1st Chapter. Testing showed that routing the first render target's RT0 BlendEnable transition from disabled to enabled through the normal register write path prevented the issue.
Further investigation found that the normal register write was restoring Shadow RAM behavior that was missing from UpdateBlendEnable.
UpdateBlendEnable uses a fast bulk update path instead of issuing a normal register write for each render target. As a result, it bypasses the Shadow RAM handling provided by DeviceStateWithShadow.WriteWithRedundancyCheck.
A normal register write updates both State and ShadowState in MethodTrack and MethodTrackWithFilter modes. In MethodReplay mode, it ignores the incoming value and restores the value previously stored in ShadowState to State.
UpdateBlendEnable must reproduce the same behavior while retaining its bulk comparison and copy path. In track modes, copy the incoming enable values to shadowState. In replay mode, copy shadowState to the incoming enable span, then let the existing comparison and copy logic update state and mark BlendState dirty when necessary.
The original implementation incorrectly used state for both track and replay handling. This prevented Shadow RAM from correctly recording or replaying BlendEnable values, which could cause rendering state synchronization errors.
Correct the bulk update path to use ShadowState for tracking and replay. This preserves the optimized bulk operation while addressing the underlying issue without requiring an RT0-specific compatibility workaround.
(cherry picked from commit 733bd0951b)
This commit is contained in:
@@ -268,10 +268,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
||||
{
|
||||
SetMmeShadowRamControlMode shadow = ShadowMode;
|
||||
Span<Boolean32> state = _state.State.BlendEnable.AsSpan();
|
||||
Span<Boolean32> shadowState = _state.ShadowState.BlendEnable.AsSpan();
|
||||
|
||||
if (shadow.IsReplay())
|
||||
{
|
||||
state.CopyTo(enable);
|
||||
shadowState.CopyTo(enable);
|
||||
}
|
||||
|
||||
if (!UnsafeEquals32Byte(enable, state))
|
||||
@@ -283,7 +284,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
||||
|
||||
if (shadow.IsTrack())
|
||||
{
|
||||
enable.CopyTo(state);
|
||||
enable.CopyTo(shadowState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user