gpu: make ShaderModule.Descriptor.next_in_chain type-safe

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-01 00:52:07 -07:00 committed by Stephen Gutekanst
parent ce8e062249
commit ab71c7fd93
2 changed files with 10 additions and 8 deletions

View file

@ -223,8 +223,4 @@ The following are definitive candidates for helpers we haven't implemented yet:
* `gpu.RenderBundleEncoder.setBindGroup` (slice param)
* `gpu.RenderPassEncoder.executeBundles` (slice param)
* `gpu.RenderPassEncoder.setBindGroup` (slice param)
Descriptors `next_in_chain` extensions could be more type-safe, at least:
* `gpu.ShaderModule.Descriptor` (WGSL/SPIRV divide simplification)
* Others mentioned after the bug we filed on Dawn was fixed (consult dawn.json now)
* Other `next_in_chain` extensions (look at dawn.json after the bug to get this documented was fixed)

View file

@ -5,19 +5,25 @@ const CompilationInfo = @import("types.zig").CompilationInfo;
const Impl = @import("interface.zig").Impl;
pub const ShaderModule = opaque {
pub const Extension = extern union {
generic: ?*const ChainedStruct,
spirv_descriptor: ?*const SPIRVDescriptor,
wgsl_descriptor: ?*const WGSLDescriptor,
};
pub const Descriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null,
next_in_chain: Extension = .{ .generic = null },
label: ?[*:0]const u8 = null,
};
pub const SPIRVDescriptor = extern struct {
chain: ChainedStruct,
chain: ChainedStruct = .{ .next = null, .s_type = .shader_module_spirv_descriptor },
code_size: u32,
code: [*]const u32,
};
pub const WGSLDescriptor = extern struct {
chain: ChainedStruct,
chain: ChainedStruct = .{ .next = null, .s_type = .shader_module_wgsl_descriptor },
source: [*:0]const u8,
};