@@ -4,10 +4,7 @@ use std::{
44} ;
55
66use wgpu_core:: binding_model:: { BindGroupEntry , BufferBinding } ;
7- use wgt:: {
8- AddressMode , BindGroupLayoutEntry , BufferBindingType , CompareFunction , FilterMode , QueryType ,
9- SamplerBindingType , StorageTextureAccess , TextureFormat , TextureSampleType , VertexFormat ,
10- } ;
7+ use wgt:: { AddressMode , BindGroupLayoutEntry , BufferBindingType , CompareFunction , Features , FilterMode , QueryType , SamplerBindingType , StorageTextureAccess , TextureFormat , TextureSampleType , VertexFormat } ;
118
129use crate :: webgpu:: gpu_buffer:: CanvasGPUBuffer ;
1310use crate :: webgpu:: gpu_sampler:: CanvasGPUSampler ;
@@ -327,6 +324,23 @@ pub enum CanvasGPUTextureFormat {
327324 /// [`Features::TEXTURE_FORMAT_NV12`] must be enabled to use this texture format.
328325 NV12 ,
329326
327+ /// YUV 4:2:0 chroma subsampled format.
328+ ///
329+ /// Contains two planes:
330+ /// - 0: Single 16 bit channel luminance, of which only the high 10 bits
331+ /// are used.
332+ /// - 1: Dual 16 bit channel chrominance at half width and half height, of
333+ /// which only the high 10 bits are used.
334+ ///
335+ /// Valid view formats for luminance are [`TextureFormat::R16Unorm`].
336+ ///
337+ /// Valid view formats for chrominance are [`TextureFormat::Rg16Unorm`].
338+ ///
339+ /// Width and height must be even.
340+ ///
341+ /// [`Features::TEXTURE_FORMAT_P010`] must be enabled to use this texture format.
342+ P010 ,
343+
330344 // Compressed textures usable with `TEXTURE_COMPRESSION_BC` feature.
331345 /// 4x4 block compressed texture. 8 bytes per block (4 bit/px). 4 color + alpha pallet. 5 bit R + 6 bit G + 5 bit B + 1 bit alpha.
332346 /// [0, 63] ([0, 1] for alpha) converted to/from float [0, 1] in shader.
@@ -573,6 +587,7 @@ impl From<wgt::TextureFormat> for CanvasGPUTextureFormat {
573587 block : block. into ( ) ,
574588 channel : channel. into ( ) ,
575589 } ,
590+ TextureFormat :: P010 => CanvasGPUTextureFormat :: P010
576591 }
577592 }
578593}
@@ -633,6 +648,7 @@ impl Into<wgt::TextureFormat> for CanvasGPUTextureFormat {
633648 wgt:: TextureFormat :: Depth32FloatStencil8
634649 }
635650 CanvasGPUTextureFormat :: NV12 => wgt:: TextureFormat :: NV12 ,
651+ CanvasGPUTextureFormat :: P010 => wgt:: TextureFormat :: P010 ,
636652 CanvasGPUTextureFormat :: Bc1RgbaUnorm => wgt:: TextureFormat :: Bc1RgbaUnorm ,
637653 CanvasGPUTextureFormat :: Bc1RgbaUnormSrgb => wgt:: TextureFormat :: Bc1RgbaUnormSrgb ,
638654 CanvasGPUTextureFormat :: Bc2RgbaUnorm => wgt:: TextureFormat :: Bc2RgbaUnorm ,
@@ -742,6 +758,7 @@ impl Into<String> for CanvasGPUTextureFormat {
742758 CanvasGPUTextureFormat :: Depth24Plus => "depth24plus" ,
743759 CanvasGPUTextureFormat :: Depth24PlusStencil8 => "depth24plus-stencil8" ,
744760 CanvasGPUTextureFormat :: NV12 => "nv12" ,
761+ CanvasGPUTextureFormat :: P010 => "p010" ,
745762 CanvasGPUTextureFormat :: Rgb9e5Ufloat => "rgb9e5ufloat" ,
746763 CanvasGPUTextureFormat :: Bc1RgbaUnorm => "bc1-rgba-unorm" ,
747764 CanvasGPUTextureFormat :: Bc1RgbaUnormSrgb => "bc1-rgba-unorm-srgb" ,
@@ -855,6 +872,7 @@ pub extern "C" fn canvas_native_webgpu_enum_gpu_texture_to_string(
855872 CanvasGPUTextureFormat :: Depth24Plus => "depth24plus" ,
856873 CanvasGPUTextureFormat :: Depth24PlusStencil8 => "depth24plus-stencil8" ,
857874 CanvasGPUTextureFormat :: NV12 => "nv12" ,
875+ CanvasGPUTextureFormat :: P010 => "p010" ,
858876 CanvasGPUTextureFormat :: Rgb9e5Ufloat => "rgb9e5ufloat" ,
859877 CanvasGPUTextureFormat :: Bc1RgbaUnorm => "bc1-rgba-unorm" ,
860878 CanvasGPUTextureFormat :: Bc1RgbaUnormSrgb => "bc1-rgba-unorm-srgb" ,
0 commit comments