Skip to content

Commit 043218a

Browse files
authored
Merge branch 'zig-gamedev:main' into main
2 parents 43562d7 + dbb3e60 commit 043218a

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/wgpu.zig

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,8 +1432,8 @@ pub const Buffer = *opaque {
14321432
}
14331433
extern fn wgpuBufferGetConstMappedRange(buffer: Buffer, offset: usize, size: usize) ?*const anyopaque;
14341434

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).
14371437
pub fn getMappedRange(buffer: Buffer, comptime T: type, offset: usize, len: usize) ?[]T {
14381438
if (len == 0) return null;
14391439
const ptr = wgpuBufferGetMappedRange(buffer, offset, @sizeOf(T) * len);
@@ -1442,9 +1442,23 @@ pub const Buffer = *opaque {
14421442
}
14431443
extern fn wgpuBufferGetMappedRange(buffer: Buffer, offset: usize, size: usize) ?*anyopaque;
14441444

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).
14481462
pub fn mapAsync(
14491463
buffer: Buffer,
14501464
mode: MapMode,

0 commit comments

Comments
 (0)