@@ -26,7 +26,7 @@ pub mod shader_io_deductions;
2626#[ derive( Debug ) ]
2727enum ResourceType {
2828 Buffer {
29- size : wgt:: BufferSize ,
29+ minimum_binding_size : wgt:: BufferSize ,
3030 } ,
3131 Texture {
3232 dim : naga:: ImageDimension ,
@@ -594,7 +594,9 @@ pub use wgpu_naga_bridge::map_storage_format_to_naga;
594594impl Resource {
595595 fn check_binding_use ( & self , entry : & BindGroupLayoutEntry ) -> Result < ( ) , BindingError > {
596596 match self . ty {
597- ResourceType :: Buffer { size } => {
597+ ResourceType :: Buffer {
598+ minimum_binding_size,
599+ } => {
598600 let min_size = match entry. ty {
599601 BindingType :: Buffer {
600602 ty,
@@ -627,9 +629,9 @@ impl Resource {
627629 }
628630 } ;
629631 match min_size {
630- Some ( non_zero) if non_zero < size => {
632+ Some ( non_zero) if non_zero < minimum_binding_size => {
631633 return Err ( BindingError :: WrongBufferSize {
632- buffer_size : size ,
634+ buffer_size : minimum_binding_size ,
633635 min_binding_size : non_zero,
634636 } )
635637 }
@@ -797,7 +799,9 @@ impl Resource {
797799 is_reffed_by_sampler_in_entrypoint : bool ,
798800 ) -> Result < BindingType , BindingError > {
799801 Ok ( match self . ty {
800- ResourceType :: Buffer { size } => BindingType :: Buffer {
802+ ResourceType :: Buffer {
803+ minimum_binding_size,
804+ } => BindingType :: Buffer {
801805 ty : match self . class {
802806 naga:: AddressSpace :: Uniform => wgt:: BufferBindingType :: Uniform ,
803807 naga:: AddressSpace :: Storage { access } => wgt:: BufferBindingType :: Storage {
@@ -806,7 +810,7 @@ impl Resource {
806810 _ => return Err ( BindingError :: WrongBufferAddressSpace { space : self . class } ) ,
807811 } ,
808812 has_dynamic_offset : false ,
809- min_binding_size : Some ( size ) ,
813+ min_binding_size : Some ( minimum_binding_size ) ,
810814 } ,
811815 ResourceType :: Sampler { comparison } => BindingType :: Sampler ( if comparison {
812816 wgt:: SamplerBindingType :: Comparison
@@ -1275,7 +1279,8 @@ impl Interface {
12751279 ResourceType :: AccelerationStructure { vertex_return }
12761280 }
12771281 ref other => ResourceType :: Buffer {
1278- size : wgt:: BufferSize :: new ( other. size ( module. to_ctx ( ) ) as u64 ) . unwrap ( ) ,
1282+ minimum_binding_size : wgt:: BufferSize :: new ( other. size ( module. to_ctx ( ) ) as u64 )
1283+ . unwrap ( ) ,
12791284 } ,
12801285 } ;
12811286 let handle = resources. append (
@@ -1448,13 +1453,16 @@ impl Interface {
14481453 match layouts {
14491454 BindingLayoutSource :: Provided ( pipeline_layout) => {
14501455 // update the required binding size for this buffer
1451- if let ResourceType :: Buffer { size } = res. ty {
1456+ if let ResourceType :: Buffer {
1457+ minimum_binding_size,
1458+ } = res. ty
1459+ {
14521460 match shader_binding_sizes. entry ( res. bind ) {
14531461 Entry :: Occupied ( e) => {
1454- * e. into_mut ( ) = size . max ( * e. get ( ) ) ;
1462+ * e. into_mut ( ) = minimum_binding_size . max ( * e. get ( ) ) ;
14551463 }
14561464 Entry :: Vacant ( e) => {
1457- e. insert ( size ) ;
1465+ e. insert ( minimum_binding_size ) ;
14581466 }
14591467 }
14601468 }
0 commit comments