Repository navigation
#724 Create shared-texture exports off the render thread - #731
Merged
Merged
Conversation
D3DDecoupledExport owns its own D3D device, and its constructor created that device on the caller's thread: the render thread, 13 to 21 ms each time a source, the encoder texture or a tile was first exported. Program lost two delivery slots per event. Creation::Deferred builds the device and textures on the exporter's own worker. Participant tiles use it and publish a frame or two late. The encoder export is created deferred as soon as a render target exists and kept, so a stream start finds it ready; that caller waits, bounded, only if a stream starts inside the creation window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the Program stall in #724 as far as the harness reproduces it.
Cause
D3DDecoupledExportowns its own D3D device. Its constructor calledD3D11CreateDeviceon the caller's thread, which is the render thread. That cost 13 to 21 ms every time something was exported for the first time: a clip taken to Program, a new guest, a capture device, the encoder texture at stream start. The core already logged it as[d3d-participant-create] ... cost_us=21545. Resizes reused the device; first creation did not.Change
D3DDecoupledExport::Creation::Deferred: the device and textures are created on the exporter's own worker thread. Untilready(),submit()refuses andhandle()is null.valid()now means "not failed", so a pending exporter is not discarded.Immediate(the default) is the old behaviour.prewarmEncoderExport, checked every render) and kept. A stream's encode path is chosen from the handle on its starting frame, soexportEncoderSharedTexturewaits for readiness, bounded at 250 ms, if a stream starts inside the creation window.CLAUDE.mdsection and a backlog row.Measured
Streaming stand-in harness,
node scripts/qa/youtube-same-run-av.mjs --local-standin --duration-seconds 12, this rig (RTX 4090):cdd2e87+ #730)Tests
D3DDecoupledExportcases: a deferred export is created off the caller's thread and then publishes pixels; an immediate one is still created on the caller's thread; resize while pending ends ready at the new size; destroy while pending does not hang.ParticipantBgraExportCopiesCachedPixelsAcrossDevices,SourceTextureCacheDedupsUploadsAcrossPasses).validate-multiviewPASS,validate-iso-recordPASS. Show drill: 60.0 fps, 0 dropped, recording 60.0 fps; its source->render latency line fails the same as on main.validate-gpu-encode: 3 of 5 on this branch and 3 of 5 on thecdd2e87core. Every failure is "no[gpu-encode] path=line found" with the stream healthy; when the line is present it readsgpu-directon this branch.Not covered
🤖 Generated with Claude Code