fix(windows): handle D3D11 device-lost (TDR) in AMD capture and encoding pipeline#596
fix(windows): handle D3D11 device-lost (TDR) in AMD capture and encoding pipeline#596
Conversation
…ing pipeline When a GPU TDR occurs during AMD DirectCapture streaming, the capture pipeline would either hang or crash because device-lost errors were not properly detected and propagated. Changes: - display_base.cpp: Handle DXGI_ERROR_DEVICE_REMOVED/RESET in AcquireNextFrame and ReleaseFrame, returning capture_e::reinit instead of capture_e::error - video.cpp: Change convert/encode failures from return (permanent exit) to break (allows outer loop to reinit pipeline) - amf_d3d11.cpp: Add device-lost detection after AMF CreateSurfaceFromDX11Native and SubmitInput failures - display_amd.cpp: Detect device-lost in AMD DirectCapture QueryOutput, return capture_e::reinit instead of masking as timeout - display_vram.cpp: Log device removed reason on AcquireSync failure for better TDR diagnostics
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🧰 Additional context used📓 Path-based instructions (2)src/**/*.{cpp,c,h}⚙️ CodeRabbit configuration file
Files:
src/platform/**⚙️ CodeRabbit configuration file
Files:
🔇 Additional comments (6)
Summary by CodeRabbit发布说明
概览此PR增强了DirectX设备丢失/重置的错误检测与处理。在编码和捕获模块的多个失败路径中添加了设备状态查询和日志记录,并改进了控制流以支持设备重新初始化机制。 变更
代码审查工作量🎯 3 (Moderate) | ⏱️ ~20 分钟 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Problem
When a GPU TDR (Timeout Detection and Recovery) occurs during AMD DirectCapture streaming, the capture pipeline would either hang indefinitely or crash. Users experience: streaming freezes, can switch to desktop but wallpaper turns black.
Root Cause
5 locations in the capture/encoding pipeline failed to properly detect and propagate D3D11 device-lost errors:
capture_e::error(fatal) instead ofcapture_e::reinit(recoverable) on device removalreturn(permanent exit) on convert/encode failure instead ofbreak(allow reinit)capture_e::timeout, causing infinite retry on dead deviceChanges
display_base.cppreinitvideo.cppreturn→breakamf_d3d11.cppdisplay_amd.cppreinitdisplay_vram.cppImpact Analysis
reinit_event+ sleep,display_wpexpiry check,shutdown_event).safe::signal_tandsync_util::sync_t.Testing
Requires AMD GPU with DirectCapture enabled. Simulate TDR by triggering GPU timeout during gameplay.