From 7fa40757145eecd928ec67f7061ab9d776e200d0 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Tue, 16 Aug 2022 20:40:24 -0700 Subject: [PATCH] gpu: add type-safety for chaining dawn.TogglesDeviceDescriptor Signed-off-by: Stephen Gutekanst --- gpu/src/device.zig | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gpu/src/device.zig b/gpu/src/device.zig index 782a951f..c7bd3bfc 100644 --- a/gpu/src/device.zig +++ b/gpu/src/device.zig @@ -28,6 +28,7 @@ const ErrorCallback = @import("callbacks.zig").ErrorCallback; const CreateComputePipelineAsyncCallback = @import("callbacks.zig").CreateComputePipelineAsyncCallback; const CreateRenderPipelineAsyncCallback = @import("callbacks.zig").CreateRenderPipelineAsyncCallback; const Impl = @import("interface.zig").Impl; +const dawn = @import("dawn.zig"); pub const Device = opaque { pub const LostCallback = fn ( @@ -42,7 +43,12 @@ pub const Device = opaque { }; pub const Descriptor = extern struct { - next_in_chain: ?*const ChainedStruct = null, + pub const NextInChain = extern union { + generic: ?*const ChainedStruct, + dawn_toggles_device_descriptor: *const dawn.TogglesDeviceDescriptor, + }; + + next_in_chain: NextInChain = .{ .generic = null }, label: ?[*:0]const u8 = null, required_features_count: u32 = 0, required_features: ?[*]const FeatureName = null, @@ -51,7 +57,7 @@ pub const Device = opaque { /// Provides a slightly friendlier Zig API to initialize this structure. pub inline fn init(v: struct { - next_in_chain: ?*const ChainedStruct = null, + next_in_chain: NextInChain = .{ .generic = null }, label: ?[*:0]const u8 = null, required_features: ?[]const FeatureName = null, required_limits: ?*const RequiredLimits = null,