gpu: make Queue.writeBuffer use a slice helper
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
77e96864ea
commit
9ed542bd7e
2 changed files with 17 additions and 7 deletions
|
|
@ -153,6 +153,7 @@ The slice helpers are:
|
||||||
|
|
||||||
* `Adapter.enumerateFeaturesOwned`
|
* `Adapter.enumerateFeaturesOwned`
|
||||||
* `Queue.writeTexture`
|
* `Queue.writeTexture`
|
||||||
|
* `Queue.writeBuffer`
|
||||||
|
|
||||||
### Typed callbacks
|
### Typed callbacks
|
||||||
|
|
||||||
|
|
@ -219,7 +220,6 @@ The following are definitive candidates for helpers we haven't implemented yet:
|
||||||
* `gpu.CommandEncoder.writeBuffer` (slices)
|
* `gpu.CommandEncoder.writeBuffer` (slices)
|
||||||
* `gpu.ComputePassEncoder.setBindGroup` (slice param)
|
* `gpu.ComputePassEncoder.setBindGroup` (slice param)
|
||||||
* `gpu.Device.enumerateFeatures` (owned slice)
|
* `gpu.Device.enumerateFeatures` (owned slice)
|
||||||
* `gpu.Queue.writeBuffer` (slices)
|
|
||||||
* `gpu.RenderBundleEncoder.setBindGroup` (slice param)
|
* `gpu.RenderBundleEncoder.setBindGroup` (slice param)
|
||||||
* `gpu.RenderPassEncoder.executeBundles` (slice param)
|
* `gpu.RenderPassEncoder.executeBundles` (slice param)
|
||||||
* `gpu.RenderPassEncoder.setBindGroup` (slice param)
|
* `gpu.RenderPassEncoder.setBindGroup` (slice param)
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,19 @@ pub const Queue = opaque {
|
||||||
Impl.queueSubmit(queue, @intCast(u32, commands.len), commands.ptr);
|
Impl.queueSubmit(queue, @intCast(u32, commands.len), commands.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn writeBuffer(queue: *Queue, buffer: *Buffer, buffer_offset: u64, data: *anyopaque, size: usize) void {
|
pub inline fn writeBuffer(
|
||||||
Impl.queueWriteBuffer(queue, buffer, buffer_offset, data, size);
|
queue: *Queue,
|
||||||
|
buffer: *Buffer,
|
||||||
|
buffer_offset_bytes: u64,
|
||||||
|
data_slice: anytype,
|
||||||
|
) void {
|
||||||
|
Impl.queueWriteBuffer(
|
||||||
|
queue,
|
||||||
|
buffer,
|
||||||
|
buffer_offset_bytes,
|
||||||
|
@ptrCast(*const anyopaque, data_slice.ptr),
|
||||||
|
@intCast(u64, data_slice.len) * @sizeOf(std.meta.Elem(@TypeOf(data_slice))),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn writeTexture(
|
pub inline fn writeTexture(
|
||||||
|
|
@ -62,14 +73,13 @@ pub const Queue = opaque {
|
||||||
destination: *const ImageCopyTexture,
|
destination: *const ImageCopyTexture,
|
||||||
data_layout: *const Texture.DataLayout,
|
data_layout: *const Texture.DataLayout,
|
||||||
write_size: *const Extent3D,
|
write_size: *const Extent3D,
|
||||||
comptime T: type,
|
data_slice: anytype,
|
||||||
data: []const T,
|
|
||||||
) void {
|
) void {
|
||||||
Impl.queueWriteTexture(
|
Impl.queueWriteTexture(
|
||||||
queue,
|
queue,
|
||||||
destination,
|
destination,
|
||||||
@ptrCast(*const anyopaque, data.ptr),
|
@ptrCast(*const anyopaque, data_slice.ptr),
|
||||||
@intCast(usize, data.len) * @sizeOf(std.meta.Elem(@TypeOf(data))),
|
@intCast(usize, data_slice.len) * @sizeOf(std.meta.Elem(@TypeOf(data_slice))),
|
||||||
data_layout,
|
data_layout,
|
||||||
write_size,
|
write_size,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue