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

View file

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