Fix shadow state handling for blend enable updates #183

Merged
LotP merged 1 commit from avan/Ryubing:fix/blend-enable-shadow-state into master 2026-08-24 20:28:48 +00:00
Contributor

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.

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.
Fix shadow state handling for blend enable updates
All checks were successful
Pull Request Triage / triage (pull_request_target) Successful in 14s
Build PR / linux-arm64 (Release) (pull_request) Successful in 3m19s
Build PR / linux-x64 (Release) (pull_request) Successful in 6m18s
Build PR / win-arm64 (Release) (pull_request) Successful in 5m18s
Build PR / win-x64 (Release) (pull_request) Successful in 4m49s
Build PR / macOS Universal (Release) (pull_request) Successful in 3m46s
1c5011ac00
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.
Member

LGTM! Works as intended.

LGTM! Works as intended.
LotP force-pushed fix/blend-enable-shadow-state from 1c5011ac00
All checks were successful
Pull Request Triage / triage (pull_request_target) Successful in 14s
Build PR / linux-arm64 (Release) (pull_request) Successful in 3m19s
Build PR / linux-x64 (Release) (pull_request) Successful in 6m18s
Build PR / win-arm64 (Release) (pull_request) Successful in 5m18s
Build PR / win-x64 (Release) (pull_request) Successful in 4m49s
Build PR / macOS Universal (Release) (pull_request) Successful in 3m46s
to f5188f9dc7
All checks were successful
Build PR / linux-arm64 (Release) (pull_request) Successful in 3m16s
Build PR / linux-x64 (Release) (pull_request) Successful in 5m39s
Build PR / win-x64 (Release) (pull_request) Successful in 5m38s
Build PR / win-arm64 (Release) (pull_request) Successful in 5m49s
Build PR / macOS Universal (Release) (pull_request) Successful in 4m42s
2026-08-24 18:01:48 +00:00
Compare
LotP force-pushed fix/blend-enable-shadow-state from f5188f9dc7
All checks were successful
Build PR / linux-arm64 (Release) (pull_request) Successful in 3m16s
Build PR / linux-x64 (Release) (pull_request) Successful in 5m39s
Build PR / win-x64 (Release) (pull_request) Successful in 5m38s
Build PR / win-arm64 (Release) (pull_request) Successful in 5m49s
Build PR / macOS Universal (Release) (pull_request) Successful in 4m42s
to 2017af9da3
All checks were successful
Build PR / linux-arm64 (Release) (pull_request) Successful in 3m27s
Build PR / linux-x64 (Release) (pull_request) Successful in 6m4s
Build PR / win-arm64 (Release) (pull_request) Successful in 5m43s
Build PR / win-x64 (Release) (pull_request) Successful in 5m13s
Build PR / macOS Universal (Release) (pull_request) Successful in 5m16s
2026-08-24 19:21:42 +00:00
Compare
LotP merged commit 9e896b8f7e into master 2026-08-24 20:28:48 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
projects/Ryubing!183
No description provided.