diff --git a/gpu/README.md b/gpu/README.md index de2be81a..9e45b701 100644 --- a/gpu/README.md +++ b/gpu/README.md @@ -168,6 +168,7 @@ And, to initialize data structures with slices in them, the following helpers ar * `BindGroupLayout.Descriptor.init` * `BindGroup.Descriptor.init` * `InstanceDescriptor.init` +* `TogglesDeviceDescriptor.init` ### Typed callbacks diff --git a/gpu/src/bind_group.zig b/gpu/src/bind_group.zig index aeff3818..8d354ec7 100644 --- a/gpu/src/bind_group.zig +++ b/gpu/src/bind_group.zig @@ -52,7 +52,7 @@ pub const BindGroup = opaque { entries: ?[*]const Entry = null, /// Provides a slightly friendlier Zig API to initialize this structure. - pub fn init(v: struct { + pub inline fn init(v: struct { next_in_chain: ?*const ChainedStruct = null, label: ?[*:0]const u8 = null, layout: *BindGroupLayout, diff --git a/gpu/src/bind_group_layout.zig b/gpu/src/bind_group_layout.zig index 8a0ffdda..5ad696de 100644 --- a/gpu/src/bind_group_layout.zig +++ b/gpu/src/bind_group_layout.zig @@ -96,7 +96,7 @@ pub const BindGroupLayout = opaque { entries: ?[*]const Entry = null, /// Provides a slightly friendlier Zig API to initialize this structure. - pub fn init(v: struct { + pub inline fn init(v: struct { next_in_chain: ?*const ChainedStruct = null, label: ?[*:0]const u8 = null, entries: ?[]const Entry = null, diff --git a/gpu/src/dawn.zig b/gpu/src/dawn.zig index 260f5d6a..c1e8979e 100644 --- a/gpu/src/dawn.zig +++ b/gpu/src/dawn.zig @@ -21,7 +21,7 @@ pub const InstanceDescriptor = extern struct { additional_runtime_search_paths: ?[*]const u8 = null, /// Provides a slightly friendlier Zig API to initialize this structure. - pub fn init(v: struct { + pub inline fn init(v: struct { chain: ChainedStruct, additional_runtime_search_paths: ?[]const u8 = null, }) InstanceDescriptor { @@ -42,10 +42,23 @@ pub const TextureInternalUsageDescriptor = extern struct { /// TODO: Can be chained in gpu.Device.Descriptor pub const TogglesDeviceDescriptor = extern struct { chain: ChainedStruct, - // TODO: slice helper force_enabled_toggles_count: u32 = 0, force_enabled_toggles: ?[*]const u8 = null, - // TODO: slice helper force_disabled_toggles_count: u32 = 0, force_disabled_toggles: ?[*]const u8 = null, + + /// Provides a slightly friendlier Zig API to initialize this structure. + pub inline fn init(v: struct { + chain: ChainedStruct, + force_enabled_toggles: ?[]const u8 = null, + force_disabled_toggles: ?[]const u8 = null, + }) TogglesDeviceDescriptor { + return .{ + .chain = v.chain, + .force_enabled_toggles_count = if (v.force_enabled_toggles) |e| @intCast(u32, e.len) else 0, + .force_enabled_toggles = if (v.force_enabled_toggles) |e| e.ptr else null, + .force_disabled_toggles_count = if (v.force_disabled_toggles) |e| @intCast(u32, e.len) else 0, + .force_disabled_toggles = if (v.force_disabled_toggles) |e| e.ptr else null, + }; + } };