Skip to content

fix(w3d): Fix crashes, leaks and memory exhaustion on device reset - #639

Open
tintinhamans wants to merge 6 commits into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/fix/upstream-device-reset
Open

tintinhamans wants to merge 6 commits into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/fix/upstream-device-reset

Conversation

@tintinhamans

@tintinhamans tintinhamans commented Oct 15, 2026 •

Copy link
Copy Markdown

Combines the device reset fixes from #632, #634 and the previous version of this PR. A device reset happens on alt-tab in fullscreen, a lock screen, a UAC prompt or a resolution change, and each of these fixes covers a different way it went wrong. All commits except the last are cherry-pick -x of merged upstream commits.

Shroud: the shroud was uploaded with CopyRects every frame. On NVIDIA the driver reserves memory for each call and allocates it all at the next reset, so after a long match one reset could take hundreds of MB and the 32-bit process ran out of address space (CLIENT-55X). On the upstream build a 10 minute skirmish followed by a forced reset lost 316 MB on main and nothing with this change, and W3DShroud::render went from 0.032 ms to 0.006 ms per frame.

Reset: Reset_Device could crash in the driver (DestroyResource during Reset) while the device still had a vertex buffer, index buffer, texture or render target bound. Buffers are now unbound once the device can be reset, render states are invalidated and the render target is reset before Reset(), and the device is left alone until a Reset() succeeds. Reproduced on the upstream retail build on an Intel UHD 770 and an RTX 4070 Ti: a bound render target plus a forced device loss failed Reset on every frame forever, with this change both reset cleanly.

Both GeneralsMD and Generals are changed where the code exists twice. The code of every commit is identical to the separate PRs it replaces.

Tested: Zero Hour (z_generals) builds here. The shroud and reset measurements above were made on the upstream build.

@tintinhamans
tintinhamans force-pushed the arctic/go/fix/upstream-device-reset branch from cf5f8e9 to 4341f19 Compare October 22, 2026 21:14
@tintinhamans tintinhamans changed the title fix(w3d): Port merged TheSuperHackers device reset fixes fix(w3d): Fix crashes, leaks and memory exhaustion on device reset Oct 22, 2026
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