@@ -1432,8 +1432,8 @@ pub const Buffer = *opaque {
1432
1432
}
1433
1433
extern fn wgpuBufferGetConstMappedRange (buffer : Buffer , offset : usize , size : usize ) ? * const anyopaque ;
1434
1434
1435
- // `offset` has to be a multiple of 8 (otherwise `null` will be returned).
1436
- // `@sizeOf(T) * len` has to be a multiple of 4 (otherwise `null` will be returned).
1435
+ // `offset` - in bytes, has to be a multiple of 8 (otherwise `null` will be returned).
1436
+ // `len` - length of slice to return, in elements of type T, ` @sizeOf(T) * len` has to be a multiple of 4 (otherwise `null` will be returned).
1437
1437
pub fn getMappedRange (buffer : Buffer , comptime T : type , offset : usize , len : usize ) ? []T {
1438
1438
if (len == 0 ) return null ;
1439
1439
const ptr = wgpuBufferGetMappedRange (buffer , offset , @sizeOf (T ) * len );
@@ -1442,9 +1442,23 @@ pub const Buffer = *opaque {
1442
1442
}
1443
1443
extern fn wgpuBufferGetMappedRange (buffer : Buffer , offset : usize , size : usize ) ? * anyopaque ;
1444
1444
1445
- // `offset` has to be a multiple of 8 (Dawn's validation layer will warn).
1446
- // `size` has to be a multiple of 4 (Dawn's validation layer will warn).
1447
- // `size == 0` will map entire range (from 'offset' to the end of the buffer).
1445
+ pub fn getMapState (buffer : Buffer ) BufferMapState {
1446
+ return wgpuBufferGetMapState (buffer );
1447
+ }
1448
+ extern fn wgpuBufferGetMapState (buffer : Buffer ) BufferMapState ;
1449
+
1450
+ pub fn getSize (buffer : Buffer ) usize {
1451
+ return @intCast (wgpuBufferGetSize (buffer ));
1452
+ }
1453
+ extern fn wgpuBufferGetSize (buffer : Buffer ) u64 ;
1454
+
1455
+ pub fn getUsage (buffer : Buffer ) BufferUsage {
1456
+ return wgpuBufferGetUsage (buffer );
1457
+ }
1458
+ extern fn wgpuBufferGetUsage (buffer : Buffer ) BufferUsage ;
1459
+
1460
+ // `offset` - in bytes, has to be a multiple of 8 (Dawn's validation layer will warn).
1461
+ // `size` - size of buffer to map in bytes, has to be a multiple of 4 (Dawn's validation layer will warn).
1448
1462
pub fn mapAsync (
1449
1463
buffer : Buffer ,
1450
1464
mode : MapMode ,
0 commit comments