From c3cfb77ac79e4781634a025ffd9a8683fdf85419 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Wed, 9 Mar 2022 08:14:46 -0700 Subject: [PATCH] gpu: correct enums to snake_case Signed-off-by: Stephen Gutekanst --- gpu/examples/main.zig | 8 +- gpu/src/feature_name.zig | 27 +++-- gpu/src/present_mode.zig | 7 +- gpu/src/texture_format.zig | 195 ++++++++++++++++++------------------- gpu/src/texture_usage.zig | 15 ++- 5 files changed, 124 insertions(+), 128 deletions(-) diff --git a/gpu/examples/main.zig b/gpu/examples/main.zig index 353f92b3..54481999 100644 --- a/gpu/examples/main.zig +++ b/gpu/examples/main.zig @@ -26,14 +26,14 @@ pub fn main() !void { const use_legacy_api = setup.backend_type == c.WGPUBackendType_OpenGL or setup.backend_type == c.WGPUBackendType_OpenGLES; var descriptor: gpu.SwapChain.Descriptor = undefined; if (!use_legacy_api) { - window_data.swap_chain_format = .BGRA8Unorm; + window_data.swap_chain_format = .bgra8_unorm; descriptor = .{ .label = "basic swap chain", - .usage = .RenderAttachment, + .usage = .render_attachment, .format = window_data.swap_chain_format, .width = framebuffer_size.width, .height = framebuffer_size.height, - .present_mode = .Fifo, + .present_mode = .fifo, .implementation = 0, }; window_data.surface = sample_utils.createSurfaceForWindow( @@ -53,7 +53,7 @@ pub fn main() !void { window_data.swap_chain_format = @intToEnum(gpu.TextureFormat, @intCast(u32, c.machUtilsBackendBinding_getPreferredSwapChainTextureFormat(binding))); window_data.swap_chain.?.configure( window_data.swap_chain_format, - .RenderAttachment, + .render_attachment, framebuffer_size.width, framebuffer_size.height, ); diff --git a/gpu/src/feature_name.zig b/gpu/src/feature_name.zig index 7823c93d..988590df 100644 --- a/gpu/src/feature_name.zig +++ b/gpu/src/feature_name.zig @@ -1,18 +1,17 @@ pub const FeatureName = enum(u32) { - Undefined = 0x00000000, - Depth24UnormStencil8 = 0x00000002, - Depth32FloatStencil8 = 0x00000003, - TimestampQuery = 0x00000004, - PipelineStatisticsQuery = 0x00000005, - TextureCompressionBC = 0x00000006, - TextureCompressionETC2 = 0x00000007, - TextureCompressionASTC = 0x00000008, - IndirectFirstInstance = 0x00000009, - DepthClamping = 0x000003E8, - DawnShaderFloat16 = 0x000003E9, - DawnInternalUsages = 0x000003EA, - DawnMultiPlanarFormats = 0x000003EB, - DawnNative = 0x000003EC, + depth24_unorm_stencil8 = 0x00000002, + depth32_float_stencil8 = 0x00000003, + timestamp_query = 0x00000004, + pipeline_statistics_query = 0x00000005, + texture_compression_bc = 0x00000006, + texture_compression_etc2 = 0x00000007, + texture_compression_astc = 0x00000008, + indirect_first_instance = 0x00000009, + depth_clamping = 0x000003e8, + dawn_shader_float16 = 0x000003e9, + dawn_internal_usages = 0x000003ea, + dawn_multi_planar_formats = 0x000003eb, + dawn_native = 0x000003ec, }; // TODO: add featureNameString method diff --git a/gpu/src/present_mode.zig b/gpu/src/present_mode.zig index 3a43cce9..78b9c76b 100644 --- a/gpu/src/present_mode.zig +++ b/gpu/src/present_mode.zig @@ -1,6 +1,5 @@ pub const PresentMode = enum(u32) { - // TODO: zig enums are not CamelCase - Immediate = 0x00000000, - Mailbox = 0x00000001, - Fifo = 0x00000002, + immediate = 0x00000000, + mailbox = 0x00000001, + fifo = 0x00000002, }; diff --git a/gpu/src/texture_format.zig b/gpu/src/texture_format.zig index d6c78357..2d358656 100644 --- a/gpu/src/texture_format.zig +++ b/gpu/src/texture_format.zig @@ -1,100 +1,99 @@ pub const TextureFormat = enum(u32) { - // TODO: enums not CamelCase - Undefined = 0x00000000, - R8Unorm = 0x00000001, - R8Snorm = 0x00000002, - R8Uint = 0x00000003, - R8Sint = 0x00000004, - R16Uint = 0x00000005, - R16Sint = 0x00000006, - R16Float = 0x00000007, - RG8Unorm = 0x00000008, - RG8Snorm = 0x00000009, - RG8Uint = 0x0000000A, - RG8Sint = 0x0000000B, - R32Float = 0x0000000C, - R32Uint = 0x0000000D, - R32Sint = 0x0000000E, - RG16Uint = 0x0000000F, - RG16Sint = 0x00000010, - RG16Float = 0x00000011, - RGBA8Unorm = 0x00000012, - RGBA8UnormSrgb = 0x00000013, - RGBA8Snorm = 0x00000014, - RGBA8Uint = 0x00000015, - RGBA8Sint = 0x00000016, - BGRA8Unorm = 0x00000017, - BGRA8UnormSrgb = 0x00000018, - RGB10A2Unorm = 0x00000019, - RG11B10Ufloat = 0x0000001A, - RGB9E5Ufloat = 0x0000001B, - RG32Float = 0x0000001C, - RG32Uint = 0x0000001D, - RG32Sint = 0x0000001E, - RGBA16Uint = 0x0000001F, - RGBA16Sint = 0x00000020, - RGBA16Float = 0x00000021, - RGBA32Float = 0x00000022, - RGBA32Uint = 0x00000023, - RGBA32Sint = 0x00000024, - Stencil8 = 0x00000025, - Depth16Unorm = 0x00000026, - Depth24Plus = 0x00000027, - Depth24PlusStencil8 = 0x00000028, - Depth24UnormStencil8 = 0x00000029, - Depth32Float = 0x0000002A, - Depth32FloatStencil8 = 0x0000002B, - BC1RGBAUnorm = 0x0000002C, - BC1RGBAUnormSrgb = 0x0000002D, - BC2RGBAUnorm = 0x0000002E, - BC2RGBAUnormSrgb = 0x0000002F, - BC3RGBAUnorm = 0x00000030, - BC3RGBAUnormSrgb = 0x00000031, - BC4RUnorm = 0x00000032, - BC4RSnorm = 0x00000033, - BC5RGUnorm = 0x00000034, - BC5RGSnorm = 0x00000035, - BC6HRGBUfloat = 0x00000036, - BC6HRGBFloat = 0x00000037, - BC7RGBAUnorm = 0x00000038, - BC7RGBAUnormSrgb = 0x00000039, - ETC2RGB8Unorm = 0x0000003A, - ETC2RGB8UnormSrgb = 0x0000003B, - ETC2RGB8A1Unorm = 0x0000003C, - ETC2RGB8A1UnormSrgb = 0x0000003D, - ETC2RGBA8Unorm = 0x0000003E, - ETC2RGBA8UnormSrgb = 0x0000003F, - EACR11Unorm = 0x00000040, - EACR11Snorm = 0x00000041, - EACRG11Unorm = 0x00000042, - EACRG11Snorm = 0x00000043, - ASTC4x4Unorm = 0x00000044, - ASTC4x4UnormSrgb = 0x00000045, - ASTC5x4Unorm = 0x00000046, - ASTC5x4UnormSrgb = 0x00000047, - ASTC5x5Unorm = 0x00000048, - ASTC5x5UnormSrgb = 0x00000049, - ASTC6x5Unorm = 0x0000004A, - ASTC6x5UnormSrgb = 0x0000004B, - ASTC6x6Unorm = 0x0000004C, - ASTC6x6UnormSrgb = 0x0000004D, - ASTC8x5Unorm = 0x0000004E, - ASTC8x5UnormSrgb = 0x0000004F, - ASTC8x6Unorm = 0x00000050, - ASTC8x6UnormSrgb = 0x00000051, - ASTC8x8Unorm = 0x00000052, - ASTC8x8UnormSrgb = 0x00000053, - ASTC10x5Unorm = 0x00000054, - ASTC10x5UnormSrgb = 0x00000055, - ASTC10x6Unorm = 0x00000056, - ASTC10x6UnormSrgb = 0x00000057, - ASTC10x8Unorm = 0x00000058, - ASTC10x8UnormSrgb = 0x00000059, - ASTC10x10Unorm = 0x0000005A, - ASTC10x10UnormSrgb = 0x0000005B, - ASTC12x10Unorm = 0x0000005C, - ASTC12x10UnormSrgb = 0x0000005D, - ASTC12x12Unorm = 0x0000005E, - ASTC12x12UnormSrgb = 0x0000005F, - R8BG8Biplanar420Unorm = 0x00000060, + none = 0x00000000, + r8_unorm = 0x00000001, + r8_snorm = 0x00000002, + r8_uint = 0x00000003, + r8_sint = 0x00000004, + r16_uint = 0x00000005, + r16_sint = 0x00000006, + r16_float = 0x00000007, + rg8_unorm = 0x00000008, + rg8_snorm = 0x00000009, + rg8_uint = 0x0000000a, + rg8_sint = 0x0000000b, + r32_float = 0x0000000c, + r32_uint = 0x0000000d, + r32_sint = 0x0000000e, + rg16_uint = 0x0000000f, + rg16_sint = 0x00000010, + rg16_float = 0x00000011, + rgba8_unorm = 0x00000012, + rgba8_unorm_srgb = 0x00000013, + rgba8_snorm = 0x00000014, + rgba8_uint = 0x00000015, + rgba8_sint = 0x00000016, + bgra8_unorm = 0x00000017, + bgra8_unorm_srgb = 0x00000018, + rgb10a2_unorm = 0x00000019, + rg11b10u_float = 0x0000001a, + rgb9e5u_float = 0x0000001b, + rg32_float = 0x0000001c, + rg32_uint = 0x0000001d, + rg32_sint = 0x0000001e, + rgba16_uint = 0x0000001f, + rgba16_sint = 0x00000020, + rgba16_float = 0x00000021, + rgba32_float = 0x00000022, + rgba32_uint = 0x00000023, + rgba32_sint = 0x00000024, + stencil8 = 0x00000025, + depth16_unorm = 0x00000026, + depth24_plus = 0x00000027, + depth24_plus_stencil8 = 0x00000028, + depth24_unorm_stencil8 = 0x00000029, + depth32_float = 0x0000002a, + depth32_float_stencil8 = 0x0000002b, + bc1rgba_unorm = 0x0000002c, + bc1rgba_unorm_srgb = 0x0000002d, + bc2rgba_unorm = 0x0000002e, + bc2rgba_unorm_srgb = 0x0000002f, + bc3rgba_unorm = 0x00000030, + bc3rgba_unorm_srgb = 0x00000031, + bc4r_unorm = 0x00000032, + bc4r_snorm = 0x00000033, + bc5rg_unorm = 0x00000034, + bc5rg_snorm = 0x00000035, + bc6hrgbu_float = 0x00000036, + bc6hrgb_float = 0x00000037, + bc7rgba_unorm = 0x00000038, + bc7rgba_unorm_srgb = 0x00000039, + etc2rgb8_unorm = 0x0000003a, + etc2rgb8_unorm_srgb = 0x0000003b, + etc2rgb8a1_unorm = 0x0000003c, + etc2rgb8a1_unorm_srgb = 0x0000003d, + etc2rgba8_unorm = 0x0000003e, + etc2rgba8_unorm_srgb = 0x0000003f, + eacr11_unorm = 0x00000040, + eacr11_snorm = 0x00000041, + eacrg11_unorm = 0x00000042, + eacrg11_snorm = 0x00000043, + astc4x4_unorm = 0x00000044, + astc4x4_unorm_srgb = 0x00000045, + astc5x4_unorm = 0x00000046, + astc5x4_unorm_srgb = 0x00000047, + astc5x5_unorm = 0x00000048, + astc5x5_unorm_srgb = 0x00000049, + astc6x5_unorm = 0x0000004a, + astc6x5_unorm_srgb = 0x0000004b, + astc6x6_unorm = 0x0000004c, + astc6x6_unorm_srgb = 0x0000004d, + astc8x5_unorm = 0x0000004e, + astc8x5_unorm_srgb = 0x0000004f, + astc8x6_unorm = 0x00000050, + astc8x6_unorm_srgb = 0x00000051, + astc8x8_unorm = 0x00000052, + astc8x8_unorm_srgb = 0x00000053, + astc10x5_unorm = 0x00000054, + astc10x5_unorm_srgb = 0x00000055, + astc10x6_unorm = 0x00000056, + astc10x6_unorm_srgb = 0x00000057, + astc10x8_unorm = 0x00000058, + astc10x8_unorm_srgb = 0x00000059, + astc10x10_unorm = 0x0000005a, + astc10x10_unorm_srgb = 0x0000005b, + astc12x10_unorm = 0x0000005c, + astc12x10_unorm_srgb = 0x0000005d, + astc12x12_unorm = 0x0000005e, + astc12x12_unorm_srgb = 0x0000005f, + r8bg8biplanar420_unorm = 0x00000060, }; diff --git a/gpu/src/texture_usage.zig b/gpu/src/texture_usage.zig index d582ae91..697b4a44 100644 --- a/gpu/src/texture_usage.zig +++ b/gpu/src/texture_usage.zig @@ -1,10 +1,9 @@ pub const TextureUsage = enum(u32) { - // TODO: enums not CamelCase - None = 0x00000000, - CopySrc = 0x00000001, - CopyDst = 0x00000002, - TextureBinding = 0x00000004, - StorageBinding = 0x00000008, - RenderAttachment = 0x00000010, - Present = 0x00000020, + none = 0x00000000, + copy_src = 0x00000001, + copy_dst = 0x00000002, + texture_binding = 0x00000004, + storage_binding = 0x00000008, + render_attachment = 0x00000010, + present = 0x00000020, };