diff --git a/gpu/README.md b/gpu/README.md index 20ccdf9f..20d4f4df 100644 --- a/gpu/README.md +++ b/gpu/README.md @@ -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 diff --git a/gpu/src/types.zig b/gpu/src/types.zig index e7c48651..fa0a8a34 100644 --- a/gpu/src/types.zig +++ b/gpu/src/types.zig @@ -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 {