Skip to content

fix(dx8): Unbind device resources before Reset - #634

Open
tintinhamans wants to merge 2 commits into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/fix/reset-device-after-failed-reset
Open

tintinhamans wants to merge 2 commits into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/fix/reset-device-after-failed-reset

Conversation

@tintinhamans

@tintinhamans tintinhamans commented Oct 9, 2026 •

Copy link
Copy Markdown

Merge with Rebase

This change has 2 commits. Same change as TheSuperHackers#3450.

DX8Wrapper::Reset_Device can crash inside the driver (DestroyResource during Reset) when the device still holds a bound vertex buffer, index buffer, texture or render target. Set_Vertex_Buffer / Set_Index_Buffer are deferred and only drop the wrapper's references, so the device keeps its bindings into Reset, which D3D8 forbids.

This consolidates the unbind into one helper, Unbind_Device_Resources, that drops the device's references to the last draw's textures, streams and index buffer. Reset_Device calls it before Reset and also restores the back buffer as the render target; Release_Device now calls the same helper instead of repeating the calls inline.

A failed Reset is retried on the next frame and no longer asserts in debug.

The second commit stops Reset_Device from releasing everything again on every frame while the device stays lost or Reset keeps failing, and stops draws on the lost device. The device state is now tracked from TestCooperativeLevel, Present and Reset. The release runs once per loss, a retry only unbinds and calls Reset, and draws do nothing until the device is usable again.

Reproduced and verified on the upstream retail build on two GPUs. Binding a custom render target and forcing a device loss made Reset fail on every frame forever (2000+ failures, an endless reset storm) on both an Intel UHD 770 (igd9trinity32.dll) and an NVIDIA RTX 4070 Ti. With this change both reset cleanly and the game continues. In the field this maps to the DestroyResource crash group (CLIENT-55Y and related); the release that had only the render-target release still hit it ~17% of the time.

@tintinhamans
tintinhamans force-pushed the arctic/go/fix/reset-device-after-failed-reset branch 3 times, most recently from 9f36faf to d4ed1dd Compare October 9, 2026 12:56
@tintinhamans
tintinhamans force-pushed the arctic/go/fix/reset-device-after-failed-reset branch from d4ed1dd to a9be7f5 Compare October 16, 2026 23:52
@tintinhamans tintinhamans changed the title fix(dx8): Unbind device resources before Reset and guard against a failed reset fix(dx8): Unbind device resources before Reset Oct 16, 2026
@tintinhamans
tintinhamans force-pushed the arctic/go/fix/reset-device-after-failed-reset branch 2 times, most recently from c028f9a to ea477be Compare October 17, 2026 00:09
@tintinhamans
tintinhamans force-pushed the arctic/go/fix/reset-device-after-failed-reset branch from ea477be to 2c74903 Compare October 17, 2026 00:31
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