gpu: use null and undefined in enums

Closes #626
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
This commit is contained in:
Eric Joldasov 2022-12-13 18:40:08 +06:00 committed by Stephen Gutekanst
parent ef05d8ca69
commit 94ba8338f5
8 changed files with 32 additions and 32 deletions

View file

@ -34,8 +34,8 @@ fn detectBackendType(allocator: std.mem.Allocator) !gpu.BackendType {
const MACH_GPU_BACKEND = try getEnvVarOwned(allocator, "MACH_GPU_BACKEND"); const MACH_GPU_BACKEND = try getEnvVarOwned(allocator, "MACH_GPU_BACKEND");
if (MACH_GPU_BACKEND) |backend| { if (MACH_GPU_BACKEND) |backend| {
defer allocator.free(backend); defer allocator.free(backend);
if (std.ascii.eqlIgnoreCase(backend, "null")) return .nul; if (std.ascii.eqlIgnoreCase(backend, "null")) return .null;
if (std.ascii.eqlIgnoreCase(backend, "webgpu")) return .nul; if (std.ascii.eqlIgnoreCase(backend, "webgpu")) return .null;
if (std.ascii.eqlIgnoreCase(backend, "d3d11")) return .d3d11; if (std.ascii.eqlIgnoreCase(backend, "d3d11")) return .d3d11;
if (std.ascii.eqlIgnoreCase(backend, "d3d12")) return .d3d12; if (std.ascii.eqlIgnoreCase(backend, "d3d12")) return .d3d12;
if (std.ascii.eqlIgnoreCase(backend, "metal")) return .metal; if (std.ascii.eqlIgnoreCase(backend, "metal")) return .metal;

View file

@ -7,7 +7,7 @@ pub const Buffer = opaque {
pub const MapCallback = *const fn (status: MapAsyncStatus, userdata: ?*anyopaque) callconv(.C) void; pub const MapCallback = *const fn (status: MapAsyncStatus, userdata: ?*anyopaque) callconv(.C) void;
pub const BindingType = enum(u32) { pub const BindingType = enum(u32) {
undef = 0x00000000, undefined = 0x00000000,
uniform = 0x00000001, uniform = 0x00000001,
storage = 0x00000002, storage = 0x00000002,
read_only_storage = 0x00000003, read_only_storage = 0x00000003,
@ -52,7 +52,7 @@ pub const Buffer = opaque {
pub const BindingLayout = extern struct { pub const BindingLayout = extern struct {
next_in_chain: ?*const ChainedStruct = null, next_in_chain: ?*const ChainedStruct = null,
type: BindingType = .undef, type: BindingType = .undefined,
has_dynamic_offset: bool = false, has_dynamic_offset: bool = false,
min_binding_size: u64 = 0, min_binding_size: u64 = 0,
}; };

View file

@ -38,7 +38,7 @@ pub const Device = opaque {
) callconv(.C) void; ) callconv(.C) void;
pub const LostReason = enum(u32) { pub const LostReason = enum(u32) {
undef = 0x00000000, undefined = 0x00000000,
destroyed = 0x00000001, destroyed = 0x00000001,
}; };

View file

@ -13,7 +13,7 @@ pub const RenderBundleEncoder = opaque {
label: ?[*:0]const u8 = null, label: ?[*:0]const u8 = null,
color_formats_count: u32 = 0, color_formats_count: u32 = 0,
color_formats: ?[*]const Texture.Format = null, color_formats: ?[*]const Texture.Format = null,
depth_stencil_format: Texture.Format = .undef, depth_stencil_format: Texture.Format = .undefined,
sample_count: u32 = 1, sample_count: u32 = 1,
depth_read_only: bool = false, depth_read_only: bool = false,
stencil_read_only: bool = false, stencil_read_only: bool = false,
@ -23,7 +23,7 @@ pub const RenderBundleEncoder = opaque {
next_in_chain: ?*const ChainedStruct = null, next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null, label: ?[*:0]const u8 = null,
color_formats: ?[]const Texture.Format = null, color_formats: ?[]const Texture.Format = null,
depth_stencil_format: Texture.Format = .undef, depth_stencil_format: Texture.Format = .undefined,
sample_count: u32 = 1, sample_count: u32 = 1,
depth_read_only: bool = false, depth_read_only: bool = false,
stencil_read_only: bool = false, stencil_read_only: bool = false,

View file

@ -11,7 +11,7 @@ pub const Sampler = opaque {
}; };
pub const BindingType = enum(u32) { pub const BindingType = enum(u32) {
undef = 0x00000000, undefined = 0x00000000,
filtering = 0x00000001, filtering = 0x00000001,
non_filtering = 0x00000002, non_filtering = 0x00000002,
comparison = 0x00000003, comparison = 0x00000003,
@ -19,7 +19,7 @@ pub const Sampler = opaque {
pub const BindingLayout = extern struct { pub const BindingLayout = extern struct {
next_in_chain: ?*const ChainedStruct = null, next_in_chain: ?*const ChainedStruct = null,
type: BindingType = .undef, type: BindingType = .undefined,
}; };
pub const Descriptor = extern struct { pub const Descriptor = extern struct {
@ -33,7 +33,7 @@ pub const Sampler = opaque {
mipmap_filter: FilterMode = .nearest, mipmap_filter: FilterMode = .nearest,
lod_min_clamp: f32 = 0.0, lod_min_clamp: f32 = 0.0,
lod_max_clamp: f32 = 1000.0, lod_max_clamp: f32 = 1000.0,
compare: CompareFunction = .undef, compare: CompareFunction = .undefined,
max_anisotropy: u16 = 1, max_anisotropy: u16 = 1,
}; };

View file

@ -29,7 +29,7 @@ pub const Texture = opaque {
}; };
pub const Format = enum(u32) { pub const Format = enum(u32) {
undef = 0x00000000, undefined = 0x00000000,
r8_unorm = 0x00000001, r8_unorm = 0x00000001,
r8_snorm = 0x00000002, r8_snorm = 0x00000002,
r8_uint = 0x00000003, r8_uint = 0x00000003,
@ -128,7 +128,7 @@ pub const Texture = opaque {
}; };
pub const SampleType = enum(u32) { pub const SampleType = enum(u32) {
undef = 0x00000000, undefined = 0x00000000,
float = 0x00000001, float = 0x00000001,
unfilterable_float = 0x00000002, unfilterable_float = 0x00000002,
depth = 0x00000003, depth = 0x00000003,
@ -162,7 +162,7 @@ pub const Texture = opaque {
pub const BindingLayout = extern struct { pub const BindingLayout = extern struct {
next_in_chain: ?*const ChainedStruct = null, next_in_chain: ?*const ChainedStruct = null,
sample_type: SampleType = .undef, sample_type: SampleType = .undefined,
view_dimension: TextureView.Dimension = .dimension_undef, view_dimension: TextureView.Dimension = .dimension_undef,
multisampled: bool = false, multisampled: bool = false,
}; };

View file

@ -17,7 +17,7 @@ pub const TextureView = opaque {
pub const Descriptor = extern struct { pub const Descriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null, next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null, label: ?[*:0]const u8 = null,
format: Texture.Format = .undef, format: Texture.Format = .undefined,
dimension: Dimension = .dimension_undef, dimension: Dimension = .dimension_undef,
base_mip_level: u32 = 0, base_mip_level: u32 = 0,
mip_level_count: u32 = types.mip_level_count_undef, mip_level_count: u32 = types.mip_level_count_undef,

View file

@ -27,14 +27,14 @@ pub const ComputePassTimestampWrite = extern struct {
pub const RenderPassDepthStencilAttachment = extern struct { pub const RenderPassDepthStencilAttachment = extern struct {
view: *TextureView, view: *TextureView,
depth_load_op: LoadOp = .undef, depth_load_op: LoadOp = .undefined,
depth_store_op: StoreOp = .undef, depth_store_op: StoreOp = .undefined,
/// deprecated /// deprecated
clear_depth: f32 = std.math.nan(f32), clear_depth: f32 = std.math.nan(f32),
depth_clear_value: f32 = 0, depth_clear_value: f32 = 0,
depth_read_only: bool = false, depth_read_only: bool = false,
stencil_load_op: LoadOp = .undef, stencil_load_op: LoadOp = .undefined,
stencil_store_op: StoreOp = .undef, stencil_store_op: StoreOp = .undefined,
/// deprecated /// deprecated
clear_stencil: u32 = 0, clear_stencil: u32 = 0,
stencil_clear_value: u32 = 0, stencil_clear_value: u32 = 0,
@ -50,7 +50,7 @@ pub const RenderPassTimestampWrite = extern struct {
pub const RequestAdapterOptions = extern struct { pub const RequestAdapterOptions = extern struct {
next_in_chain: ?*const ChainedStruct = null, next_in_chain: ?*const ChainedStruct = null,
compatible_surface: ?*Surface = null, compatible_surface: ?*Surface = null,
power_preference: PowerPreference = .undef, power_preference: PowerPreference = .undefined,
force_fallback_adapter: bool = false, force_fallback_adapter: bool = false,
}; };
@ -115,7 +115,7 @@ pub const RenderPassDescriptor = extern struct {
pub const AlphaMode = enum(u32) { premultiplied = 0x00000000, unpremultiplied = 0x00000001, opaq = 0x00000002 }; pub const AlphaMode = enum(u32) { premultiplied = 0x00000000, unpremultiplied = 0x00000001, opaq = 0x00000002 };
pub const BackendType = enum(u32) { pub const BackendType = enum(u32) {
nul, null,
webgpu, webgpu,
d3d11, d3d11,
d3d12, d3d12,
@ -126,7 +126,7 @@ pub const BackendType = enum(u32) {
pub fn name(t: BackendType) []const u8 { pub fn name(t: BackendType) []const u8 {
return switch (t) { return switch (t) {
.nul => "Null", .null => "Null",
.webgpu => "WebGPU", .webgpu => "WebGPU",
.d3d11 => "D3D11", .d3d11 => "D3D11",
.d3d12 => "D3D12", .d3d12 => "D3D12",
@ -163,7 +163,7 @@ pub const BlendOperation = enum(u32) {
}; };
pub const CompareFunction = enum(u32) { pub const CompareFunction = enum(u32) {
undef = 0x00000000, undefined = 0x00000000,
never = 0x00000001, never = 0x00000001,
less = 0x00000002, less = 0x00000002,
less_equal = 0x00000003, less_equal = 0x00000003,
@ -220,7 +220,7 @@ pub const ErrorType = enum(u32) {
}; };
pub const FeatureName = enum(u32) { pub const FeatureName = enum(u32) {
undef = 0x00000000, undefined = 0x00000000,
depth_clip_control = 0x00000001, depth_clip_control = 0x00000001,
depth32_float_stencil8 = 0x00000002, depth32_float_stencil8 = 0x00000002,
timestamp_query = 0x00000003, timestamp_query = 0x00000003,
@ -247,13 +247,13 @@ pub const FrontFace = enum(u32) {
}; };
pub const IndexFormat = enum(u32) { pub const IndexFormat = enum(u32) {
undef = 0x00000000, undefined = 0x00000000,
uint16 = 0x00000001, uint16 = 0x00000001,
uint32 = 0x00000002, uint32 = 0x00000002,
}; };
pub const LoadOp = enum(u32) { pub const LoadOp = enum(u32) {
undef = 0x00000000, undefined = 0x00000000,
clear = 0x00000001, clear = 0x00000001,
load = 0x00000002, load = 0x00000002,
}; };
@ -274,7 +274,7 @@ pub const PipelineStatisticName = enum(u32) {
}; };
pub const PowerPreference = enum(u32) { pub const PowerPreference = enum(u32) {
undef = 0x00000000, undefined = 0x00000000,
low_power = 0x00000001, low_power = 0x00000001,
high_performance = 0x00000002, high_performance = 0x00000002,
}; };
@ -352,18 +352,18 @@ pub const StencilOperation = enum(u32) {
}; };
pub const StorageTextureAccess = enum(u32) { pub const StorageTextureAccess = enum(u32) {
undef = 0x00000000, undefined = 0x00000000,
write_only = 0x00000001, write_only = 0x00000001,
}; };
pub const StoreOp = enum(u32) { pub const StoreOp = enum(u32) {
undef = 0x00000000, undefined = 0x00000000,
store = 0x00000001, store = 0x00000001,
discard = 0x00000002, discard = 0x00000002,
}; };
pub const VertexFormat = enum(u32) { pub const VertexFormat = enum(u32) {
undef = 0x00000000, undefined = 0x00000000,
uint8x2 = 0x00000001, uint8x2 = 0x00000001,
uint8x4 = 0x00000002, uint8x4 = 0x00000002,
sint8x2 = 0x00000003, sint8x2 = 0x00000003,
@ -586,7 +586,7 @@ pub const PrimitiveState = extern struct {
next_in_chain: NextInChain = .{ .generic = null }, next_in_chain: NextInChain = .{ .generic = null },
topology: PrimitiveTopology = .triangle_list, topology: PrimitiveTopology = .triangle_list,
strip_index_format: IndexFormat = .undef, strip_index_format: IndexFormat = .undefined,
front_face: FrontFace = .ccw, front_face: FrontFace = .ccw,
cull_mode: CullMode = .none, cull_mode: CullMode = .none,
}; };
@ -605,8 +605,8 @@ pub const StencilFaceState = extern struct {
pub const StorageTextureBindingLayout = extern struct { pub const StorageTextureBindingLayout = extern struct {
next_in_chain: ?*const ChainedStruct = null, next_in_chain: ?*const ChainedStruct = null,
access: StorageTextureAccess = .undef, access: StorageTextureAccess = .undefined,
format: Texture.Format = .undef, format: Texture.Format = .undefined,
view_dimension: TextureView.Dimension = .dimension_undef, view_dimension: TextureView.Dimension = .dimension_undef,
}; };