gpu: add RenderBundleEncoder.Descriptor.init slice helper
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
c82f640296
commit
05cb8b90c9
2 changed files with 23 additions and 1 deletions
|
|
@ -172,6 +172,7 @@ And, to initialize data structures with slices in them, the following helpers ar
|
||||||
* `Device.Descriptor.init`
|
* `Device.Descriptor.init`
|
||||||
* `PipelineLayout.Descriptor.init`
|
* `PipelineLayout.Descriptor.init`
|
||||||
* `QuerySet.Descriptor.init`
|
* `QuerySet.Descriptor.init`
|
||||||
|
* `RenderBundleEncoder.Descriptor.init`
|
||||||
|
|
||||||
### Typed callbacks
|
### Typed callbacks
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,34 @@ pub const RenderBundleEncoder = opaque {
|
||||||
pub const Descriptor = extern struct {
|
pub const Descriptor = extern struct {
|
||||||
next_in_chain: ?*const ChainedStruct = null,
|
next_in_chain: ?*const ChainedStruct = null,
|
||||||
label: ?[*:0]const u8 = null,
|
label: ?[*:0]const u8 = null,
|
||||||
// TODO: slice helper
|
|
||||||
color_formats_count: u32 = 0,
|
color_formats_count: u32 = 0,
|
||||||
color_formats: ?[*]const Texture.Format = null,
|
color_formats: ?[*]const Texture.Format = null,
|
||||||
depth_stencil_format: Texture.Format = .undef,
|
depth_stencil_format: Texture.Format = .undef,
|
||||||
sample_count: u32 = 1,
|
sample_count: u32 = 1,
|
||||||
depth_read_only: bool = false,
|
depth_read_only: bool = false,
|
||||||
stencil_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
|
/// Default `instance_count`: 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue