Repository navigation
fix: Use the display size of VideoFrames in texture.write() - #3224
RaphaelFakhri wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Reviewed changes This PR fixes
I confirmed the test genuinely pins the fix: reverting ( ◦°^°◦) 🏴☠️ Aye, I read the whole diff, checked the WebGPU spec to be sure
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This PR fixes texture.write(videoFrame) reading the decoder's padded codedWidth/codedHeight instead of the visible displayWidth/displayHeight, which caused a spurious size-mismatch throw whenever a frame's coded size was macroblock-padded.
imageSize()uses the display size forVideoFramesources —packages/typegpu/src/core/texture/textureWrite.ts:88now returnsdisplayWidth/displayHeight. The WebGPU spec's external-source-dimensions table definesVideoFramesource dimensions asVideoFrame.displayWidth/displayHeight, so theresolveImageWritesize check now lines up with the regioncopyExternalImageToTextureactually copies.- Regression test added —
packages/typegpu/tests/texture.test.ts:775writes a mock frame with a 320x258 coded size and a 320x240 display size into a 320x240 texture and asserts the copy size[320, 240].
I confirmed the test genuinely pins the fix: reverting imageSize() to codedWidth/codedHeight makes the new test fail with the exact error from #3213 (Texture write source size 320x258 does not match target size 320x240). The targeted suite passes (54/54) and the working tree is clean. The branch ordering in imageSize() is unaffected, since a VideoFrame exposes neither videoWidth, naturalWidth, nor width/height.
( ◦°^°◦) 🏴☠️ Aye, I read the whole diff, checked the WebGPU spec to be sure displayWidth be the right measure, ran the new test (she passes), then scuttled the fix to prove the test catches the old bug — and put it back. No issues found, matey.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
vende11s
left a comment
There was a problem hiding this comment.
Looks good! Just a small suggestion to improve the test
| .$usage('render'); | ||
|
|
||
| const mockFrame = { | ||
| codedWidth: 320, |
There was a problem hiding this comment.
| codedWidth: 320, | |
| codedWidth: 336, |
Could we set codedWidth to something different from displayWidth? This would catch regressions in both dimensions.
Co-authored-by: Michał Wierzbiński <74505994+vende11s@users.noreply.github.com>
|
@vende11s Applied the suggestion in c7fb86c: the mock frame now has a 336x258 coded size and a 320x240 display size, so the test covers both dimensions.
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the delta since the prior pullfrog review at 0f97455: a single test-only commit that applies the human reviewer's suggestion. No production code changed, so the fix validated in the prior review stands.
- Regression test now distinguishes both dimensions —
packages/typegpu/tests/texture.test.ts:784setscodedWidthto336(previously320, equal todisplayWidth), so the test now catches a regression that read the coded width as well as one that read the coded height.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Fixes #3213.
texture.write(videoFrame)read the frame size fromcodedWidth/codedHeight. Those are the decoder's padded buffer dimensions, so a 320x240 H.264 frame can report a coded size of 320x258 and the write fails the size check against a 320x240 texture.This change reads
displayWidth/displayHeightinstead, which match the region thatcopyExternalImageToTexturecopies.Changes
imageSize()inpackages/typegpu/src/core/texture/textureWrite.tsusesdisplayWidth/displayHeightforVideoFramesources.packages/typegpu/tests/texture.test.tswrites a mock frame with a 320x258 coded size and a 320x240 display size into a 320x240 texture and checks the copy size. Without the fix it throwsTexture write source size 320x258 does not match target size 320x240.Testing
pnpm vitest run --project=!browser packages/typegpu/tests/texture.test.ts: 54 passed.oxlint --type-aware,oxfmt --check, andtscforpackages/typegpuare clean.