@@ -360,11 +360,21 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
360
360
}
361
361
362
362
fn zombie_convert_ptr_to_u ( & self , def : Word ) {
363
- self . zombie ( def, "cannot convert pointers to integers" ) ;
363
+ if !self
364
+ . builder
365
+ . has_capability ( Capability :: PhysicalStorageBufferAddresses )
366
+ {
367
+ self . zombie ( def, "cannot convert pointers to integers without OpCapability PhysicalStorageBufferAddresses" ) ;
368
+ }
364
369
}
365
370
366
371
fn zombie_convert_u_to_ptr ( & self , def : Word ) {
367
- self . zombie ( def, "cannot convert integers to pointers" ) ;
372
+ if !self
373
+ . builder
374
+ . has_capability ( Capability :: PhysicalStorageBufferAddresses )
375
+ {
376
+ self . zombie ( def, "cannot convert integers to pointers without OpCapability PhysicalStorageBufferAddresses" ) ;
377
+ }
368
378
}
369
379
370
380
fn zombie_ptr_equal ( & self , def : Word , inst : & str ) {
@@ -1752,20 +1762,23 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
1752
1762
}
1753
1763
1754
1764
fn inttoptr ( & mut self , val : Self :: Value , dest_ty : Self :: Type ) -> Self :: Value {
1755
- match self . lookup_type ( dest_ty) {
1756
- SpirvType :: Pointer { .. } => ( ) ,
1765
+ let result_ty = match self . lookup_type ( dest_ty) {
1766
+ SpirvType :: Pointer { pointee, .. } => self . type_ptr_to_with_storage_class (
1767
+ pointee,
1768
+ StorageClassKind :: Explicit ( StorageClass :: PhysicalStorageBuffer ) ,
1769
+ ) ,
1757
1770
other => self . fatal ( format ! (
1758
1771
"inttoptr called on non-pointer dest type: {other:?}"
1759
1772
) ) ,
1760
- }
1761
- if val. ty == dest_ty {
1773
+ } ;
1774
+ if val. ty == result_ty {
1762
1775
val
1763
1776
} else {
1764
1777
let result = self
1765
1778
. emit ( )
1766
- . convert_u_to_ptr ( dest_ty , None , val. def ( self ) )
1779
+ . convert_u_to_ptr ( result_ty , None , val. def ( self ) )
1767
1780
. unwrap ( )
1768
- . with_type ( dest_ty ) ;
1781
+ . with_type ( result_ty ) ;
1769
1782
self . zombie_convert_u_to_ptr ( result. def ( self ) ) ;
1770
1783
result
1771
1784
}
0 commit comments