gpu: add Texture.Descriptor.init slice helper
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
05cb8b90c9
commit
4dae765252
2 changed files with 27 additions and 1 deletions
|
|
@ -173,6 +173,7 @@ And, to initialize data structures with slices in them, the following helpers ar
|
|||
* `PipelineLayout.Descriptor.init`
|
||||
* `QuerySet.Descriptor.init`
|
||||
* `RenderBundleEncoder.Descriptor.init`
|
||||
* `Texture.Descriptor.init`
|
||||
|
||||
### Typed callbacks
|
||||
|
||||
|
|
|
|||
|
|
@ -182,9 +182,34 @@ pub const Texture = opaque {
|
|||
format: Format,
|
||||
mip_level_count: u32 = 1,
|
||||
sample_count: u32 = 1,
|
||||
// TODO: slice helper
|
||||
view_format_count: u32 = 0,
|
||||
view_formats: ?[*]const Format = null,
|
||||
|
||||
/// 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,
|
||||
usage: UsageFlags,
|
||||
dimension: Dimension = .dimension_2d,
|
||||
size: Extent3D,
|
||||
format: Format,
|
||||
mip_level_count: u32 = 1,
|
||||
sample_count: u32 = 1,
|
||||
view_formats: ?[]const Format = null,
|
||||
}) Descriptor {
|
||||
return .{
|
||||
.next_in_chain = v.next_in_chain,
|
||||
.label = v.label,
|
||||
.usage = v.usage,
|
||||
.dimension = v.dimension,
|
||||
.size = v.size,
|
||||
.format = v.format,
|
||||
.mip_level_count = v.mip_level_count,
|
||||
.sample_count = v.sample_count,
|
||||
.view_format_count = if (v.view_formats) |e| @intCast(u32, e.len) else 0,
|
||||
.view_formats = if (v.view_formats) |e| e.ptr else null,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
pub inline fn createView(texture: *Texture, descriptor: ?*const TextureView.Descriptor) *TextureView {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue