Skip to content

fix(dx8): Unbind device resources before Reset and guard against a failed reset - #634

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

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

Conversation

@tintinhamans

Copy link
Copy Markdown

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.

The helper does nothing after a failed Reset: the device is then in an undefined state and must not be touched until a later Reset succeeds, and nothing is drawn in between so nothing is bound. The state is tracked in a new DeviceResetFailed member, cleared when a device is created.

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 2 times, most recently from 7798f90 to 9f36faf Compare October 9, 2026 12:34
@tintinhamans
tintinhamans force-pushed the arctic/go/fix/reset-device-after-failed-reset branch from 9f36faf to d4ed1dd Compare October 9, 2026 12:56
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