From 94ba8338f583a2ee3e1cefa669266b822a6853c9 Mon Sep 17 00:00:00 2001 From: Eric Joldasov Date: Tue, 13 Dec 2022 18:40:08 +0600 Subject: [PATCH] gpu: use null and undefined in enums Closes #626 Signed-off-by: Eric Joldasov --- libs/gpu/examples/sample_utils.zig | 4 +-- libs/gpu/src/buffer.zig | 4 +-- libs/gpu/src/device.zig | 2 +- libs/gpu/src/render_bundle_encoder.zig | 4 +-- libs/gpu/src/sampler.zig | 6 ++--- libs/gpu/src/texture.zig | 6 ++--- libs/gpu/src/texture_view.zig | 2 +- libs/gpu/src/types.zig | 36 +++++++++++++------------- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/libs/gpu/examples/sample_utils.zig b/libs/gpu/examples/sample_utils.zig index 1c201443..f94dd1bc 100644 --- a/libs/gpu/examples/sample_utils.zig +++ b/libs/gpu/examples/sample_utils.zig @@ -34,8 +34,8 @@ fn detectBackendType(allocator: std.mem.Allocator) !gpu.BackendType { const MACH_GPU_BACKEND = try getEnvVarOwned(allocator, "MACH_GPU_BACKEND"); if (MACH_GPU_BACKEND) |backend| { defer allocator.free(backend); - if (std.ascii.eqlIgnoreCase(backend, "null")) return .nul; - if (std.ascii.eqlIgnoreCase(backend, "webgpu")) return .nul; + if (std.ascii.eqlIgnoreCase(backend, "null")) return .null; + if (std.ascii.eqlIgnoreCase(backend, "webgpu")) return .null; if (std.ascii.eqlIgnoreCase(backend, "d3d11")) return .d3d11; if (std.ascii.eqlIgnoreCase(backend, "d3d12")) return .d3d12; if (std.ascii.eqlIgnoreCase(backend, "metal")) return .metal; diff --git a/libs/gpu/src/buffer.zig b/libs/gpu/src/buffer.zig index 6f432be5..511975e1 100644 --- a/libs/gpu/src/buffer.zig +++ b/libs/gpu/src/buffer.zig @@ -7,7 +7,7 @@ pub const Buffer = opaque { pub const MapCallback = *const fn (status: MapAsyncStatus, userdata: ?*anyopaque) callconv(.C) void; pub const BindingType = enum(u32) { - undef = 0x00000000, + undefined = 0x00000000, uniform = 0x00000001, storage = 0x00000002, read_only_storage = 0x00000003, @@ -52,7 +52,7 @@ pub const Buffer = opaque { pub const BindingLayout = extern struct { next_in_chain: ?*const ChainedStruct = null, - type: BindingType = .undef, + type: BindingType = .undefined, has_dynamic_offset: bool = false, min_binding_size: u64 = 0, }; diff --git a/libs/gpu/src/device.zig b/libs/gpu/src/device.zig index 2ad11d0d..5d4f7bd9 100644 --- a/libs/gpu/src/device.zig +++ b/libs/gpu/src/device.zig @@ -38,7 +38,7 @@ pub const Device = opaque { ) callconv(.C) void; pub const LostReason = enum(u32) { - undef = 0x00000000, + undefined = 0x00000000, destroyed = 0x00000001, }; diff --git a/libs/gpu/src/render_bundle_encoder.zig b/libs/gpu/src/render_bundle_encoder.zig index 8d4e550a..775f55cb 100644 --- a/libs/gpu/src/render_bundle_encoder.zig +++ b/libs/gpu/src/render_bundle_encoder.zig @@ -13,7 +13,7 @@ pub const RenderBundleEncoder = opaque { label: ?[*:0]const u8 = null, color_formats_count: u32 = 0, color_formats: ?[*]const Texture.Format = null, - depth_stencil_format: Texture.Format = .undef, + depth_stencil_format: Texture.Format = .undefined, sample_count: u32 = 1, depth_read_only: bool = false, stencil_read_only: bool = false, @@ -23,7 +23,7 @@ pub const RenderBundleEncoder = opaque { next_in_chain: ?*const ChainedStruct = null, label: ?[*:0]const u8 = null, color_formats: ?[]const Texture.Format = null, - depth_stencil_format: Texture.Format = .undef, + depth_stencil_format: Texture.Format = .undefined, sample_count: u32 = 1, depth_read_only: bool = false, stencil_read_only: bool = false, diff --git a/libs/gpu/src/sampler.zig b/libs/gpu/src/sampler.zig index 3b74871e..31b0256b 100644 --- a/libs/gpu/src/sampler.zig +++ b/libs/gpu/src/sampler.zig @@ -11,7 +11,7 @@ pub const Sampler = opaque { }; pub const BindingType = enum(u32) { - undef = 0x00000000, + undefined = 0x00000000, filtering = 0x00000001, non_filtering = 0x00000002, comparison = 0x00000003, @@ -19,7 +19,7 @@ pub const Sampler = opaque { pub const BindingLayout = extern struct { next_in_chain: ?*const ChainedStruct = null, - type: BindingType = .undef, + type: BindingType = .undefined, }; pub const Descriptor = extern struct { @@ -33,7 +33,7 @@ pub const Sampler = opaque { mipmap_filter: FilterMode = .nearest, lod_min_clamp: f32 = 0.0, lod_max_clamp: f32 = 1000.0, - compare: CompareFunction = .undef, + compare: CompareFunction = .undefined, max_anisotropy: u16 = 1, }; diff --git a/libs/gpu/src/texture.zig b/libs/gpu/src/texture.zig index 280a5940..ed5254d0 100644 --- a/libs/gpu/src/texture.zig +++ b/libs/gpu/src/texture.zig @@ -29,7 +29,7 @@ pub const Texture = opaque { }; pub const Format = enum(u32) { - undef = 0x00000000, + undefined = 0x00000000, r8_unorm = 0x00000001, r8_snorm = 0x00000002, r8_uint = 0x00000003, @@ -128,7 +128,7 @@ pub const Texture = opaque { }; pub const SampleType = enum(u32) { - undef = 0x00000000, + undefined = 0x00000000, float = 0x00000001, unfilterable_float = 0x00000002, depth = 0x00000003, @@ -162,7 +162,7 @@ pub const Texture = opaque { pub const BindingLayout = extern struct { next_in_chain: ?*const ChainedStruct = null, - sample_type: SampleType = .undef, + sample_type: SampleType = .undefined, view_dimension: TextureView.Dimension = .dimension_undef, multisampled: bool = false, }; diff --git a/libs/gpu/src/texture_view.zig b/libs/gpu/src/texture_view.zig index 9fa88267..e32a6f2e 100644 --- a/libs/gpu/src/texture_view.zig +++ b/libs/gpu/src/texture_view.zig @@ -17,7 +17,7 @@ pub const TextureView = opaque { pub const Descriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, label: ?[*:0]const u8 = null, - format: Texture.Format = .undef, + format: Texture.Format = .undefined, dimension: Dimension = .dimension_undef, base_mip_level: u32 = 0, mip_level_count: u32 = types.mip_level_count_undef, diff --git a/libs/gpu/src/types.zig b/libs/gpu/src/types.zig index 83460a05..3fd3090f 100644 --- a/libs/gpu/src/types.zig +++ b/libs/gpu/src/types.zig @@ -27,14 +27,14 @@ pub const ComputePassTimestampWrite = extern struct { pub const RenderPassDepthStencilAttachment = extern struct { view: *TextureView, - depth_load_op: LoadOp = .undef, - depth_store_op: StoreOp = .undef, + depth_load_op: LoadOp = .undefined, + depth_store_op: StoreOp = .undefined, /// deprecated clear_depth: f32 = std.math.nan(f32), depth_clear_value: f32 = 0, depth_read_only: bool = false, - stencil_load_op: LoadOp = .undef, - stencil_store_op: StoreOp = .undef, + stencil_load_op: LoadOp = .undefined, + stencil_store_op: StoreOp = .undefined, /// deprecated clear_stencil: u32 = 0, stencil_clear_value: u32 = 0, @@ -50,7 +50,7 @@ pub const RenderPassTimestampWrite = extern struct { pub const RequestAdapterOptions = extern struct { next_in_chain: ?*const ChainedStruct = null, compatible_surface: ?*Surface = null, - power_preference: PowerPreference = .undef, + power_preference: PowerPreference = .undefined, 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 BackendType = enum(u32) { - nul, + null, webgpu, d3d11, d3d12, @@ -126,7 +126,7 @@ pub const BackendType = enum(u32) { pub fn name(t: BackendType) []const u8 { return switch (t) { - .nul => "Null", + .null => "Null", .webgpu => "WebGPU", .d3d11 => "D3D11", .d3d12 => "D3D12", @@ -163,7 +163,7 @@ pub const BlendOperation = enum(u32) { }; pub const CompareFunction = enum(u32) { - undef = 0x00000000, + undefined = 0x00000000, never = 0x00000001, less = 0x00000002, less_equal = 0x00000003, @@ -220,7 +220,7 @@ pub const ErrorType = enum(u32) { }; pub const FeatureName = enum(u32) { - undef = 0x00000000, + undefined = 0x00000000, depth_clip_control = 0x00000001, depth32_float_stencil8 = 0x00000002, timestamp_query = 0x00000003, @@ -247,13 +247,13 @@ pub const FrontFace = enum(u32) { }; pub const IndexFormat = enum(u32) { - undef = 0x00000000, + undefined = 0x00000000, uint16 = 0x00000001, uint32 = 0x00000002, }; pub const LoadOp = enum(u32) { - undef = 0x00000000, + undefined = 0x00000000, clear = 0x00000001, load = 0x00000002, }; @@ -274,7 +274,7 @@ pub const PipelineStatisticName = enum(u32) { }; pub const PowerPreference = enum(u32) { - undef = 0x00000000, + undefined = 0x00000000, low_power = 0x00000001, high_performance = 0x00000002, }; @@ -352,18 +352,18 @@ pub const StencilOperation = enum(u32) { }; pub const StorageTextureAccess = enum(u32) { - undef = 0x00000000, + undefined = 0x00000000, write_only = 0x00000001, }; pub const StoreOp = enum(u32) { - undef = 0x00000000, + undefined = 0x00000000, store = 0x00000001, discard = 0x00000002, }; pub const VertexFormat = enum(u32) { - undef = 0x00000000, + undefined = 0x00000000, uint8x2 = 0x00000001, uint8x4 = 0x00000002, sint8x2 = 0x00000003, @@ -586,7 +586,7 @@ pub const PrimitiveState = extern struct { next_in_chain: NextInChain = .{ .generic = null }, topology: PrimitiveTopology = .triangle_list, - strip_index_format: IndexFormat = .undef, + strip_index_format: IndexFormat = .undefined, front_face: FrontFace = .ccw, cull_mode: CullMode = .none, }; @@ -605,8 +605,8 @@ pub const StencilFaceState = extern struct { pub const StorageTextureBindingLayout = extern struct { next_in_chain: ?*const ChainedStruct = null, - access: StorageTextureAccess = .undef, - format: Texture.Format = .undef, + access: StorageTextureAccess = .undefined, + format: Texture.Format = .undefined, view_dimension: TextureView.Dimension = .dimension_undef, };