texture.write(VideoFrame) uses the padded coded size instead of the visible size

Đang mở Phù hợp với người mới
#3,213 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@RaphaelFakhri đang làm issue này rồi.

Từ ngày 20/10/2026.

  • #3224 của @RaphaelFakhri — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
74/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
backend, computer-graphics

Hướng nghiên cứu

Đọc packages/typegpu/src/core/texture/textureWrite.ts, tập trung vào imageSize() và cách xử lý VideoFrame. So sánh các kích thước được dùng với displayWidth/displayHeight hoặc visibleRect, như mô tả trong issue. Thêm hoặc cập nhật một bài kiểm thử cho frame có kích thước mã hóa khác với kích thước hiển thị, sau đó xác nhận rằng texture.write(frame) chấp nhận texture có kích thước hiển thị tương ứng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

Description

texture.write(videoFrame) reads a VideoFrame's size from codedWidth/codedHeight. Those are the decoder's padded buffer dimensions, not the visible image. Decoders often pad to a macroblock multiple, so a 320×240 video can give frames with a coded size of 320×258. The size check then fails against a texture created at the video's real size:

Texture write source size 320x258 does not match target size 320x240

Repro

const root = await tgpu.init();
// `frame` is a decoded VideoFrame from a 320x240 H.264 file
// (e.g. from a WebCodecs VideoDecoder or Mediabunny's VideoSample.toVideoFrame()).
// frame.codedWidth/Height = 320x258; frame.displayWidth/Height = 320x240.
const texture = root
  .createTexture({ size: [frame.displayWidth, frame.displayHeight], format: 'rgba8unorm' })
  .$usage('sampled', 'render');

texture.write(frame); // throws: source size 320x258 does not match target size 320x240

Cause

imageSize() in packages/typegpu/src/core/texture/textureWrite.ts falls back to codedWidth/codedHeight for VideoFrames. It should use displayWidth/displayHeight (or visibleRect). Those match what copyExternalImageToTexture copies and what the WebGL path's texSubImage2D uploads.

Workaround

Pass { fit: 'clip' } to write(), which copies the top-left region of the requested size.


Found in typegpu 0.12.7.

Ngôn ngữ chính
TypeScript
Star
3.3k
Fork
143
Merge trung bình
2 ngày 23 giờ
Pull request đã merge (30 ngày)
72

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của software-mansion/TypeGPU

Tất cả issue của software-mansion/TypeGPU

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.