Repository navigation
Conversation
|
@kyzer1023 is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
|
@greptileai review |
|
@greptileai review |
|
@greptileai review |
|
@greptileai review |
|
@greptileai review |
|
Thanks, the reuse looks right. One thing before we take it: RGB24/BGR24 cameras now hit the new size check and error out, so their recordings stop where they used to complete (with bad colours). Can you convert those to BGRA before the upload instead, so they're actually fixed rather than failing? |
|
@greptileai review |
|
@greptileai review |
|
@richiemcilroy e0eaaec (fix in ff7c575): RGB24/BGR24 camera frames now convert to BGRA before upload instead of hard-failing. Greptile 5/5. Windows CI green: tests 1–4, clippy, GPUI build, sync-tests, real-capture (windows-2022), window discovery. Earlier windows sync-tests failure was an unrelated rendering transition flake; only macos-26-intel GPUI build still queued. |
|
@greptileai review |
The Windows native camera path allocated twice for every frame.
setup_cameracopied each sample into a newMFCreateMemoryBuffer, andupload_mf_buffer_to_texturethen created a newID3D11Texture2Dfrom that copy withCreateTexture2D. This change reuses both.output_pipeline/win.rs:CameraBuffersnow keeps one cached upload texture. It is aD3D11_USAGE_DYNAMICtexture filled withMap(WRITE_DISCARD), copied row by row with separate source and mapped row pitches (both planes for NV12). It is recreated only when width, height, DXGI format or device change. If the driver refuses the dynamic texture, it falls back to a cachedD3D11_USAGE_DEFAULTtexture updated withUpdateSubresource. One texture is enough because the encoder'sVideoProcessorcopies the input into its own texture withCopyResourceon the same immediate context before it asks for the next frame, andWRITE_DISCARDkeeps the memory that queued GPU work still reads.CreateTexture2D.feeds/camera.rs: the native frame path keeps a pool of up to 3 media buffers. A buffer is reused only when the pool holds the only reference to it, it is large enough and it is not poisoned. Otherwise a new buffer is allocated as before. The current length is set on every frame, and a buffer that fails a write is dropped from the pool. The preview FFmpeg copy is unchanged.examples/windows-camera-upload-benchmark.rs: a Windows only example that captures real webcam frames and replays them through an inline copy of the previous path and through the new one, plus a GPU readback check. Capture only accepts top-down YUYV, NV12, RGB32 and ARGB frames, the modes both paths can replay. It is a no-op main on other platforms.Benchmark
Per frame cost of the camera upload path (media buffer copy plus texture upload), release build.
Speedup, submit only: 3.67x median, 3.77x p95, 3.57x mean, 3.08x CPU.
Speedup, waiting for GPU: 2.40x median, 2.14x p95, 2.13x mean, 2.00x CPU.
CPU s is total process CPU time across the 1500 timed frames of each row. An earlier run with a separate harness that built the original library code for the before side gave similar numbers (3.97x and 2.60x median).
How to rerun
The camera name argument is optional and matches by substring; without it the first camera is used.
beforeandafterrun one side each.Correctness
validateuploads 90 synthetic frames throughupload_mf_buffer_to_texturewith one sharedCameraBuffersand checks each GPU readback byte for byte: YUYV, UYVY, NV12 (both planes), RGB32 and ARGB, padded rows, bottom up flips, three frames in a row per format, and size and format changes. It passes on the dynamic path. The same checks also passed in a local build with theUpdateSubresourcefallback forced.AMD caveat
WindowsCameraMuxerroutes AMD GPUs to the FFmpeg software camera encoder, which does not callupload_mf_buffer_to_texture. So on that path the texture upload gain applies to hardware encoding on Intel and NVIDIA, not to AMD machines like the one measured here. The numbers above measure the upload path in isolation, not a full recording. The segmented camera encoder has no AMD check and uses the upload on every vendor. The media buffer pool applies everywhere a native camera sender is attached.Tests
cargo fmt --allandcargo clippy -p cap-recording --all-targetsare clean apart from two existing warnings (cursor.rsunused import,capture_pipeline.rsitems after test module).cargo test -p cap-recording: library tests 714 passed, 4 ignored.instant_mode_scenarioshas 3 failures (many_segments_50_plus_concatenate_correctly,segment_callback_receives_events_during_encoding,segment_duration_100ms_produces_many_segments). They fail the same way on unmodified main on this machine and go through the FFmpeg AMF encoder, which this change does not touch.oop_muxertests could not findcap-muxer.exebecause this run used a shared target dir outside the worktree.

Confidence Score: 5/5
The PR appears safe to merge, with both prior findings addressed and no new findings.Summary
Reuses Windows camera media buffers and upload textures to reduce per-frame allocations.
No code changed since the previous review. Both prior findings are addressed: capture excludes unsupported benchmark modes and rejects bottom-up frames before writing; the benchmark’s opening narrative comments are removed. No new findings or repository-rule violations remain.
Reviews (10) · Last reviewed commit: "ci: retrigger after macos-intel native-d..." · Reviewed by Greptile