@@ -976,22 +976,33 @@ impl<A: HalApi> Device<A> {
976976 label : Option < & str > ,
977977 entry_map : binding_model:: BindEntryMap ,
978978 ) -> Result < binding_model:: BindGroupLayout < A > , binding_model:: CreateBindGroupLayoutError > {
979+ #[ derive( PartialEq ) ]
980+ enum WritableStorage {
981+ Yes ,
982+ No ,
983+ }
984+
979985 for entry in entry_map. values ( ) {
980986 use wgt:: BindingType as Bt ;
981987
982988 let mut required_features = wgt:: Features :: empty ( ) ;
983- let mut required_downlevel_flags = wgt:: DownlevelFlags :: empty ( ) ;
984- let ( array_feature, is_writable_storage) = match entry. ty {
989+ let ( array_feature, writable_storage) = match entry. ty {
985990 Bt :: Buffer {
986991 ty : wgt:: BufferBindingType :: Uniform ,
987992 has_dynamic_offset : false ,
988993 min_binding_size : _,
989- } => ( Some ( wgt:: Features :: BUFFER_BINDING_ARRAY ) , false ) ,
994+ } => (
995+ Some ( wgt:: Features :: BUFFER_BINDING_ARRAY ) ,
996+ WritableStorage :: No ,
997+ ) ,
990998 Bt :: Buffer {
991999 ty : wgt:: BufferBindingType :: Uniform ,
9921000 has_dynamic_offset : true ,
9931001 min_binding_size : _,
994- } => ( Some ( wgt:: Features :: BUFFER_BINDING_ARRAY ) , false ) ,
1002+ } => (
1003+ Some ( wgt:: Features :: BUFFER_BINDING_ARRAY ) ,
1004+ WritableStorage :: No ,
1005+ ) ,
9951006 Bt :: Buffer {
9961007 ty : wgt:: BufferBindingType :: Storage { read_only } ,
9971008 ..
@@ -1000,22 +1011,28 @@ impl<A: HalApi> Device<A> {
10001011 wgt:: Features :: BUFFER_BINDING_ARRAY
10011012 | wgt:: Features :: STORAGE_RESOURCE_BINDING_ARRAY ,
10021013 ) ,
1003- !read_only,
1014+ match read_only {
1015+ true => WritableStorage :: No ,
1016+ false => WritableStorage :: Yes ,
1017+ } ,
1018+ ) ,
1019+ Bt :: Sampler { .. } => ( None , WritableStorage :: No ) ,
1020+ Bt :: Texture { .. } => (
1021+ Some ( wgt:: Features :: TEXTURE_BINDING_ARRAY ) ,
1022+ WritableStorage :: No ,
10041023 ) ,
1005- Bt :: Sampler { .. } => ( None , false ) ,
1006- Bt :: Texture { .. } => ( Some ( wgt:: Features :: TEXTURE_BINDING_ARRAY ) , false ) ,
10071024 Bt :: StorageTexture { access, .. } => (
10081025 Some (
10091026 wgt:: Features :: TEXTURE_BINDING_ARRAY
10101027 | wgt:: Features :: STORAGE_RESOURCE_BINDING_ARRAY ,
10111028 ) ,
10121029 match access {
1013- wgt:: StorageTextureAccess :: ReadOnly => false ,
1014- wgt:: StorageTextureAccess :: WriteOnly => true ,
1030+ wgt:: StorageTextureAccess :: ReadOnly => WritableStorage :: No ,
1031+ wgt:: StorageTextureAccess :: WriteOnly => WritableStorage :: Yes ,
10151032 wgt:: StorageTextureAccess :: ReadWrite => {
10161033 required_features |=
10171034 wgt:: Features :: TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES ;
1018- true
1035+ WritableStorage :: Yes
10191036 }
10201037 } ,
10211038 ) ,
@@ -1030,13 +1047,14 @@ impl<A: HalApi> Device<A> {
10301047 error,
10311048 } ) ?;
10321049 }
1033- if entry. visibility . contains ( wgt:: ShaderStages :: VERTEX ) {
1034- required_downlevel_flags |= wgt:: DownlevelFlags :: VERTEX_ACCESSABLE_STORAGE_BUFFERS ;
1035- }
1036- if is_writable_storage && entry. visibility . contains ( wgt:: ShaderStages :: VERTEX ) {
1050+ if writable_storage == WritableStorage :: Yes
1051+ && entry. visibility . contains ( wgt:: ShaderStages :: VERTEX )
1052+ {
10371053 required_features |= wgt:: Features :: VERTEX_WRITABLE_STORAGE ;
10381054 }
1039- if is_writable_storage && entry. visibility . contains ( wgt:: ShaderStages :: FRAGMENT ) {
1055+ if writable_storage == WritableStorage :: Yes
1056+ && entry. visibility . contains ( wgt:: ShaderStages :: FRAGMENT )
1057+ {
10401058 self . require_downlevel_flags ( wgt:: DownlevelFlags :: FRAGMENT_WRITABLE_STORAGE )
10411059 . map_err ( binding_model:: BindGroupLayoutEntryError :: MissingDownlevelFlags )
10421060 . map_err ( |error| binding_model:: CreateBindGroupLayoutError :: Entry {
@@ -1051,13 +1069,6 @@ impl<A: HalApi> Device<A> {
10511069 binding : entry. binding ,
10521070 error,
10531071 } ) ?;
1054-
1055- self . require_downlevel_flags ( required_downlevel_flags)
1056- . map_err ( binding_model:: BindGroupLayoutEntryError :: MissingDownlevelFlags )
1057- . map_err ( |error| binding_model:: CreateBindGroupLayoutError :: Entry {
1058- binding : entry. binding ,
1059- error,
1060- } ) ?;
10611072 }
10621073
10631074 let mut hal_bindings = entry_map. values ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
0 commit comments