diff --git a/gpu/src/native.zig b/gpu/src/NativeInstance.zig similarity index 63% rename from gpu/src/native.zig rename to gpu/src/NativeInstance.zig index 8d06def2..a02ae409 100644 --- a/gpu/src/native.zig +++ b/gpu/src/NativeInstance.zig @@ -2,12 +2,18 @@ const c = @import("c.zig").c; const Interface = @import("Interface.zig"); -/// Returns a native webgpu.h implementation of the gpu.Interface, wrapping the given WGPUInstance. -pub fn native(instance: c.WGPUInstance) Interface { - // TODO: implement Interface - _ = instance; +const NativeInstance = @This(); + +/// The WGPUInstance that is wrapped by this native instance. +instance: c.WGPUInstance, + +/// Returns the gpu.Interface for interacting with this native instance. +pub fn interface(native: NativeInstance) Interface { + _ = native; @panic("not implemented"); + // TODO: implement Interface + // TODO: implement Device interface // TODO: implement Adapter interface: @@ -18,3 +24,8 @@ pub fn native(instance: c.WGPUInstance) Interface { // WGPU_EXPORT bool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits); // WGPU_EXPORT void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties); } + +/// Wraps a native WGPUInstance to provide an implementation of the gpu.Interface. +pub fn wrap(instance: c.WGPUInstance) NativeInstance { + return .{ .instance = instance }; +} diff --git a/gpu/src/main.zig b/gpu/src/main.zig index 2094b50b..7a42857c 100644 --- a/gpu/src/main.zig +++ b/gpu/src/main.zig @@ -17,7 +17,7 @@ //! const std = @import("std"); const Interface = @import("Interface.zig"); -const native = @import("native.zig").native; +const NativeInstance = @import("NativeInstance.zig"); const Adapter = @import("Adapter.zig"); const Device = @import("Device.zig"); @@ -26,10 +26,12 @@ const FeatureName = @import("feature_name.zig").FeatureName; const SupportedLimits = @import("supported_limits.zig").SupportedLimits; test "syntax" { + _ = Interface; + _ = NativeInstance; + _ = Adapter; _ = Device; - _ = Interface; - _ = native; + _ = FeatureName; _ = SupportedLimits; }