gpu: add ComputePassDescriptor.init slice helper

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-16 18:51:59 -07:00
parent 4dae765252
commit 6c9c4c71bb
2 changed files with 15 additions and 1 deletions

View file

@ -174,6 +174,7 @@ And, to initialize data structures with slices in them, the following helpers ar
* `QuerySet.Descriptor.init`
* `RenderBundleEncoder.Descriptor.init`
* `Texture.Descriptor.init`
* `ComputePassDescriptor.init`
### Typed callbacks

View file

@ -57,9 +57,22 @@ pub const RequestAdapterOptions = extern struct {
pub const ComputePassDescriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null,
// TODO: slice helper
timestamp_write_count: u32 = 0,
timestamp_writes: ?[*]const ComputePassTimestampWrite = null,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null,
timestamp_writes: ?[]const ComputePassTimestampWrite = null,
}) ComputePassDescriptor {
return .{
.next_in_chain = v.next_in_chain,
.label = v.label,
.timestamp_write_count = if (v.timestamp_writes) |e| @intCast(u32, e.len) else 0,
.timestamp_writes = if (v.timestamp_writes) |e| e.ptr else null,
};
}
};
pub const RenderPassDescriptor = extern struct {