gpu: add VertexBufferLayout.init slice helper
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
e95481db21
commit
8cd2fb3f19
2 changed files with 17 additions and 3 deletions
|
|
@ -177,6 +177,7 @@ And, to initialize data structures with slices in them, the following helpers ar
|
||||||
* `ComputePassDescriptor.init`
|
* `ComputePassDescriptor.init`
|
||||||
* `RenderPassDescriptor.init`
|
* `RenderPassDescriptor.init`
|
||||||
* `ProgrammableStageDescriptor.init`
|
* `ProgrammableStageDescriptor.init`
|
||||||
|
* `VertexBufferLayout.init`
|
||||||
|
|
||||||
### Typed callbacks
|
### Typed callbacks
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ pub const RenderPassDescriptor = extern struct {
|
||||||
depth_stencil_attachment: ?*const RenderPassDepthStencilAttachment = null,
|
depth_stencil_attachment: ?*const RenderPassDepthStencilAttachment = null,
|
||||||
occlusion_query_set: ?*QuerySet = null,
|
occlusion_query_set: ?*QuerySet = null,
|
||||||
timestamp_writes: ?[]const RenderPassTimestampWrite = null,
|
timestamp_writes: ?[]const RenderPassTimestampWrite = null,
|
||||||
}) ComputePassDescriptor {
|
}) RenderPassDescriptor {
|
||||||
return .{
|
return .{
|
||||||
.next_in_chain = v.next_in_chain,
|
.next_in_chain = v.next_in_chain,
|
||||||
.label = v.label,
|
.label = v.label,
|
||||||
|
|
@ -664,7 +664,7 @@ pub const ProgrammableStageDescriptor = extern struct {
|
||||||
module: *ShaderModule,
|
module: *ShaderModule,
|
||||||
entry_point: [*:0]const u8,
|
entry_point: [*:0]const u8,
|
||||||
constants: ?[]const ConstantEntry = null,
|
constants: ?[]const ConstantEntry = null,
|
||||||
}) ComputePassDescriptor {
|
}) ProgrammableStageDescriptor {
|
||||||
return .{
|
return .{
|
||||||
.next_in_chain = v.next_in_chain,
|
.next_in_chain = v.next_in_chain,
|
||||||
.module = v.module,
|
.module = v.module,
|
||||||
|
|
@ -703,9 +703,22 @@ pub const SupportedLimits = extern struct {
|
||||||
pub const VertexBufferLayout = extern struct {
|
pub const VertexBufferLayout = extern struct {
|
||||||
array_stride: u64,
|
array_stride: u64,
|
||||||
step_mode: VertexStepMode = .vertex,
|
step_mode: VertexStepMode = .vertex,
|
||||||
// TODO: slice helper
|
|
||||||
attribute_count: u32,
|
attribute_count: u32,
|
||||||
attributes: ?[*]const VertexAttribute = null,
|
attributes: ?[*]const VertexAttribute = null,
|
||||||
|
|
||||||
|
/// Provides a slightly friendlier Zig API to initialize this structure.
|
||||||
|
pub inline fn init(v: struct {
|
||||||
|
array_stride: u64,
|
||||||
|
step_mode: VertexStepMode = .vertex,
|
||||||
|
attributes: ?[]const VertexAttribute = null,
|
||||||
|
}) ProgrammableStageDescriptor {
|
||||||
|
return .{
|
||||||
|
.array_stride = v.array_stride,
|
||||||
|
.step_mode = v.step_mode,
|
||||||
|
.attribute_count = if (v.attributes) |e| @intCast(u32, e.len) else 0,
|
||||||
|
.attributes = if (v.attributes) |e| e.ptr else null,
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ColorTargetState = extern struct {
|
pub const ColorTargetState = extern struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue