From 836c46cc6c3535763a4f33c448daa71911007ccd Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 29 Jul 2022 23:53:36 -0700 Subject: [PATCH] gpu: internalize RenderBundleEncoder types Signed-off-by: Stephen Gutekanst --- gpu/src/device.zig | 3 +-- gpu/src/interface.zig | 6 +++--- gpu/src/render_bundle_encoder.zig | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/gpu/src/device.zig b/gpu/src/device.zig index 25491e8c..c9a4f5df 100644 --- a/gpu/src/device.zig +++ b/gpu/src/device.zig @@ -8,7 +8,6 @@ const ExternalTexture = @import("external_texture.zig").ExternalTexture; const PipelineLayout = @import("pipeline_layout.zig").PipelineLayout; const QuerySet = @import("query_set.zig").QuerySet; const RenderBundleEncoder = @import("render_bundle_encoder.zig").RenderBundleEncoder; -const RenderBundleEncoderDescriptor = @import("render_bundle_encoder.zig").RenderBundleEncoderDescriptor; const RenderPipeline = @import("render_pipeline.zig").RenderPipeline; const RenderPipelineDescriptor = @import("render_pipeline.zig").RenderPipelineDescriptor; const Sampler = @import("sampler.zig").Sampler; @@ -97,7 +96,7 @@ pub const Device = opaque { return Impl.deviceCreateQuerySet(device, descriptor); } - pub inline fn createRenderBundleEncoder(device: *Device, descriptor: *const RenderBundleEncoderDescriptor) *RenderBundleEncoder { + pub inline fn createRenderBundleEncoder(device: *Device, descriptor: *const RenderBundleEncoder.Descriptor) *RenderBundleEncoder { return Impl.deviceCreateRenderBundleEncoder(device, descriptor); } diff --git a/gpu/src/interface.zig b/gpu/src/interface.zig index 6d8ec187..3cc3a622 100644 --- a/gpu/src/interface.zig +++ b/gpu/src/interface.zig @@ -90,7 +90,7 @@ pub fn Interface(comptime T: type) type { assertDecl(T, "deviceCreateExternalTexture", fn (device: *gpu.Device, external_texture_descriptor: *const gpu.ExternalTexture.Descriptor) callconv(.Inline) *gpu.ExternalTexture); assertDecl(T, "deviceCreatePipelineLayout", fn (device: *gpu.Device, pipeline_layout_descriptor: *const gpu.PipelineLayout.Descriptor) callconv(.Inline) *gpu.PipelineLayout); assertDecl(T, "deviceCreateQuerySet", fn (device: *gpu.Device, descriptor: *const gpu.QuerySet.Descriptor) callconv(.Inline) *gpu.QuerySet); - assertDecl(T, "deviceCreateRenderBundleEncoder", fn (device: *gpu.Device, descriptor: *const gpu.RenderBundleEncoderDescriptor) callconv(.Inline) *gpu.RenderBundleEncoder); + assertDecl(T, "deviceCreateRenderBundleEncoder", fn (device: *gpu.Device, descriptor: *const gpu.RenderBundleEncoder.Descriptor) callconv(.Inline) *gpu.RenderBundleEncoder); assertDecl(T, "deviceCreateRenderPipeline", fn (device: *gpu.Device, descriptor: *const gpu.RenderPipelineDescriptor) callconv(.Inline) *gpu.RenderPipeline); assertDecl(T, "deviceCreateRenderPipelineAsync", fn (device: *gpu.Device, descriptor: *const gpu.RenderPipelineDescriptor, callback: gpu.CreateRenderPipelineAsyncCallback, userdata: *anyopaque) callconv(.Inline) void); assertDecl(T, "deviceCreateSampler", fn (device: *gpu.Device, descriptor: ?*const gpu.SamplerDescriptor) callconv(.Inline) *gpu.Sampler); @@ -604,7 +604,7 @@ pub fn Export(comptime T: type) type { } // WGPU_EXPORT WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor); - export fn wgpuDeviceCreateRenderBundleEncoder(device: *gpu.Device, descriptor: *const gpu.RenderBundleEncoderDescriptor) *gpu.RenderBundleEncoder { + export fn wgpuDeviceCreateRenderBundleEncoder(device: *gpu.Device, descriptor: *const gpu.RenderBundleEncoder.Descriptor) *gpu.RenderBundleEncoder { return T.deviceCreateRenderBundleEncoder(device, descriptor); } @@ -1683,7 +1683,7 @@ pub const StubInterface = Interface(struct { unreachable; } - pub inline fn deviceCreateRenderBundleEncoder(device: *gpu.Device, descriptor: *const gpu.RenderBundleEncoderDescriptor) *gpu.RenderBundleEncoder { + pub inline fn deviceCreateRenderBundleEncoder(device: *gpu.Device, descriptor: *const gpu.RenderBundleEncoder.Descriptor) *gpu.RenderBundleEncoder { _ = device; _ = descriptor; unreachable; diff --git a/gpu/src/render_bundle_encoder.zig b/gpu/src/render_bundle_encoder.zig index 8870ac2d..1cf8b344 100644 --- a/gpu/src/render_bundle_encoder.zig +++ b/gpu/src/render_bundle_encoder.zig @@ -9,6 +9,18 @@ const IndexFormat = @import("types.zig").IndexFormat; const Impl = @import("interface.zig").Impl; pub const RenderBundleEncoder = opaque { + pub const Descriptor = extern struct { + next_in_chain: ?*const ChainedStruct = null, + label: ?[*:0]const u8 = null, + color_formats_count: u32, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + color_formats: ?[*]const TextureFormat, + depth_stencil_format: TextureFormat = .undef, + sample_count: u32 = 1, + depth_read_only: bool = false, + stencil_read_only: bool = false, + }; + /// Default `instance_count`: 1 /// Default `first_vertex`: 0 /// Default `first_instance`: 0 @@ -82,15 +94,3 @@ pub const RenderBundleEncoder = opaque { Impl.renderBundleEncoderRelease(render_bundle_encoder); } }; - -pub const RenderBundleEncoderDescriptor = extern struct { - next_in_chain: ?*const ChainedStruct = null, - label: ?[*:0]const u8 = null, - color_formats_count: u32, - // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. - color_formats: ?[*]const TextureFormat, - depth_stencil_format: TextureFormat = .undef, - sample_count: u32 = 1, - depth_read_only: bool = false, - stencil_read_only: bool = false, -};