Skip to content

Fix multi-monitor swapchain threading for issue #449#482

Open
AndreTheAss wants to merge 1 commit intoVirtualDrivers:masterfrom
AndreTheAss:codex/fix-multi-monitor-swapchain-449
Open

Fix multi-monitor swapchain threading for issue #449#482
AndreTheAss wants to merge 1 commit intoVirtualDrivers:masterfrom
AndreTheAss:codex/fix-multi-monitor-swapchain-449

Conversation

@AndreTheAss
Copy link
Copy Markdown

Summary

This PR fixes the multi-monitor swapchain threading bug described in issue #449.

It changes the indirect display driver from a single global swapchain worker model to a per-monitor worker model, so each virtual monitor keeps its own SwapChainProcessor and processing thread.

This PR was prepared by an AI coding assistant on the explicit instruction of Andre, and it is intended to address only bug/issue #449.

What changed

  • Replaced the single global processing thread in IndirectDeviceContext with a per-monitor mapping of IDDCX_MONITOR -> SwapChainProcessor
  • Updated AssignSwapChain so only the worker for the affected monitor is created or replaced
  • Updated UnassignSwapChain so only the worker for the affected monitor is removed
  • Ensured all per-monitor workers are released cleanly in the IndirectDeviceContext destructor
  • Changed the swapchain frame loop to wait event-based on frame/termination handles when buffer acquisition returns E_PENDING
  • Added a central known-monitor-mode cache rebuild path so the cache is cleared before repopulating from current monitorModes
  • Short-circuited logging immediately when logging is disabled to avoid hot-path filesystem overhead across parallel monitor workers

Why

The previous single-worker architecture caused each new swapchain assignment to tear down the existing processor for other monitors. In practice, that meant only the most recently assigned monitor stayed stable, while other virtual displays could lag, stutter, or stop processing reliably.

The new per-monitor model allows swapchain processing to run independently and in parallel for each virtual monitor.

Scope

This PR is intentionally limited to bug/issue #449 only.
It does not attempt to change unrelated driver behavior beyond what is necessary to fix the multi-monitor swapchain processing issue.

Validation

  • Built successfully with MttVDD.vcxproj in Release|x64
  • Verified the driver still packages successfully
  • Remaining warning is the existing INF warning for WUDFRd.sys, unrelated to this fix

@AndreTheAss AndreTheAss reopened this Apr 11, 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