#41

dxmt: advance the GS/TS draw-argument marshal loops (backport 3Shain/dxmt aadf0fb; Dark Souls III freeze)

Openmeshoklvwants to merge intofrom

This backports upstream 3Shain/dxmt aadf0fb ("add missing increment in loop") and the zero-count guard from the same functions on upstream main (3Shain/dxmt#200).

The bugs

  • gs_draw_arguments_marshal and ts_draw_arguments_marshal never advance index. The host sets end_of_command only on the last task. So any batch of two or more GS/TS draws spins on tasks[0] until the GPU times out, and the later tasks' dispatch arguments are never written.
  • A draw with zero vertices or instances underflows x - 1, so it can request about 4G threadgroups.

Effect: Dark Souls III froze for good in combat on an iPhone Air. Frames stopped and never resumed, and the log shows tessellated draws in flight plus kIOGPUCommandBufferCallbackErrorInnocentVictim errors every ~10 s afterwards. Sekiro on macOS hit the same loop (3Shain/dxmt#200).

Tested: I built d3d11.dll (arm64ec) from 128b297 with this change and #40, and compiled the metallib with xcrun metal -std=metal3.1 --target=air64-apple-macos14.0 as meson does. With that DLL, DS3 did not freeze in the two combat sessions since (one ended in an unrelated crash, since fixed by a Wine setting). Before this change, it froze in combat in both earlier sessions.

🤖 Generated with Claude Code