struct VertexOutput { @builtin(position) clip_position: vec4, @location(0) tex_coords: vec2, } @vertex fn vs_main( @builtin(vertex_index) in_vertex_index: u32, ) -> VertexOutput { var out: VertexOutput; let uv = vec2(f32((in_vertex_index << 1u) & 2u), f32(in_vertex_index & 2u)); out.clip_position = vec4(uv * 2.0 - 1.0, 0.0, 1.0); out.clip_position.y = -out.clip_position.y; out.tex_coords = uv; return out; } @group(0) @binding(0) var y_texture: texture_2d; @group(0) @binding(1) var uv_texture: texture_2d; @group(0) @binding(2) var texture_sampler: sampler; @group(0) @binding(3) var rgb_primaries: mat3x3; @fragment fn fs_main(input: VertexOutput) -> @location(0) vec4 { let y = textureSample(y_texture, texture_sampler, input.tex_coords).r; let uv = textureSample(uv_texture, texture_sampler, input.tex_coords).rg; let yuv = vec3f(y, uv.x - 0.5, uv.y - 0.5); return vec4f(yuv * rgb_primaries, 1.0); }