gpu: add VertexState.init slice helper
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
8cd2fb3f19
commit
772eb9b89d
2 changed files with 22 additions and 4 deletions
|
|
@ -178,6 +178,7 @@ And, to initialize data structures with slices in them, the following helpers ar
|
|||
* `RenderPassDescriptor.init`
|
||||
* `ProgrammableStageDescriptor.init`
|
||||
* `VertexBufferLayout.init`
|
||||
* `VertexState.init`
|
||||
|
||||
### Typed callbacks
|
||||
|
||||
|
|
|
|||
|
|
@ -669,7 +669,7 @@ pub const ProgrammableStageDescriptor = extern struct {
|
|||
.next_in_chain = v.next_in_chain,
|
||||
.module = v.module,
|
||||
.entry_point = v.entry_point,
|
||||
.constant_count = if (v.timestamp_writes) |e| @intCast(u32, e.len) else 0,
|
||||
.constant_count = if (v.constants) |e| @intCast(u32, e.len) else 0,
|
||||
.constants = if (v.constants) |e| e.ptr else null,
|
||||
};
|
||||
}
|
||||
|
|
@ -711,7 +711,7 @@ pub const VertexBufferLayout = extern struct {
|
|||
array_stride: u64,
|
||||
step_mode: VertexStepMode = .vertex,
|
||||
attributes: ?[]const VertexAttribute = null,
|
||||
}) ProgrammableStageDescriptor {
|
||||
}) VertexBufferLayout {
|
||||
return .{
|
||||
.array_stride = v.array_stride,
|
||||
.step_mode = v.step_mode,
|
||||
|
|
@ -732,12 +732,29 @@ pub const VertexState = extern struct {
|
|||
next_in_chain: ?*const ChainedStruct = null,
|
||||
module: *ShaderModule,
|
||||
entry_point: [*:0]const u8,
|
||||
// TODO: slice helper
|
||||
constant_count: u32 = 0,
|
||||
constants: ?[*]const ConstantEntry = null,
|
||||
// TODO: slice helper
|
||||
buffer_count: u32 = 0,
|
||||
buffers: ?[*]const VertexBufferLayout = null,
|
||||
|
||||
/// Provides a slightly friendlier Zig API to initialize this structure.
|
||||
pub inline fn init(v: struct {
|
||||
next_in_chain: ?*const ChainedStruct = null,
|
||||
module: *ShaderModule,
|
||||
entry_point: [*:0]const u8,
|
||||
constants: ?[]const ConstantEntry = null,
|
||||
buffers: ?[]const VertexBufferLayout = null,
|
||||
}) VertexState {
|
||||
return .{
|
||||
.next_in_chain = v.next_in_chain,
|
||||
.module = v.module,
|
||||
.entry_point = v.entry_point,
|
||||
.constant_count = if (v.constants) |e| @intCast(u32, e.len) else 0,
|
||||
.constants = if (v.constants) |e| e.ptr else null,
|
||||
.buffer_count = if (v.buffers) |e| @intCast(u32, e.len) else 0,
|
||||
.buffers = if (v.buffers) |e| e.ptr else null,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
pub const FragmentState = extern struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue