From 1c537d99da664d823167d58104ebebb075e2dcae Mon Sep 17 00:00:00 2001 From: Skyler Lehmkuhl Date: Fri, 26 Jun 2026 02:26:39 -0400 Subject: [PATCH] fix: nv12_blit uniform size mismatch (64 vs 80 bytes) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The WGSL struct trailed `full_range: u32` with `_pad: vec3`, but vec3 has 16-byte alignment so the struct rounded up to 80 bytes while the Rust-side Nv12Params (BlitTransform + u32 + [u32;3]) is 64 — wgpu rejected the draw ("Buffer is bound with size 64 where the shader expects 80"). Pack the flag as a single `flags: vec4` (.x = full_range) so both sides are 64 bytes. --- .../lightningbeam-editor/src/panes/shaders/nv12_blit.wgsl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lightningbeam-ui/lightningbeam-editor/src/panes/shaders/nv12_blit.wgsl b/lightningbeam-ui/lightningbeam-editor/src/panes/shaders/nv12_blit.wgsl index 46d5d79..5a7e3f7 100644 --- a/lightningbeam-ui/lightningbeam-editor/src/panes/shaders/nv12_blit.wgsl +++ b/lightningbeam-ui/lightningbeam-editor/src/panes/shaders/nv12_blit.wgsl @@ -14,8 +14,9 @@ struct Nv12Params { col0: vec4, col1: vec4, col2: vec4, - full_range: u32, - _pad: vec3, + // .x = full_range flag; .yzw padding. A vec4 keeps the struct 64 bytes (matching the Rust + // `u32 + [u32; 3]`); a bare u32 + vec3 would round up to 80 and mismatch the bound buffer. + flags: vec4, } @group(0) @binding(0) var y_tex: texture_2d; @@ -60,7 +61,7 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4 { var Y: f32; var Cb: f32; var Cr: f32; - if params.full_range != 0u { + if params.flags.x != 0u { // Full ("JPEG") range: [0,255] luma, chroma centered at 128. Y = yv; Cb = cbcr.r - 0.5;