From 979c3dd9c6bc5d702b31b21629259c058a4b5338 Mon Sep 17 00:00:00 2001 From: asimos-bot Date: Mon, 13 Oct 2025 23:18:07 -0300 Subject: [PATCH 1/3] add llvm option to triangle example --- README.md | 2 +- build.zig | 6 + build.zig.zon | 60 +++---- examples/bmp.zig | 25 +-- examples/triangle/triangle.zig | 74 ++++---- src/adapter.zig | 83 ++++----- src/bind_group.zig | 34 ++-- src/buffer.zig | 76 ++++---- src/command_encoder.zig | 164 +++++++++-------- src/device.zig | 116 ++++++------ src/global.zig | 9 +- src/instance.zig | 91 +++++----- src/log.zig | 15 +- src/misc.zig | 130 +++++++------- src/pipeline.zig | 260 ++++++++++++++------------- src/query_set.zig | 41 ++--- src/queue.zig | 29 +-- src/render_bundle.zig | 47 ++--- src/sampler.zig | 39 ++-- src/shader.zig | 64 ++++--- src/surface.zig | 83 ++++----- src/texture.zig | 315 +++++++++++++++++---------------- tests/compute.zig | 42 +++-- tests/compute_c.zig | 69 ++++---- 24 files changed, 930 insertions(+), 944 deletions(-) diff --git a/README.md b/README.md index b1a51f0..338ad02 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ b.getInstallStep().dependOn(&install_dll.step); message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque - ) callconv(.C) void { + ) callconv(.c) void { switch(status) { .success => { const ud_adapter: **Adapter = @ptrCast(@alignCast(userdata1)); diff --git a/build.zig b/build.zig index 421a8da..bed14bf 100644 --- a/build.zig +++ b/build.zig @@ -54,6 +54,7 @@ const WGPUBuildContext = struct { install_lib_dir: []const u8, wgpu_mod: *std.Build.Module, wgpu_c_mod: *std.Build.Module, + use_llvm: bool, fn init(b: *std.Build) ?WGPUBuildContext { const link_mode = b.option(std.builtin.LinkMode, "link_mode", "Use static linking instead of dynamic linking.") orelse .static; @@ -212,6 +213,7 @@ const WGPUBuildContext = struct { .install_lib_dir = b.getInstallPath(.lib, ""), .wgpu_mod = wgpu_mod, .wgpu_c_mod = wgpu_c_mod, + .use_llvm = b.option(bool, "use_llvm", "Force use of LLVM") orelse false, }; } }; @@ -247,6 +249,7 @@ fn triangle_example(b: *std.Build, context: *const WGPUBuildContext) void { const triangle_example_exe = b.addExecutable(.{ .name = "triangle-example", .root_module = triangle_example_exe_mod, + .use_llvm = context.use_llvm, }); handle_rt(context, triangle_example_exe); @@ -289,6 +292,7 @@ fn unit_tests(b: *std.Build, context: *const WGPUBuildContext) void { const t = b.addTest(.{ .name = test_name, .root_module = test_mod, + .use_llvm = context.use_llvm, }); handle_rt(context, t); if (context.libwgpu_path != null) { @@ -333,6 +337,7 @@ fn compute_tests(b: *std.Build, context: *const WGPUBuildContext) void { const compute_test = b.addTest(.{ .name = "compute-test", .root_module = compute_test_mod, + .use_llvm = context.use_llvm, }); handle_rt(context, compute_test); @@ -347,6 +352,7 @@ fn compute_tests(b: *std.Build, context: *const WGPUBuildContext) void { const compute_test_c = b.addTest(.{ .name = "compute-test-c", .root_module = compute_test_c_mod, + .use_llvm = context.use_llvm, }); handle_rt(context, compute_test_c); diff --git a/build.zig.zon b/build.zig.zon index 8b887af..7238252 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -45,152 +45,152 @@ // .lazy = false, //}, .wgpu_android_aarch64_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-android-aarch64-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-aarch64-debug.zip", .hash = "N-V-__8AAPQyVxT6i7mm0AzaidOZmgXO0JlVRTK4cIzdhiIJ", .lazy = true, }, .wgpu_android_aarch64_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-android-aarch64-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-aarch64-release.zip", .hash = "N-V-__8AAH5jwgMJj3SR-h6LEpl2nU1rEwl4tS6ZGvV4Kr_A", .lazy = true, }, .wgpu_android_armv7_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-android-armv7-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-armv7-debug.zip", .hash = "N-V-__8AAPrsHxCJ4mgD4JYP4LlWrV8cgHLPzAdz5HePfW-0", .lazy = true, }, .wgpu_android_armv7_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-android-armv7-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-armv7-release.zip", .hash = "N-V-__8AAHKm5wI40Gj43wFTj6iZnGz9id_y087a-jnfQBRi", .lazy = true, }, .wgpu_android_x86_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-android-i686-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-i686-debug.zip", .hash = "N-V-__8AAMD9TBCN2rrJG9dqTyQh0Wv9MWisv3bSIdoMH_VG", .lazy = true, }, .wgpu_android_x86_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-android-i686-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-i686-release.zip", .hash = "N-V-__8AAFwDIQNZ003uYMHrFbiexqSqI3sVgpXB2W4DLoqq", .lazy = true, }, .wgpu_android_x86_64_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-android-x86_64-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-x86_64-debug.zip", .hash = "N-V-__8AAAAjNBQaSprsYmeSlIDJWQg-jZHiUxxIMHylLp7E", .lazy = true, }, .wgpu_android_x86_64_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-android-x86_64-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-x86_64-release.zip", .hash = "N-V-__8AALxtxANPhha93qENJNdLw9ZAaHUXp2_X8QBskpOM", .lazy = true, }, .wgpu_ios_aarch64_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-ios-aarch64-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-ios-aarch64-debug.zip", .hash = "N-V-__8AAJj1lQlJYBWH3qMo3USVJcGKJ1ithSzQ-u04QUxa", .lazy = true, }, .wgpu_ios_aarch64_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-ios-aarch64-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-ios-aarch64-release.zip", .hash = "N-V-__8AALh8YgKjs1OKvnTlaRqB_euceGNN_TfX1HLMrnNi", .lazy = true, }, .wgpu_ios_aarch64_simulator_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-ios-aarch64-simulator-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-ios-aarch64-simulator-debug.zip", .hash = "N-V-__8AAABClgk_Seuqe9XuxYUDDZe9T9aOYuhd4JhXTeg9", .lazy = true, }, .wgpu_ios_aarch64_simulator_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-ios-aarch64-simulator-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-ios-aarch64-simulator-release.zip", .hash = "N-V-__8AAAgFYgLavBRZjHgkULhWRweVNw-VeLMxcxRHZYF1", .lazy = true, }, .wgpu_ios_x86_64_simulator_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-ios-x86_64-simulator-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-ios-x86_64-simulator-debug.zip", .hash = "N-V-__8AAKCSXgkyBFHn1Uwy1Sop2KeA6XwmrVs2_C8cru8M", .lazy = true, }, .wgpu_ios_x86_64_simulator_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-ios-x86_64-simulator-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-ios-x86_64-simulator-release.zip", .hash = "N-V-__8AAPBFWQJxhwRTeBxlztWVNalvobmyX_zEoF24X_S6", .lazy = true, }, .wgpu_linux_aarch64_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-linux-aarch64-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-linux-aarch64-debug.zip", .hash = "N-V-__8AALSbGhS93ZKwkkKk-yN3BzFl6iBPh9etfftVkhSk", .lazy = true, }, .wgpu_linux_aarch64_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-linux-aarch64-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-linux-aarch64-release.zip", .hash = "N-V-__8AAC42tgMsCqChk-HZ0n7dyD1HT29f6QM0UTCdj_iF", .lazy = true, }, .wgpu_linux_x86_64_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-linux-x86_64-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-linux-x86_64-debug.zip", .hash = "N-V-__8AAHS_-BNtAmT4hK9geZG361RETmD2lG0fk2gyDYh-", .lazy = true, }, .wgpu_linux_x86_64_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-linux-x86_64-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-linux-x86_64-release.zip", .hash = "N-V-__8AALK1sQPqMGESXUOHBpzwDj1GMf_nYBdfbjewJ9kH", .lazy = true, }, .wgpu_macos_aarch64_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-macos-aarch64-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-macos-aarch64-debug.zip", .hash = "N-V-__8AACj6lQmZEGeyjdn2CCD0as1hGMvrAUBsoTuBu_cR", .lazy = true, }, .wgpu_macos_aarch64_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-macos-aarch64-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-macos-aarch64-release.zip", .hash = "N-V-__8AAGDGYgIAQ6tOKxxonhabDmuFj9Y35AKvPwynW_UO", .lazy = true, }, .wgpu_macos_x86_64_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-macos-x86_64-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-macos-x86_64-debug.zip", .hash = "N-V-__8AAOCufAlp1bMuFqQCd152bYQLNu-tjLdu9edJ8b4e", .lazy = true, }, .wgpu_macos_x86_64_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-macos-x86_64-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-macos-x86_64-release.zip", .hash = "N-V-__8AAFi6YgLHU9dEEx9n190MvnIZaCq5SVMg8BX7zD87", .lazy = true, }, .wgpu_windows_aarch64_msvc_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-windows-aarch64-msvc-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-aarch64-msvc-debug.zip", .hash = "N-V-__8AACUsDR0QuXpFRCjd-TcdKredsnN5Uiy6thaqghfy", .lazy = true, }, .wgpu_windows_aarch64_msvc_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-windows-aarch64-msvc-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-aarch64-msvc-release.zip", .hash = "N-V-__8AAEmpwwOechqvtlmAlMzCIbnIzIgSYcfEUWhSZ7Cj", .lazy = true, }, .wgpu_windows_x86_msvc_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-windows-i686-msvc-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-i686-msvc-debug.zip", .hash = "N-V-__8AAP8AIx3OgW8N8DkBj5JMcJUkcy7iHLuOH--fY3IX", .lazy = true, }, .wgpu_windows_x86_msvc_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-windows-i686-msvc-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-i686-msvc-release.zip", .hash = "N-V-__8AAMn2lQPoxD9cdgm97Fvxqes4Jlvwct-GWDgsws5k", .lazy = true, }, .wgpu_windows_x86_64_msvc_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-windows-x86_64-msvc-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-x86_64-msvc-debug.zip", .hash = "N-V-__8AADEvMB0uTuAXXabR4Fw-2LjtJfoSP8vux2m_eDok", .lazy = true, }, .wgpu_windows_x86_64_msvc_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-windows-x86_64-msvc-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-x86_64-msvc-release.zip", .hash = "N-V-__8AAG8mAQR0Vg9K8e0Ln46g_UJq1HqtXwif_Uvt1_ZE", .lazy = true, }, .wgpu_windows_x86_64_gnu_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-windows-x86_64-gnu-debug.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-x86_64-gnu-debug.zip", .hash = "N-V-__8AAFICSxIMF7kdKvI3pTwiLWmIxjSopWIadDt9yUpp", .lazy = true, }, .wgpu_windows_x86_64_gnu_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v25.0.2.1/wgpu-windows-x86_64-gnu-release.zip", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-x86_64-gnu-release.zip", .hash = "N-V-__8AAMZ8DwPtTjIxd_0zIGEoJwriDQY-Ykx8ldVc_7N0", .lazy = true, }, diff --git a/examples/bmp.zig b/examples/bmp.zig index ddc1b65..875d35f 100644 --- a/examples/bmp.zig +++ b/examples/bmp.zig @@ -4,17 +4,16 @@ pub fn write24BitBMP(file_name: []const u8, comptime width: u32, comptime height const file = try std.fs.cwd().createFile(file_name, .{}); defer file.close(); - var writer = file.writer(); + var buffer: [1024]u8 = undefined; + var fw = file.writer(&buffer); + const writer = &fw.interface; + + const bytes_per_line = comptime std.mem.alignForward(u32, width * 3, 4); + const file_size = 54 + (bytes_per_line * height); // ID - _ = try writer.write(&[2]u8{'B', 'M'}); + _ = try writer.write(&[2]u8{ 'B', 'M' }); - const colors_per_line = width * 3; - const bytes_per_line = switch(colors_per_line & 0x00000003) { - 0 => colors_per_line, - else => (colors_per_line | 0x00000003) + 1, - }; - const file_size = 54 + (bytes_per_line * height); try writer.writeInt(u32, file_size, .little); // reserved @@ -33,9 +32,9 @@ pub fn write24BitBMP(file_name: []const u8, comptime width: u32, comptime height try writer.writeInt(u16, 24, .little); // Six 32-bit words, all set to zero: // compression type, compressed image size, x pixels/meter, y pixels/meter, colors used, important colors - try writer.writeByteNTimes(0, 4 * 6); + try writer.splatByteAll(0, 4 * 6); - var line_buffer = [_]u8{0} ** bytes_per_line; + var line_buffer: [bytes_per_line]u8 = @splat(0); const bgra_pixels_per_line = width * 4; for (0..height) |i_y| { const y = height - i_y - 1; @@ -45,8 +44,10 @@ pub fn write24BitBMP(file_name: []const u8, comptime width: u32, comptime height const bgra_pixel_offset = line_offset + (x * 4); line_buffer[bgr_pixel_offset] = bgra_data[bgra_pixel_offset]; line_buffer[bgr_pixel_offset + 1] = bgra_data[bgra_pixel_offset + 1]; - line_buffer[bgr_pixel_offset + 2] = bgra_data[bgra_pixel_offset + 2]; + line_buffer[bgr_pixel_offset + 2] = bgra_data[bgra_pixel_offset + 2]; } _ = try writer.write(&line_buffer); } -} \ No newline at end of file + try writer.flush(); +} + diff --git a/examples/triangle/triangle.zig b/examples/triangle/triangle.zig index f0fbf25..45c3907 100644 --- a/examples/triangle/triangle.zig +++ b/examples/triangle/triangle.zig @@ -2,7 +2,7 @@ const std = @import("std"); const wgpu = @import("wgpu"); const bmp = @import("bmp"); -const output_extent = wgpu.Extent3D { +const output_extent = wgpu.Extent3D{ .width = 640, .height = 480, .depth_or_array_layers = 1, @@ -10,7 +10,7 @@ const output_extent = wgpu.Extent3D { const output_bytes_per_row = 4 * output_extent.width; const output_size = output_bytes_per_row * output_extent.height; -fn handleBufferMap(status: wgpu.MapAsyncStatus, _: wgpu.StringView, userdata1: ?*anyopaque, _: ?*anyopaque) callconv(.C) void { +fn handleBufferMap(status: wgpu.MapAsyncStatus, _: wgpu.StringView, userdata1: ?*anyopaque, _: ?*anyopaque) callconv(.c) void { std.log.info("buffer_map status={x:.8}\n", .{@intFromEnum(status)}); const complete: *bool = @ptrCast(@alignCast(userdata1)); complete.* = true; @@ -22,17 +22,17 @@ pub fn main() !void { const instance = wgpu.Instance.create(null).?; defer instance.release(); - const adapter_request = instance.requestAdapterSync(&wgpu.RequestAdapterOptions {}, 0); - const adapter = switch(adapter_request.status) { + const adapter_request = instance.requestAdapterSync(&wgpu.RequestAdapterOptions{}, 0); + const adapter = switch (adapter_request.status) { .success => adapter_request.adapter.?, else => return error.NoAdapter, }; defer adapter.release(); - const device_request = adapter.requestDeviceSync(instance, &wgpu.DeviceDescriptor { + const device_request = adapter.requestDeviceSync(instance, &wgpu.DeviceDescriptor{ .required_limits = null, }, 0); - const device = switch(device_request.status) { + const device = switch (device_request.status) { .success => device_request.device.?, else => return error.NoDevice, }; @@ -43,7 +43,7 @@ pub fn main() !void { const swap_chain_format = wgpu.TextureFormat.bgra8_unorm_srgb; - const target_texture = device.createTexture(&wgpu.TextureDescriptor { + const target_texture = device.createTexture(&wgpu.TextureDescriptor{ .label = wgpu.StringView.fromSlice("Render texture"), .size = output_extent, .format = swap_chain_format, @@ -51,7 +51,7 @@ pub fn main() !void { }).?; defer target_texture.release(); - const target_texture_view = target_texture.createView(&wgpu.TextureViewDescriptor { + const target_texture_view = target_texture.createView(&wgpu.TextureViewDescriptor{ .label = wgpu.StringView.fromSlice("Render texture view"), .mip_level_count = 1, .array_layer_count = 1, @@ -62,7 +62,7 @@ pub fn main() !void { })).?; defer shader_module.release(); - const staging_buffer = device.createBuffer(&wgpu.BufferDescriptor { + const staging_buffer = device.createBuffer(&wgpu.BufferDescriptor{ .label = wgpu.StringView.fromSlice("staging_buffer"), .usage = wgpu.BufferUsages.map_read | wgpu.BufferUsages.copy_dst, .size = output_size, @@ -70,16 +70,16 @@ pub fn main() !void { }).?; defer staging_buffer.release(); - const color_targets = &[_] wgpu.ColorTargetState{ - wgpu.ColorTargetState { + const color_targets = &[_]wgpu.ColorTargetState{ + wgpu.ColorTargetState{ .format = swap_chain_format, - .blend = &wgpu.BlendState { - .color = wgpu.BlendComponent { + .blend = &wgpu.BlendState{ + .color = wgpu.BlendComponent{ .operation = .add, .src_factor = .src_alpha, .dst_factor = .one_minus_src_alpha, }, - .alpha = wgpu.BlendComponent { + .alpha = wgpu.BlendComponent{ .operation = .add, .src_factor = .zero, .dst_factor = .one, @@ -88,37 +88,30 @@ pub fn main() !void { }, }; - const pipeline = device.createRenderPipeline(&wgpu.RenderPipelineDescriptor { - .vertex = wgpu.VertexState { + const pipeline = device.createRenderPipeline(&wgpu.RenderPipelineDescriptor{ + .vertex = wgpu.VertexState{ .module = shader_module, .entry_point = wgpu.StringView.fromSlice("vs_main"), }, - .primitive = wgpu.PrimitiveState {}, - .fragment = &wgpu.FragmentState { - .module = shader_module, - .entry_point = wgpu.StringView.fromSlice("fs_main"), - .target_count = color_targets.len, - .targets = color_targets.ptr - }, - .multisample = wgpu.MultisampleState {}, + .primitive = wgpu.PrimitiveState{}, + .fragment = &wgpu.FragmentState{ .module = shader_module, .entry_point = wgpu.StringView.fromSlice("fs_main"), .target_count = color_targets.len, .targets = color_targets.ptr }, + .multisample = wgpu.MultisampleState{}, }).?; defer pipeline.release(); { // Mock main "loop" const next_texture = target_texture_view; - const encoder = device.createCommandEncoder(&wgpu.CommandEncoderDescriptor { + const encoder = device.createCommandEncoder(&wgpu.CommandEncoderDescriptor{ .label = wgpu.StringView.fromSlice("Command Encoder"), }).?; defer encoder.release(); - const color_attachments = &[_]wgpu.ColorAttachment{ - wgpu.ColorAttachment { - .view = next_texture, - .clear_value = wgpu.Color {}, - } - }; - const render_pass = encoder.beginRenderPass(&wgpu.RenderPassDescriptor { + const color_attachments = &[_]wgpu.ColorAttachment{wgpu.ColorAttachment{ + .view = next_texture, + .clear_value = wgpu.Color{}, + }}; + const render_pass = encoder.beginRenderPass(&wgpu.RenderPassDescriptor{ .color_attachment_count = color_attachments.len, .color_attachments = color_attachments.ptr, }).?; @@ -133,12 +126,12 @@ pub fn main() !void { defer next_texture.release(); - const img_copy_src = wgpu.TexelCopyTextureInfo { - .origin = wgpu.Origin3D {}, + const img_copy_src = wgpu.TexelCopyTextureInfo{ + .origin = wgpu.Origin3D{}, .texture = target_texture, }; - const img_copy_dst = wgpu.TexelCopyBufferInfo { - .layout = wgpu.TexelCopyBufferLayout { + const img_copy_dst = wgpu.TexelCopyBufferInfo{ + .layout = wgpu.TexelCopyBufferLayout{ .bytes_per_row = output_bytes_per_row, .rows_per_image = output_extent.height, }, @@ -147,7 +140,7 @@ pub fn main() !void { encoder.copyTextureToBuffer(&img_copy_src, &img_copy_dst, &output_extent); - const command_buffer = encoder.finish(&wgpu.CommandBufferDescriptor { + const command_buffer = encoder.finish(&wgpu.CommandBufferDescriptor{ .label = wgpu.StringView.fromSlice("Command Buffer"), }).?; defer command_buffer.release(); @@ -155,12 +148,12 @@ pub fn main() !void { queue.submit(&[_]*const wgpu.CommandBuffer{command_buffer}); var buffer_map_complete = false; - _ = staging_buffer.mapAsync(wgpu.MapModes.read, 0, output_size, wgpu.BufferMapCallbackInfo { + _ = staging_buffer.mapAsync(wgpu.MapModes.read, 0, output_size, wgpu.BufferMapCallbackInfo{ .callback = handleBufferMap, .userdata1 = @ptrCast(&buffer_map_complete), }); instance.processEvents(); - while(!buffer_map_complete) { + while (!buffer_map_complete) { instance.processEvents(); } // _ = device.poll(true, null); @@ -171,4 +164,5 @@ pub fn main() !void { const output = buf[0..output_size]; try bmp.write24BitBMP("examples/output/triangle.bmp", output_extent.width, output_extent.height, output); } -} \ No newline at end of file +} + diff --git a/src/adapter.zig b/src/adapter.zig index b319239..c4dc74b 100644 --- a/src/adapter.zig +++ b/src/adapter.zig @@ -30,33 +30,33 @@ const CallbackMode = _async.CallbackMode; const Future = _async.Future; pub const PowerPreference = enum(u32) { - @"undefined" = 0x00000000, // No preference. - low_power = 0x00000001, - high_performance = 0x00000002, + undefined = 0x00000000, // No preference. + low_power = 0x00000001, + high_performance = 0x00000002, }; pub const AdapterType = enum(u32) { - discrete_gpu = 0x00000001, + discrete_gpu = 0x00000001, integrated_gpu = 0x00000002, - cpu = 0x00000003, - unknown = 0x00000004, + cpu = 0x00000003, + unknown = 0x00000004, }; pub const BackendType = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument - null = 0x00000001, - webgpu = 0x00000002, - d3d11 = 0x00000003, - d3d12 = 0x00000004, - metal = 0x00000005, - vulkan = 0x00000006, - opengl = 0x00000007, - opengl_es = 0x00000008, + undefined = 0x00000000, // Indicates no value is passed for this argument + null = 0x00000001, + webgpu = 0x00000002, + d3d11 = 0x00000003, + d3d12 = 0x00000004, + metal = 0x00000005, + vulkan = 0x00000006, + opengl = 0x00000007, + opengl_es = 0x00000008, }; pub const FeatureLevel = enum(u32) { compatibility = 0x00000001, // "Compatibility" profile which can be supported on OpenGL ES 3.1. - core = 0x00000002, // "Core" profile which can be supported on Vulkan/Metal/D3D12. + core = 0x00000002, // "Core" profile which can be supported on Vulkan/Metal/D3D12. }; pub const RequestAdapterOptions = extern struct { @@ -69,7 +69,7 @@ pub const RequestAdapterOptions = extern struct { // FeatureLevel.core is the default in the JS API, but in C, this field is **required** (must not be undefined). feature_level: FeatureLevel = FeatureLevel.core, - power_preference: PowerPreference = PowerPreference.@"undefined", + power_preference: PowerPreference = PowerPreference.undefined, // If true, requires the adapter to be a "fallback" adapter as defined by the JS spec. // If this is not possible, the request returns null. @@ -77,7 +77,7 @@ pub const RequestAdapterOptions = extern struct { // If set, requires the adapter to have a particular backend type. // If this is not possible, the request returns null. - backend_type: BackendType = BackendType.@"undefined", + backend_type: BackendType = BackendType.undefined, // If set, requires the adapter to be able to output to a particular surface. // If this is not possible, the request returns null. @@ -85,11 +85,11 @@ pub const RequestAdapterOptions = extern struct { }; pub const RequestAdapterStatus = enum(u32) { - success = 0x00000001, + success = 0x00000001, instance_dropped = 0x00000002, - unavailable = 0x00000003, - @"error" = 0x00000004, - unknown = 0x00000005, + unavailable = 0x00000003, + @"error" = 0x00000004, + unknown = 0x00000005, }; pub const RequestAdapterCallbackInfo = extern struct { @@ -104,13 +104,13 @@ pub const RequestAdapterCallbackInfo = extern struct { }; // TODO: This should maybe be relocated to instance.zig; it is only used there. -pub const RequestAdapterCallback = *const fn( +pub const RequestAdapterCallback = *const fn ( status: RequestAdapterStatus, adapter: ?*Adapter, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque, -) callconv(.C) void; +) callconv(.c) void; pub const RequestAdapterResponse = struct { status: RequestAdapterStatus, @@ -119,7 +119,7 @@ pub const RequestAdapterResponse = struct { }; pub const AdapterInfoProcs = struct { - pub const FreeMembers = *const fn(AdapterInfo) callconv(.C) void; + pub const FreeMembers = *const fn (AdapterInfo) callconv(.c) void; }; extern fn wgpuAdapterInfoFreeMembers(adapter_info: AdapterInfo) void; @@ -141,13 +141,13 @@ pub const AdapterInfo = extern struct { }; pub const AdapterProcs = struct { - pub const GetFeatures = *const fn(*Adapter, *SupportedFeatures) callconv(.C) void; - pub const GetLimits = *const fn(*Adapter, *Limits) callconv(.C) Status; - pub const GetInfo = *const fn(*Adapter, *AdapterInfo) callconv(.C) Status; - pub const HasFeature = *const fn(*Adapter, FeatureName) callconv(.C) WGPUBool; - pub const RequestDevice = *const fn(*Adapter, ?*const DeviceDescriptor, RequestDeviceCallbackInfo) callconv(.C) Future; - pub const AddRef = *const fn(*Adapter) callconv(.C) void; - pub const Release = *const fn(*Adapter) callconv(.C) void; + pub const GetFeatures = *const fn (*Adapter, *SupportedFeatures) callconv(.c) void; + pub const GetLimits = *const fn (*Adapter, *Limits) callconv(.c) Status; + pub const GetInfo = *const fn (*Adapter, *AdapterInfo) callconv(.c) Status; + pub const HasFeature = *const fn (*Adapter, FeatureName) callconv(.c) WGPUBool; + pub const RequestDevice = *const fn (*Adapter, ?*const DeviceDescriptor, RequestDeviceCallbackInfo) callconv(.c) Future; + pub const AddRef = *const fn (*Adapter) callconv(.c) void; + pub const Release = *const fn (*Adapter) callconv(.c) void; }; extern fn wgpuAdapterGetFeatures(adapter: *Adapter, features: *SupportedFeatures) void; @@ -158,7 +158,7 @@ extern fn wgpuAdapterRequestDevice(adapter: *Adapter, descriptor: ?*const Device extern fn wgpuAdapterAddRef(adapter: *Adapter) void; extern fn wgpuAdapterRelease(adapter: *Adapter) void; -pub const Adapter = opaque{ +pub const Adapter = opaque { pub inline fn getFeatures(self: *Adapter, features: *SupportedFeatures) void { wgpuAdapterGetFeatures(self, features); } @@ -172,9 +172,9 @@ pub const Adapter = opaque{ return wgpuAdapterHasFeature(self, feature) != 0; } - fn defaultDeviceCallback(status: RequestDeviceStatus, device: ?*Device, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.C) void { + fn defaultDeviceCallback(status: RequestDeviceStatus, device: ?*Device, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.c) void { const ud_response: *RequestDeviceResponse = @ptrCast(@alignCast(userdata1)); - ud_response.* = RequestDeviceResponse { + ud_response.* = RequestDeviceResponse{ .status = status, .message = message.toSlice(), .device = device, @@ -189,7 +189,7 @@ pub const Adapter = opaque{ pub fn requestDeviceSync(self: *Adapter, instance: *Instance, descriptor: ?*const DeviceDescriptor, polling_interval_nanoseconds: u64) RequestDeviceResponse { var response: RequestDeviceResponse = undefined; var completed = false; - const callback_info = RequestDeviceCallbackInfo { + const callback_info = RequestDeviceCallbackInfo{ .callback = defaultDeviceCallback, .userdata1 = @ptrCast(&response), .userdata2 = @ptrCast(&completed), @@ -200,7 +200,7 @@ pub const Adapter = opaque{ // it takes in futures and returns when one of them completes. _ = device_future; instance.processEvents(); - while(!completed) { + while (!completed) { std.Thread.sleep(polling_interval_nanoseconds); instance.processEvents(); } @@ -224,14 +224,15 @@ test "can request device" { const instance = Instance.create(null); const adapter_response = instance.?.requestAdapterSync(null, 200_000_000); - const adapter: ?*Adapter = switch(adapter_response.status) { + const adapter: ?*Adapter = switch (adapter_response.status) { .success => adapter_response.adapter, else => null, }; const device_response = adapter.?.requestDeviceSync(instance.?, null, 200_000_000); - const device: ?*Device = switch(device_response.status) { + const device: ?*Device = switch (device_response.status) { .success => device_response.device, - else => null + else => null, }; try testing.expect(device != null); -} \ No newline at end of file +} + diff --git a/src/bind_group.zig b/src/bind_group.zig index e32465f..9c0280a 100644 --- a/src/bind_group.zig +++ b/src/bind_group.zig @@ -26,7 +26,7 @@ const WGPU_WHOLE_SIZE = _misc.WGPU_WHOLE_SIZE; const StringView = _misc.StringView; pub const BindGroupLayoutEntryExtras = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.bind_group_layout_entry_extras, }, @@ -38,22 +38,22 @@ pub const BindGroupLayoutEntry = extern struct { next_in_chain: ?*const ChainedStruct = null, binding: u32, visibility: ShaderStage, - buffer: BufferBindingLayout = BufferBindingLayout { - .@"type" = BufferBindingType.binding_not_used, + buffer: BufferBindingLayout = BufferBindingLayout{ + .type = BufferBindingType.binding_not_used, }, - sampler: SamplerBindingLayout = SamplerBindingLayout { - .@"type" = SamplerBindingType.binding_not_used, + sampler: SamplerBindingLayout = SamplerBindingLayout{ + .type = SamplerBindingType.binding_not_used, }, - texture: TextureBindingLayout = TextureBindingLayout { + texture: TextureBindingLayout = TextureBindingLayout{ .sample_type = SampleType.binding_not_used, }, - storage_texture: StorageTextureBindingLayout = StorageTextureBindingLayout { + storage_texture: StorageTextureBindingLayout = StorageTextureBindingLayout{ .access = StorageTextureAccess.binding_not_used, }, pub inline fn withCount(self: BindGroupLayoutEntry, count: u32) BindGroupLayoutEntry { var bgle = self; - bgle.next_in_chain = @ptrCast(&BindGroupLayoutEntryExtras { + bgle.next_in_chain = @ptrCast(&BindGroupLayoutEntryExtras{ .count = count, }); return bgle; @@ -62,15 +62,15 @@ pub const BindGroupLayoutEntry = extern struct { pub const BindGroupLayoutDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, entry_count: usize, entries: [*]const BindGroupLayoutEntry, }; pub const BindGroupLayoutProcs = struct { - pub const SetLabel = *const fn(*BindGroupLayout, StringView) callconv(.C) void; - pub const AddRef = *const fn(*BindGroupLayout) callconv(.C) void; - pub const Release = *const fn(*BindGroupLayout) callconv(.C) void; + pub const SetLabel = *const fn (*BindGroupLayout, StringView) callconv(.c) void; + pub const AddRef = *const fn (*BindGroupLayout) callconv(.c) void; + pub const Release = *const fn (*BindGroupLayout) callconv(.c) void; }; extern fn wgpuBindGroupLayoutSetLabel(bind_group_layout: *BindGroupLayout, label: StringView) void; @@ -93,7 +93,7 @@ pub const BindGroupLayout = opaque { }; pub const BindGroupEntryExtras = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.bind_group_entry_extras, }, buffers: ?[*]const *Buffer, @@ -122,16 +122,16 @@ pub const BindGroupEntry = extern struct { pub const BindGroupDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, layout: *BindGroupLayout, entry_count: usize, entries: [*]const BindGroupEntry, }; pub const BindGroupProcs = struct { - pub const SetLabel = *const fn(*BindGroup, StringView) callconv(.C) void; - pub const AddRef = *const fn(*BindGroup) callconv(.C) void; - pub const Release = *const fn(*BindGroup) callconv(.C) void; + pub const SetLabel = *const fn (*BindGroup, StringView) callconv(.c) void; + pub const AddRef = *const fn (*BindGroup) callconv(.c) void; + pub const Release = *const fn (*BindGroup) callconv(.c) void; }; extern fn wgpuBindGroupSetLabel(bind_group: *BindGroup, label: StringView) void; diff --git a/src/buffer.zig b/src/buffer.zig index a09e84a..c7d736a 100644 --- a/src/buffer.zig +++ b/src/buffer.zig @@ -4,7 +4,6 @@ const WGPUFlags = _misc.WGPUFlags; const StringView = _misc.StringView; const USIZE_MAX = _misc.USIZE_MAX; - pub const WGPU_WHOLE_MAP_SIZE = USIZE_MAX; const _async = @import("async.zig"); @@ -14,54 +13,54 @@ const Future = _async.Future; const ChainedStruct = @import("chained_struct.zig").ChainedStruct; pub const BufferBindingType = enum(u32) { - binding_not_used = 0x00000000, // Indicates that this BufferBindingLayout member of its parent BindGroupLayoutEntry is not used. - @"undefined" = 0x00000001, // Indicates no value is passed for this argument - uniform = 0x00000002, - storage = 0x00000003, + binding_not_used = 0x00000000, // Indicates that this BufferBindingLayout member of its parent BindGroupLayoutEntry is not used. + undefined = 0x00000001, // Indicates no value is passed for this argument + uniform = 0x00000002, + storage = 0x00000003, read_only_storage = 0x00000004, }; pub const BufferBindingLayout = extern struct { next_in_chain: ?*const ChainedStruct = null, - @"type": BufferBindingType = BufferBindingType.@"undefined", + type: BufferBindingType = BufferBindingType.undefined, has_dynamic_offset: WGPUBool = @intFromBool(false), min_binding_size: u64 = 0, }; pub const BufferUsage = WGPUFlags; pub const BufferUsages = struct { - pub const none = @as(BufferUsage, 0x0000000000000000); - pub const map_read = @as(BufferUsage, 0x0000000000000001); - pub const map_write = @as(BufferUsage, 0x0000000000000002); - pub const copy_src = @as(BufferUsage, 0x0000000000000004); - pub const copy_dst = @as(BufferUsage, 0x0000000000000008); - pub const index = @as(BufferUsage, 0x0000000000000010); - pub const vertex = @as(BufferUsage, 0x0000000000000020); - pub const uniform = @as(BufferUsage, 0x0000000000000040); - pub const storage = @as(BufferUsage, 0x0000000000000080); - pub const indirect = @as(BufferUsage, 0x0000000000000100); + pub const none = @as(BufferUsage, 0x0000000000000000); + pub const map_read = @as(BufferUsage, 0x0000000000000001); + pub const map_write = @as(BufferUsage, 0x0000000000000002); + pub const copy_src = @as(BufferUsage, 0x0000000000000004); + pub const copy_dst = @as(BufferUsage, 0x0000000000000008); + pub const index = @as(BufferUsage, 0x0000000000000010); + pub const vertex = @as(BufferUsage, 0x0000000000000020); + pub const uniform = @as(BufferUsage, 0x0000000000000040); + pub const storage = @as(BufferUsage, 0x0000000000000080); + pub const indirect = @as(BufferUsage, 0x0000000000000100); pub const query_resolve = @as(BufferUsage, 0x0000000000000200); }; pub const BufferMapState = enum(u32) { unmapped = 0x00000001, - pending = 0x00000002, - mapped = 0x00000003, + pending = 0x00000002, + mapped = 0x00000003, }; pub const MapMode = WGPUFlags; pub const MapModes = struct { - pub const none = @as(MapMode, 0x0000000000000000); - pub const read = @as(MapMode, 0x0000000000000001); + pub const none = @as(MapMode, 0x0000000000000000); + pub const read = @as(MapMode, 0x0000000000000001); pub const write = @as(MapMode, 0x0000000000000002); }; pub const MapAsyncStatus = enum(u32) { - success = 0x00000001, + success = 0x00000001, instance_dropped = 0x00000002, - @"error" = 0x00000003, - aborted = 0x00000004, - unknown = 0x00000005, + @"error" = 0x00000003, + aborted = 0x00000004, + unknown = 0x00000005, }; pub const BufferMapCallbackInfo = extern struct { @@ -75,28 +74,28 @@ pub const BufferMapCallbackInfo = extern struct { userdata2: ?*anyopaque = null, }; -pub const BufferMapCallback = *const fn(status: MapAsyncStatus, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.C) void; +pub const BufferMapCallback = *const fn (status: MapAsyncStatus, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.c) void; pub const BufferDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, usage: BufferUsage, size: u64, mapped_at_creation: WGPUBool = @intFromBool(false), }; pub const BufferProcs = struct { - pub const Destroy = *const fn(*Buffer) callconv(.C) void; - pub const GetConstMappedRange = *const fn(*Buffer, usize, usize) callconv(.C) ?*const anyopaque; - pub const GetMapState = *const fn(*Buffer) callconv(.C) BufferMapState; - pub const GetMappedRange = *const fn(*Buffer, usize, usize) callconv(.C) ?*anyopaque; - pub const GetSize = *const fn(*Buffer) callconv(.C) u64; - pub const GetUsage = *const fn(*Buffer) callconv(.C) BufferUsage; - pub const MapAsync = *const fn(*Buffer, MapMode, usize, usize, BufferMapCallbackInfo) callconv(.C) Future; - pub const SetLabel = *const fn(*Buffer, StringView) callconv(.C) void; - pub const Unmap = *const fn(*Buffer) callconv(.C) void; - pub const AddRef = *const fn(*Buffer) callconv(.C) void; - pub const Release = *const fn(*Buffer) callconv(.C) void; + pub const Destroy = *const fn (*Buffer) callconv(.c) void; + pub const GetConstMappedRange = *const fn (*Buffer, usize, usize) callconv(.c) ?*const anyopaque; + pub const GetMapState = *const fn (*Buffer) callconv(.c) BufferMapState; + pub const GetMappedRange = *const fn (*Buffer, usize, usize) callconv(.c) ?*anyopaque; + pub const GetSize = *const fn (*Buffer) callconv(.c) u64; + pub const GetUsage = *const fn (*Buffer) callconv(.c) BufferUsage; + pub const MapAsync = *const fn (*Buffer, MapMode, usize, usize, BufferMapCallbackInfo) callconv(.c) Future; + pub const SetLabel = *const fn (*Buffer, StringView) callconv(.c) void; + pub const Unmap = *const fn (*Buffer) callconv(.c) void; + pub const AddRef = *const fn (*Buffer) callconv(.c) void; + pub const Release = *const fn (*Buffer) callconv(.c) void; }; extern fn wgpuBufferDestroy(buffer: *Buffer) void; @@ -184,4 +183,5 @@ pub const Buffer = opaque { pub inline fn release(self: *Buffer) void { wgpuBufferRelease(self); } -}; \ No newline at end of file +}; + diff --git a/src/command_encoder.zig b/src/command_encoder.zig index 847a54e..dfb37cf 100644 --- a/src/command_encoder.zig +++ b/src/command_encoder.zig @@ -40,33 +40,33 @@ pub const ComputePassTimestampWrites = TimestampWrites; pub const ComputePassDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, timestamp_writes: ?*const ComputePassTimestampWrites = null, }; pub const CommandEncoderDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, }; const ComputePassEncoderProcs = struct { - pub const DispatchWorkgroups = *const fn(*ComputePassEncoder, u32, u32, u32) callconv(.C) void; - pub const DispatchWorkgroupsIndirect = *const fn(*ComputePassEncoder, *Buffer, u64) callconv(.C) void; - pub const End = *const fn(*ComputePassEncoder) callconv(.C) void; - pub const InsertDebugMarker = *const fn(*ComputePassEncoder, StringView) callconv(.C) void; - pub const PopDebugGroup = *const fn(*ComputePassEncoder) callconv(.C) void; - pub const PushDebugGroup = *const fn(*ComputePassEncoder, StringView) callconv(.C) void; - pub const SetBindGroup = *const fn(*ComputePassEncoder, u32, *BindGroup, usize, ?[*]const u32) callconv(.C) void; - pub const SetLabel = *const fn(*ComputePassEncoder, StringView) callconv(.C) void; - pub const SetPipeline = *const fn(*ComputePassEncoder, *ComputePipeline) callconv(.C) void; - pub const AddRef = *const fn(*ComputePassEncoder) callconv(.C) void; - pub const Release = *const fn(*ComputePassEncoder) callconv(.C) void; + pub const DispatchWorkgroups = *const fn (*ComputePassEncoder, u32, u32, u32) callconv(.c) void; + pub const DispatchWorkgroupsIndirect = *const fn (*ComputePassEncoder, *Buffer, u64) callconv(.c) void; + pub const End = *const fn (*ComputePassEncoder) callconv(.c) void; + pub const InsertDebugMarker = *const fn (*ComputePassEncoder, StringView) callconv(.c) void; + pub const PopDebugGroup = *const fn (*ComputePassEncoder) callconv(.c) void; + pub const PushDebugGroup = *const fn (*ComputePassEncoder, StringView) callconv(.c) void; + pub const SetBindGroup = *const fn (*ComputePassEncoder, u32, *BindGroup, usize, ?[*]const u32) callconv(.c) void; + pub const SetLabel = *const fn (*ComputePassEncoder, StringView) callconv(.c) void; + pub const SetPipeline = *const fn (*ComputePassEncoder, *ComputePipeline) callconv(.c) void; + pub const AddRef = *const fn (*ComputePassEncoder) callconv(.c) void; + pub const Release = *const fn (*ComputePassEncoder) callconv(.c) void; // wgpu-native procs? - // pub const SetPushConstants = *const fn(*ComputePassEncoder, u32, u32, *const anyopaque) callconv(.C) void; - // pub const BeginPipelineStatisticsQuery = *const fn(*ComputePassEncoder, *QuerySet, u32) callconv(.C) void; - // pub const EndPipelineStatisticsQuery = *const fn(*ComputePassEncoder) callconv(.C) void; - // pub const WriteTimestamp = *const fn(*ComputePassEncoder, *QuerySet, u32) callconv(.C) void; + // pub const SetPushConstants = *const fn(*ComputePassEncoder, u32, u32, *const anyopaque) callconv(.c) void; + // pub const BeginPipelineStatisticsQuery = *const fn(*ComputePassEncoder, *QuerySet, u32) callconv(.c) void; + // pub const EndPipelineStatisticsQuery = *const fn(*ComputePassEncoder) callconv(.c) void; + // pub const WriteTimestamp = *const fn(*ComputePassEncoder, *QuerySet, u32) callconv(.c) void; }; extern fn wgpuComputePassEncoderDispatchWorkgroups(compute_pass_encoder: *ComputePassEncoder, workgroup_count_x: u32, workgroup_count_y: u32, workgroup_count_z: u32) void; @@ -142,15 +142,15 @@ pub const ComputePassEncoder = opaque { }; pub const LoadOp = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument. - load = 0x00000001, - clear = 0x00000002, + undefined = 0x00000000, // Indicates no value is passed for this argument. + load = 0x00000001, + clear = 0x00000002, }; pub const StoreOp = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument - store = 0x00000001, - discard = 0x00000002, + undefined = 0x00000000, // Indicates no value is passed for this argument + store = 0x00000001, + discard = 0x00000002, }; pub const Color = extern struct { @@ -167,17 +167,17 @@ pub const ColorAttachment = extern struct { resolve_target: ?*TextureView = null, load_op: LoadOp = LoadOp.clear, store_op: StoreOp = StoreOp.store, - clear_value: Color = Color {}, + clear_value: Color = Color{}, }; pub const DepthStencilAttachment = extern struct { view: *TextureView, - depth_load_op: LoadOp = LoadOp.@"undefined", - depth_store_op: StoreOp = StoreOp.@"undefined", + depth_load_op: LoadOp = LoadOp.undefined, + depth_store_op: StoreOp = StoreOp.undefined, depth_clear_value: f32 = 0, depth_read_only: WGPUBool = @intFromBool(false), - stencil_load_op: LoadOp = LoadOp.@"undefined", - stencil_store_op: StoreOp = StoreOp.@"undefined", + stencil_load_op: LoadOp = LoadOp.undefined, + stencil_store_op: StoreOp = StoreOp.undefined, stencil_clear_value: u32 = 0, stencil_read_only: WGPUBool = @intFromBool(false), }; @@ -185,15 +185,13 @@ pub const DepthStencilAttachment = extern struct { pub const RenderPassTimestampWrites = TimestampWrites; pub const RenderPassMaxDrawCount = extern struct { - chain: ChainedStruct = ChainedStruct { - .s_type = SType.render_pass_max_draw_count - }, + chain: ChainedStruct = ChainedStruct{ .s_type = SType.render_pass_max_draw_count }, max_draw_count: u64 = 50000000, }; pub const RenderPassDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, color_attachment_count: usize, color_attachments: [*]const ColorAttachment, depth_stencil_attachment: ?*const DepthStencilAttachment = null, @@ -202,7 +200,7 @@ pub const RenderPassDescriptor = extern struct { pub inline fn withMaxDrawCount(self: RenderPassDescriptor, max_draw_count: u64) RenderPassDescriptor { var descriptor = self; - descriptor.next_in_chain = @ptrCast(&RenderPassMaxDrawCount { + descriptor.next_in_chain = @ptrCast(&RenderPassMaxDrawCount{ .max_draw_count = max_draw_count, }); @@ -211,38 +209,38 @@ pub const RenderPassDescriptor = extern struct { }; pub const RenderPassEncoderProcs = struct { - pub const BeginOcclusionQuery = *const fn(*RenderPassEncoder, u32) callconv(.C) void; - pub const Draw = *const fn(*RenderPassEncoder, u32, u32, u32, u32) callconv(.C) void; - pub const DrawIndexed = *const fn(*RenderPassEncoder, u32, u32, u32, i32, u32) callconv(.C) void; - pub const DrawIndexedIndirect = *const fn(*RenderPassEncoder, *Buffer, u64) callconv(.C) void; - pub const DrawIndirect = *const fn(*RenderPassEncoder, *Buffer, u64) callconv(.C) void; - pub const End = *const fn(*RenderPassEncoder) callconv(.C) void; - pub const EndOcclusionQuery = *const fn(*RenderPassEncoder) callconv(.C) void; - pub const ExecuteBundles = *const fn(*RenderPassEncoder, usize, [*]const *const RenderBundle) callconv(.C) void; - pub const InsertDebugMarker = *const fn(*RenderPassEncoder, StringView) callconv(.C) void; - pub const PopDebugGroup = *const fn(*RenderPassEncoder) callconv(.C) void; - pub const PushDebugGroup = *const fn(*RenderPassEncoder, StringView) callconv(.C) void; - pub const SetBindGroup = *const fn(*RenderPassEncoder, u32, *BindGroup, usize, ?[*]const u32) callconv(.C) void; - pub const SetBlendConstant = *const fn(*RenderPassEncoder, *const Color) callconv(.C) void; - pub const SetIndexBuffer = *const fn(*RenderPassEncoder, *Buffer, IndexFormat, u64, u64) callconv(.C) void; - pub const SetLabel = *const fn(*RenderPassEncoder, StringView) callconv(.C) void; - pub const SetPipeline = *const fn(*RenderPassEncoder, *RenderPipeline) callconv(.C) void; - pub const SetScissorRect = *const fn(*RenderPassEncoder, u32, u32, u32, u32) callconv(.C) void; - pub const SetStencilReference = *const fn(*RenderPassEncoder, u32) callconv(.C) void; - pub const SetVertexBuffer = *const fn(*RenderPassEncoder, u32, *Buffer, u64, u64) callconv(.C) void; - pub const SetViewport = *const fn(*RenderPassEncoder, f32, f32, f32, f32, f32, f32) callconv(.C) void; - pub const AddRef = *const fn(*RenderPassEncoder) callconv(.C) void; - pub const Release = *const fn(*RenderPassEncoder) callconv(.C) void; + pub const BeginOcclusionQuery = *const fn (*RenderPassEncoder, u32) callconv(.c) void; + pub const Draw = *const fn (*RenderPassEncoder, u32, u32, u32, u32) callconv(.c) void; + pub const DrawIndexed = *const fn (*RenderPassEncoder, u32, u32, u32, i32, u32) callconv(.c) void; + pub const DrawIndexedIndirect = *const fn (*RenderPassEncoder, *Buffer, u64) callconv(.c) void; + pub const DrawIndirect = *const fn (*RenderPassEncoder, *Buffer, u64) callconv(.c) void; + pub const End = *const fn (*RenderPassEncoder) callconv(.c) void; + pub const EndOcclusionQuery = *const fn (*RenderPassEncoder) callconv(.c) void; + pub const ExecuteBundles = *const fn (*RenderPassEncoder, usize, [*]const *const RenderBundle) callconv(.c) void; + pub const InsertDebugMarker = *const fn (*RenderPassEncoder, StringView) callconv(.c) void; + pub const PopDebugGroup = *const fn (*RenderPassEncoder) callconv(.c) void; + pub const PushDebugGroup = *const fn (*RenderPassEncoder, StringView) callconv(.c) void; + pub const SetBindGroup = *const fn (*RenderPassEncoder, u32, *BindGroup, usize, ?[*]const u32) callconv(.c) void; + pub const SetBlendConstant = *const fn (*RenderPassEncoder, *const Color) callconv(.c) void; + pub const SetIndexBuffer = *const fn (*RenderPassEncoder, *Buffer, IndexFormat, u64, u64) callconv(.c) void; + pub const SetLabel = *const fn (*RenderPassEncoder, StringView) callconv(.c) void; + pub const SetPipeline = *const fn (*RenderPassEncoder, *RenderPipeline) callconv(.c) void; + pub const SetScissorRect = *const fn (*RenderPassEncoder, u32, u32, u32, u32) callconv(.c) void; + pub const SetStencilReference = *const fn (*RenderPassEncoder, u32) callconv(.c) void; + pub const SetVertexBuffer = *const fn (*RenderPassEncoder, u32, *Buffer, u64, u64) callconv(.c) void; + pub const SetViewport = *const fn (*RenderPassEncoder, f32, f32, f32, f32, f32, f32) callconv(.c) void; + pub const AddRef = *const fn (*RenderPassEncoder) callconv(.c) void; + pub const Release = *const fn (*RenderPassEncoder) callconv(.c) void; // wgpu-native procs? - // pub const SetPushConstants = *const fn(*RenderPassEncoder, ShaderStage, u32, u32, *const anyopaque) callconv(.C) void; - // pub const MultiDrawIndirect = *const fn(*RenderPassEncoder, *Buffer, u64, u32) callconv(.C) void; - // pub const MultiDrawIndexedIndirect = *const fn(*RenderPassEncoder, *Buffer, u64, u32) callconv(.C) void; - // pub const MultiDrawIndirectCount = *const fn(*RenderPassEncoder, *Buffer, u64, *Buffer, u64, u32) callconv(.C) void; - // pub const MultiDrawIndexedIndirectCount = *const fn(*RenderPassEncoder, *Buffer, u64, *Buffer, u64, u32) callconv(.C) void; - // pub const BeginPipelineStatisticsQuery = *const fn(*RenderPassEncoder, *QuerySet, u32) callconv(.C) void; - // pub const EndPipelineStatisticsQuery = *const fn(*RenderPassEncoder) callconv(.C) void; - // pub const WriteTimestamp = *const fn(*RenderPassEncoder, *QuerySet, u32) callconv(.C) void; + // pub const SetPushConstants = *const fn(*RenderPassEncoder, ShaderStage, u32, u32, *const anyopaque) callconv(.c) void; + // pub const MultiDrawIndirect = *const fn(*RenderPassEncoder, *Buffer, u64, u32) callconv(.c) void; + // pub const MultiDrawIndexedIndirect = *const fn(*RenderPassEncoder, *Buffer, u64, u32) callconv(.c) void; + // pub const MultiDrawIndirectCount = *const fn(*RenderPassEncoder, *Buffer, u64, *Buffer, u64, u32) callconv(.c) void; + // pub const MultiDrawIndexedIndirectCount = *const fn(*RenderPassEncoder, *Buffer, u64, *Buffer, u64, u32) callconv(.c) void; + // pub const BeginPipelineStatisticsQuery = *const fn(*RenderPassEncoder, *QuerySet, u32) callconv(.c) void; + // pub const EndPipelineStatisticsQuery = *const fn(*RenderPassEncoder) callconv(.c) void; + // pub const WriteTimestamp = *const fn(*RenderPassEncoder, *QuerySet, u32) callconv(.c) void; }; extern fn wgpuRenderPassEncoderBeginOcclusionQuery(render_pass_encoder: *RenderPassEncoder, query_index: u32) void; @@ -379,13 +377,13 @@ pub const RenderPassEncoder = opaque { pub const CommandBufferDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, }; pub const CommandBufferProcs = struct { - pub const SetLabel = *const fn(*CommandBuffer, StringView) callconv(.C) void; - pub const AddRef = *const fn(*CommandBuffer) callconv(.C) void; - pub const Release = *const fn(*CommandBuffer) callconv(.C) void; + pub const SetLabel = *const fn (*CommandBuffer, StringView) callconv(.c) void; + pub const AddRef = *const fn (*CommandBuffer) callconv(.c) void; + pub const Release = *const fn (*CommandBuffer) callconv(.c) void; }; extern fn wgpuCommandBufferSetLabel(command_buffer: *CommandBuffer, label: StringView) void; @@ -408,22 +406,22 @@ pub const CommandBuffer = opaque { }; pub const CommandEncoderProcs = struct { - pub const BeginComputePass = *const fn(*CommandEncoder, ?*const ComputePassDescriptor) callconv(.C) ?*ComputePassEncoder; - pub const BeginRenderPass = *const fn(*CommandEncoder, *const RenderPassDescriptor) callconv(.C) ?*RenderPassEncoder; - pub const ClearBuffer = *const fn(*CommandEncoder, *Buffer, u64, u64) callconv(.C) void; - pub const CopyBufferToBuffer = *const fn(*CommandEncoder, *Buffer, u64, *Buffer, u64, u64) callconv(.C) void; - pub const CopyBufferToTexture = *const fn(*CommandEncoder, *const TexelCopyBufferInfo, *const TexelCopyTextureInfo, *const Extent3D) callconv(.C) void; - pub const CopyTextureToBuffer = *const fn(*CommandEncoder, *const TexelCopyTextureInfo, *const TexelCopyBufferInfo, *const Extent3D) callconv(.C) void; - pub const CopyTextureToTexture = *const fn(*CommandEncoder, *const TexelCopyTextureInfo, *const TexelCopyTextureInfo, *const Extent3D) callconv(.C) void; - pub const Finish = *const fn(*CommandEncoder, ?*const CommandBufferDescriptor) callconv(.C) ?*CommandBuffer; - pub const InsertDebugMarker = *const fn(*CommandEncoder, StringView) callconv(.C) void; - pub const PopDebugGroup = *const fn(*CommandEncoder) callconv(.C) void; - pub const PushDebugGroup = *const fn(*CommandEncoder, StringView) callconv(.C) void; - pub const ResolveQuerySet = *const fn(*CommandEncoder, *QuerySet, u32, u32, *Buffer, u64) callconv(.C) void; - pub const SetLabel = *const fn(*CommandEncoder, StringView) callconv(.C) void; - pub const WriteTimestamp = *const fn(*CommandEncoder, *QuerySet, u32) callconv(.C) void; - pub const AddRef = *const fn(*CommandEncoder) callconv(.C) void; - pub const Release = *const fn(*CommandEncoder) callconv(.C) void; + pub const BeginComputePass = *const fn (*CommandEncoder, ?*const ComputePassDescriptor) callconv(.c) ?*ComputePassEncoder; + pub const BeginRenderPass = *const fn (*CommandEncoder, *const RenderPassDescriptor) callconv(.c) ?*RenderPassEncoder; + pub const ClearBuffer = *const fn (*CommandEncoder, *Buffer, u64, u64) callconv(.c) void; + pub const CopyBufferToBuffer = *const fn (*CommandEncoder, *Buffer, u64, *Buffer, u64, u64) callconv(.c) void; + pub const CopyBufferToTexture = *const fn (*CommandEncoder, *const TexelCopyBufferInfo, *const TexelCopyTextureInfo, *const Extent3D) callconv(.c) void; + pub const CopyTextureToBuffer = *const fn (*CommandEncoder, *const TexelCopyTextureInfo, *const TexelCopyBufferInfo, *const Extent3D) callconv(.c) void; + pub const CopyTextureToTexture = *const fn (*CommandEncoder, *const TexelCopyTextureInfo, *const TexelCopyTextureInfo, *const Extent3D) callconv(.c) void; + pub const Finish = *const fn (*CommandEncoder, ?*const CommandBufferDescriptor) callconv(.c) ?*CommandBuffer; + pub const InsertDebugMarker = *const fn (*CommandEncoder, StringView) callconv(.c) void; + pub const PopDebugGroup = *const fn (*CommandEncoder) callconv(.c) void; + pub const PushDebugGroup = *const fn (*CommandEncoder, StringView) callconv(.c) void; + pub const ResolveQuerySet = *const fn (*CommandEncoder, *QuerySet, u32, u32, *Buffer, u64) callconv(.c) void; + pub const SetLabel = *const fn (*CommandEncoder, StringView) callconv(.c) void; + pub const WriteTimestamp = *const fn (*CommandEncoder, *QuerySet, u32) callconv(.c) void; + pub const AddRef = *const fn (*CommandEncoder) callconv(.c) void; + pub const Release = *const fn (*CommandEncoder) callconv(.c) void; }; extern fn wgpuCommandEncoderBeginComputePass(command_encoder: *CommandEncoder, descriptor: ?*const ComputePassDescriptor) ?*ComputePassEncoder; diff --git a/src/device.zig b/src/device.zig index 4fccbb5..9d66b5d 100644 --- a/src/device.zig +++ b/src/device.zig @@ -63,7 +63,7 @@ const Sampler = _sampler.Sampler; const _shader = @import("shader.zig"); const ShaderModuleDescriptor = _shader.ShaderModuleDescriptor; -const ShaderModuleDescriptorSpirV =_shader.ShaderModuleDescriptorSpirV; +const ShaderModuleDescriptorSpirV = _shader.ShaderModuleDescriptorSpirV; const ShaderModule = _shader.ShaderModule; const _texture = @import("texture.zig"); @@ -71,10 +71,10 @@ const TextureDescriptor = _texture.TextureDescriptor; const Texture = _texture.Texture; pub const DeviceLostReason = enum(u32) { - unknown = 0x00000001, - destroyed = 0x00000002, + unknown = 0x00000001, + destroyed = 0x00000002, instance_dropped = 0x00000003, - failed_creation = 0x00000004, + failed_creation = 0x00000004, }; pub const DeviceLostCallbackInfo = extern struct { @@ -92,8 +92,8 @@ pub const DeviceLostCallbackInfo = extern struct { }; // `device` is a reference to the device which was lost. If, and only if, the `reason` is DeviceLostReason.failed_creation, `device` is a non-null pointer to a null Device. -pub const DeviceLostCallback = *const fn(device: *const ?*Device, reason: DeviceLostReason, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.C) void; -pub fn defaultDeviceLostCallback(device: *const ?*Device, reason: DeviceLostReason, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.C) void { +pub const DeviceLostCallback = *const fn (device: *const ?*Device, reason: DeviceLostReason, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.c) void; +pub fn defaultDeviceLostCallback(device: *const ?*Device, reason: DeviceLostReason, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.c) void { _ = device; _ = userdata1; _ = userdata2; @@ -106,26 +106,26 @@ pub fn defaultDeviceLostCallback(device: *const ?*Device, reason: DeviceLostReas } pub const DeviceExtras = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.device_extras, }, trace_path: StringView, }; pub const ErrorType = enum(u32) { - no_error = 0x00000001, - validation = 0x00000002, + no_error = 0x00000001, + validation = 0x00000002, out_of_memory = 0x00000003, - internal = 0x00000004, - unknown = 0x00000005, + internal = 0x00000004, + unknown = 0x00000005, }; -pub const UncapturedErrorCallback = *const fn(device: ?*Device, error_type: ErrorType, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.C) void; +pub const UncapturedErrorCallback = *const fn (device: ?*Device, error_type: ErrorType, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.c) void; pub const ErrorFilter = enum(u32) { - validation = 0x00000001, + validation = 0x00000001, out_of_memory = 0x00000002, - internal = 0x00000003, + internal = 0x00000003, }; pub const UncapturedErrorCallbackInfo = extern struct { @@ -137,17 +137,17 @@ pub const UncapturedErrorCallbackInfo = extern struct { pub const DeviceDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, required_feature_count: usize = 0, - required_features: [*]const FeatureName = &[0]FeatureName {}, + required_features: [*]const FeatureName = &[0]FeatureName{}, required_limits: ?*const Limits, default_queue: QueueDescriptor = QueueDescriptor{}, - device_lost_callback_info: DeviceLostCallbackInfo = DeviceLostCallbackInfo {}, + device_lost_callback_info: DeviceLostCallbackInfo = DeviceLostCallbackInfo{}, uncaptured_error_callback_info: UncapturedErrorCallbackInfo = UncapturedErrorCallbackInfo{}, pub inline fn withTracePath(self: DeviceDescriptor, trace_path: []const u8) DeviceDescriptor { var dd = self; - dd.next_in_chain = @ptrCast(&DeviceExtras { + dd.next_in_chain = @ptrCast(&DeviceExtras{ .trace_path = StringView.fromSlice(trace_path), }); return dd; @@ -155,20 +155,14 @@ pub const DeviceDescriptor = extern struct { }; pub const RequestDeviceStatus = enum(u32) { - success = 0x00000001, + success = 0x00000001, instance_dropped = 0x00000002, - @"error" = 0x00000003, - unknown = 0x00000004, + @"error" = 0x00000003, + unknown = 0x00000004, }; // TODO: This probably belongs in adapter.zig -pub const RequestDeviceCallback = *const fn( - status: RequestDeviceStatus, - device: ?*Device, - message: StringView, - userdata1: ?*anyopaque, - userdata2: ?*anyopaque -) callconv(.C) void; +pub const RequestDeviceCallback = *const fn (status: RequestDeviceStatus, device: ?*Device, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.c) void; pub const RequestDeviceResponse = struct { status: RequestDeviceStatus, @@ -188,9 +182,9 @@ pub const RequestDeviceCallbackInfo = extern struct { }; pub const PopErrorScopeStatus = enum(u32) { - success = 0x00000001, // The error scope stack was successfully popped and a result was reported. + success = 0x00000001, // The error scope stack was successfully popped and a result was reported. instance_dropped = 0x00000002, - empty_stack = 0x00000003, // The error scope stack could not be popped, because it was empty. + empty_stack = 0x00000003, // The error scope stack could not be popped, because it was empty. }; // status @@ -204,13 +198,13 @@ pub const PopErrorScopeStatus = enum(u32) { // If the `type` is not ErrorType.no_error, this is a non-empty string; // otherwise, this is an empty string. // -pub const PopErrorScopeCallback = *const fn( +pub const PopErrorScopeCallback = *const fn ( status: PopErrorScopeStatus, error_type: ErrorType, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque, -) callconv(.C) void; +) callconv(.c) void; pub const PopErrorScopeCallbackInfo = extern struct { next_in_chain: ?*ChainedStruct = null, @@ -224,36 +218,36 @@ pub const PopErrorScopeCallbackInfo = extern struct { }; pub const DeviceProcs = struct { - pub const CreateBindGroup = *const fn(*Device, *const BindGroupDescriptor) callconv(.C) ?*BindGroup; - pub const CreateBindGroupLayout = *const fn(*Device, *const BindGroupLayoutDescriptor) callconv(.C) ?*BindGroupLayout; - pub const CreateBuffer = *const fn(*Device, *const BufferDescriptor) callconv(.C) ?*Buffer; - pub const CreateCommandEncoder = *const fn(*Device, *const CommandEncoderDescriptor) callconv(.C) ?*CommandEncoder; - pub const CreateComputePipeline = *const fn(*Device, *const ComputePipelineDescriptor) callconv(.C) ?*ComputePipeline; - pub const CreateComputePipelineAsync = *const fn(*Device, *const ComputePipelineDescriptor, CreateComputePipelineAsyncCallbackInfo) callconv(.C) Future; - pub const CreatePipelineLayout = *const fn(*Device, *const PipelineLayoutDescriptor) callconv(.C) ?*PipelineLayout; - pub const CreateQuerySet = *const fn(*Device, *const QuerySetDescriptor) callconv(.C) ?*QuerySet; - pub const CreateRenderBundleEncoder = *const fn(*Device, *const RenderBundleEncoderDescriptor) callconv(.C) ?*RenderBundleEncoder; - pub const CreateRenderPipeline = *const fn(*Device, *const RenderPipelineDescriptor) callconv(.C) ?*RenderPipeline; - pub const CreateRenderPipelineAsync = *const fn(*Device, *const RenderPipelineDescriptor, CreateRenderPipelineAsyncCallbackInfo) callconv(.C) Future; - pub const CreateSampler = *const fn(*Device, *const SamplerDescriptor) callconv(.C) ?*Sampler; - pub const CreateShaderModule = *const fn(*Device, *const ShaderModuleDescriptor) callconv(.C) ?*ShaderModule; - pub const CreateTexture = *const fn(*Device, *const TextureDescriptor) callconv(.C) ?*Texture; - pub const Destroy = *const fn(*Device) callconv(.C) void; - pub const GetAdapterInfo = *const fn(*Device) callconv(.C) AdapterInfo; - pub const GetFeatures = *const fn(*Device, *SupportedFeatures) callconv(.C) void; - pub const GetLimits = *const fn(*Device, *Limits) callconv(.C) Status; - pub const GetLostFuture = *const fn(*Device) callconv(.C) Future; - pub const GetQueue = *const fn(*Device) callconv(.C) ?*Queue; - pub const HasFeature = *const fn(*Device, FeatureName) callconv(.C) WGPUBool; - pub const PopErrorScope = *const fn(*Device, PopErrorScopeCallbackInfo) callconv(.C) Future; - pub const PushErrorScope = *const fn(*Device, ErrorFilter) callconv(.C) void; - pub const SetLabel = *const fn(*Device, StringView) callconv(.C) void; - pub const AddRef = *const fn(*Device) callconv(.C) void; - pub const Release = *const fn(*Device) callconv(.C) void; + pub const CreateBindGroup = *const fn (*Device, *const BindGroupDescriptor) callconv(.c) ?*BindGroup; + pub const CreateBindGroupLayout = *const fn (*Device, *const BindGroupLayoutDescriptor) callconv(.c) ?*BindGroupLayout; + pub const CreateBuffer = *const fn (*Device, *const BufferDescriptor) callconv(.c) ?*Buffer; + pub const CreateCommandEncoder = *const fn (*Device, *const CommandEncoderDescriptor) callconv(.c) ?*CommandEncoder; + pub const CreateComputePipeline = *const fn (*Device, *const ComputePipelineDescriptor) callconv(.c) ?*ComputePipeline; + pub const CreateComputePipelineAsync = *const fn (*Device, *const ComputePipelineDescriptor, CreateComputePipelineAsyncCallbackInfo) callconv(.c) Future; + pub const CreatePipelineLayout = *const fn (*Device, *const PipelineLayoutDescriptor) callconv(.c) ?*PipelineLayout; + pub const CreateQuerySet = *const fn (*Device, *const QuerySetDescriptor) callconv(.c) ?*QuerySet; + pub const CreateRenderBundleEncoder = *const fn (*Device, *const RenderBundleEncoderDescriptor) callconv(.c) ?*RenderBundleEncoder; + pub const CreateRenderPipeline = *const fn (*Device, *const RenderPipelineDescriptor) callconv(.c) ?*RenderPipeline; + pub const CreateRenderPipelineAsync = *const fn (*Device, *const RenderPipelineDescriptor, CreateRenderPipelineAsyncCallbackInfo) callconv(.c) Future; + pub const CreateSampler = *const fn (*Device, *const SamplerDescriptor) callconv(.c) ?*Sampler; + pub const CreateShaderModule = *const fn (*Device, *const ShaderModuleDescriptor) callconv(.c) ?*ShaderModule; + pub const CreateTexture = *const fn (*Device, *const TextureDescriptor) callconv(.c) ?*Texture; + pub const Destroy = *const fn (*Device) callconv(.c) void; + pub const GetAdapterInfo = *const fn (*Device) callconv(.c) AdapterInfo; + pub const GetFeatures = *const fn (*Device, *SupportedFeatures) callconv(.c) void; + pub const GetLimits = *const fn (*Device, *Limits) callconv(.c) Status; + pub const GetLostFuture = *const fn (*Device) callconv(.c) Future; + pub const GetQueue = *const fn (*Device) callconv(.c) ?*Queue; + pub const HasFeature = *const fn (*Device, FeatureName) callconv(.c) WGPUBool; + pub const PopErrorScope = *const fn (*Device, PopErrorScopeCallbackInfo) callconv(.c) Future; + pub const PushErrorScope = *const fn (*Device, ErrorFilter) callconv(.c) void; + pub const SetLabel = *const fn (*Device, StringView) callconv(.c) void; + pub const AddRef = *const fn (*Device) callconv(.c) void; + pub const Release = *const fn (*Device) callconv(.c) void; // wgpu-native procs? - // pub const Poll = *const fn(*Device, WGPUBool, ?*const SubmissionIndex) callconv(.C) WGPUBool; - // pub const CreateShaderModuleSpirV = *const fn(*Device, *const ShaderModuleDescriptorSpirV) callconv(.C) ?*ShaderModule; + // pub const Poll = *const fn(*Device, WGPUBool, ?*const SubmissionIndex) callconv(.c) WGPUBool; + // pub const CreateShaderModuleSpirV = *const fn(*Device, *const ShaderModuleDescriptorSpirV) callconv(.c) ?*ShaderModule; }; extern fn wgpuDeviceCreateBindGroup(device: *Device, descriptor: *const BindGroupDescriptor) ?*BindGroup; @@ -398,4 +392,4 @@ pub const Device = opaque { } }; -// TODO: Test methods of Device (as long as they can be tested headlessly: see https://eliemichel.github.io/LearnWebGPU/advanced-techniques/headless.html) \ No newline at end of file +// TODO: Test methods of Device (as long as they can be tested headlessly: see https://eliemichel.github.io/LearnWebGPU/advanced-techniques/headless.html) diff --git a/src/global.zig b/src/global.zig index 7517723..20de2aa 100644 --- a/src/global.zig +++ b/src/global.zig @@ -1,18 +1,19 @@ // const StringView = @import("misc.zig").StringView; // Generic function return type for wgpuGetProcAddress -// pub const Proc = *const fn() callconv(.C) void; +// pub const Proc = *const fn() callconv(.c) void; // Supposedly getProcAddress is a global function, but it doesn't seem like it should work without being tied to a Device? // Could be it's one of those functions that's meant to be called with null the first time, TODO: look into that. -// +// // Regardless, apparently the reason it exists is because different devices have different drivers and therefore different procs, // so you need to get the version of the proc that is meant for that particular device. -// +// // Although this function appears in webgpu.h, it is currently unimplemented in wgpu-native, // (https://github.com/gfx-rs/wgpu-native/blob/trunk/src/unimplemented.rs) // so I'm leaving it here in case it gets implemented eventually, but commented out until/unless that happens. // extern fn wgpuGetProcAddress(proc_name: StringView) ?Proc; // pub inline fn getProcAddress(proc_name: StringView) ?Proc { // return wgpuGetProcAddress(proc_name); -// } \ No newline at end of file +// } + diff --git a/src/instance.zig b/src/instance.zig index 2ec163e..83464d2 100644 --- a/src/instance.zig +++ b/src/instance.zig @@ -31,36 +31,36 @@ const FutureWaitInfo = _async.FutureWaitInfo; pub const InstanceBackend = WGPUFlags; pub const InstanceBackends = struct { - pub const all = @as(InstanceBackend, 0x00000000); - pub const vulkan = @as(InstanceBackend, 0x00000001); - pub const gl = @as(InstanceBackend, 0x00000002); - pub const metal = @as(InstanceBackend, 0x00000004); - pub const dx12 = @as(InstanceBackend, 0x00000008); - pub const dx11 = @as(InstanceBackend, 0x00000010); + pub const all = @as(InstanceBackend, 0x00000000); + pub const vulkan = @as(InstanceBackend, 0x00000001); + pub const gl = @as(InstanceBackend, 0x00000002); + pub const metal = @as(InstanceBackend, 0x00000004); + pub const dx12 = @as(InstanceBackend, 0x00000008); + pub const dx11 = @as(InstanceBackend, 0x00000010); pub const browser_webgpu = @as(InstanceBackend, 0x00000020); - pub const primary = vulkan | metal | dx12 | browser_webgpu; - pub const secondary = gl | dx11; + pub const primary = vulkan | metal | dx12 | browser_webgpu; + pub const secondary = gl | dx11; }; pub const InstanceFlag = WGPUFlags; pub const InstanceFlags = struct { - pub const default = @as(InstanceFlag, 0x00000000); - pub const debug = @as(InstanceFlag, 0x00000001); - pub const validation = @as(InstanceFlag, 0x00000002); + pub const default = @as(InstanceFlag, 0x00000000); + pub const debug = @as(InstanceFlag, 0x00000001); + pub const validation = @as(InstanceFlag, 0x00000002); pub const discard_hal_labels = @as(InstanceFlag, 0x00000004); }; pub const Dx12Compiler = enum(u32) { - @"undefined" = 0x00000000, - fxc = 0x00000001, - dxc = 0x00000002, + undefined = 0x00000000, + fxc = 0x00000001, + dxc = 0x00000002, }; pub const Gles3MinorVersion = enum(u32) { - automatic = 0x00000000, - version_0 = 0x00000001, - version_1 = 0x00000002, - version_2 = 0x00000003, + automatic = 0x00000000, + version_0 = 0x00000001, + version_1 = 0x00000002, + version_2 = 0x00000003, }; pub const DxcMaxShaderModel = enum(u32) { @@ -75,12 +75,12 @@ pub const DxcMaxShaderModel = enum(u32) { }; pub const GLFenceBehaviour = enum(u32) { - gl_fence_behaviour_normal = 0x00000000, + gl_fence_behaviour_normal = 0x00000000, gl_fence_behaviour_auto_finish = 0x00000001, }; pub const InstanceExtras = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.instance_extras, }, backends: InstanceBackend, @@ -88,8 +88,8 @@ pub const InstanceExtras = extern struct { dx12_shader_compiler: Dx12Compiler, gles3_minor_version: Gles3MinorVersion, gl_fence_behavior: GLFenceBehaviour, - dxil_path: StringView = StringView {}, - dxc_path: StringView = StringView {}, + dxil_path: StringView = StringView{}, + dxc_path: StringView = StringView{}, dxc_max_shader_model: DxcMaxShaderModel, }; @@ -119,13 +119,13 @@ pub const InstanceDescriptor = extern struct { pub const WGSLLanguageFeatureName = enum(u32) { readonly_and_readwrite_storage_textures = 0x00000001, - packed4x8_integer_dot_product = 0x00000002, - unrestricted_pointer_parameters = 0x00000003, - pointer_composite_access = 0x00000004, + packed4x8_integer_dot_product = 0x00000002, + unrestricted_pointer_parameters = 0x00000003, + pointer_composite_access = 0x00000004, }; pub const SupportedWGSLLanguageFeaturesProcs = struct { - pub const FreeMembers = *const fn(SupportedWGSLLanguageFeatures) callconv(.C) void; + pub const FreeMembers = *const fn (SupportedWGSLLanguageFeatures) callconv(.c) void; }; extern fn wgpuSupportedWGSLLanguageFeaturesFreeMembers(supported_wgsl_language_features: SupportedWGSLLanguageFeatures) void; @@ -142,21 +142,21 @@ pub const SupportedWGSLLanguageFeatures = extern struct { }; pub const InstanceProcs = struct { - pub const CreateInstance = *const fn(?*const InstanceDescriptor) callconv(.C) ?*Instance; - pub const GetCapabilities = *const fn(*InstanceCapabilities) callconv(.C) Status; - - pub const CreateSurface = *const fn(*Instance, *const SurfaceDescriptor) callconv(.C) ?*Surface; - pub const GetWGSLLanguageFeatures = *const fn(*Instance, *SupportedWGSLLanguageFeatures) callconv(.C) Status; - pub const HasWGSLLanguageFeature = *const fn(*Instance, WGSLLanguageFeatureName) callconv(.C) WGPUBool; - pub const ProcessEvents = *const fn(*Instance) callconv(.C) void; - pub const RequestAdapter = *const fn(*Instance, ?*const RequestAdapterOptions, RequestAdapterCallbackInfo) callconv(.C) Future; - pub const WaitAny = *const fn(*Instance, usize, ?[*] FutureWaitInfo, u64) callconv(.C) WaitStatus; - pub const InstanceAddRef = *const fn(*Instance) callconv(.C) void; - pub const InstanceRelease = *const fn(*Instance) callconv(.C) void; + pub const CreateInstance = *const fn (?*const InstanceDescriptor) callconv(.c) ?*Instance; + pub const GetCapabilities = *const fn (*InstanceCapabilities) callconv(.c) Status; + + pub const CreateSurface = *const fn (*Instance, *const SurfaceDescriptor) callconv(.c) ?*Surface; + pub const GetWGSLLanguageFeatures = *const fn (*Instance, *SupportedWGSLLanguageFeatures) callconv(.c) Status; + pub const HasWGSLLanguageFeature = *const fn (*Instance, WGSLLanguageFeatureName) callconv(.c) WGPUBool; + pub const ProcessEvents = *const fn (*Instance) callconv(.c) void; + pub const RequestAdapter = *const fn (*Instance, ?*const RequestAdapterOptions, RequestAdapterCallbackInfo) callconv(.c) Future; + pub const WaitAny = *const fn (*Instance, usize, ?[*]FutureWaitInfo, u64) callconv(.c) WaitStatus; + pub const InstanceAddRef = *const fn (*Instance) callconv(.c) void; + pub const InstanceRelease = *const fn (*Instance) callconv(.c) void; // wgpu-native procs? - // pub const GenerateReport = *const fn(*Instance, *GlobalReport) callconv(.C) void; - // pub const EnumerateAdapters = *const fn(*Instance, ?*const EnumerateAdapterOptions, ?[*]Adapter) callconv(.C) usize; + // pub const GenerateReport = *const fn(*Instance, *GlobalReport) callconv(.c) void; + // pub const EnumerateAdapters = *const fn(*Instance, ?*const EnumerateAdapterOptions, ?[*]Adapter) callconv(.c) usize; }; extern fn wgpuGetInstanceCapabilities(capabilities: *InstanceCapabilities) Status; @@ -167,7 +167,7 @@ extern fn wgpuInstanceGetWGSLLanguageFeatures(instance: *Instance, features: *Su extern fn wgpuInstanceHasWGSLLanguageFeature(instance: *Instance, feature: WGSLLanguageFeatureName) WGPUBool; extern fn wgpuInstanceProcessEvents(instance: *Instance) void; extern fn wgpuInstanceRequestAdapter(instance: *Instance, options: ?*const RequestAdapterOptions, callback_info: RequestAdapterCallbackInfo) Future; -extern fn wgpuInstanceWaitAny(instance: *Instance, future_count: usize, futures: ?[*] FutureWaitInfo, timeout_ns: u64) WaitStatus; +extern fn wgpuInstanceWaitAny(instance: *Instance, future_count: usize, futures: ?[*]FutureWaitInfo, timeout_ns: u64) WaitStatus; extern fn wgpuInstanceAddRef(instance: *Instance) void; extern fn wgpuInstanceRelease(instance: *Instance) void; @@ -245,9 +245,9 @@ pub const Instance = opaque { wgpuInstanceProcessEvents(self); } - fn defaultAdapterCallback(status: RequestAdapterStatus, adapter: ?*Adapter, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.C) void { + fn defaultAdapterCallback(status: RequestAdapterStatus, adapter: ?*Adapter, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.c) void { const ud_response: *RequestAdapterResponse = @ptrCast(@alignCast(userdata1)); - ud_response.* = RequestAdapterResponse { + ud_response.* = RequestAdapterResponse{ .status = status, .message = message.toSlice(), .adapter = adapter, @@ -262,7 +262,7 @@ pub const Instance = opaque { pub fn requestAdapterSync(self: *Instance, options: ?*const RequestAdapterOptions, polling_interval_nanoseconds: u64) RequestAdapterResponse { var response: RequestAdapterResponse = undefined; var completed = false; - const callback_info = RequestAdapterCallbackInfo { + const callback_info = RequestAdapterCallbackInfo{ .callback = defaultAdapterCallback, .userdata1 = @ptrCast(&response), .userdata2 = @ptrCast(&completed), @@ -296,7 +296,6 @@ pub const Instance = opaque { wgpuInstanceAddRef(self); } - pub inline fn release(self: *Instance) void { wgpuInstanceRelease(self); } @@ -323,9 +322,9 @@ test "can request adapter" { const instance = Instance.create(null); const response = instance.?.requestAdapterSync(null, 200_000_000); - const adapter: ?*Adapter = switch(response.status) { + const adapter: ?*Adapter = switch (response.status) { .success => response.adapter, else => null, }; try testing.expect(adapter != null); -} \ No newline at end of file +} diff --git a/src/log.zig b/src/log.zig index c61ea3a..9092547 100644 --- a/src/log.zig +++ b/src/log.zig @@ -1,15 +1,15 @@ const StringView = @import("misc.zig").StringView; pub const LogLevel = enum(u32) { - off = 0x00000000, + off = 0x00000000, @"error" = 0x00000001, - warn = 0x00000002, - info = 0x00000003, - debug = 0x00000004, - trace = 0x00000005, + warn = 0x00000002, + info = 0x00000003, + debug = 0x00000004, + trace = 0x00000005, }; -pub const LogCallback = *const fn(level: LogLevel, message: StringView, userdata: ?*anyopaque) callconv(.C) void; +pub const LogCallback = *const fn (level: LogLevel, message: StringView, userdata: ?*anyopaque) callconv(.c) void; extern fn wgpuSetLogCallback(callback: LogCallback, userdata: ?*anyopaque) void; extern fn wgpuSetLogLevel(level: LogLevel) void; @@ -19,4 +19,5 @@ pub inline fn setLogCallback(callback: LogCallback, userdata: ?*anyopaque) void } pub inline fn setLogLevel(level: LogLevel) void { wgpuSetLogLevel(level); -} \ No newline at end of file +} + diff --git a/src/misc.zig b/src/misc.zig index 60ba1fb..7e5e538 100644 --- a/src/misc.zig +++ b/src/misc.zig @@ -12,14 +12,14 @@ pub const WGPUFlags = u64; // Status code returned (synchronously) from many operations. // Generally indicates an invalid input like an unknown enum value or OutStructChainError. pub const Status = enum(u32) { - success = 0x00000001, + success = 0x00000001, @"error" = 0x00000002, }; pub const OptionalBool = enum(u32) { - false = 0x00000000, - true = 0x00000001, - @"undefined" = 0x00000002, + false = 0x00000000, + true = 0x00000001, + undefined = 0x00000002, }; // Used by both device and adapter @@ -27,58 +27,58 @@ pub const OptionalBool = enum(u32) { // but idk if they should go in device.zig, adapter.zig, or their own separate file. // So they're going in the "miscellaneous" pile for now. pub const FeatureName = enum(u32) { - @"undefined" = 0x00000000, - depth_clip_control = 0x00000001, - depth32_float_stencil8 = 0x00000002, - timestamp_query = 0x00000003, - texture_compression_bc = 0x00000004, - texture_compression_bc_sliced_3d = 0x00000005, - texture_compression_etc2 = 0x00000006, - texture_compression_astc = 0x00000007, - texture_compression_astc_sliced_3d = 0x00000008, - indirect_first_instance = 0x00000009, - shader_f16 = 0x0000000A, - rg11b10_ufloat_renderable = 0x0000000B, - bgra8_unorm_storage = 0x0000000C, - float32_filterable = 0x0000000D, - float32_blendable = 0x0000000E, - clip_distances = 0x0000000F, - dual_source_blending = 0x00000010, + undefined = 0x00000000, + depth_clip_control = 0x00000001, + depth32_float_stencil8 = 0x00000002, + timestamp_query = 0x00000003, + texture_compression_bc = 0x00000004, + texture_compression_bc_sliced_3d = 0x00000005, + texture_compression_etc2 = 0x00000006, + texture_compression_astc = 0x00000007, + texture_compression_astc_sliced_3d = 0x00000008, + indirect_first_instance = 0x00000009, + shader_f16 = 0x0000000A, + rg11b10_ufloat_renderable = 0x0000000B, + bgra8_unorm_storage = 0x0000000C, + float32_filterable = 0x0000000D, + float32_blendable = 0x0000000E, + clip_distances = 0x0000000F, + dual_source_blending = 0x00000010, // wgpu-native extras - push_constants = 0x00030001, - texture_adapter_specific_format_features = 0x00030002, - multi_draw_indirect = 0x00030003, - multi_draw_indirect_count = 0x00030004, - vertex_writable_storage = 0x00030005, - texture_binding_array = 0x00030006, + push_constants = 0x00030001, + texture_adapter_specific_format_features = 0x00030002, + multi_draw_indirect = 0x00030003, + multi_draw_indirect_count = 0x00030004, + vertex_writable_storage = 0x00030005, + texture_binding_array = 0x00030006, sampled_texture_and_storage_buffer_array_non_uniform_indexing = 0x00030007, - pipeline_statistics_query = 0x00030008, - storage_resource_binding_array = 0x00030009, - partially_bound_binding_array = 0x0003000A, - texture_format_16bit_norm = 0x0003000B, - texture_compression_astc_hdr = 0x0003000C, - mappable_primary_buffers = 0x0003000E, - buffer_binding_array = 0x0003000F, + pipeline_statistics_query = 0x00030008, + storage_resource_binding_array = 0x00030009, + partially_bound_binding_array = 0x0003000A, + texture_format_16bit_norm = 0x0003000B, + texture_compression_astc_hdr = 0x0003000C, + mappable_primary_buffers = 0x0003000E, + buffer_binding_array = 0x0003000F, uniform_buffer_and_storage_texture_array_non_uniform_indexing = 0x00030010, - spirv_shader_passthrough = 0x00030017, - vertex_attribute_64bit = 0x00030019, - texture_format_nv12 = 0x0003001A, - ray_tracing_acceleration_structure = 0x0003001B, - ray_query = 0x0003001C, - shader_f64 = 0x0003001D, - shader_i16 = 0x0003001E, - shader_primitive_index = 0x0003001F, - shader_early_depth_test = 0x00030020, - subgroup = 0x00030021, - subgroup_vertex = 0x00030022, - subgroup_barrier = 0x00030023, - timestamp_query_inside_encoders = 0x00030024, - timestamp_query_inside_passes = 0x00030025, + spirv_shader_passthrough = 0x00030017, + vertex_attribute_64bit = 0x00030019, + texture_format_nv12 = 0x0003001A, + ray_tracing_acceleration_structure = 0x0003001B, + ray_query = 0x0003001C, + shader_f64 = 0x0003001D, + shader_i16 = 0x0003001E, + shader_primitive_index = 0x0003001F, + shader_early_depth_test = 0x00030020, + subgroup = 0x00030021, + subgroup_vertex = 0x00030022, + subgroup_barrier = 0x00030023, + timestamp_query_inside_encoders = 0x00030024, + timestamp_query_inside_passes = 0x00030025, }; pub const SupportedFeaturesProcs = struct { - pub const FreeMembers = *const fn(SupportedFeatures) callconv(.C) void; + pub const FreeMembers = *const fn (SupportedFeatures) callconv(.c) void; }; extern fn wgpuSupportedFeaturesFreeMembers(supported_features: SupportedFeatures) void; @@ -94,21 +94,21 @@ pub const SupportedFeatures = extern struct { }; pub const IndexFormat = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument. - uint16 = 0x00000001, - uint32 = 0x00000002, + undefined = 0x00000000, // Indicates no value is passed for this argument. + uint16 = 0x00000001, + uint32 = 0x00000002, }; pub const CompareFunction = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument - never = 0x00000001, - less = 0x00000002, - equal = 0x00000003, - less_equal = 0x00000004, - greater = 0x00000005, - not_equal = 0x00000006, + undefined = 0x00000000, // Indicates no value is passed for this argument + never = 0x00000001, + less = 0x00000002, + equal = 0x00000003, + less_equal = 0x00000004, + greater = 0x00000005, + not_equal = 0x00000006, greater_equal = 0x00000007, - always = 0x00000008, + always = 0x00000008, }; extern fn wgpuGetVersion() u32; @@ -142,7 +142,7 @@ pub const StringView = extern struct { length: usize = WGPU_STRLEN, pub inline fn fromSlice(slice: []const u8) StringView { - return StringView { + return StringView{ .data = slice.ptr, .length = slice.len, }; @@ -165,7 +165,7 @@ pub const StringView = extern struct { test "StringView can be constructed from slice" { const test_slice = "test"; - try std.testing.expectEqualDeep(StringView { + try std.testing.expectEqualDeep(StringView{ .data = test_slice.ptr, .length = test_slice.len, }, StringView.fromSlice("test")); @@ -173,7 +173,7 @@ test "StringView can be constructed from slice" { test "slice can be constructed from normal StringView" { const test_slice = "test"; - const sv = StringView { + const sv = StringView{ .data = test_slice.ptr, .length = test_slice.len, }; @@ -183,7 +183,7 @@ test "slice can be constructed from normal StringView" { test "slice can be constructed from null-terminated StringView" { const test_slice = "test"; - const sv = StringView { + const sv = StringView{ .data = test_slice.ptr, .length = WGPU_STRLEN, }; @@ -192,7 +192,7 @@ test "slice can be constructed from null-terminated StringView" { } test "StringView.toSlice returns null if data is null" { - const sv = StringView { + const sv = StringView{ .data = null, .length = WGPU_STRLEN, }; diff --git a/src/pipeline.zig b/src/pipeline.zig index 2f244a5..348234d 100644 --- a/src/pipeline.zig +++ b/src/pipeline.zig @@ -28,7 +28,7 @@ pub const PushConstantRange = extern struct { }; pub const PipelineLayoutExtras = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.pipeline_layout_extras, }, push_constant_range_count: usize, @@ -37,17 +37,13 @@ pub const PipelineLayoutExtras = extern struct { pub const PipelineLayoutDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, bind_group_layout_count: usize, bind_group_layouts: [*]const *BindGroupLayout, - pub inline fn withPushConstantRanges( - self: PipelineLayoutDescriptor, - push_constant_range_count: usize, - push_constant_ranges: [*]const PushConstantRange - ) PipelineLayoutDescriptor { + pub inline fn withPushConstantRanges(self: PipelineLayoutDescriptor, push_constant_range_count: usize, push_constant_ranges: [*]const PushConstantRange) PipelineLayoutDescriptor { var pld = self; - pld.next_in_chain = @ptrCast(&PipelineLayoutExtras { + pld.next_in_chain = @ptrCast(&PipelineLayoutExtras{ .push_constant_range_count = push_constant_range_count, .push_constant_ranges = push_constant_ranges, }); @@ -56,9 +52,9 @@ pub const PipelineLayoutDescriptor = extern struct { }; pub const PipelineLayoutProcs = struct { - pub const SetLabel = *const fn(*PipelineLayout, StringView) callconv(.C) void; - pub const AddRef = *const fn(*PipelineLayout) callconv(.C) void; - pub const Release = *const fn(*PipelineLayout) callconv(.C) void; + pub const SetLabel = *const fn (*PipelineLayout, StringView) callconv(.c) void; + pub const AddRef = *const fn (*PipelineLayout) callconv(.c) void; + pub const Release = *const fn (*PipelineLayout) callconv(.c) void; }; extern fn wgpuPipelineLayoutSetLabel(pipeline_layout: *PipelineLayout, label: StringView) void; @@ -90,24 +86,24 @@ pub const ConstantEntry = extern struct { pub const ProgrammableStageDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, module: *ShaderModule, - entry_point: StringView = StringView {}, + entry_point: StringView = StringView{}, constant_count: usize = 0, - constants: [*]const ConstantEntry = &[0]ConstantEntry {}, + constants: [*]const ConstantEntry = &[0]ConstantEntry{}, }; pub const ComputePipelineDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, layout: ?*PipelineLayout = null, compute: ProgrammableStageDescriptor, }; pub const CreatePipelineAsyncStatus = enum(u32) { - success = 0x00000001, + success = 0x00000001, instance_dropped = 0x00000002, validation_error = 0x00000003, - internal_error = 0x00000004, - unknown = 0x00000005, + internal_error = 0x00000004, + unknown = 0x00000005, }; pub const CreateComputePipelineAsyncCallbackInfo = extern struct { @@ -122,19 +118,19 @@ pub const CreateComputePipelineAsyncCallbackInfo = extern struct { }; // TODO: This should probably be in device.zig, as well as its RenderPipeline counterpart -pub const CreateComputePipelineAsyncCallback = *const fn( +pub const CreateComputePipelineAsyncCallback = *const fn ( status: CreatePipelineAsyncStatus, pipeline: ?*ComputePipeline, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque, -) callconv(.C) void; +) callconv(.c) void; pub const ComputePipelineProcs = struct { - pub const GetBindGroupLayout = *const fn(*ComputePipeline, u32) callconv(.C) ?*BindGroupLayout; - pub const SetLabel = *const fn(*ComputePipeline, StringView) callconv(.C) void; - pub const AddRef = *const fn(*ComputePipeline) callconv(.C) void; - pub const Release = *const fn(*ComputePipeline) callconv(.C) void; + pub const GetBindGroupLayout = *const fn (*ComputePipeline, u32) callconv(.c) ?*BindGroupLayout; + pub const SetLabel = *const fn (*ComputePipeline, StringView) callconv(.c) void; + pub const AddRef = *const fn (*ComputePipeline) callconv(.c) void; + pub const Release = *const fn (*ComputePipeline) callconv(.c) void; }; extern fn wgpuComputePipelineGetBindGroupLayout(compute_pipeline: *ComputePipeline, group_index: u32) ?*BindGroupLayout; @@ -163,53 +159,53 @@ pub const ComputePipeline = opaque { pub const VertexStepMode = enum(u32) { vertex_buffer_not_used = 0x00000000, // This VertexBufferLayout is a "hole" in the VertexState `buffers` array. - @"undefined" = 0x00000001, // Indicates no value is passed for this argument. - vertex = 0x00000002, - instance = 0x00000003, + undefined = 0x00000001, // Indicates no value is passed for this argument. + vertex = 0x00000002, + instance = 0x00000003, }; pub const VertexFormat = enum(u32) { - uint8 = 0x00000001, - uint8x2 = 0x00000002, - uint8x4 = 0x00000003, - sint8 = 0x00000004, - sint8x2 = 0x00000005, - sint8x4 = 0x00000006, - unorm8 = 0x00000007, - unorm8x2 = 0x00000008, - unorm8x4 = 0x00000009, - snorm8 = 0x0000000A, - snorm8x2 = 0x0000000B, - snorm8x4 = 0x0000000C, - uint16 = 0x0000000D, - uint16x2 = 0x0000000E, - uint16x4 = 0x0000000F, - sint16 = 0x00000010, - sint16x2 = 0x00000011, - sint16x4 = 0x00000012, - unorm16 = 0x00000013, - unorm16x2 = 0x00000014, - unorm16x4 = 0x00000015, - snorm16 = 0x00000016, - snorm16x2 = 0x00000017, - snorm16x4 = 0x00000018, - float16 = 0x00000019, - float16x2 = 0x0000001A, - float16x4 = 0x0000001B, - float32 = 0x0000001C, - float32x2 = 0x0000001D, - float32x3 = 0x0000001E, - float32x4 = 0x0000001F, - uint32 = 0x00000020, - uint32x2 = 0x00000021, - uint32x3 = 0x00000022, - uint32x4 = 0x00000023, - sint32 = 0x00000024, - sint32x2 = 0x00000025, - sint32x3 = 0x00000026, - sint32x4 = 0x00000027, + uint8 = 0x00000001, + uint8x2 = 0x00000002, + uint8x4 = 0x00000003, + sint8 = 0x00000004, + sint8x2 = 0x00000005, + sint8x4 = 0x00000006, + unorm8 = 0x00000007, + unorm8x2 = 0x00000008, + unorm8x4 = 0x00000009, + snorm8 = 0x0000000A, + snorm8x2 = 0x0000000B, + snorm8x4 = 0x0000000C, + uint16 = 0x0000000D, + uint16x2 = 0x0000000E, + uint16x4 = 0x0000000F, + sint16 = 0x00000010, + sint16x2 = 0x00000011, + sint16x4 = 0x00000012, + unorm16 = 0x00000013, + unorm16x2 = 0x00000014, + unorm16x4 = 0x00000015, + snorm16 = 0x00000016, + snorm16x2 = 0x00000017, + snorm16x4 = 0x00000018, + float16 = 0x00000019, + float16x2 = 0x0000001A, + float16x4 = 0x0000001B, + float32 = 0x0000001C, + float32x2 = 0x0000001D, + float32x3 = 0x0000001E, + float32x4 = 0x0000001F, + uint32 = 0x00000020, + uint32x2 = 0x00000021, + uint32x3 = 0x00000022, + uint32x4 = 0x00000023, + sint32 = 0x00000024, + sint32x2 = 0x00000025, + sint32x3 = 0x00000026, + sint32x4 = 0x00000027, unorm10_10_10_2 = 0x00000028, - unorm8x4_bgra = 0x00000029, + unorm8x4_bgra = 0x00000029, }; pub const VertexAttribute = extern struct { @@ -232,54 +228,54 @@ pub const VertexBufferLayout = extern struct { pub const VertexState = extern struct { next_in_chain: ?*const ChainedStruct = null, module: *ShaderModule, - entry_point: StringView = StringView {}, + entry_point: StringView = StringView{}, constant_count: usize = 0, - constants: [*]const ConstantEntry = &[0]ConstantEntry {}, + constants: [*]const ConstantEntry = &[0]ConstantEntry{}, buffer_count: usize = 0, - buffers: [*]const VertexBufferLayout = &[0]VertexBufferLayout {}, + buffers: [*]const VertexBufferLayout = &[0]VertexBufferLayout{}, }; pub const PrimitiveTopology = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument. - point_list = 0x00000001, - line_list = 0x00000002, - line_strip = 0x00000003, - triangle_list = 0x00000004, + undefined = 0x00000000, // Indicates no value is passed for this argument. + point_list = 0x00000001, + line_list = 0x00000002, + line_strip = 0x00000003, + triangle_list = 0x00000004, triangle_strip = 0x00000005, }; pub const FrontFace = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument. - ccw = 0x00000001, - cw = 0x00000002, + undefined = 0x00000000, // Indicates no value is passed for this argument. + ccw = 0x00000001, + cw = 0x00000002, }; pub const CullMode = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument - none = 0x00000001, - front = 0x00000002, - back = 0x00000003, + undefined = 0x00000000, // Indicates no value is passed for this argument + none = 0x00000001, + front = 0x00000002, + back = 0x00000003, }; pub const PrimitiveState = extern struct { next_in_chain: ?*const ChainedStruct = null, topology: PrimitiveTopology = PrimitiveTopology.triangle_list, - strip_index_format: IndexFormat = IndexFormat.@"undefined", + strip_index_format: IndexFormat = IndexFormat.undefined, front_face: FrontFace = FrontFace.ccw, cull_mode: CullMode = CullMode.none, unclipped_depth: WGPUBool = @intFromBool(false), }; pub const StencilOperation = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument. - keep = 0x00000001, - zero = 0x00000002, - replace = 0x00000003, - invert = 0x00000004, + undefined = 0x00000000, // Indicates no value is passed for this argument. + keep = 0x00000001, + zero = 0x00000002, + replace = 0x00000003, + invert = 0x00000004, increment_clamp = 0x00000005, decrement_clamp = 0x00000006, - increment_wrap = 0x00000007, - decrement_wrap = 0x00000008, + increment_wrap = 0x00000007, + decrement_wrap = 0x00000008, }; pub const StencilFaceState = extern struct { @@ -292,8 +288,8 @@ pub const StencilFaceState = extern struct { pub const DepthStencilState = extern struct { next_in_chain: ?*const ChainedStruct = null, format: TextureFormat, - depth_write_enabled: OptionalBool = OptionalBool.@"undefined", - depth_compare: CompareFunction = CompareFunction.@"undefined", + depth_write_enabled: OptionalBool = OptionalBool.undefined, + depth_compare: CompareFunction = CompareFunction.undefined, stencil_front: StencilFaceState, stencil_back: StencilFaceState, stencil_read_mask: u32 = 0xffffffff, @@ -311,32 +307,32 @@ pub const MultisampleState = extern struct { }; pub const BlendOperation = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument - add = 0x00000001, - subtract = 0x00000002, + undefined = 0x00000000, // Indicates no value is passed for this argument + add = 0x00000001, + subtract = 0x00000002, reverse_subtract = 0x00000003, - min = 0x00000004, - max = 0x00000005, + min = 0x00000004, + max = 0x00000005, }; pub const BlendFactor = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument - zero = 0x00000001, - one = 0x00000002, - src = 0x00000003, - one_minus_src = 0x00000004, - src_alpha = 0x00000005, - one_minus_src_alpha = 0x00000006, - dst = 0x00000007, - one_minus_dst = 0x00000008, - dst_alpha = 0x00000009, - one_minus_dst_alpha = 0x0000000A, - src_alpha_saturated = 0x0000000B, - constant = 0x0000000C, - one_minus_constant = 0x0000000D, - src_1 = 0x0000000E, - one_minus_src_1 = 0x0000000F, - src_1_alpha = 0x00000010, + undefined = 0x00000000, // Indicates no value is passed for this argument + zero = 0x00000001, + one = 0x00000002, + src = 0x00000003, + one_minus_src = 0x00000004, + src_alpha = 0x00000005, + one_minus_src_alpha = 0x00000006, + dst = 0x00000007, + one_minus_dst = 0x00000008, + dst_alpha = 0x00000009, + one_minus_dst_alpha = 0x0000000A, + src_alpha_saturated = 0x0000000B, + constant = 0x0000000C, + one_minus_constant = 0x0000000D, + src_1 = 0x0000000E, + one_minus_src_1 = 0x0000000F, + src_1_alpha = 0x00000010, one_minus_src_1_alpha = 0x00000011, }; @@ -346,12 +342,12 @@ pub const BlendComponent = extern struct { dst_factor: BlendFactor = BlendFactor.zero, // Preset components borrowed from wgpu-types - pub const replace = BlendComponent { + pub const replace = BlendComponent{ .operation = BlendOperation.add, .src_factor = BlendFactor.one, .dst_factor = BlendFactor.zero, }; - pub const over = BlendComponent { + pub const over = BlendComponent{ .operation = BlendOperation.add, .src_factor = BlendFactor.one, .dst_factor = BlendFactor.one_minus_src_alpha, @@ -363,19 +359,19 @@ pub const BlendState = extern struct { alpha: BlendComponent, // Preset blend states borrowed from wgpu-types - pub const replace = BlendState { + pub const replace = BlendState{ .color = BlendComponent.replace, .alpha = BlendComponent.replace, }; - pub const alpha_blending = BlendState { - .color = BlendComponent { + pub const alpha_blending = BlendState{ + .color = BlendComponent{ .operation = BlendOperation.add, .src_factor = BlendFactor.src_alpha, .dst_factor = BlendFactor.one_minus_src_alpha, }, .alpha = BlendComponent.over, }; - pub const premultiplied_alpha_blending = BlendState { + pub const premultiplied_alpha_blending = BlendState{ .color = BlendComponent.over, .alpha = BlendComponent.over, }; @@ -383,12 +379,12 @@ pub const BlendState = extern struct { pub const ColorWriteMask = WGPUFlags; pub const ColorWriteMasks = struct { - pub const none = @as(ColorWriteMask, 0x0000000000000000); - pub const red = @as(ColorWriteMask, 0x0000000000000001); + pub const none = @as(ColorWriteMask, 0x0000000000000000); + pub const red = @as(ColorWriteMask, 0x0000000000000001); pub const green = @as(ColorWriteMask, 0x0000000000000002); - pub const blue = @as(ColorWriteMask, 0x0000000000000004); + pub const blue = @as(ColorWriteMask, 0x0000000000000004); pub const alpha = @as(ColorWriteMask, 0x0000000000000008); - pub const all = none | red | green | blue | alpha; + pub const all = none | red | green | blue | alpha; }; pub const ColorTargetState = extern struct { @@ -406,16 +402,16 @@ pub const ColorTargetState = extern struct { pub const FragmentState = extern struct { next_in_chain: ?*const ChainedStruct = null, module: *ShaderModule, - entry_point: StringView = StringView {}, + entry_point: StringView = StringView{}, constant_count: usize = 0, - constants: [*]const ConstantEntry = &[0]ConstantEntry {}, + constants: [*]const ConstantEntry = &[0]ConstantEntry{}, target_count: usize, targets: [*]const ColorTargetState, }; pub const RenderPipelineDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, layout: ?*PipelineLayout = null, vertex: VertexState, primitive: PrimitiveState, @@ -425,10 +421,10 @@ pub const RenderPipelineDescriptor = extern struct { }; pub const RenderPipelineProcs = struct { - pub const GetBindGroupLayout = *const fn(*RenderPipeline, u32) callconv(.C) ?*BindGroupLayout; - pub const SetLabel = *const fn(*RenderPipeline, StringView) callconv(.C) void; - pub const AddRef = *const fn(*RenderPipeline) callconv(.C) void; - pub const Release = *const fn(*RenderPipeline) callconv(.C) void; + pub const GetBindGroupLayout = *const fn (*RenderPipeline, u32) callconv(.c) ?*BindGroupLayout; + pub const SetLabel = *const fn (*RenderPipeline, StringView) callconv(.c) void; + pub const AddRef = *const fn (*RenderPipeline) callconv(.c) void; + pub const Release = *const fn (*RenderPipeline) callconv(.c) void; }; extern fn wgpuRenderPipelineGetBindGroupLayout(render_pipeline: *RenderPipeline, group_index: u32) ?*BindGroupLayout; @@ -466,10 +462,10 @@ pub const CreateRenderPipelineAsyncCallbackInfo = extern struct { userdata2: ?*anyopaque = null, }; -pub const CreateRenderPipelineAsyncCallback = *const fn( +pub const CreateRenderPipelineAsyncCallback = *const fn ( status: CreatePipelineAsyncStatus, pipeline: ?*RenderPipeline, message: StringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque, -) callconv(.C) void; +) callconv(.c) void; diff --git a/src/query_set.zig b/src/query_set.zig index c1dff6f..a7d09cf 100644 --- a/src/query_set.zig +++ b/src/query_set.zig @@ -5,23 +5,23 @@ const SType = _chained_struct.SType; const StringView = @import("misc.zig").StringView; pub const QueryType = enum(u32) { - occlusion = 0x00000001, - timestamp = 0x00000002, + occlusion = 0x00000001, + timestamp = 0x00000002, // wgpu-native pipeline statistics pipeline_statistics = 0x00030000, }; pub const PipelineStatisticName = enum(u32) { - vertex_shader_invocations = 0x00000000, - clipper_invocations = 0x00000001, - clipper_primitives_out = 0x00000002, + vertex_shader_invocations = 0x00000000, + clipper_invocations = 0x00000001, + clipper_primitives_out = 0x00000002, fragment_shader_invocations = 0x00000003, - compute_shader_invocations = 0x00000004, + compute_shader_invocations = 0x00000004, }; pub const QuerySetDescriptorExtras = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.query_set_descriptor_extras, }, pipeline_statistics: [*]const PipelineStatisticName, @@ -30,17 +30,13 @@ pub const QuerySetDescriptorExtras = extern struct { pub const QuerySetDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, - @"type": QueryType, + label: StringView = StringView{}, + type: QueryType, count: u32, - pub inline fn withPipelineStatistics( - self: QuerySetDescriptor, - pipeline_statistic_count: usize, - pipeline_statistics: [*]const PipelineStatisticName - ) QuerySetDescriptor { + pub inline fn withPipelineStatistics(self: QuerySetDescriptor, pipeline_statistic_count: usize, pipeline_statistics: [*]const PipelineStatisticName) QuerySetDescriptor { var qsd = self; - qsd.next_in_chain = @ptrCast(&QuerySetDescriptorExtras { + qsd.next_in_chain = @ptrCast(&QuerySetDescriptorExtras{ .pipeline_statistics = pipeline_statistics, .pipeline_statistic_count = pipeline_statistic_count, }); @@ -49,12 +45,12 @@ pub const QuerySetDescriptor = extern struct { }; pub const QuerySetProcs = struct { - pub const Destroy = *const fn(*QuerySet) callconv(.C) void; - pub const GetCount = *const fn(*QuerySet) callconv(.C) u32; - pub const GetType = *const fn(*QuerySet) callconv(.C) QueryType; - pub const SetLabel = *const fn(*QuerySet, StringView) callconv(.C) void; - pub const AddRef = *const fn(*QuerySet) callconv(.C) void; - pub const Release = *const fn(*QuerySet) callconv(.C) void; + pub const Destroy = *const fn (*QuerySet) callconv(.c) void; + pub const GetCount = *const fn (*QuerySet) callconv(.c) u32; + pub const GetType = *const fn (*QuerySet) callconv(.c) QueryType; + pub const SetLabel = *const fn (*QuerySet, StringView) callconv(.c) void; + pub const AddRef = *const fn (*QuerySet) callconv(.c) void; + pub const Release = *const fn (*QuerySet) callconv(.c) void; }; extern fn wgpuQuerySetDestroy(query_set: *QuerySet) void; @@ -87,4 +83,5 @@ pub const QuerySet = opaque { pub inline fn release(self: *QuerySet) void { wgpuQuerySetRelease(self); } -}; \ No newline at end of file +}; + diff --git a/src/queue.zig b/src/queue.zig index b5a5bef..bacf033 100644 --- a/src/queue.zig +++ b/src/queue.zig @@ -17,14 +17,14 @@ pub const SubmissionIndex = u64; pub const QueueDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, }; pub const WorkDoneStatus = enum(u32) { - success = 0x00000001, + success = 0x00000001, instance_dropped = 0x00000002, - @"error" = 0x00000003, - unknown = 0x00000004, + @"error" = 0x00000003, + unknown = 0x00000004, }; pub const QueueWorkDoneCallbackInfo = extern struct { @@ -38,19 +38,19 @@ pub const QueueWorkDoneCallbackInfo = extern struct { userdata2: ?*anyopaque = null, }; -pub const QueueWorkDoneCallback = *const fn(status: WorkDoneStatus, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.C) void; +pub const QueueWorkDoneCallback = *const fn (status: WorkDoneStatus, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.c) void; pub const QueueProcs = struct { - pub const OnSubmittedWorkDone = *const fn(*Queue, QueueWorkDoneCallbackInfo) callconv(.C) Future; - pub const SetLabel = *const fn(*Queue, StringView) callconv(.C) void; - pub const Submit = *const fn(*Queue, usize, [*]const *const CommandBuffer) callconv(.C) void; - pub const WriteBuffer = *const fn(*Queue, Buffer, u64, *const anyopaque, usize) callconv(.C) void; - pub const WriteTexture = *const fn(*Queue, *const TexelCopyTextureInfo, *const anyopaque, usize, *const TexelCopyBufferLayout, *const Extent3D) callconv(.C) void; - pub const AddRef = *const fn(*Queue) callconv(.C) void; - pub const Release = *const fn(*Queue) callconv(.C) void; + pub const OnSubmittedWorkDone = *const fn (*Queue, QueueWorkDoneCallbackInfo) callconv(.c) Future; + pub const SetLabel = *const fn (*Queue, StringView) callconv(.c) void; + pub const Submit = *const fn (*Queue, usize, [*]const *const CommandBuffer) callconv(.c) void; + pub const WriteBuffer = *const fn (*Queue, Buffer, u64, *const anyopaque, usize) callconv(.c) void; + pub const WriteTexture = *const fn (*Queue, *const TexelCopyTextureInfo, *const anyopaque, usize, *const TexelCopyBufferLayout, *const Extent3D) callconv(.c) void; + pub const AddRef = *const fn (*Queue) callconv(.c) void; + pub const Release = *const fn (*Queue) callconv(.c) void; // wgpu-native procs? - // pub const SubmitForIndex = *const fn(*Queue, usize, [*]const *const CommandBuffer) callconv(.C) SubmissionIndex; + // pub const SubmitForIndex = *const fn(*Queue, usize, [*]const *const CommandBuffer) callconv(.c) SubmissionIndex; }; extern fn wgpuQueueOnSubmittedWorkDone(queue: *Queue, callback_info: QueueWorkDoneCallbackInfo) Future; @@ -97,4 +97,5 @@ pub const Queue = opaque { pub inline fn submitForIndex(self: *Queue, commands: []const *const CommandBuffer) SubmissionIndex { return wgpuQueueSubmitForIndex(self, commands.len, commands.ptr); } -}; \ No newline at end of file +}; + diff --git a/src/render_bundle.zig b/src/render_bundle.zig index c81454a..93cbbb9 100644 --- a/src/render_bundle.zig +++ b/src/render_bundle.zig @@ -12,34 +12,34 @@ const ShaderStage = @import("shader.zig").ShaderStage; pub const RenderBundleEncoderDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, color_format_count: usize, color_formats: [*]const TextureFormat, - depth_stencil_format: TextureFormat = TextureFormat.@"undefined", + depth_stencil_format: TextureFormat = TextureFormat.undefined, sample_count: u32 = 1, depth_read_only: WGPUBool = @intFromBool(false), stencil_read_only: WGPUBool = @intFromBool(false), }; pub const RenderBundleEncoderProcs = struct { - pub const Draw = *const fn(*RenderBundleEncoder, u32, u32, u32, u32) callconv(.C) void; - pub const DrawIndexed = *const fn(*RenderBundleEncoder, u32, u32, u32, i32, u32) callconv(.C) void; - pub const DrawIndexedIndirect = *const fn(*RenderBundleEncoder, *Buffer, u64) callconv(.C) void; - pub const DrawIndirect = *const fn(*RenderBundleEncoder, *Buffer, u64) callconv(.C) void; - pub const Finish = *const fn(*RenderBundleEncoder, *const RenderBundleDescriptor) callconv(.C) ?*RenderBundle; - pub const InsertDebugMarker = *const fn(*RenderBundleEncoder, StringView) callconv(.C) void; - pub const PopDebugGroup = *const fn(*RenderBundleEncoder) callconv(.C) void; - pub const PushDebugGroup = *const fn(*RenderBundleEncoder, StringView) callconv(.C) void; - pub const SetBindGroup = *const fn(*RenderBundleEncoder, u32, *BindGroup, usize, ?[*]const u32) callconv(.C) void; - pub const SetIndexBuffer = *const fn(*RenderBundleEncoder, *Buffer, IndexFormat, u64, u64) callconv(.C) void; - pub const SetLabel = *const fn(*RenderBundleEncoder, StringView) callconv(.C) void; - pub const SetPipeline = *const fn(*RenderBundleEncoder, *RenderPipeline) callconv(.C) void; - pub const SetVertexBuffer = *const fn(*RenderBundleEncoder, u32, *Buffer, u64, u64) callconv(.C) void; - pub const AddRef = *const fn(*RenderBundleEncoder) callconv(.C) void; - pub const Release = *const fn(*RenderBundleEncoder) callconv(.C) void; + pub const Draw = *const fn (*RenderBundleEncoder, u32, u32, u32, u32) callconv(.c) void; + pub const DrawIndexed = *const fn (*RenderBundleEncoder, u32, u32, u32, i32, u32) callconv(.c) void; + pub const DrawIndexedIndirect = *const fn (*RenderBundleEncoder, *Buffer, u64) callconv(.c) void; + pub const DrawIndirect = *const fn (*RenderBundleEncoder, *Buffer, u64) callconv(.c) void; + pub const Finish = *const fn (*RenderBundleEncoder, *const RenderBundleDescriptor) callconv(.c) ?*RenderBundle; + pub const InsertDebugMarker = *const fn (*RenderBundleEncoder, StringView) callconv(.c) void; + pub const PopDebugGroup = *const fn (*RenderBundleEncoder) callconv(.c) void; + pub const PushDebugGroup = *const fn (*RenderBundleEncoder, StringView) callconv(.c) void; + pub const SetBindGroup = *const fn (*RenderBundleEncoder, u32, *BindGroup, usize, ?[*]const u32) callconv(.c) void; + pub const SetIndexBuffer = *const fn (*RenderBundleEncoder, *Buffer, IndexFormat, u64, u64) callconv(.c) void; + pub const SetLabel = *const fn (*RenderBundleEncoder, StringView) callconv(.c) void; + pub const SetPipeline = *const fn (*RenderBundleEncoder, *RenderPipeline) callconv(.c) void; + pub const SetVertexBuffer = *const fn (*RenderBundleEncoder, u32, *Buffer, u64, u64) callconv(.c) void; + pub const AddRef = *const fn (*RenderBundleEncoder) callconv(.c) void; + pub const Release = *const fn (*RenderBundleEncoder) callconv(.c) void; // wgpu-native procs? - // pub const SetPushConstants = *const fn(*RenderBundleEncoder, ShaderStage, u32, u32, *const anyopaque) callconv(.C) void; + // pub const SetPushConstants = *const fn(*RenderBundleEncoder, ShaderStage, u32, u32, *const anyopaque) callconv(.c) void; }; extern fn wgpuRenderBundleEncoderDraw(render_bundle_encoder: *RenderBundleEncoder, vertex_count: u32, instance_count: u32, first_vertex: u32, first_instance: u32) void; @@ -121,13 +121,13 @@ pub const RenderBundleEncoder = opaque { pub const RenderBundleDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, }; pub const RenderBundleProcs = struct { - pub const SetLabel = *const fn(*RenderBundle, StringView) callconv(.C) void; - pub const AddRef = *const fn(*RenderBundle) callconv(.C) void; - pub const Release = *const fn(*RenderBundle) callconv(.C) void; + pub const SetLabel = *const fn (*RenderBundle, StringView) callconv(.c) void; + pub const AddRef = *const fn (*RenderBundle) callconv(.c) void; + pub const Release = *const fn (*RenderBundle) callconv(.c) void; }; extern fn wgpuRenderBundleSetLabel(render_bundle: *RenderBundle, label: StringView) void; @@ -147,4 +147,5 @@ pub const RenderBundle = opaque { pub inline fn release(self: *RenderBundle) void { wgpuRenderBundleRelease(self); } -}; \ No newline at end of file +}; + diff --git a/src/sampler.zig b/src/sampler.zig index 308a03e..9f94aa6 100644 --- a/src/sampler.zig +++ b/src/sampler.zig @@ -9,40 +9,40 @@ pub const SamplerBindingType = enum(u32) { binding_not_used = 0x00000000, // Indicates no value is passed for this argument. - @"undefined" = 0x00000001, + undefined = 0x00000001, - filtering = 0x00000002, - non_filtering = 0x00000003, - comparison = 0x00000004, + filtering = 0x00000002, + non_filtering = 0x00000003, + comparison = 0x00000004, }; pub const SamplerBindingLayout = extern struct { next_in_chain: ?*const ChainedStruct = null, - @"type": SamplerBindingType = SamplerBindingType.@"undefined", + type: SamplerBindingType = SamplerBindingType.undefined, }; pub const AddressMode = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument + undefined = 0x00000000, // Indicates no value is passed for this argument clamp_to_edge = 0x00000001, - repeat = 0x00000002, + repeat = 0x00000002, mirror_repeat = 0x00000003, }; pub const FilterMode = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument. - nearest = 0x00000001, - linear = 0x00000002, + undefined = 0x00000000, // Indicates no value is passed for this argument. + nearest = 0x00000001, + linear = 0x00000002, }; pub const MipmapFilterMode = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument. - nearest = 0x00000001, - linear = 0x00000002, + undefined = 0x00000000, // Indicates no value is passed for this argument. + nearest = 0x00000001, + linear = 0x00000002, }; pub const SamplerDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, address_mode_u: AddressMode = AddressMode.clamp_to_edge, address_mode_v: AddressMode = AddressMode.clamp_to_edge, address_mode_w: AddressMode = AddressMode.clamp_to_edge, @@ -51,14 +51,14 @@ pub const SamplerDescriptor = extern struct { mipmap_filter: MipmapFilterMode = MipmapFilterMode.nearest, lod_min_clamp: f32 = 0.0, lod_max_clamp: f32 = 32.0, - compare: CompareFunction = CompareFunction.@"undefined", + compare: CompareFunction = CompareFunction.undefined, max_anisotropy: u16 = 1, }; pub const SamplerProcs = struct { - pub const SetLabel = *const fn(*Sampler, StringView) callconv(.C) void; - pub const AddRef = *const fn(*Sampler) callconv(.C) void; - pub const Release = *const fn(*Sampler) callconv(.C) void; + pub const SetLabel = *const fn (*Sampler, StringView) callconv(.c) void; + pub const AddRef = *const fn (*Sampler) callconv(.c) void; + pub const Release = *const fn (*Sampler) callconv(.c) void; }; extern fn wgpuSamplerSetLabel(sampler: *Sampler, label: StringView) void; @@ -78,4 +78,5 @@ pub const Sampler = opaque { pub inline fn release(self: *Sampler) void { wgpuSamplerRelease(self); } -}; \ No newline at end of file +}; + diff --git a/src/shader.zig b/src/shader.zig index bc5209e..121a960 100644 --- a/src/shader.zig +++ b/src/shader.zig @@ -14,26 +14,26 @@ const Future = _async.Future; pub const ShaderStage = WGPUFlags; pub const ShaderStages = struct { - pub const none = @as(ShaderStage, 0x0000000000000000); - pub const vertex = @as(ShaderStage, 0x0000000000000001); + pub const none = @as(ShaderStage, 0x0000000000000000); + pub const vertex = @as(ShaderStage, 0x0000000000000001); pub const fragment = @as(ShaderStage, 0x0000000000000002); - pub const compute = @as(ShaderStage, 0x0000000000000004); + pub const compute = @as(ShaderStage, 0x0000000000000004); }; pub const ShaderModuleDescriptor = extern struct { next_in_chain: *const ChainedStruct, - label: StringView = StringView {}, + label: StringView = StringView{}, }; // This is specific to wgpu-native (from wgpu.h), and unfortunately it is *NOT* the same thing as ShaderSourceSPIRV pub const ShaderModuleDescriptorSpirV = extern struct { - label: StringView = StringView {}, + label: StringView = StringView{}, source_size: u32, source: [*]const u32, }; pub const ShaderSourceSPIRV = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.shader_source_spirv, }, code_size: u32, @@ -44,11 +44,9 @@ pub const ShaderModuleSPIRVMergedDescriptor = struct { code_size: u32, code: [*]const u32, }; -pub inline fn shaderModuleSPIRVDescriptor( - descriptor: ShaderModuleSPIRVMergedDescriptor -) ShaderModuleDescriptor { - return ShaderModuleDescriptor { - .next_in_chain = @ptrCast(&ShaderSourceSPIRV { +pub inline fn shaderModuleSPIRVDescriptor(descriptor: ShaderModuleSPIRVMergedDescriptor) ShaderModuleDescriptor { + return ShaderModuleDescriptor{ + .next_in_chain = @ptrCast(&ShaderSourceSPIRV{ .code_size = descriptor.code_size, .code = descriptor.code, }), @@ -56,12 +54,9 @@ pub inline fn shaderModuleSPIRVDescriptor( }; } -pub const ShaderSourceWGSL = extern struct { - chain: ChainedStruct = ChainedStruct { - .s_type = SType.shader_source_wgsl, - }, - code: StringView -}; +pub const ShaderSourceWGSL = extern struct { chain: ChainedStruct = ChainedStruct{ + .s_type = SType.shader_source_wgsl, +}, code: StringView }; pub const ShaderModuleWGSLMergedDescriptor = struct { label: []const u8 = "", code: []const u8, @@ -69,8 +64,8 @@ pub const ShaderModuleWGSLMergedDescriptor = struct { pub inline fn shaderModuleWGSLDescriptor( descriptor: ShaderModuleWGSLMergedDescriptor, ) ShaderModuleDescriptor { - return ShaderModuleDescriptor { - .next_in_chain = @ptrCast(&ShaderSourceWGSL { + return ShaderModuleDescriptor{ + .next_in_chain = @ptrCast(&ShaderSourceWGSL{ .code = StringView.fromSlice(descriptor.code), }), .label = StringView.fromSlice(descriptor.label), @@ -82,7 +77,7 @@ pub const ShaderDefine = extern struct { value: StringView, }; pub const ShaderSourceGLSL = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.shader_source_glsl, }, stage: ShaderStage, @@ -100,8 +95,8 @@ pub const ShaderModuleGLSLMergedDescriptor = struct { pub inline fn shaderModuleGLSLDescriptor( descriptor: ShaderModuleGLSLMergedDescriptor, ) ShaderModuleDescriptor { - return ShaderModuleDescriptor { - .next_in_chain = @ptrCast(&ShaderSourceGLSL { + return ShaderModuleDescriptor{ + .next_in_chain = @ptrCast(&ShaderSourceGLSL{ .stage = descriptor.stage, .code = StringView.fromSlice(descriptor.code), .define_count = descriptor.define_count, @@ -112,16 +107,16 @@ pub inline fn shaderModuleGLSLDescriptor( } pub const CompilationInfoRequestStatus = enum(u32) { - success = 0x00000001, + success = 0x00000001, instance_dropped = 0x00000002, - @"error" = 0x00000003, - unknown = 0x00000004, + @"error" = 0x00000003, + unknown = 0x00000004, }; pub const CompilationMessageType = enum(u32) { @"error" = 0x00000001, - warning = 0x00000002, - info = 0x00000003, + warning = 0x00000002, + info = 0x00000003, }; pub const CompilationMessage = extern struct { @@ -129,7 +124,7 @@ pub const CompilationMessage = extern struct { message: StringView, // Severity level of the message. - @"type": CompilationMessageType, + type: CompilationMessageType, // Line number where the message is attached, starting at 1. line_num: u64, @@ -150,7 +145,7 @@ pub const CompilationInfo = extern struct { messages: [*]const CompilationMessage, }; -pub const CompilationInfoCallback = *const fn(status: CompilationInfoRequestStatus, compilationInfo: ?*const CompilationInfo, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.C) void; +pub const CompilationInfoCallback = *const fn (status: CompilationInfoRequestStatus, compilationInfo: ?*const CompilationInfo, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.c) void; pub const CompilationInfoCallbackInfo = extern struct { next_in_chain: ?*const ChainedStruct = null, @@ -164,10 +159,10 @@ pub const CompilationInfoCallbackInfo = extern struct { }; pub const ShaderModuleProcs = struct { - pub const GetCompilationInfo = *const fn(*ShaderModule, CompilationInfoCallbackInfo) callconv(.C) Future; - pub const SetLabel = *const fn(*ShaderModule, StringView) callconv(.C) void; - pub const AddRef = *const fn(*ShaderModule) callconv(.C) void; - pub const Release = *const fn(*ShaderModule) callconv(.C) void; + pub const GetCompilationInfo = *const fn (*ShaderModule, CompilationInfoCallbackInfo) callconv(.c) Future; + pub const SetLabel = *const fn (*ShaderModule, StringView) callconv(.c) void; + pub const AddRef = *const fn (*ShaderModule) callconv(.c) void; + pub const Release = *const fn (*ShaderModule) callconv(.c) void; }; extern fn wgpuShaderModuleGetCompilationInfo(shader_module: *ShaderModule, callback_info: CompilationInfoCallbackInfo) Future; @@ -194,4 +189,5 @@ pub const ShaderModule = opaque { pub inline fn release(self: *ShaderModule) void { wgpuShaderModuleRelease(self); } -}; \ No newline at end of file +}; + diff --git a/src/surface.zig b/src/surface.zig index dd99cc2..ba9cc70 100644 --- a/src/surface.zig +++ b/src/surface.zig @@ -26,12 +26,12 @@ pub const SurfaceDescriptor = extern struct { next_in_chain: *const ChainedStruct, // Label used to refer to the object. - label: StringView = StringView {}, + label: StringView = StringView{}, }; // Chained in SurfaceDescriptor to make an Surface wrapping an Android [`ANativeWindow`](https://developer.android.com/ndk/reference/group/a-native-window). pub const SurfaceSourceAndroidNativeWindow = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.surface_source_android_native_window, }, @@ -44,7 +44,7 @@ pub const MergedSurfaceDescriptorFromAndroidWindow = struct { }; pub inline fn surfaceDescriptorFromAndroidNativeWindow(descriptor: MergedSurfaceDescriptorFromAndroidWindow) SurfaceDescriptor { return SurfaceDescriptor{ - .next_in_chain = @ptrCast(&SurfaceSourceAndroidNativeWindow { + .next_in_chain = @ptrCast(&SurfaceSourceAndroidNativeWindow{ .window = descriptor.window, }), .label = StringView.fromSlice(descriptor.label), @@ -53,7 +53,7 @@ pub inline fn surfaceDescriptorFromAndroidNativeWindow(descriptor: MergedSurface // Chained in SurfaceDescriptor to make an Surface wrapping a [`CAMetalLayer`](https://developer.apple.com/documentation/quartzcore/cametallayer?language=objc). pub const SurfaceSourceMetalLayer = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.surface_source_metal_layer, }, @@ -66,7 +66,7 @@ pub const MergedSurfaceDescriptorFromMetalLayer = struct { }; pub inline fn surfaceDescriptorFromMetalLayer(descriptor: MergedSurfaceDescriptorFromMetalLayer) SurfaceDescriptor { return SurfaceDescriptor{ - .next_in_chain = @ptrCast(&SurfaceSourceMetalLayer { + .next_in_chain = @ptrCast(&SurfaceSourceMetalLayer{ .layer = descriptor.layer, }), .label = StringView.fromSlice(descriptor.label), @@ -75,7 +75,7 @@ pub inline fn surfaceDescriptorFromMetalLayer(descriptor: MergedSurfaceDescripto // Chained in SurfaceDescriptor to make an Surface wrapping a [Wayland](https://wayland.freedesktop.org/) [`wl_surface`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface). pub const SurfaceSourceWaylandSurface = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.surface_source_wayland_surface, }, @@ -92,7 +92,7 @@ pub const MergedSurfaceDescriptorFromWaylandSurface = struct { }; pub inline fn surfaceDescriptorFromWaylandSurface(descriptor: MergedSurfaceDescriptorFromWaylandSurface) SurfaceDescriptor { return SurfaceDescriptor{ - .next_in_chain = @ptrCast(&SurfaceSourceWaylandSurface { + .next_in_chain = @ptrCast(&SurfaceSourceWaylandSurface{ .display = descriptor.display, .surface = descriptor.surface, }), @@ -102,7 +102,7 @@ pub inline fn surfaceDescriptorFromWaylandSurface(descriptor: MergedSurfaceDescr // Chained in SurfaceDescriptor to make an Surface wrapping a Windows [`HWND`](https://learn.microsoft.com/en-us/windows/apps/develop/ui-input/retrieve-hwnd). pub const SurfaceSourceWindowsHWND = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.surface_source_windows_hwnd, }, @@ -120,7 +120,7 @@ pub const MergedSurfaceDescriptorFromWindowsHWND = struct { }; pub inline fn surfaceDescriptorFromWindowsHWND(descriptor: MergedSurfaceDescriptorFromWindowsHWND) SurfaceDescriptor { return SurfaceDescriptor{ - .next_in_chain = @ptrCast(&SurfaceSourceWindowsHWND { + .next_in_chain = @ptrCast(&SurfaceSourceWindowsHWND{ .hinstance = descriptor.hinstance, .hwnd = descriptor.hwnd, }), @@ -130,7 +130,7 @@ pub inline fn surfaceDescriptorFromWindowsHWND(descriptor: MergedSurfaceDescript // Chained in SurfaceDescriptor to make an Surface wrapping an [XCB](https://xcb.freedesktop.org/) `xcb_window_t`. pub const SurfaceSourceXCBWindow = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.surface_source_xcb_window, }, @@ -147,7 +147,7 @@ pub const MergedSurfaceDescriptorFromXcbWindow = struct { }; pub inline fn surfaceDescriptorFromXcbWindow(descriptor: MergedSurfaceDescriptorFromXcbWindow) SurfaceDescriptor { return SurfaceDescriptor{ - .next_in_chain = @ptrCast(&SurfaceSourceXCBWindow { + .next_in_chain = @ptrCast(&SurfaceSourceXCBWindow{ .connection = descriptor.connection, .window = descriptor.window, }), @@ -157,7 +157,7 @@ pub inline fn surfaceDescriptorFromXcbWindow(descriptor: MergedSurfaceDescriptor // Chained in SurfaceDescriptor to make an Surface wrapping an [Xlib](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html) `Window`. pub const SurfaceSourceXlibWindow = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.surface_source_xlib_window, }, @@ -174,7 +174,7 @@ pub const MergedSurfaceDescriptorFromXlibWindow = struct { }; pub inline fn surfaceDescriptorFromXlibWindow(descriptor: MergedSurfaceDescriptorFromXlibWindow) SurfaceDescriptor { return SurfaceDescriptor{ - .next_in_chain = @ptrCast(&SurfaceSourceXlibWindow { + .next_in_chain = @ptrCast(&SurfaceSourceXlibWindow{ .display = descriptor.display, .window = descriptor.window, }), @@ -185,14 +185,14 @@ pub inline fn surfaceDescriptorFromXlibWindow(descriptor: MergedSurfaceDescripto // Describes how frames are composited with other contents on the screen when `::wgpuSurfacePresent` is called pub const CompositeAlphaMode = enum(u32) { // Lets the WebGPU implementation choose the best mode (supported, and with the best performance) between `@"opaque"` or `inherit`. - auto = 0x00000000, + auto = 0x00000000, // The alpha component of the image is ignored and teated as if it is always 1.0. - @"opaque" = 0x00000001, + @"opaque" = 0x00000001, // The alpha component is respected and non-alpha components are assumed to be already multiplied with the alpha component. // For example, (0.5, 0, 0, 0.5) is semi-transparent bright red. - premultiplied = 0x00000002, + premultiplied = 0x00000002, // The alpha component is respected and non-alpha components are assumed to NOT be already multiplied with the alpha component. // For example, (1.0, 0, 0, 0.5) is semi-transparent bright red. @@ -200,18 +200,18 @@ pub const CompositeAlphaMode = enum(u32) { // The handling of the alpha component is unknown to WebGPU and should be handled by the application using system-specific APIs. // This mode may be unavailable (for example on Wasm). - inherit = 0x00000004, + inherit = 0x00000004, }; // Describes when and in which order frames are presented on the screen when `::wgpuSurfacePresent` is called. pub const PresentMode = enum(u32) { // Present mode is not specified. Use the default. - @"undefined" = 0x00000000, + undefined = 0x00000000, // The presentation of the image to the user waits for the next vertical blanking period to update in a first-in, first-out manner. // Tearing cannot be observed and frame-loop will be limited to the display's refresh rate. // This is the only mode that's always available. - fifo = 0x00000001, + fifo = 0x00000001, // The presentation of the image to the user tries to wait for the next vertical blanking period but may decide to not wait if a frame is presented late. // Tearing can sometimes be observed but late-frame don't produce a full-frame stutter in the presentation. @@ -220,15 +220,15 @@ pub const PresentMode = enum(u32) { // The presentation of the image to the user is updated immediately without waiting for a vertical blank. // Tearing can be observed but latency is minimized. - immediate = 0x00000003, + immediate = 0x00000003, // The presentation of the image to the user waits for the next vertical blanking period to update to the latest provided image. // Tearing cannot be observed and a frame-loop is not limited to the display's refresh rate. - mailbox = 0x00000004, + mailbox = 0x00000004, }; pub const SurfaceConfigurationExtras = extern struct { - chain: ChainedStruct = ChainedStruct { + chain: ChainedStruct = ChainedStruct{ .s_type = SType.surface_configuration_extras, }, @@ -256,7 +256,7 @@ pub const SurfaceConfiguration = extern struct { // The additional TextureFormat for TextureView format reinterpretation of the surface's textures. view_format_count: usize = 0, - view_formats: [*]const TextureFormat = &[0]TextureFormat {}, + view_formats: [*]const TextureFormat = &[0]TextureFormat{}, // How the surface's frames will be composited on the screen. alpha_mode: CompositeAlphaMode = CompositeAlphaMode.auto, @@ -266,7 +266,7 @@ pub const SurfaceConfiguration = extern struct { pub inline fn withDesiredMaxFrameLatency(self: SurfaceConfiguration, desired_max_frame_latency: u32) SurfaceConfiguration { var sc = self; - sc.next_in_chain = @ptrCast(&SurfaceConfigurationExtras { + sc.next_in_chain = @ptrCast(&SurfaceConfigurationExtras{ .desired_maximum_frame_latency = desired_max_frame_latency, }); return sc; @@ -274,7 +274,7 @@ pub const SurfaceConfiguration = extern struct { }; pub const SurfaceCapabilitiesProcs = struct { - pub const FreeMembers = *const fn(SurfaceCapabilities) callconv(.C) void; + pub const FreeMembers = *const fn (SurfaceCapabilities) callconv(.c) void; }; extern fn wgpuSurfaceCapabilitiesFreeMembers(surface_capabilities: SurfaceCapabilities) void; @@ -310,29 +310,29 @@ pub const SurfaceCapabilities = extern struct { // The status enum for `::wgpuSurfaceGetCurrentTexture`. pub const GetCurrentTextureStatus = enum(u32) { // Yay! Everything is good and we can render this frame. - success_optimal = 0x00000001, + success_optimal = 0x00000001, // Still OK - the surface can present the frame, but in a suboptimal way. // The surface may need reconfiguration. success_suboptimal = 0x00000002, // Some operation timed out while trying to acquire the frame. - timeout = 0x00000003, + timeout = 0x00000003, // The surface is too different to be used, compared to when it was originally created. - outdated = 0x00000004, + outdated = 0x00000004, // The connection to whatever owns the surface was lost. - lost = 0x00000005, + lost = 0x00000005, // The system ran out of memory. - out_of_memory = 0x00000006, + out_of_memory = 0x00000006, // The Device configured on the Surface was lost. - device_lost = 0x00000007, + device_lost = 0x00000007, // The surface is not configured, or there was an OutStructChainError. - @"error" = 0x00000008, + @"error" = 0x00000008, }; // Queried each frame from a Surface to get a Texture to render to along with some metadata. @@ -348,14 +348,14 @@ pub const SurfaceTexture = extern struct { }; pub const SurfaceProcs = struct { - pub const Configure = *const fn(*Surface, *const SurfaceConfiguration) callconv(.C) void; - pub const GetCapabilities = *const fn(*Surface, *Adapter, *SurfaceCapabilities) callconv(.C) Status; - pub const GetCurrentTexture = *const fn(*Surface, *SurfaceTexture) callconv(.C) void; - pub const Present = *const fn(*Surface) callconv(.C) Status; - pub const SetLabel = *const fn(*Surface, StringView) void; - pub const Unconfigure = *const fn(*Surface) callconv(.C) void; - pub const AddRef = *const fn(*Surface) callconv(.C) void; - pub const Release = *const fn(*Surface) callconv(.C) void; + pub const Configure = *const fn (*Surface, *const SurfaceConfiguration) callconv(.c) void; + pub const GetCapabilities = *const fn (*Surface, *Adapter, *SurfaceCapabilities) callconv(.c) Status; + pub const GetCurrentTexture = *const fn (*Surface, *SurfaceTexture) callconv(.c) void; + pub const Present = *const fn (*Surface) callconv(.c) Status; + pub const SetLabel = *const fn (*Surface, StringView) void; + pub const Unconfigure = *const fn (*Surface) callconv(.c) void; + pub const AddRef = *const fn (*Surface) callconv(.c) void; + pub const Release = *const fn (*Surface) callconv(.c) void; }; extern fn wgpuSurfaceConfigure(surface: *Surface, config: *const SurfaceConfiguration) void; @@ -422,4 +422,5 @@ pub const Surface = opaque { pub inline fn release(self: *Surface) void { wgpuSurfaceRelease(self); } -}; \ No newline at end of file +}; + diff --git a/src/texture.zig b/src/texture.zig index 951d8c3..77907a0 100644 --- a/src/texture.zig +++ b/src/texture.zig @@ -13,120 +13,120 @@ pub const WGPU_COPY_STRIDE_UNDEFINED = U32_MAX; const Buffer = @import("buffer.zig").Buffer; pub const TextureFormat = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument. - 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_uint = 0x00000019, - rgb10a2_unorm = 0x0000001A, - rg11b10_ufloat = 0x0000001B, - rgb9e5_ufloat = 0x0000001C, - rg32_float = 0x0000001D, - rg32_uint = 0x0000001E, - rg32_sint = 0x0000001F, - rgba16_uint = 0x00000020, - rgba16_sint = 0x00000021, - rgba16_float = 0x00000022, - rgba32_float = 0x00000023, - rgba32_uint = 0x00000024, - rgba32_sint = 0x00000025, - stencil8 = 0x00000026, - depth16_unorm = 0x00000027, - depth24_plus = 0x00000028, - depth24_plus_stencil8 = 0x00000029, - depth32_float = 0x0000002A, - depth32_float_stencil8 = 0x0000002B, - bc1_rgba_unorm = 0x0000002C, - bc1_rgba_unorm_srgb = 0x0000002D, - bc2_rgba_unorm = 0x0000002E, - bc2_rgba_unorm_srgb = 0x0000002F, - bc3_rgba_unorm = 0x00000030, - bc3_rgba_unorm_srgb = 0x00000031, - bc4_r_unorm = 0x00000032, - bc4_r_snorm = 0x00000033, - bc5_rg_unorm = 0x00000034, - bc5_rg_snorm = 0x00000035, - bc6_hrgb_ufloat = 0x00000036, - bc6_hrgb_float = 0x00000037, - bc7_rgba_unorm = 0x00000038, - bc7_rgba_unorm_srgb = 0x00000039, - etc2_rgb8_unorm = 0x0000003A, - etc2_rgb8_unorm_srgb = 0x0000003B, - etc2_rgb8a1_unorm = 0x0000003C, - etc2_rgb8a1_unorm_srgb = 0x0000003D, - etc2_rgba8_unorm = 0x0000003E, - etc2_rgba8_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, + undefined = 0x00000000, // Indicates no value is passed for this argument. + 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_uint = 0x00000019, + rgb10a2_unorm = 0x0000001A, + rg11b10_ufloat = 0x0000001B, + rgb9e5_ufloat = 0x0000001C, + rg32_float = 0x0000001D, + rg32_uint = 0x0000001E, + rg32_sint = 0x0000001F, + rgba16_uint = 0x00000020, + rgba16_sint = 0x00000021, + rgba16_float = 0x00000022, + rgba32_float = 0x00000023, + rgba32_uint = 0x00000024, + rgba32_sint = 0x00000025, + stencil8 = 0x00000026, + depth16_unorm = 0x00000027, + depth24_plus = 0x00000028, + depth24_plus_stencil8 = 0x00000029, + depth32_float = 0x0000002A, + depth32_float_stencil8 = 0x0000002B, + bc1_rgba_unorm = 0x0000002C, + bc1_rgba_unorm_srgb = 0x0000002D, + bc2_rgba_unorm = 0x0000002E, + bc2_rgba_unorm_srgb = 0x0000002F, + bc3_rgba_unorm = 0x00000030, + bc3_rgba_unorm_srgb = 0x00000031, + bc4_r_unorm = 0x00000032, + bc4_r_snorm = 0x00000033, + bc5_rg_unorm = 0x00000034, + bc5_rg_snorm = 0x00000035, + bc6_hrgb_ufloat = 0x00000036, + bc6_hrgb_float = 0x00000037, + bc7_rgba_unorm = 0x00000038, + bc7_rgba_unorm_srgb = 0x00000039, + etc2_rgb8_unorm = 0x0000003A, + etc2_rgb8_unorm_srgb = 0x0000003B, + etc2_rgb8a1_unorm = 0x0000003C, + etc2_rgb8a1_unorm_srgb = 0x0000003D, + etc2_rgba8_unorm = 0x0000003E, + etc2_rgba8_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, // wgpu-native texture formats - r16_unorm = 0x00030001, - r16_snorm = 0x00030002, - rg16_unorm = 0x00030003, - rg16_snorm = 0x00030004, - rgba16_unorm = 0x00030005, - rgba16_snorm = 0x00030006, - nv12 = 0x00030007, + r16_unorm = 0x00030001, + r16_snorm = 0x00030002, + rg16_unorm = 0x00030003, + rg16_snorm = 0x00030004, + rgba16_unorm = 0x00030005, + rgba16_snorm = 0x00030006, + nv12 = 0x00030007, }; pub const TextureUsage = WGPUFlags; pub const TextureUsages = struct { - pub const none = @as(TextureUsage, 0x0000000000000000); - pub const copy_src = @as(TextureUsage, 0x0000000000000001); - pub const copy_dst = @as(TextureUsage, 0x0000000000000002); - pub const texture_binding = @as(TextureUsage, 0x0000000000000004); - pub const storage_binding = @as(TextureUsage, 0x0000000000000008); + pub const none = @as(TextureUsage, 0x0000000000000000); + pub const copy_src = @as(TextureUsage, 0x0000000000000001); + pub const copy_dst = @as(TextureUsage, 0x0000000000000002); + pub const texture_binding = @as(TextureUsage, 0x0000000000000004); + pub const storage_binding = @as(TextureUsage, 0x0000000000000008); pub const render_attachment = @as(TextureUsage, 0x0000000000000010); }; @@ -134,17 +134,17 @@ pub const TextureUsages = struct { // in front of the name, even though "Aspect" is exclusively used in TextureAspect. I've done this because just calling // it "Aspect" seems like it'd confuse people thinking it is an aspect ratio or something, but should it just be "Aspect"? pub const TextureAspect = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument. - all = 0x00000001, + undefined = 0x00000000, // Indicates no value is passed for this argument. + all = 0x00000001, stencil_only = 0x00000002, - depth_only = 0x00000003, + depth_only = 0x00000003, }; pub const TextureViewDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, - format: TextureFormat = TextureFormat.@"undefined", - dimension: ViewDimension = ViewDimension.@"undefined", + label: StringView = StringView{}, + format: TextureFormat = TextureFormat.undefined, + dimension: ViewDimension = ViewDimension.undefined, base_mip_level: u32 = 0, mip_level_count: u32 = WGPU_MIP_LEVEL_COUNT_UNDEFINED, base_array_layer: u32 = 0, @@ -154,9 +154,9 @@ pub const TextureViewDescriptor = extern struct { }; pub const TextureViewProcs = struct { - pub const SetLabel = *const fn(*TextureView, StringView) callconv(.C) void; - pub const AddRef = *const fn(*TextureView) callconv(.C) void; - pub const Release = *const fn(*TextureView) callconv(.C) void; + pub const SetLabel = *const fn (*TextureView, StringView) callconv(.c) void; + pub const AddRef = *const fn (*TextureView) callconv(.c) void; + pub const Release = *const fn (*TextureView) callconv(.c) void; }; extern fn wgpuTextureViewSetLabel(texture_view: *TextureView, label: StringView) void; @@ -181,31 +181,31 @@ pub const TextureView = opaque { // TODO: Should this maybe go in sampler.zig instead? pub const SampleType = enum(u32) { // Indicates that this TextureBindingLayout member of its parent BindGroupLayoutEntry is not used. - binding_not_used = 0x00000000, + binding_not_used = 0x00000000, // Indicates no value is passed for this argument. - @"undefined" = 0x00000001, + undefined = 0x00000001, - float = 0x00000002, + float = 0x00000002, unfilterable_float = 0x00000003, - depth = 0x00000004, - s_int = 0x00000005, - u_int = 0x00000006, + depth = 0x00000004, + s_int = 0x00000005, + u_int = 0x00000006, }; pub const ViewDimension = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument. - @"1d" = 0x00000001, - @"2d" = 0x00000002, - @"2d_array" = 0x00000003, - cube = 0x00000004, - cube_array = 0x00000005, - @"3d" = 0x00000006, + undefined = 0x00000000, // Indicates no value is passed for this argument. + @"1d" = 0x00000001, + @"2d" = 0x00000002, + @"2d_array" = 0x00000003, + cube = 0x00000004, + cube_array = 0x00000005, + @"3d" = 0x00000006, }; pub const TextureBindingLayout = extern struct { next_in_chain: ?*const ChainedStruct = null, - sample_type: SampleType = SampleType.@"undefined", + sample_type: SampleType = SampleType.undefined, view_dimension: ViewDimension = ViewDimension.@"2d", multisampled: WGPUBool = @intFromBool(false), }; @@ -215,25 +215,25 @@ pub const StorageTextureAccess = enum(u32) { binding_not_used = 0x00000000, // Indicates no value is passed for this argument. - @"undefined" = 0x00000001, + undefined = 0x00000001, - write_only = 0x00000002, - read_only = 0x00000003, - read_write = 0x00000004, + write_only = 0x00000002, + read_only = 0x00000003, + read_write = 0x00000004, }; pub const StorageTextureBindingLayout = extern struct { next_in_chain: ?*const ChainedStruct = null, - access: StorageTextureAccess = StorageTextureAccess.@"undefined", - format: TextureFormat = TextureFormat.@"undefined", + access: StorageTextureAccess = StorageTextureAccess.undefined, + format: TextureFormat = TextureFormat.undefined, view_dimension: ViewDimension = ViewDimension.@"2d", }; pub const TextureDimension = enum(u32) { - @"undefined" = 0x00000000, // Indicates no value is passed for this argument. - @"1d" = 0x00000001, - @"2d" = 0x00000002, - @"3d" = 0x00000003, + undefined = 0x00000000, // Indicates no value is passed for this argument. + @"1d" = 0x00000001, + @"2d" = 0x00000002, + @"3d" = 0x00000003, }; pub const Extent3D = extern struct { @@ -244,7 +244,7 @@ pub const Extent3D = extern struct { pub const TextureDescriptor = extern struct { next_in_chain: ?*const ChainedStruct = null, - label: StringView = StringView {}, + label: StringView = StringView{}, usage: TextureUsage, dimension: TextureDimension = TextureDimension.@"2d", size: Extent3D, @@ -252,23 +252,23 @@ pub const TextureDescriptor = extern struct { mip_level_count: u32 = 1, sample_count: u32 = 1, view_format_count: usize = 0, - view_formats: [*]const TextureFormat = &[_]TextureFormat {}, + view_formats: [*]const TextureFormat = &[_]TextureFormat{}, }; pub const TextureProcs = struct { - pub const CreateView = *const fn(*Texture, ?*const TextureViewDescriptor) callconv(.C) ?*TextureView; - pub const Destroy = *const fn(*Texture) callconv(.C) void; - pub const GetDepthOrArrayLayers = *const fn(*Texture) callconv(.C) u32; - pub const GetDimension = *const fn(*Texture) callconv(.C) TextureDimension; - pub const GetFormat = *const fn(*Texture) callconv(.C) TextureFormat; - pub const GetHeight = *const fn(*Texture) callconv(.C) u32; - pub const GetMipLevelCount = *const fn(*Texture) callconv(.C) u32; - pub const GetSampleCount = *const fn(*Texture) callconv(.C) u32; - pub const GetUsage = *const fn(*Texture) callconv(.C) TextureUsage; - pub const GetWidth = *const fn(*Texture) callconv(.C) u32; - pub const SetLabel = *const fn(*Texture, StringView) callconv(.C) void; - pub const AddRef = *const fn(*Texture) callconv(.C) void; - pub const Release = *const fn(*Texture) callconv(.C) void; + pub const CreateView = *const fn (*Texture, ?*const TextureViewDescriptor) callconv(.c) ?*TextureView; + pub const Destroy = *const fn (*Texture) callconv(.c) void; + pub const GetDepthOrArrayLayers = *const fn (*Texture) callconv(.c) u32; + pub const GetDimension = *const fn (*Texture) callconv(.c) TextureDimension; + pub const GetFormat = *const fn (*Texture) callconv(.c) TextureFormat; + pub const GetHeight = *const fn (*Texture) callconv(.c) u32; + pub const GetMipLevelCount = *const fn (*Texture) callconv(.c) u32; + pub const GetSampleCount = *const fn (*Texture) callconv(.c) u32; + pub const GetUsage = *const fn (*Texture) callconv(.c) TextureUsage; + pub const GetWidth = *const fn (*Texture) callconv(.c) u32; + pub const SetLabel = *const fn (*Texture, StringView) callconv(.c) void; + pub const AddRef = *const fn (*Texture) callconv(.c) void; + pub const Release = *const fn (*Texture) callconv(.c) void; }; extern fn wgpuTextureCreateView(texture: *Texture, descriptor: ?*const TextureViewDescriptor) ?*TextureView; @@ -355,4 +355,5 @@ pub const TexelCopyBufferLayout = extern struct { pub const TexelCopyBufferInfo = extern struct { layout: TexelCopyBufferLayout, buffer: *Buffer, -}; \ No newline at end of file +}; + diff --git a/tests/compute.zig b/tests/compute.zig index b0f9474..e6ba6d9 100644 --- a/tests/compute.zig +++ b/tests/compute.zig @@ -3,7 +3,7 @@ const testing = std.testing; const wgpu = @import("wgpu"); -fn handleBufferMap(status: wgpu.MapAsyncStatus, _: wgpu.StringView, userdata1: ?*anyopaque, _: ?*anyopaque) callconv(.C) void { +fn handleBufferMap(status: wgpu.MapAsyncStatus, _: wgpu.StringView, userdata1: ?*anyopaque, _: ?*anyopaque) callconv(.c) void { std.log.info("buffer_map status={x:.8}\n", .{@intFromEnum(status)}); const completed: *bool = @ptrCast(@alignCast(userdata1)); completed.* = true; @@ -18,14 +18,14 @@ fn compute_collatz() ![4]u32 { defer instance.release(); const adapter_response = instance.requestAdapterSync(null, 200_000_000); - const adapter = switch(adapter_response.status) { + const adapter = switch (adapter_response.status) { .success => adapter_response.adapter.?, else => return error.NoAdapter, }; defer adapter.release(); const device_response = adapter.requestDeviceSync(instance, null, 200_000_000); - const device = switch(device_response.status) { + const device = switch (device_response.status) { .success => device_response.device.?, else => return error.NoDevice, }; @@ -40,7 +40,7 @@ fn compute_collatz() ![4]u32 { })).?; defer shader_module.release(); - const staging_buffer = device.createBuffer(&wgpu.BufferDescriptor { + const staging_buffer = device.createBuffer(&wgpu.BufferDescriptor{ .label = wgpu.StringView.fromSlice("staging_buffer"), .usage = wgpu.BufferUsages.map_read | wgpu.BufferUsages.copy_dst, .size = numbers_size, @@ -48,7 +48,7 @@ fn compute_collatz() ![4]u32 { }).?; defer staging_buffer.release(); - const storage_buffer = device.createBuffer(&wgpu.BufferDescriptor { + const storage_buffer = device.createBuffer(&wgpu.BufferDescriptor{ .label = wgpu.StringView.fromSlice("storage_buffer"), .usage = wgpu.BufferUsages.storage | wgpu.BufferUsages.copy_dst | wgpu.BufferUsages.copy_src, .size = numbers_size, @@ -56,9 +56,9 @@ fn compute_collatz() ![4]u32 { }).?; defer storage_buffer.release(); - const compute_pipeline = device.createComputePipeline(&wgpu.ComputePipelineDescriptor { + const compute_pipeline = device.createComputePipeline(&wgpu.ComputePipelineDescriptor{ .label = wgpu.StringView.fromSlice("compute_pipeline"), - .compute = wgpu.ProgrammableStageDescriptor { + .compute = wgpu.ProgrammableStageDescriptor{ .module = shader_module, .entry_point = wgpu.StringView.fromSlice("main"), }, @@ -68,27 +68,25 @@ fn compute_collatz() ![4]u32 { const bind_group_layout = compute_pipeline.getBindGroupLayout(0).?; defer bind_group_layout.release(); - const bind_group = device.createBindGroup(&wgpu.BindGroupDescriptor { + const bind_group = device.createBindGroup(&wgpu.BindGroupDescriptor{ .label = wgpu.StringView.fromSlice("bind_group"), .layout = bind_group_layout, .entry_count = 1, - .entries = &[_]wgpu.BindGroupEntry { - wgpu.BindGroupEntry { - .binding = 0, - .buffer = storage_buffer, - .offset = 0, - .size = numbers_size, - } - }, + .entries = &[_]wgpu.BindGroupEntry{wgpu.BindGroupEntry{ + .binding = 0, + .buffer = storage_buffer, + .offset = 0, + .size = numbers_size, + }}, }).?; defer bind_group.release(); - const command_encoder = device.createCommandEncoder(&wgpu.CommandEncoderDescriptor { + const command_encoder = device.createCommandEncoder(&wgpu.CommandEncoderDescriptor{ .label = wgpu.StringView.fromSlice("command_encoder"), }).?; defer command_encoder.release(); - const compute_pass_encoder = command_encoder.beginComputePass(&wgpu.ComputePassDescriptor { + const compute_pass_encoder = command_encoder.beginComputePass(&wgpu.ComputePassDescriptor{ .label = wgpu.StringView.fromSlice("compute_pass"), }).?; @@ -102,7 +100,7 @@ fn compute_collatz() ![4]u32 { command_encoder.copyBufferToBuffer(storage_buffer, 0, staging_buffer, 0, numbers_size); - const command_buffer = command_encoder.finish(&wgpu.CommandBufferDescriptor { + const command_buffer = command_encoder.finish(&wgpu.CommandBufferDescriptor{ .label = wgpu.StringView.fromSlice("command_buffer"), }).?; defer command_buffer.release(); @@ -111,19 +109,19 @@ fn compute_collatz() ![4]u32 { queue.submit(&[_]*const wgpu.CommandBuffer{command_buffer}); var buffer_map_complete = false; - _ = staging_buffer.mapAsync(wgpu.MapModes.read, 0, numbers_size, wgpu.BufferMapCallbackInfo { + _ = staging_buffer.mapAsync(wgpu.MapModes.read, 0, numbers_size, wgpu.BufferMapCallbackInfo{ .callback = handleBufferMap, .userdata1 = @ptrCast(&buffer_map_complete), }); instance.processEvents(); - while(!buffer_map_complete) { + while (!buffer_map_complete) { instance.processEvents(); } const buf: [*]u32 = @ptrCast(@alignCast(staging_buffer.getMappedRange(0, numbers_size).?)); defer staging_buffer.unmap(); - const ret = [4]u32 {buf[0], buf[1], buf[2], buf[3]}; + const ret = [4]u32{ buf[0], buf[1], buf[2], buf[3] }; return ret; } diff --git a/tests/compute_c.zig b/tests/compute_c.zig index 6388517..ab7943a 100644 --- a/tests/compute_c.zig +++ b/tests/compute_c.zig @@ -3,35 +3,35 @@ const testing = std.testing; const wgpu = @import("wgpu-c"); -fn handleRequestAdapter(status: wgpu.WGPURequestAdapterStatus, adapter: wgpu.WGPUAdapter, _: wgpu.WGPUStringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.C) void { - switch(status) { +fn handleRequestAdapter(status: wgpu.WGPURequestAdapterStatus, adapter: wgpu.WGPUAdapter, _: wgpu.WGPUStringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.c) void { + switch (status) { wgpu.WGPURequestAdapterStatus_Success => { const ud_adapter: *wgpu.WGPUAdapter = @ptrCast(@alignCast(userdata1)); ud_adapter.* = adapter; }, else => { std.log.err("adapter request failed", .{}); - } + }, } const completed: *bool = @ptrCast(@alignCast(userdata2)); completed.* = true; } -fn handleRequestDevice(status: wgpu.WGPURequestDeviceStatus, device: wgpu.WGPUDevice, _: wgpu.WGPUStringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.C) void { - switch(status) { +fn handleRequestDevice(status: wgpu.WGPURequestDeviceStatus, device: wgpu.WGPUDevice, _: wgpu.WGPUStringView, userdata1: ?*anyopaque, userdata2: ?*anyopaque) callconv(.c) void { + switch (status) { wgpu.WGPURequestDeviceStatus_Success => { const ud_device: *wgpu.WGPUDevice = @ptrCast(@alignCast(userdata1)); ud_device.* = device; }, else => { std.log.err("device request failed", .{}); - } + }, } const completed: *bool = @ptrCast(@alignCast(userdata2)); completed.* = true; } -fn handleBufferMap(status: wgpu.WGPUMapAsyncStatus, _: wgpu.WGPUStringView, userdata1: ?*anyopaque, _: ?*anyopaque) callconv(.C) void { +fn handleBufferMap(status: wgpu.WGPUMapAsyncStatus, _: wgpu.WGPUStringView, userdata1: ?*anyopaque, _: ?*anyopaque) callconv(.c) void { std.log.info("buffer_map status={x:.8}\n", .{status}); const completed: *bool = @ptrCast(@alignCast(userdata1)); completed.* = true; @@ -39,7 +39,7 @@ fn handleBufferMap(status: wgpu.WGPUMapAsyncStatus, _: wgpu.WGPUStringView, user fn waitForCompletion(instance: wgpu.WGPUInstance, complete: *bool) void { wgpu.wgpuInstanceProcessEvents(instance); - while(!complete.*) { + while (!complete.*) { wgpu.wgpuInstanceProcessEvents(instance); } } @@ -52,11 +52,10 @@ fn compute_collatz() [4]u32 { const instance = wgpu.wgpuCreateInstance(null); defer wgpu.wgpuInstanceRelease(instance); - var adapter: wgpu.WGPUAdapter = null; { var request_complete = false; - _ = wgpu.wgpuInstanceRequestAdapter(instance, null, wgpu.WGPURequestAdapterCallbackInfo { + _ = wgpu.wgpuInstanceRequestAdapter(instance, null, wgpu.WGPURequestAdapterCallbackInfo{ .nextInChain = null, .mode = wgpu.WGPUCallbackMode_AllowProcessEvents, .callback = handleRequestAdapter, @@ -70,7 +69,7 @@ fn compute_collatz() [4]u32 { var device: wgpu.WGPUDevice = null; { var request_complete = false; - _ = wgpu.wgpuAdapterRequestDevice(adapter.?, null, wgpu.WGPURequestDeviceCallbackInfo { + _ = wgpu.wgpuAdapterRequestDevice(adapter.?, null, wgpu.WGPURequestDeviceCallbackInfo{ .nextInChain = null, .mode = wgpu.WGPUCallbackMode_AllowProcessEvents, .callback = handleRequestDevice, @@ -85,16 +84,16 @@ fn compute_collatz() [4]u32 { defer wgpu.wgpuQueueRelease(queue); const compute_shader = @embedFile("./compute.wgsl"); - const shader_module = wgpu.wgpuDeviceCreateShaderModule(device.?, &wgpu.WGPUShaderModuleDescriptor { - .label = wgpu.WGPUStringView { + const shader_module = wgpu.wgpuDeviceCreateShaderModule(device.?, &wgpu.WGPUShaderModuleDescriptor{ + .label = wgpu.WGPUStringView{ .data = "compute.wgsl", .length = wgpu.WGPU_STRLEN, // Treat as null-terminated string }, - .nextInChain = @ptrCast(&wgpu.WGPUShaderSourceWGSL { - .chain = wgpu.WGPUChainedStruct { + .nextInChain = @ptrCast(&wgpu.WGPUShaderSourceWGSL{ + .chain = wgpu.WGPUChainedStruct{ .sType = wgpu.WGPUSType_ShaderSourceWGSL, }, - .code = wgpu.WGPUStringView { + .code = wgpu.WGPUStringView{ .data = compute_shader.ptr, .length = compute_shader.len, }, @@ -102,8 +101,8 @@ fn compute_collatz() [4]u32 { }); defer wgpu.wgpuShaderModuleRelease(shader_module); - const staging_buffer = wgpu.wgpuDeviceCreateBuffer(device.?, &wgpu.WGPUBufferDescriptor { - .label = wgpu.WGPUStringView { + const staging_buffer = wgpu.wgpuDeviceCreateBuffer(device.?, &wgpu.WGPUBufferDescriptor{ + .label = wgpu.WGPUStringView{ .data = "staging_buffer", .length = wgpu.WGPU_STRLEN, }, @@ -113,8 +112,8 @@ fn compute_collatz() [4]u32 { }); defer wgpu.wgpuBufferRelease(staging_buffer); - const storage_buffer = wgpu.wgpuDeviceCreateBuffer(device.?, &wgpu.WGPUBufferDescriptor { - .label = wgpu.WGPUStringView { + const storage_buffer = wgpu.wgpuDeviceCreateBuffer(device.?, &wgpu.WGPUBufferDescriptor{ + .label = wgpu.WGPUStringView{ .data = "storage_buffer", .length = wgpu.WGPU_STRLEN, }, @@ -124,14 +123,14 @@ fn compute_collatz() [4]u32 { }); defer wgpu.wgpuBufferRelease(storage_buffer); - const compute_pipeline = wgpu.wgpuDeviceCreateComputePipeline(device.?, &wgpu.WGPUComputePipelineDescriptor { - .label = wgpu.WGPUStringView { + const compute_pipeline = wgpu.wgpuDeviceCreateComputePipeline(device.?, &wgpu.WGPUComputePipelineDescriptor{ + .label = wgpu.WGPUStringView{ .data = "compute_pipeline", .length = wgpu.WGPU_STRLEN, }, .compute = wgpu.WGPUProgrammableStageDescriptor{ .module = shader_module, - .entryPoint = wgpu.WGPUStringView { + .entryPoint = wgpu.WGPUStringView{ .data = "main", .length = wgpu.WGPU_STRLEN, }, @@ -142,15 +141,15 @@ fn compute_collatz() [4]u32 { const bind_group_layout = wgpu.wgpuComputePipelineGetBindGroupLayout(compute_pipeline, 0); defer wgpu.wgpuBindGroupLayoutRelease(bind_group_layout); - const bind_group = wgpu.wgpuDeviceCreateBindGroup(device.?, &wgpu.WGPUBindGroupDescriptor { - .label = wgpu.WGPUStringView { + const bind_group = wgpu.wgpuDeviceCreateBindGroup(device.?, &wgpu.WGPUBindGroupDescriptor{ + .label = wgpu.WGPUStringView{ .data = "bind_group", .length = wgpu.WGPU_STRLEN, }, .layout = bind_group_layout, .entryCount = 1, - .entries = &[_]wgpu.WGPUBindGroupEntry { - wgpu.WGPUBindGroupEntry { + .entries = &[_]wgpu.WGPUBindGroupEntry{ + wgpu.WGPUBindGroupEntry{ .binding = 0, .buffer = storage_buffer, .offset = 0, @@ -160,16 +159,16 @@ fn compute_collatz() [4]u32 { }); defer wgpu.wgpuBindGroupRelease(bind_group); - const command_encoder = wgpu.wgpuDeviceCreateCommandEncoder(device.?, &wgpu.WGPUCommandEncoderDescriptor { - .label = wgpu.WGPUStringView { + const command_encoder = wgpu.wgpuDeviceCreateCommandEncoder(device.?, &wgpu.WGPUCommandEncoderDescriptor{ + .label = wgpu.WGPUStringView{ .data = "command_encoder", .length = wgpu.WGPU_STRLEN, }, }); defer wgpu.wgpuCommandEncoderRelease(command_encoder); - const compute_pass_encoder = wgpu.wgpuCommandEncoderBeginComputePass(command_encoder, &wgpu.WGPUComputePassDescriptor { - .label = wgpu.WGPUStringView { + const compute_pass_encoder = wgpu.wgpuCommandEncoderBeginComputePass(command_encoder, &wgpu.WGPUComputePassDescriptor{ + .label = wgpu.WGPUStringView{ .data = "compute_pass", .length = wgpu.WGPU_STRLEN, }, @@ -185,8 +184,8 @@ fn compute_collatz() [4]u32 { wgpu.wgpuCommandEncoderCopyBufferToBuffer(command_encoder, storage_buffer, 0, staging_buffer, 0, numbers_size); - const command_buffer = wgpu.wgpuCommandEncoderFinish(command_encoder, &wgpu.WGPUCommandBufferDescriptor { - .label = wgpu.WGPUStringView { + const command_buffer = wgpu.wgpuCommandEncoderFinish(command_encoder, &wgpu.WGPUCommandBufferDescriptor{ + .label = wgpu.WGPUStringView{ .data = "command_buffer", .length = wgpu.WGPU_STRLEN, }, @@ -197,7 +196,7 @@ fn compute_collatz() [4]u32 { wgpu.wgpuQueueSubmit(queue, 1, &command_buffer); var buffer_map_complete = false; - _ = wgpu.wgpuBufferMapAsync(staging_buffer, wgpu.WGPUMapMode_Read, 0, numbers_size, wgpu.WGPUBufferMapCallbackInfo { + _ = wgpu.wgpuBufferMapAsync(staging_buffer, wgpu.WGPUMapMode_Read, 0, numbers_size, wgpu.WGPUBufferMapCallbackInfo{ .nextInChain = null, .mode = wgpu.WGPUCallbackMode_AllowProcessEvents, .callback = handleBufferMap, @@ -209,7 +208,7 @@ fn compute_collatz() [4]u32 { const buf: [*]u32 = @ptrCast(@alignCast(wgpu.wgpuBufferGetMappedRange(staging_buffer, 0, numbers_size))); defer wgpu.wgpuBufferUnmap(staging_buffer); - const ret = [4]u32 {buf[0], buf[1], buf[2], buf[3]}; + const ret = [4]u32{ buf[0], buf[1], buf[2], buf[3] }; return ret; } From c7832a20edcd560c4484a3a339371d5683005837 Mon Sep 17 00:00:00 2001 From: asimos-bot Date: Tue, 14 Oct 2025 00:14:02 -0300 Subject: [PATCH 2/3] minimum zig version bump --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 7238252..649acd0 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -8,7 +8,7 @@ // This field is optional. // This is currently advisory only; Zig does not yet do anything // with this value. - .minimum_zig_version = "0.14.0", + .minimum_zig_version = "0.15.1", // This field is optional. // Each dependency must either provide a `url` and `hash`, or a `path`. From 0ccc6e12611bfba72f2abaffe12bc285ee5a7da2 Mon Sep 17 00:00:00 2001 From: asimos-bot Date: Fri, 2 Jan 2026 13:04:19 -0300 Subject: [PATCH 3/3] fixed dependency links --- build.zig.zon | 128 +++++++++++++++++++++++++------------------------- links | 13 +++++ 2 files changed, 77 insertions(+), 64 deletions(-) create mode 100644 links diff --git a/build.zig.zon b/build.zig.zon index 649acd0..ba03a8e 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -45,153 +45,153 @@ // .lazy = false, //}, .wgpu_android_aarch64_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-aarch64-debug.zip", - .hash = "N-V-__8AAPQyVxT6i7mm0AzaidOZmgXO0JlVRTK4cIzdhiIJ", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-android-aarch64-debug.zip", + .hash = "N-V-__8AAODWkhXNqK9bNJttDnJOtuklZSMIVfDBxUrv-xAv", .lazy = true, }, .wgpu_android_aarch64_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-aarch64-release.zip", - .hash = "N-V-__8AAH5jwgMJj3SR-h6LEpl2nU1rEwl4tS6ZGvV4Kr_A", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-android-aarch64-release.zip", + .hash = "N-V-__8AAHLc1wNhiH07l4S8rp4j7wifjvHyDoZAcoeWJMoq", .lazy = true, }, .wgpu_android_armv7_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-armv7-debug.zip", - .hash = "N-V-__8AAPrsHxCJ4mgD4JYP4LlWrV8cgHLPzAdz5HePfW-0", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-android-armv7-debug.zip", + .hash = "N-V-__8AAJzNFRGJiH4NduSd92sNXebTKXAtuXOooIxRSiW7", .lazy = true, }, .wgpu_android_armv7_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-armv7-release.zip", - .hash = "N-V-__8AAHKm5wI40Gj43wFTj6iZnGz9id_y087a-jnfQBRi", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-android-armv7-release.zip", + .hash = "N-V-__8AAJjM9ALkIDACTSluw02ifbCuE1KKxFTSK9kLPRGj", .lazy = true, }, - .wgpu_android_x86_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-i686-debug.zip", - .hash = "N-V-__8AAMD9TBCN2rrJG9dqTyQh0Wv9MWisv3bSIdoMH_VG", + .wgpu_android_i686_debug = .{ + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-android-i686-debug.zip", + .hash = "N-V-__8AACxTPxEm1q-805vR2s1KgjHSafP6SSYdOQ4as3OB", .lazy = true, }, - .wgpu_android_x86_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-i686-release.zip", - .hash = "N-V-__8AAFwDIQNZ003uYMHrFbiexqSqI3sVgpXB2W4DLoqq", + .wgpu_android_i686_release = .{ + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-android-i686-release.zip", + .hash = "N-V-__8AACLCKgO4T-h5bpJiKsvEemqLeHpqURJHW9bXEH3q", .lazy = true, }, .wgpu_android_x86_64_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-x86_64-debug.zip", - .hash = "N-V-__8AAAAjNBQaSprsYmeSlIDJWQg-jZHiUxxIMHylLp7E", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-android-x86_64-debug.zip", + .hash = "N-V-__8AAN4BXRX5s7cLo4gEjgrMevSzzz_DnXEkf12NIko1", .lazy = true, }, .wgpu_android_x86_64_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-android-x86_64-release.zip", - .hash = "N-V-__8AALxtxANPhha93qENJNdLw9ZAaHUXp2_X8QBskpOM", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-android-x86_64-release.zip", + .hash = "N-V-__8AAOyW3gPNHsw4UEwI06DxG67A2g25z3D9OEeYQN3n", .lazy = true, }, .wgpu_ios_aarch64_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-ios-aarch64-debug.zip", - .hash = "N-V-__8AAJj1lQlJYBWH3qMo3USVJcGKJ1ithSzQ-u04QUxa", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-ios-aarch64-debug.zip", + .hash = "N-V-__8AANBkMQplyTAMfQ9mcVGEd2wWqaYFkSgh9QrXnIvP", .lazy = true, }, .wgpu_ios_aarch64_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-ios-aarch64-release.zip", - .hash = "N-V-__8AALh8YgKjs1OKvnTlaRqB_euceGNN_TfX1HLMrnNi", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-ios-aarch64-release.zip", + .hash = "N-V-__8AAGC4cgJGe_H08e0EEAH2gFDU5D_FOnwhfBRxKzGF", .lazy = true, }, .wgpu_ios_aarch64_simulator_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-ios-aarch64-simulator-debug.zip", - .hash = "N-V-__8AAABClgk_Seuqe9XuxYUDDZe9T9aOYuhd4JhXTeg9", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-ios-aarch64-simulator-debug.zip", + .hash = "N-V-__8AAGjpMwrPW-vskOePX0XHnASueAqe_684azRDVsWT", .lazy = true, }, .wgpu_ios_aarch64_simulator_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-ios-aarch64-simulator-release.zip", - .hash = "N-V-__8AAAgFYgLavBRZjHgkULhWRweVNw-VeLMxcxRHZYF1", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-ios-aarch64-simulator-release.zip", + .hash = "N-V-__8AAGj6cQKYyPEPcS21NWldmcq-Sc0ea-6GuTUR8yDo", .lazy = true, }, .wgpu_ios_x86_64_simulator_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-ios-x86_64-simulator-debug.zip", - .hash = "N-V-__8AAKCSXgkyBFHn1Uwy1Sop2KeA6XwmrVs2_C8cru8M", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-ios-x86_64-simulator-debug.zip", + .hash = "N-V-__8AAOim8Al2DKP4fI_G1zoyATvSyJKR-kW9Z0twdAhX", .lazy = true, }, .wgpu_ios_x86_64_simulator_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-ios-x86_64-simulator-release.zip", - .hash = "N-V-__8AAPBFWQJxhwRTeBxlztWVNalvobmyX_zEoF24X_S6", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-ios-x86_64-simulator-release.zip", + .hash = "N-V-__8AAHiIbQJSSUyRvGGs9RY_0soQZABi_0oxf0RLDd5w", .lazy = true, }, .wgpu_linux_aarch64_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-linux-aarch64-debug.zip", - .hash = "N-V-__8AALSbGhS93ZKwkkKk-yN3BzFl6iBPh9etfftVkhSk", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-linux-aarch64-debug.zip", + .hash = "N-V-__8AAJzHexVRY6srpy0_WL1xewabnBs2KS-VdBoTqW2r", .lazy = true, }, .wgpu_linux_aarch64_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-linux-aarch64-release.zip", - .hash = "N-V-__8AAC42tgMsCqChk-HZ0n7dyD1HT29f6QM0UTCdj_iF", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-linux-aarch64-release.zip", + .hash = "N-V-__8AAADr0gMElWHqEZGI9rghv_AUtEY68_Vm_8Kfdbud", .lazy = true, }, .wgpu_linux_x86_64_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-linux-x86_64-debug.zip", - .hash = "N-V-__8AAHS_-BNtAmT4hK9geZG361RETmD2lG0fk2gyDYh-", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-linux-x86_64-debug.zip", + .hash = "N-V-__8AACx_YhW8kbx_vuKCJQu1_0cVbbcLZjm-OX-TIm0B", .lazy = true, }, .wgpu_linux_x86_64_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-linux-x86_64-release.zip", - .hash = "N-V-__8AALK1sQPqMGESXUOHBpzwDj1GMf_nYBdfbjewJ9kH", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-linux-x86_64-release.zip", + .hash = "N-V-__8AAPpC1APAPud19Yp8rJyNQuJ0HwIHTSyIceokAG9W", .lazy = true, }, .wgpu_macos_aarch64_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-macos-aarch64-debug.zip", - .hash = "N-V-__8AACj6lQmZEGeyjdn2CCD0as1hGMvrAUBsoTuBu_cR", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-macos-aarch64-debug.zip", + .hash = "N-V-__8AANjnOQoNkft8Nn5WRAL__IxRPP83A0SOpfv-TJkC", .lazy = true, }, .wgpu_macos_aarch64_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-macos-aarch64-release.zip", - .hash = "N-V-__8AAGDGYgIAQ6tOKxxonhabDmuFj9Y35AKvPwynW_UO", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-macos-aarch64-release.zip", + .hash = "N-V-__8AAIjJdgK6krBtoLxbfvHRrQYxVSvlm1l8Glhc78dM", .lazy = true, }, .wgpu_macos_x86_64_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-macos-x86_64-debug.zip", - .hash = "N-V-__8AAOCufAlp1bMuFqQCd152bYQLNu-tjLdu9edJ8b4e", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-macos-x86_64-debug.zip", + .hash = "N-V-__8AAMBJFQon8Hu6WhO-Kp_7GLNV3nypyTsKLYNuBnEb", .lazy = true, }, .wgpu_macos_x86_64_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-macos-x86_64-release.zip", - .hash = "N-V-__8AAFi6YgLHU9dEEx9n190MvnIZaCq5SVMg8BX7zD87", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-macos-x86_64-release.zip", + .hash = "N-V-__8AAFhmewJO7pRDr9GC7fI8vR1aL7DIHb_PRAF8aGTj", .lazy = true, }, .wgpu_windows_aarch64_msvc_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-aarch64-msvc-debug.zip", - .hash = "N-V-__8AACUsDR0QuXpFRCjd-TcdKredsnN5Uiy6thaqghfy", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-aarch64-msvc-debug.zip", + .hash = "N-V-__8AAJwlTB8RCirdeiEG_lnkQvEFxMnjnmtMrNMpnF8K", .lazy = true, }, .wgpu_windows_aarch64_msvc_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-aarch64-msvc-release.zip", - .hash = "N-V-__8AAEmpwwOechqvtlmAlMzCIbnIzIgSYcfEUWhSZ7Cj", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-aarch64-msvc-release.zip", + .hash = "N-V-__8AAOxy4QPPqfIVDF2kvMQyAle9lqdX3RghA9EZcPbb", .lazy = true, }, - .wgpu_windows_x86_msvc_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-i686-msvc-debug.zip", - .hash = "N-V-__8AAP8AIx3OgW8N8DkBj5JMcJUkcy7iHLuOH--fY3IX", + .wgpu_windows_i686_msvc_debug = .{ + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-i686-msvc-debug.zip", + .hash = "N-V-__8AAHwJMx--mBEvHUsHVL7moKl2oyEU_2NGjtCPRLSC", .lazy = true, }, - .wgpu_windows_x86_msvc_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-i686-msvc-release.zip", - .hash = "N-V-__8AAMn2lQPoxD9cdgm97Fvxqes4Jlvwct-GWDgsws5k", + .wgpu_windows_i686_msvc_release = .{ + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-i686-msvc-release.zip", + .hash = "N-V-__8AAFRVnAN3dJfZ8FSu0PncArBKoAJO2S_4NRSDgl5P", .lazy = true, }, .wgpu_windows_x86_64_msvc_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-x86_64-msvc-debug.zip", - .hash = "N-V-__8AADEvMB0uTuAXXabR4Fw-2LjtJfoSP8vux2m_eDok", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-x86_64-msvc-debug.zip", + .hash = "N-V-__8AAGbvVh_MR__tPfivjEheDiC8B5MAMafo6-i3os0h", .lazy = true, }, .wgpu_windows_x86_64_msvc_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-x86_64-msvc-release.zip", - .hash = "N-V-__8AAG8mAQR0Vg9K8e0Ln46g_UJq1HqtXwif_Uvt1_ZE", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-x86_64-msvc-release.zip", + .hash = "N-V-__8AAD5sIQTCi8ZlqVjmmFfBvGcmUB9qY3_ZsL_ctkv1", .lazy = true, }, .wgpu_windows_x86_64_gnu_debug = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-x86_64-gnu-debug.zip", - .hash = "N-V-__8AAFICSxIMF7kdKvI3pTwiLWmIxjSopWIadDt9yUpp", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-x86_64-gnu-debug.zip", + .hash = "N-V-__8AADxhgRMl9YGsWAOdmsKsNXOk7uztVzpr1o_h4OBh", .lazy = true, }, .wgpu_windows_x86_64_gnu_release = .{ - .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2/wgpu-windows-x86_64-gnu-release.zip", - .hash = "N-V-__8AAMZ8DwPtTjIxd_0zIGEoJwriDQY-Ykx8ldVc_7N0", + .url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-x86_64-gnu-release.zip", + .hash = "N-V-__8AACT6EwMFgBCKPqN_K7KvG-gbwuj_pO1uAe6UsUEF", .lazy = true, }, }, diff --git a/links b/links new file mode 100644 index 0000000..e543ed7 --- /dev/null +++ b/links @@ -0,0 +1,13 @@ +https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-linux-x86_64-release.zip +https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-macos-aarch64-debug.zip +https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-macos-aarch64-release.zip +https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-macos-x86_64-debug.zip +https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-macos-x86_64-release.zip +https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-aarch64-msvc-debug.zip +https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-aarch64-msvc-release.zip +https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-i686-msvc-debug.zip +https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-i686-msvc-release.zip +https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-x86_64-msvc-debug.zip +https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-x86_64-msvc-release.zip +https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-x86_64-gnu-debug.zip +https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/wgpu-windows-x86_64-gnu-release.zip