Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 6 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};
}
};
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand Down
130 changes: 65 additions & 65 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -45,153 +45,153 @@
// .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",
.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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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/v25.0.2.1/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,
},
},
Expand Down
25 changes: 13 additions & 12 deletions examples/bmp.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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);
}
}
try writer.flush();
}

Loading