From 1a57ae1c4d6114747258672f57f1677e3abbc281 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 29 Jul 2022 23:50:23 -0700 Subject: [PATCH] gpu: internalize PipelineLayout types Signed-off-by: Stephen Gutekanst --- gpu/src/device.zig | 3 +-- gpu/src/interface.zig | 6 +++--- gpu/src/pipeline_layout.zig | 16 ++++++++-------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/gpu/src/device.zig b/gpu/src/device.zig index da73f372..806cf942 100644 --- a/gpu/src/device.zig +++ b/gpu/src/device.zig @@ -7,7 +7,6 @@ const CommandEncoder = @import("command_encoder.zig").CommandEncoder; const ComputePipeline = @import("compute_pipeline.zig").ComputePipeline; const ExternalTexture = @import("external_texture.zig").ExternalTexture; const PipelineLayout = @import("pipeline_layout.zig").PipelineLayout; -const PipelineLayoutDescriptor = @import("pipeline_layout.zig").PipelineLayoutDescriptor; const QuerySet = @import("query_set.zig").QuerySet; const QuerySetDescriptor = @import("query_set.zig").QuerySetDescriptor; const RenderBundleEncoder = @import("render_bundle_encoder.zig").RenderBundleEncoder; @@ -92,7 +91,7 @@ pub const Device = opaque { return Impl.deviceCreateExternalTexture(device, external_texture_descriptor); } - pub inline fn createPipelineLayout(device: *Device, pipeline_layout_descriptor: *const PipelineLayoutDescriptor) *PipelineLayout { + pub inline fn createPipelineLayout(device: *Device, pipeline_layout_descriptor: *const PipelineLayout.Descriptor) *PipelineLayout { return Impl.deviceCreatePipelineLayout(device, pipeline_layout_descriptor); } diff --git a/gpu/src/interface.zig b/gpu/src/interface.zig index 5b8b5184..4b438480 100644 --- a/gpu/src/interface.zig +++ b/gpu/src/interface.zig @@ -88,7 +88,7 @@ pub fn Interface(comptime T: type) type { assertDecl(T, "deviceCreateErrorBuffer", fn (device: *gpu.Device) callconv(.Inline) *gpu.Buffer); assertDecl(T, "deviceCreateErrorExternalTexture", fn (device: *gpu.Device) callconv(.Inline) *gpu.ExternalTexture); 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.PipelineLayoutDescriptor) callconv(.Inline) *gpu.PipelineLayout); + 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.QuerySetDescriptor) callconv(.Inline) *gpu.QuerySet); assertDecl(T, "deviceCreateRenderBundleEncoder", fn (device: *gpu.Device, descriptor: *const gpu.RenderBundleEncoderDescriptor) callconv(.Inline) *gpu.RenderBundleEncoder); assertDecl(T, "deviceCreateRenderPipeline", fn (device: *gpu.Device, descriptor: *const gpu.RenderPipelineDescriptor) callconv(.Inline) *gpu.RenderPipeline); @@ -594,7 +594,7 @@ pub fn Export(comptime T: type) type { } // WGPU_EXPORT WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor); - export fn wgpuDeviceCreatePipelineLayout(device: *gpu.Device, pipeline_layout_descriptor: *const gpu.PipelineLayoutDescriptor) *gpu.PipelineLayout { + export fn wgpuDeviceCreatePipelineLayout(device: *gpu.Device, pipeline_layout_descriptor: *const gpu.PipelineLayout.Descriptor) *gpu.PipelineLayout { return T.deviceCreatePipelineLayout(device, pipeline_layout_descriptor); } @@ -1671,7 +1671,7 @@ pub const StubInterface = Interface(struct { unreachable; } - pub inline fn deviceCreatePipelineLayout(device: *gpu.Device, pipeline_layout_descriptor: *const gpu.PipelineLayoutDescriptor) *gpu.PipelineLayout { + pub inline fn deviceCreatePipelineLayout(device: *gpu.Device, pipeline_layout_descriptor: *const gpu.PipelineLayout.Descriptor) *gpu.PipelineLayout { _ = device; _ = pipeline_layout_descriptor; unreachable; diff --git a/gpu/src/pipeline_layout.zig b/gpu/src/pipeline_layout.zig index 6a5f2ef9..b2770c60 100644 --- a/gpu/src/pipeline_layout.zig +++ b/gpu/src/pipeline_layout.zig @@ -3,6 +3,14 @@ const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout; const Impl = @import("interface.zig").Impl; pub const PipelineLayout = opaque { + pub const Descriptor = extern struct { + next_in_chain: ?*const ChainedStruct = null, + label: ?[*:0]const u8 = null, + bind_group_layout_count: u32, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + bind_group_layouts: ?[*]const *BindGroupLayout, + }; + pub inline fn setLabel(pipeline_layout: *PipelineLayout, label: [*:0]const u8) void { Impl.pipelineLayoutSetLabel(pipeline_layout, label); } @@ -15,11 +23,3 @@ pub const PipelineLayout = opaque { Impl.pipelineLayoutRelease(pipeline_layout); } }; - -pub const PipelineLayoutDescriptor = extern struct { - next_in_chain: ?*const ChainedStruct = null, - label: ?[*:0]const u8 = null, - bind_group_layout_count: u32, - // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. - bind_group_layouts: ?[*]const *BindGroupLayout, -};