gpu: convert Adapter from enum(usize) to *opaque
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
311ea3f62c
commit
f7df77e2d2
1 changed files with 28 additions and 33 deletions
|
|
@ -1,41 +1,36 @@
|
||||||
const testing = @import("std").testing;
|
const testing = @import("std").testing;
|
||||||
const ChainedStructOut = @import("types.zig").ChainedStructOut;
|
const ChainedStructOut = @import("types.zig").ChainedStructOut;
|
||||||
|
|
||||||
pub const Adapter = enum(usize) {
|
pub const Adapter = *opaque {};
|
||||||
_,
|
|
||||||
|
|
||||||
// TODO: verify there is a use case for nullable value of this type.
|
pub const AdapterType = enum(u32) {
|
||||||
pub const none: Adapter = @intToEnum(Adapter, 0);
|
discrete_gpu,
|
||||||
|
integrated_gpu,
|
||||||
|
cpu,
|
||||||
|
unknown,
|
||||||
|
|
||||||
pub const Type = enum(u32) {
|
pub fn name(t: AdapterType) []const u8 {
|
||||||
discrete_gpu,
|
return switch (t) {
|
||||||
integrated_gpu,
|
.discrete_gpu => "Discrete GPU",
|
||||||
cpu,
|
.integrated_gpu => "Integrated GPU",
|
||||||
unknown,
|
.cpu => "CPU",
|
||||||
|
.unknown => "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" {
|
pub const AdapterProperties = extern struct {
|
||||||
try testing.expectEqualStrings("Discrete GPU", Adapter.Type.discrete_gpu.name());
|
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: AdapterType,
|
||||||
|
backend_type: AdapterType,
|
||||||
|
};
|
||||||
|
|
||||||
|
test "AdapterType name" {
|
||||||
|
try testing.expectEqualStrings("Discrete GPU", AdapterType.discrete_gpu.name());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue