@@ -5,7 +5,7 @@ use thiserror::Error;
5
5
use wgpu:: {
6
6
util:: DeviceExt , BindGroup , BindGroupDescriptor , BindGroupEntry , BindGroupLayout , BindGroupLayoutDescriptor ,
7
7
BindGroupLayoutEntry , BindingResource , BindingType , CommandBuffer , CommandEncoder , CommandEncoderDescriptor ,
8
- Device , Extent3d , ImageCopyTexture , ImageDataLayout , Origin3d , ShaderStages , Texture , TextureAspect ,
8
+ Device , Extent3d , Features , ImageCopyTexture , ImageDataLayout , Origin3d , ShaderStages , Texture , TextureAspect ,
9
9
TextureDescriptor , TextureDimension , TextureSampleType , TextureView , TextureViewDescriptor , TextureViewDimension ,
10
10
} ;
11
11
@@ -108,7 +108,7 @@ impl<T: 'static> TextureManager<T> {
108
108
texture : crate :: types:: Texture ,
109
109
cube : bool ,
110
110
) -> Result < ( Option < CommandBuffer > , InternalTexture ) , TextureCreationError > {
111
- validate_texture_format ( texture. format ) ?;
111
+ validate_texture_format ( texture. format , renderer . device . features ( ) ) ?;
112
112
113
113
let ( block_x, block_y) = texture. format . block_dimensions ( ) ;
114
114
let size = Extent3d {
@@ -142,9 +142,12 @@ impl<T: 'static> TextureManager<T> {
142
142
let ( buffer, tex) = match texture. mip_source {
143
143
MipmapSource :: Uploaded => {
144
144
let scope = AllocationErrorScope :: new ( & renderer. device ) ;
145
- let texture = renderer
146
- . device
147
- . create_texture_with_data ( & renderer. queue , & desc, & texture. data ) ;
145
+ let texture = renderer. device . create_texture_with_data (
146
+ & renderer. queue ,
147
+ & desc,
148
+ wgpu:: util:: TextureDataOrder :: LayerMajor ,
149
+ & texture. data ,
150
+ ) ;
148
151
scope. end ( ) . map_err ( TextureCreationError :: TextureAllocationFailed ) ?;
149
152
( None , texture)
150
153
}
@@ -160,7 +163,7 @@ impl<T: 'static> TextureManager<T> {
160
163
scope. end ( ) . map_err ( TextureCreationError :: TextureAllocationFailed ) ?;
161
164
162
165
let ( block_width, _) = texture. format . block_dimensions ( ) ;
163
- let block_size = texture. format . block_size ( None ) . unwrap ( ) ;
166
+ let block_size = texture. format . block_copy_size ( None ) . unwrap ( ) ;
164
167
165
168
let scope = AllocationErrorScope :: new ( & renderer. device ) ;
166
169
// write first level
@@ -415,8 +418,8 @@ fn create_null_tex_view(device: &Device, dimension: TextureViewDimension) -> Tex
415
418
} )
416
419
}
417
420
418
- fn validate_texture_format ( format : TextureFormat ) -> Result < ( ) , TextureCreationError > {
419
- let sample_type = format. sample_type ( None ) ;
421
+ fn validate_texture_format ( format : TextureFormat , features : Features ) -> Result < ( ) , TextureCreationError > {
422
+ let sample_type = format. sample_type ( None , Some ( features ) ) ;
420
423
match sample_type {
421
424
Some ( TextureSampleType :: Float { filterable : true } ) => Ok ( ( ) ) ,
422
425
Some ( TextureSampleType :: Float { filterable : false } ) => Err ( TextureCreationError :: TextureFormatNotFilterable {
0 commit comments