diff --git a/gpu/src/Adapter.zig b/gpu/src/Adapter.zig deleted file mode 100644 index 4431094d..00000000 --- a/gpu/src/Adapter.zig +++ /dev/null @@ -1,36 +0,0 @@ -const testing = @import("std").testing; -const ChainedStructOut = @import("types.zig").ChainedStructOut; - -ptr: *anyopaque, - -pub const Type = enum(u32) { - discrete_gpu, - integrated_gpu, - cpu, - unknown, - - pub fn name(t: Type) []const u8 { - return switch (t) { - .discrete_gpu => "Discrete GPU", - .integrated_gpu => "Integrated GPU", - .cpu => "CPU", - .unknown => "Unknown", - }; - } -}; - -pub const Properties = extern struct { - next_in_chain: *ChainedStructOut, - vendor_id: u32, - vendor_name: [*:0]const u8, - architecture: [*:0]const u8, - device_id: u32, - name: [*:0]const u8, - driver_description: [*:0]const u8, - adapter_type: Type, - backend_type: Type, -}; - -test "Adapter.Type name" { - try testing.expectEqualStrings("Discrete GPU", Type.discrete_gpu.name()); -} diff --git a/gpu/src/adapter.zig b/gpu/src/adapter.zig new file mode 100644 index 00000000..d92e1463 --- /dev/null +++ b/gpu/src/adapter.zig @@ -0,0 +1,40 @@ +const testing = @import("std").testing; +const ChainedStructOut = @import("types.zig").ChainedStructOut; + +pub const Adapter = enum(usize) { + _, + + pub const none: Adapter = @intToEnum(Adapter, 0); + + pub const Type = enum(u32) { + discrete_gpu, + integrated_gpu, + cpu, + unknown, + + pub fn name(t: Type) []const u8 { + return switch (t) { + .discrete_gpu => "Discrete GPU", + .integrated_gpu => "Integrated GPU", + .cpu => "CPU", + .unknown => "Unknown", + }; + } + }; + + pub const Properties = extern struct { + next_in_chain: *ChainedStructOut, + vendor_id: u32, + vendor_name: [*:0]const u8, + architecture: [*:0]const u8, + device_id: u32, + name: [*:0]const u8, + driver_description: [*:0]const u8, + adapter_type: Type, + backend_type: Type, + }; +}; + +test "Adapter.Type name" { + try testing.expectEqualStrings("Discrete GPU", Adapter.Type.discrete_gpu.name()); +} diff --git a/gpu/src/main.zig b/gpu/src/main.zig index f6fde902..1effd72b 100644 --- a/gpu/src/main.zig +++ b/gpu/src/main.zig @@ -9,7 +9,7 @@ pub const stride_undefined = 0xffffffff; pub const whole_map_size = std.math.maxInt(usize); pub const whole_size = 0xffffffffffffffff; -pub const Adapter = @import("Adapter.zig"); +pub const Adapter = @import("adapter.zig").Adapter; pub const BindGroup = @import("BindGroup.zig"); pub const BindGroupLayout = @import("BindGroupLayout.zig"); pub const Buffer = @import("buffer.zig").Buffer; @@ -37,7 +37,7 @@ pub const TextureView = @import("TextureView.zig"); pub const AlphaMode = @import("types.zig").AlphaMode; test { - refAllDecls(@import("Adapter.zig")); + refAllDecls(@import("adapter.zig")); refAllDecls(@import("BindGroup.zig")); refAllDecls(@import("BindGroupLayout.zig")); refAllDecls(@import("buffer.zig"));