From 801d7727524c2c70bf0f4bc4b2229df1848302ea Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Tue, 16 Aug 2022 20:49:59 -0700 Subject: [PATCH] gpu: add type-safety for chaining dawn.InstanceDescriptor Signed-off-by: Stephen Gutekanst --- gpu/src/dawn.zig | 1 - gpu/src/instance.zig | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gpu/src/dawn.zig b/gpu/src/dawn.zig index e858e201..33438109 100644 --- a/gpu/src/dawn.zig +++ b/gpu/src/dawn.zig @@ -13,7 +13,6 @@ pub const EncoderInternalUsageDescriptor = extern struct { use_internal_usages: bool = false, }; -/// TODO: Can be chained in gpu.Instance.Descriptor pub const InstanceDescriptor = extern struct { chain: ChainedStruct = .{ .next = null, .s_type = .dawn_instance_descriptor }, additional_runtime_search_paths_count: u32 = 0, diff --git a/gpu/src/instance.zig b/gpu/src/instance.zig index f45d4b9b..c0d9dcd8 100644 --- a/gpu/src/instance.zig +++ b/gpu/src/instance.zig @@ -5,10 +5,16 @@ const Adapter = @import("adapter.zig").Adapter; const RequestAdapterOptions = @import("types.zig").RequestAdapterOptions; const RequestAdapterCallback = @import("callbacks.zig").RequestAdapterCallback; const Impl = @import("interface.zig").Impl; +const dawn = @import("dawn.zig"); pub const Instance = opaque { pub const Descriptor = extern struct { - next_in_chain: ?*const ChainedStruct = null, + pub const NextInChain = extern union { + generic: ?*const ChainedStruct, + dawn_instance_descriptor: *const dawn.InstanceDescriptor, + }; + + next_in_chain: NextInChain = .{ .generic = null }, }; pub inline fn createSurface(instance: *Instance, descriptor: *const Surface.Descriptor) *Surface {