Repository navigation
Windows hardware acceleration and NV12 rendering optimizations - #1482
Merged
Merged
Conversation
| if (frameCount % 60 === 0) { | ||
| const avgDelta = frameTimeSum / 60; | ||
| const elapsedSec = (now - lastLogTime) / 1000; | ||
| const mbPerSec = totalBytesReceived / 1_000_000 / elapsedSec; |
Contributor
There was a problem hiding this comment.
logic: renderFrameCount is referenced here but never declared or incremented in this code path. The variable is only reset to 0 on line 540, but never defined or incremented when frames are actually rendered through directCtx.putImageData.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/utils/socket.ts
Line: 533:533
Comment:
**logic:** `renderFrameCount` is referenced here but never declared or incremented in this code path. The variable is only reset to 0 on line 540, but never defined or incremented when frames are actually rendered through `directCtx.putImageData`.
How can I resolve this? If you propose a fix, please make it concise.
This was referenced Jan 25, 2026
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.
Greptile Summary
This PR implements comprehensive Windows hardware acceleration and NV12 rendering optimizations across the video pipeline. The changes enable zero-copy D3D11→D3D12 texture sharing via shared handles, eliminating expensive CPU-side YUV conversions during hardware-accelerated decoding. Native NV12 support is added to the WebGPU renderer with a dedicated shader pipeline for YUV→RGB conversion on the GPU. The WebSocket frame streaming now uses watch channels with intelligent NV12 downscaling (50%) for efficient preview delivery. FFmpeg decoder refactoring separates CPU/GPU frame processing paths with improved frame caching and seeking logic. Additional improvements include WebGPU pipeline caching for faster shader compilation, Windows 11 caption controls in the editor UI, and enhanced recording recovery with minimum audio file size validation (500 bytes).
Key architectural improvements:
Issue found:
renderFrameCountvariable insocket.ts:533is used but never declared or incremented in the direct canvas rendering pathConfidence Score: 4/5
renderFrameCountis referenced but never declared in the direct canvas rendering path in socket.ts, which will cause a runtime reference error. The rest of the changes are well-structured, follow existing patterns, and add substantial performance improvements through hardware acceleration.renderFrameCountvariable before mergingImportant Files Changed
dirs::data_local_dir()for faster shader compilation on subsequent runsSequence Diagram
sequenceDiagram participant FFmpeg as FFmpeg Decoder<br/>(Rust) participant D3D11 as D3D11 Device<br/>(Windows) participant Shared as Shared Handle<br/>(NT Handle) participant D3D12 as D3D12 Device<br/>(wgpu) participant WebSocket as WebSocket Server<br/>(Tauri) participant Frontend as Frontend<br/>(TypeScript) participant WebGPU as WebGPU Renderer<br/>(Browser) Note over FFmpeg,D3D11: Hardware Decoding Path FFmpeg->>D3D11: Decode video frame to NV12 D3D11->>D3D11: Create shared texture<br/>(D3D11_RESOURCE_MISC_SHARED_NTHANDLE) D3D11->>Shared: Export shared handle Note over Shared,D3D12: Zero-Copy Texture Sharing Shared->>D3D12: OpenSharedHandle() D3D12->>D3D12: Create HAL texture from D3D12Resource D3D12->>WebGPU: create_texture_from_hal() Note over FFmpeg,WebSocket: Frame Streaming (Camera Preview) FFmpeg->>WebSocket: Send NV12 frame data WebSocket->>WebSocket: Downscale 50%<br/>RGB→YUV conversion WebSocket->>Frontend: Send over ws:// with metadata Frontend->>Frontend: Detect NV12 magic (0x4e563132) Frontend->>WebGPU: renderNv12FrameWebGPU() WebGPU->>WebGPU: Upload Y plane (r8unorm) WebGPU->>WebGPU: Upload UV plane (rg8unorm) WebGPU->>WebGPU: YUV→RGB shader conversion WebGPU->>Frontend: Display frame on canvas