Skip to content

Fix desync caused by graphics drivers corrupting the SSE control register - #71

Open
11EJDE11 wants to merge 1 commit into
CnCNet:mainfrom
11EJDE11:fix-renderer-desync
Open

Fix desync caused by graphics drivers corrupting the SSE control register#71
11EJDE11 wants to merge 1 commit into
CnCNet:mainfrom
11EJDE11:fix-renderer-desync

Conversation

@11EJDE11

@11EJDE11 11EJDE11 commented Jul 22, 2026

Copy link
Copy Markdown
Member

Some graphics drivers return from D3D9 calls with the calling thread's MXCSR modified and never restore it.

From the attached logs, the rounding mode is changed during that call:

Bad: SetVideoMode-after-SetDisplayMode MXCSR=7FA0(rc=ZERO) x87CW=0E7F(rc=ZERO,pc=53)
vs
Good: SetVideoMode-after-SetDisplayMode MXCSR=1FA0(rc=nearest) x87CW=0E7F(rc=ZERO,pc=53)

rc=ZERO means SSE math truncates instead of rounding to nearest. Phobos replaces INIClass::ReadDouble (0x5283D0) with an SSE implementation, so percentage values parse low on the affected machine:

[Sidebar]HarvesterCounter.ConditionRed=50%: 0.49999997 (should be 0.5)
[Road]Hover=75%: 0.74999994 (should be 0.75)

debug_bad.log
debug_good.log

Fixed by restoring the SSE control register (MXCSR) right after SetDisplayMode, which is where it actually gets flipped and before before INIClass::ReadDouble runs. Also restore it at the start of every logic frame in case it happens mid-game.

@github-actions

Copy link
Copy Markdown

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@11EJDE11
11EJDE11 marked this pull request as ready for review July 31, 2026 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant