gpu: add type-safety for chaining dawn.TextureInternalUsageDescriptor

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-16 20:45:24 -07:00
parent e4ee5e221b
commit 8462427524
2 changed files with 8 additions and 3 deletions

View file

@ -32,7 +32,6 @@ pub const InstanceDescriptor = extern struct {
} }
}; };
/// TODO: Can be chained in gpu.Texture.Descriptor
pub const TextureInternalUsageDescriptor = extern struct { pub const TextureInternalUsageDescriptor = extern struct {
chain: ChainedStruct = .{ .next = null, .s_type = .dawn_texture_internal_usage_descriptor }, chain: ChainedStruct = .{ .next = null, .s_type = .dawn_texture_internal_usage_descriptor },
internal_usage: Texture.UsageFlags = Texture.UsageFlags.none, internal_usage: Texture.UsageFlags = Texture.UsageFlags.none,

View file

@ -4,6 +4,7 @@ const TextureView = @import("texture_view.zig").TextureView;
const Extent3D = @import("types.zig").Extent3D; const Extent3D = @import("types.zig").Extent3D;
const Impl = @import("interface.zig").Impl; const Impl = @import("interface.zig").Impl;
const types = @import("types.zig"); const types = @import("types.zig");
const dawn = @import("dawn.zig");
pub const Texture = opaque { pub const Texture = opaque {
pub const Aspect = enum(u32) { pub const Aspect = enum(u32) {
@ -174,7 +175,12 @@ pub const Texture = opaque {
}; };
pub const Descriptor = extern struct { pub const Descriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null, pub const NextInChain = extern union {
generic: ?*const ChainedStruct,
dawn_texture_internal_usage_descriptor: *const dawn.TextureInternalUsageDescriptor,
};
next_in_chain: NextInChain = .{ .generic = null },
label: ?[*:0]const u8 = null, label: ?[*:0]const u8 = null,
usage: UsageFlags, usage: UsageFlags,
dimension: Dimension = .dimension_2d, dimension: Dimension = .dimension_2d,
@ -187,7 +193,7 @@ pub const Texture = opaque {
/// Provides a slightly friendlier Zig API to initialize this structure. /// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct { pub inline fn init(v: struct {
next_in_chain: ?*const ChainedStruct = null, next_in_chain: NextInChain = .{ .generic = null },
label: ?[*:0]const u8 = null, label: ?[*:0]const u8 = null,
usage: UsageFlags, usage: UsageFlags,
dimension: Dimension = .dimension_2d, dimension: Dimension = .dimension_2d,