gpu: internalize CommandBuffer types

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-07-29 23:43:47 -07:00 committed by Stephen Gutekanst
parent 9ba109f659
commit 99ff21e992
3 changed files with 9 additions and 10 deletions

View file

@ -2,6 +2,11 @@ const ChainedStruct = @import("types.zig").ChainedStruct;
const Impl = @import("interface.zig").Impl;
pub const CommandBuffer = opaque {
pub const Descriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null,
};
pub inline fn setLabel(command_buffer: *CommandBuffer, label: [*:0]const u8) void {
Impl.commandBufferSetLabel(command_buffer, label);
}
@ -14,8 +19,3 @@ pub const CommandBuffer = opaque {
Impl.commandBufferRelease(command_buffer);
}
};
pub const CommandBufferDescriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null,
};

View file

@ -1,7 +1,6 @@
const ComputePassEncoder = @import("compute_pass_encoder.zig").ComputePassEncoder;
const RenderPassEncoder = @import("render_pass_encoder.zig").RenderPassEncoder;
const CommandBuffer = @import("command_buffer.zig").CommandBuffer;
const CommandBufferDescriptor = @import("command_buffer.zig").CommandBufferDescriptor;
const Buffer = @import("buffer.zig").Buffer;
const QuerySet = @import("query_set.zig").QuerySet;
const RenderPassDescriptor = @import("main.zig").RenderPassDescriptor;
@ -49,7 +48,7 @@ pub const CommandEncoder = opaque {
Impl.commandEncoderCopyTextureToTextureInternal(command_encoder, source, destination, copy_size);
}
pub inline fn finish(command_encoder: *CommandEncoder, descriptor: ?*const CommandBufferDescriptor) *CommandBuffer {
pub inline fn finish(command_encoder: *CommandEncoder, descriptor: ?*const CommandBuffer.Descriptor) *CommandBuffer {
return Impl.commandEncoderFinish(command_encoder, descriptor);
}

View file

@ -52,7 +52,7 @@ pub fn Interface(comptime T: type) type {
assertDecl(T, "commandEncoderCopyTextureToBuffer", fn (command_encoder: *gpu.CommandEncoder, source: *const gpu.ImageCopyTexture, destination: *const gpu.ImageCopyBuffer, copy_size: *const gpu.Extent3D) callconv(.Inline) void);
assertDecl(T, "commandEncoderCopyTextureToTexture", fn (command_encoder: *gpu.CommandEncoder, source: *const gpu.ImageCopyTexture, destination: *const gpu.ImageCopyTexture, copy_size: *const gpu.Extent3D) callconv(.Inline) void);
assertDecl(T, "commandEncoderCopyTextureToTextureInternal", fn (command_encoder: *gpu.CommandEncoder, source: *const gpu.ImageCopyTexture, destination: *const gpu.ImageCopyTexture, copy_size: *const gpu.Extent3D) callconv(.Inline) void);
assertDecl(T, "commandEncoderFinish", fn (command_encoder: *gpu.CommandEncoder, descriptor: ?*const gpu.CommandBufferDescriptor) callconv(.Inline) *gpu.CommandBuffer);
assertDecl(T, "commandEncoderFinish", fn (command_encoder: *gpu.CommandEncoder, descriptor: ?*const gpu.CommandBuffer.Descriptor) callconv(.Inline) *gpu.CommandBuffer);
assertDecl(T, "commandEncoderInjectValidationError", fn (command_encoder: *gpu.CommandEncoder, message: [*:0]const u8) callconv(.Inline) void);
assertDecl(T, "commandEncoderInsertDebugMarker", fn (command_encoder: *gpu.CommandEncoder, marker_label: [*:0]const u8) callconv(.Inline) void);
assertDecl(T, "commandEncoderPopDebugGroup", fn (command_encoder: *gpu.CommandEncoder) callconv(.Inline) void);
@ -414,7 +414,7 @@ pub fn Export(comptime T: type) type {
}
// WGPU_EXPORT WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor /* nullable */);
export fn wgpuCommandEncoderFinish(command_encoder: *gpu.CommandEncoder, descriptor: ?*const gpu.CommandBufferDescriptor) *gpu.CommandBuffer {
export fn wgpuCommandEncoderFinish(command_encoder: *gpu.CommandEncoder, descriptor: ?*const gpu.CommandBuffer.Descriptor) *gpu.CommandBuffer {
return T.commandEncoderFinish(command_encoder, descriptor);
}
@ -1450,7 +1450,7 @@ pub const StubInterface = Interface(struct {
unreachable;
}
pub inline fn commandEncoderFinish(command_encoder: *gpu.CommandEncoder, descriptor: ?*const gpu.CommandBufferDescriptor) *gpu.CommandBuffer {
pub inline fn commandEncoderFinish(command_encoder: *gpu.CommandEncoder, descriptor: ?*const gpu.CommandBuffer.Descriptor) *gpu.CommandBuffer {
_ = command_encoder;
_ = descriptor;
unreachable;