gpu: add BindGroupLayout.Descriptor slice helper
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
68d5f6fcb1
commit
67d07b0c55
1 changed files with 14 additions and 1 deletions
|
|
@ -92,9 +92,22 @@ pub const BindGroupLayout = 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
|
|
||||||
entry_count: u32 = 0,
|
entry_count: u32 = 0,
|
||||||
entries: ?[*]const Entry = null,
|
entries: ?[*]const Entry = null,
|
||||||
|
|
||||||
|
/// Provides a slightly friendlier Zig API to initialize this structure.
|
||||||
|
pub fn init(v: struct {
|
||||||
|
next_in_chain: ?*const ChainedStruct = null,
|
||||||
|
label: ?[*:0]const u8 = null,
|
||||||
|
entries: ?[]const Entry = null,
|
||||||
|
}) Descriptor {
|
||||||
|
return .{
|
||||||
|
.next_in_chain = v.next_in_chain,
|
||||||
|
.label = v.label,
|
||||||
|
.entry_count = if (v.entries) |e| @intCast(u32, e.len) else 0,
|
||||||
|
.entries = if (v.entries) |e| e.ptr else null,
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn setLabel(bind_group_layout: *BindGroupLayout, label: [*:0]const u8) void {
|
pub inline fn setLabel(bind_group_layout: *BindGroupLayout, label: [*:0]const u8) void {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue