@@ -489,112 +489,11 @@ pub trait TextureFormatPixelInfo {
489489impl TextureFormatPixelInfo for TextureFormat {
490490 #[ allow( clippy:: match_same_arms) ]
491491 fn pixel_info ( & self ) -> PixelInfo {
492- let type_size = match self {
493- // 8bit
494- TextureFormat :: R8Unorm
495- | TextureFormat :: R8Snorm
496- | TextureFormat :: R8Uint
497- | TextureFormat :: R8Sint
498- | TextureFormat :: Rg8Unorm
499- | TextureFormat :: Rg8Snorm
500- | TextureFormat :: Rg8Uint
501- | TextureFormat :: Rg8Sint
502- | TextureFormat :: Rgba8Unorm
503- | TextureFormat :: Rgba8UnormSrgb
504- | TextureFormat :: Rgba8Snorm
505- | TextureFormat :: Rgba8Uint
506- | TextureFormat :: Rgba8Sint
507- | TextureFormat :: Bgra8Unorm
508- | TextureFormat :: Bgra8UnormSrgb => 1 ,
509-
510- // 16bit
511- TextureFormat :: R16Uint
512- | TextureFormat :: R16Sint
513- | TextureFormat :: R16Float
514- | TextureFormat :: R16Unorm
515- | TextureFormat :: Rg16Uint
516- | TextureFormat :: Rg16Sint
517- | TextureFormat :: Rg16Unorm
518- | TextureFormat :: Rg16Float
519- | TextureFormat :: Rgba16Uint
520- | TextureFormat :: Rgba16Sint
521- | TextureFormat :: Rgba16Float => 2 ,
522-
523- // 32bit
524- TextureFormat :: R32Uint
525- | TextureFormat :: R32Sint
526- | TextureFormat :: R32Float
527- | TextureFormat :: Rg32Uint
528- | TextureFormat :: Rg32Sint
529- | TextureFormat :: Rg32Float
530- | TextureFormat :: Rgba32Uint
531- | TextureFormat :: Rgba32Sint
532- | TextureFormat :: Rgba32Float
533- | TextureFormat :: Depth32Float => 4 ,
534-
535- // special cases
536- TextureFormat :: Rgb9e5Ufloat => 4 ,
537- TextureFormat :: Rgb10a2Unorm => 4 ,
538- TextureFormat :: Rg11b10Float => 4 ,
539- TextureFormat :: Depth24Plus => 3 , // FIXME is this correct?
540- TextureFormat :: Depth24PlusStencil8 => 4 ,
541- // TODO: this is not good! this is a temporary step while porting bevy_render to direct wgpu usage
542- _ => panic ! ( "cannot get pixel info for type" ) ,
543- } ;
544-
545- let components = match self {
546- TextureFormat :: R8Unorm
547- | TextureFormat :: R8Snorm
548- | TextureFormat :: R8Uint
549- | TextureFormat :: R8Sint
550- | TextureFormat :: R16Uint
551- | TextureFormat :: R16Sint
552- | TextureFormat :: R16Unorm
553- | TextureFormat :: R16Float
554- | TextureFormat :: R32Uint
555- | TextureFormat :: R32Sint
556- | TextureFormat :: R32Float => 1 ,
557-
558- TextureFormat :: Rg8Unorm
559- | TextureFormat :: Rg8Snorm
560- | TextureFormat :: Rg8Uint
561- | TextureFormat :: Rg8Sint
562- | TextureFormat :: Rg16Uint
563- | TextureFormat :: Rg16Sint
564- | TextureFormat :: Rg16Unorm
565- | TextureFormat :: Rg16Float
566- | TextureFormat :: Rg32Uint
567- | TextureFormat :: Rg32Sint
568- | TextureFormat :: Rg32Float => 2 ,
569-
570- TextureFormat :: Rgba8Unorm
571- | TextureFormat :: Rgba8UnormSrgb
572- | TextureFormat :: Rgba8Snorm
573- | TextureFormat :: Rgba8Uint
574- | TextureFormat :: Rgba8Sint
575- | TextureFormat :: Bgra8Unorm
576- | TextureFormat :: Bgra8UnormSrgb
577- | TextureFormat :: Rgba16Uint
578- | TextureFormat :: Rgba16Sint
579- | TextureFormat :: Rgba16Float
580- | TextureFormat :: Rgba32Uint
581- | TextureFormat :: Rgba32Sint
582- | TextureFormat :: Rgba32Float => 4 ,
583-
584- // special cases
585- TextureFormat :: Rgb9e5Ufloat
586- | TextureFormat :: Rgb10a2Unorm
587- | TextureFormat :: Rg11b10Float
588- | TextureFormat :: Depth32Float
589- | TextureFormat :: Depth24Plus
590- | TextureFormat :: Depth24PlusStencil8 => 1 ,
591- // TODO: this is not good! this is a temporary step while porting bevy_render to direct wgpu usage
592- _ => panic ! ( "cannot get pixel info for type" ) ,
593- } ;
492+ let info = self . describe ( ) ;
594493
595494 PixelInfo {
596- type_size,
597- num_components : components,
495+ type_size : info . block_size . into ( ) ,
496+ num_components : info . components . into ( ) ,
598497 }
599498 }
600499}
0 commit comments