From 99ff21e992bc337e1ca8acdbc1b001f8f2f298ca Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 29 Jul 2022 23:43:47 -0700 Subject: [PATCH] gpu: internalize CommandBuffer types Signed-off-by: Stephen Gutekanst --- gpu/src/command_buffer.zig | 10 +++++----- gpu/src/command_encoder.zig | 3 +-- gpu/src/interface.zig | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/gpu/src/command_buffer.zig b/gpu/src/command_buffer.zig index ccdf1f6c..6bd3fc48 100644 --- a/gpu/src/command_buffer.zig +++ b/gpu/src/command_buffer.zig @@ -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, -}; diff --git a/gpu/src/command_encoder.zig b/gpu/src/command_encoder.zig index a06f1b50..c5257c7a 100644 --- a/gpu/src/command_encoder.zig +++ b/gpu/src/command_encoder.zig @@ -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); } diff --git a/gpu/src/interface.zig b/gpu/src/interface.zig index c66090e5..b006e451 100644 --- a/gpu/src/interface.zig +++ b/gpu/src/interface.zig @@ -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;