diff --git a/gpu/src/device.zig b/gpu/src/device.zig index d3ccede6..da73f372 100644 --- a/gpu/src/device.zig +++ b/gpu/src/device.zig @@ -6,7 +6,6 @@ const Buffer = @import("buffer.zig").Buffer; const CommandEncoder = @import("command_encoder.zig").CommandEncoder; const ComputePipeline = @import("compute_pipeline.zig").ComputePipeline; const ExternalTexture = @import("external_texture.zig").ExternalTexture; -const ExternalTextureDescriptor = @import("external_texture.zig").ExternalTextureDescriptor; const PipelineLayout = @import("pipeline_layout.zig").PipelineLayout; const PipelineLayoutDescriptor = @import("pipeline_layout.zig").PipelineLayoutDescriptor; const QuerySet = @import("query_set.zig").QuerySet; @@ -89,7 +88,7 @@ pub const Device = opaque { return Impl.deviceCreateErrorExternalTexture(device); } - pub inline fn createExternalTexture(device: *Device, external_texture_descriptor: *const ExternalTextureDescriptor) *ExternalTexture { + pub inline fn createExternalTexture(device: *Device, external_texture_descriptor: *const ExternalTexture.Descriptor) *ExternalTexture { return Impl.deviceCreateExternalTexture(device, external_texture_descriptor); } diff --git a/gpu/src/external_texture.zig b/gpu/src/external_texture.zig index 9d20cc28..cb42e93a 100644 --- a/gpu/src/external_texture.zig +++ b/gpu/src/external_texture.zig @@ -3,6 +3,31 @@ const TextureView = @import("texture_view.zig").TextureView; const Impl = @import("interface.zig").Impl; pub const ExternalTexture = opaque { + pub const BindingEntry = extern struct { + chain: ChainedStruct, + external_texture: *ExternalTexture, + }; + + pub const BindingLayout = extern struct { + chain: ChainedStruct, + }; + + pub const Descriptor = extern struct { + next_in_chain: ?*const ChainedStruct = null, + label: ?[*:0]const u8 = null, + plane0: *TextureView, + plane1: ?*TextureView, + do_yuv_to_rgb_conversion_only: bool = false, + // TODO: dawn.json says length 12, does it mean array length? + yuv_to_rgb_conversion_matrix: ?[*]const f32, + // TODO: dawn.json says length 7, does it mean array length? + src_transform_function_parameters: [*]const f32, + // TODO: dawn.json says length 7, does it mean array length? + dst_transform_function_parameters: [*]const f32, + // TODO: dawn.json says length 9, does it mean array length? + gamut_conversion_matrix: [*]const f32, + }; + pub inline fn destroy(external_texture: *ExternalTexture) void { Impl.externalTextureDestroy(external_texture); } @@ -19,28 +44,3 @@ pub const ExternalTexture = opaque { Impl.externalTextureRelease(external_texture); } }; - -pub const ExternalTextureBindingEntry = extern struct { - chain: ChainedStruct, - external_texture: *ExternalTexture, -}; - -pub const ExternalTextureBindingLayout = extern struct { - chain: ChainedStruct, -}; - -pub const ExternalTextureDescriptor = extern struct { - next_in_chain: ?*const ChainedStruct = null, - label: ?[*:0]const u8 = null, - plane0: *TextureView, - plane1: ?*TextureView, - do_yuv_to_rgb_conversion_only: bool = false, - // TODO: dawn.json says length 12, does it mean array length? - yuv_to_rgb_conversion_matrix: ?[*]const f32, - // TODO: dawn.json says length 7, does it mean array length? - src_transform_function_parameters: [*]const f32, - // TODO: dawn.json says length 7, does it mean array length? - dst_transform_function_parameters: [*]const f32, - // TODO: dawn.json says length 9, does it mean array length? - gamut_conversion_matrix: [*]const f32, -}; diff --git a/gpu/src/interface.zig b/gpu/src/interface.zig index 699ee869..5b8b5184 100644 --- a/gpu/src/interface.zig +++ b/gpu/src/interface.zig @@ -87,7 +87,7 @@ pub fn Interface(comptime T: type) type { assertDecl(T, "deviceCreateComputePipelineAsync", fn (device: *gpu.Device, descriptor: *const gpu.ComputePipeline.Descriptor, callback: gpu.CreateComputePipelineAsyncCallback, userdata: *anyopaque) callconv(.Inline) void); 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.ExternalTextureDescriptor) 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, "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); @@ -589,7 +589,7 @@ pub fn Export(comptime T: type) type { } // WGPU_EXPORT WGPUExternalTexture wgpuDeviceCreateExternalTexture(WGPUDevice device, WGPUExternalTextureDescriptor const * externalTextureDescriptor); - export fn wgpuDeviceCreateExternalTexture(device: *gpu.Device, external_texture_descriptor: *const gpu.ExternalTextureDescriptor) *gpu.ExternalTexture { + export fn wgpuDeviceCreateExternalTexture(device: *gpu.Device, external_texture_descriptor: *const gpu.ExternalTexture.Descriptor) *gpu.ExternalTexture { return T.deviceCreateExternalTexture(device, external_texture_descriptor); } @@ -1665,7 +1665,7 @@ pub const StubInterface = Interface(struct { unreachable; } - pub inline fn deviceCreateExternalTexture(device: *gpu.Device, external_texture_descriptor: *const gpu.ExternalTextureDescriptor) *gpu.ExternalTexture { + pub inline fn deviceCreateExternalTexture(device: *gpu.Device, external_texture_descriptor: *const gpu.ExternalTexture.Descriptor) *gpu.ExternalTexture { _ = device; _ = external_texture_descriptor; unreachable;