gpu: add type-safety for chaining ExternalTexture.BindingEntry

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-16 20:32:03 -07:00
parent 34ea41e319
commit 1f0b50ba13
3 changed files with 8 additions and 3 deletions

View file

@ -3,11 +3,17 @@ const Sampler = @import("sampler.zig").Sampler;
const TextureView = @import("texture_view.zig").TextureView;
const ChainedStruct = @import("types.zig").ChainedStruct;
const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout;
const ExternalTexture = @import("external_texture.zig").ExternalTexture;
const Impl = @import("interface.zig").Impl;
pub const BindGroup = opaque {
pub const Entry = extern struct {
next_in_chain: ?*const ChainedStruct = null,
pub const NextInChain = extern union {
generic: ?*const ChainedStruct,
external_texture_binding_entry: *const ExternalTexture.BindingEntry,
};
next_in_chain: NextInChain = .{ .generic = null },
binding: u32,
buffer: ?*Buffer = null,
offset: u64 = 0,

View file

@ -3,7 +3,6 @@ const TextureView = @import("texture_view.zig").TextureView;
const Impl = @import("interface.zig").Impl;
pub const ExternalTexture = opaque {
/// TODO: Can be chained in gpu.BindGroup.Entry
pub const BindingEntry = extern struct {
chain: ChainedStruct = .{ .next = null, .s_type = .external_texture_binding_entry },
external_texture: *ExternalTexture,

View file

@ -92,7 +92,7 @@ pub const RenderPassDescriptor = extern struct {
/// 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,
color_attachments: ?[]const RenderPassColorAttachment = null,
depth_stencil_attachment: ?*const RenderPassDepthStencilAttachment = null,