File tree Expand file tree Collapse file tree 5 files changed +13
-1
lines changed Expand file tree Collapse file tree 5 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -852,13 +852,15 @@ impl<A: HalApi> Device<A> {
852852 ) ) ;
853853 }
854854
855+ let mut allow_different_view_format = false ;
855856 for format in desc. view_formats . iter ( ) {
856857 if desc. format == * format {
857858 continue ;
858859 }
859860 if desc. format . remove_srgb_suffix ( ) != format. remove_srgb_suffix ( ) {
860861 return Err ( CreateTextureError :: InvalidViewFormat ( * format, desc. format ) ) ;
861862 }
863+ allow_different_view_format = true ;
862864 }
863865
864866 // Enforce having COPY_DST/DEPTH_STENCIL_WRIT/COLOR_TARGET otherwise we
@@ -891,6 +893,7 @@ impl<A: HalApi> Device<A> {
891893 format : desc. format ,
892894 usage : hal_usage,
893895 memory_flags : hal:: MemoryFlags :: empty ( ) ,
896+ allow_different_view_format,
894897 } ;
895898
896899 let raw_texture = unsafe {
Original file line number Diff line number Diff line change @@ -299,6 +299,7 @@ impl<A: hal::Api> Example<A> {
299299 format : wgt:: TextureFormat :: Rgba8UnormSrgb ,
300300 usage : hal:: TextureUses :: COPY_DST | hal:: TextureUses :: RESOURCE ,
301301 memory_flags : hal:: MemoryFlags :: empty ( ) ,
302+ allow_different_view_format : false ,
302303 } ;
303304 let texture = unsafe { device. create_texture ( & texture_desc) . unwrap ( ) } ;
304305
Original file line number Diff line number Diff line change @@ -848,6 +848,9 @@ pub struct TextureDescriptor<'a> {
848848 pub format : wgt:: TextureFormat ,
849849 pub usage : TextureUses ,
850850 pub memory_flags : MemoryFlags ,
851+ /// Allows views of this texture to have a different format
852+ /// than the this texture does.
853+ pub allow_different_view_format : bool ,
851854}
852855
853856/// TextureView descriptor.
Original file line number Diff line number Diff line change @@ -331,7 +331,8 @@ impl PhysicalDeviceFeatures {
331331 | Df :: DEPTH_TEXTURE_AND_BUFFER_COPIES
332332 | Df :: BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED
333333 | Df :: UNRESTRICTED_INDEX_BUFFER
334- | Df :: INDIRECT_EXECUTION ;
334+ | Df :: INDIRECT_EXECUTION
335+ | Df :: VIEW_FORMATS ;
335336
336337 dl_flags. set ( Df :: CUBE_ARRAY_TEXTURES , self . core . image_cube_array != 0 ) ;
337338 dl_flags. set ( Df :: ANISOTROPIC_FILTERING , self . core . sampler_anisotropy != 0 ) ;
Original file line number Diff line number Diff line change @@ -895,6 +895,10 @@ impl crate::Device<super::Api> for super::Device {
895895 raw_flags |= vk:: ImageCreateFlags :: CUBE_COMPATIBLE ;
896896 }
897897
898+ if desc. allow_different_view_format {
899+ raw_flags |= vk:: ImageCreateFlags :: MUTABLE_FORMAT ;
900+ }
901+
898902 let vk_info = vk:: ImageCreateInfo :: builder ( )
899903 . flags ( raw_flags)
900904 . image_type ( conv:: map_texture_dimension ( desc. dimension ) )
You can’t perform that action at this time.
0 commit comments