gpu: make ConstantEntry & ColorTargetState C ABI compatible

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-03-11 19:36:21 -07:00 committed by Stephen Gutekanst
parent 36afd39945
commit f5e6976937
2 changed files with 12 additions and 10 deletions

View file

@ -411,10 +411,10 @@ inline fn convertRenderPipelineDescriptor(
.nextInChain = null, .nextInChain = null,
.module = @ptrCast(c.WGPUShaderModule, d.fragment.module.ptr), .module = @ptrCast(c.WGPUShaderModule, d.fragment.module.ptr),
.entryPoint = d.vertex.entry_point, .entryPoint = d.vertex.entry_point,
.constantCount = 0, // d.fragment.constants.len, .constantCount = @intCast(u32, d.fragment.constants.len),
.constants = null, // TODO: need to convert entire list to WGPUConstantEntry .constants = @ptrCast(*const c.WGPUConstantEntry, &d.fragment.constants[0]),
.targetCount = 0, // d.fragment.targets.len, .targetCount = @intCast(u32, d.fragment.targets.len),
.targets = null, // TODO: need to convert entire list to WGPUColorTargetState .targets = @ptrCast(*const c.WGPUColorTargetState, &d.fragment.targets[0]),
}; };
return c.WGPURenderPipelineDescriptor{ return c.WGPURenderPipelineDescriptor{
@ -425,10 +425,10 @@ inline fn convertRenderPipelineDescriptor(
.nextInChain = null, .nextInChain = null,
.module = @ptrCast(c.WGPUShaderModule, d.vertex.module.ptr), .module = @ptrCast(c.WGPUShaderModule, d.vertex.module.ptr),
.entryPoint = d.vertex.entry_point, .entryPoint = d.vertex.entry_point,
.constantCount = 0, // d.vertex.constants.len, .constantCount = @intCast(u32, d.vertex.constants.len),
.constants = null, // TODO: need to convert entire list to WGPUConstantEntry .constants = @ptrCast(*const c.WGPUConstantEntry, &d.vertex.constants[0]),
.bufferCount = 0, // d.vertex.buffers.len .bufferCount = @intCast(u32, d.vertex.buffers.len),
.buffers = null, // TODO: need to convert entire list to WGPUVertexBufferLayout .buffers = @ptrCast(*const c.WGPUVertexBufferLayout, &d.vertex.buffers[0]),
}, },
.primitive = c.WGPUPrimitiveState{ .primitive = c.WGPUPrimitiveState{
.nextInChain = null, .nextInChain = null,

View file

@ -69,7 +69,8 @@ pub const DepthStencilState = struct {
}; };
// TODO: how does this map to browser API? // TODO: how does this map to browser API?
pub const ConstantEntry = struct { pub const ConstantEntry = extern struct {
reserved: ?*anyopaque = null,
key: [*:0]const u8, key: [*:0]const u8,
value: f64, value: f64,
}; };
@ -129,7 +130,8 @@ pub const FragmentState = struct {
targets: []const ColorTargetState, targets: []const ColorTargetState,
}; };
pub const ColorTargetState = struct { pub const ColorTargetState = extern struct {
reserved: ?*anyopaque = null,
format: Texture.Format, format: Texture.Format,
blend: *const BlendState, blend: *const BlendState,
write_mask: ColorWriteMask, write_mask: ColorWriteMask,