gpu: add RenderBundleEncoder.Descriptor.init slice helper

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-16 18:44:50 -07:00
parent c82f640296
commit 05cb8b90c9
2 changed files with 23 additions and 1 deletions

View file

@ -172,6 +172,7 @@ And, to initialize data structures with slices in them, the following helpers ar
* `Device.Descriptor.init`
* `PipelineLayout.Descriptor.init`
* `QuerySet.Descriptor.init`
* `RenderBundleEncoder.Descriptor.init`
### Typed callbacks

View file

@ -11,13 +11,34 @@ pub const RenderBundleEncoder = opaque {
pub const Descriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null,
// TODO: slice helper
color_formats_count: u32 = 0,
color_formats: ?[*]const Texture.Format = null,
depth_stencil_format: Texture.Format = .undef,
sample_count: u32 = 1,
depth_read_only: bool = false,
stencil_read_only: bool = false,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null,
color_formats: ?[]const Texture.Format = null,
depth_stencil_format: Texture.Format = .undef,
sample_count: u32 = 1,
depth_read_only: bool = false,
stencil_read_only: bool = false,
}) Descriptor {
return .{
.next_in_chain = v.next_in_chain,
.label = v.label,
.color_formats_count = if (v.color_formats) |e| @intCast(u32, e.len) else 0,
.color_formats = if (v.color_formats) |e| e.ptr else null,
.depth_stencil_format = v.depth_stencil_format,
.sample_count = v.sample_count,
.depth_read_only = v.depth_read_only,
.stencil_read_only = v.stencil_read_only,
};
}
};
/// Default `instance_count`: 1