diff --git a/gpu/README.md b/gpu/README.md index e0910de3..de2be81a 100644 --- a/gpu/README.md +++ b/gpu/README.md @@ -167,6 +167,7 @@ And, to initialize data structures with slices in them, the following helpers ar * `BindGroupLayout.Descriptor.init` * `BindGroup.Descriptor.init` +* `InstanceDescriptor.init` ### Typed callbacks diff --git a/gpu/src/bind_group.zig b/gpu/src/bind_group.zig index a1bfc6c8..aeff3818 100644 --- a/gpu/src/bind_group.zig +++ b/gpu/src/bind_group.zig @@ -48,7 +48,6 @@ pub const BindGroup = opaque { next_in_chain: ?*const ChainedStruct = null, label: ?[*:0]const u8 = null, layout: *BindGroupLayout, - // TODO: slice helper entry_count: u32 = 0, entries: ?[*]const Entry = null, diff --git a/gpu/src/dawn.zig b/gpu/src/dawn.zig index 01ed55c9..260f5d6a 100644 --- a/gpu/src/dawn.zig +++ b/gpu/src/dawn.zig @@ -17,9 +17,20 @@ pub const EncoderInternalUsageDescriptor = extern struct { /// TODO: Can be chained in gpu.Instance.Descriptor pub const InstanceDescriptor = extern struct { chain: ChainedStruct, - // TODO: slice helper additional_runtime_search_paths_count: u32 = 0, additional_runtime_search_paths: ?[*]const u8 = null, + + /// Provides a slightly friendlier Zig API to initialize this structure. + pub fn init(v: struct { + chain: ChainedStruct, + additional_runtime_search_paths: ?[]const u8 = null, + }) InstanceDescriptor { + return .{ + .chain = v.chain, + .additional_runtime_search_paths_count = if (v.additional_runtime_search_paths) |e| @intCast(u32, e.len) else 0, + .additional_runtime_search_paths = if (v.additional_runtime_search_paths) |e| e.ptr else null, + }; + } }; /// TODO: Can be chained in gpu.Texture.Descriptor