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
92 changes: 46 additions & 46 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.2",

// 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",
.url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/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.0/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.0/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.0/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.0/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.0/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.0/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.0/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.0/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.0/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.0/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.0/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.0/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.0/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",
.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",
.url = "https://github.com/gfx-rs/wgpu-native/releases/download/v27.0.2.0/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",
.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",
.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",
.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
26 changes: 15 additions & 11 deletions examples/bmp.zig
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
const std = @import("std");

pub fn write24BitBMP(file_name: []const u8, comptime width: u32, comptime height: u32, bgra_data: *[width * height * 4]u8) !void {
const file = try std.fs.cwd().createFile(file_name, .{});
defer file.close();

var writer = file.writer();

// ID
_ = 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);

const file = try std.fs.cwd().createFile(file_name, .{});
defer file.close();

var buffer: [256]u8 = undefined;

var writer_backing = file.writer(&buffer);
const writer = &writer_backing.interface;

// ID
try writer.writeAll(&[2]u8{ 'B', 'M' });
try writer.writeInt(u32, file_size, .little);

// reserved
Expand All @@ -33,9 +36,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 = undefined;
const bgra_pixels_per_line = width * 4;
for (0..height) |i_y| {
const y = height - i_y - 1;
Expand All @@ -45,8 +48,9 @@ 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();
}
4 changes: 2 additions & 2 deletions examples/triangle/triangle.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -147,7 +147,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();
Expand Down
20 changes: 10 additions & 10 deletions src/adapter.zig
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub const RequestAdapterCallback = *const fn(
message: StringView,
userdata1: ?*anyopaque,
userdata2: ?*anyopaque,
) callconv(.C) void;
) callconv(.c) void;

pub const RequestAdapterResponse = struct {
status: RequestAdapterStatus,
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -172,7 +172,7 @@ 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 {
.status = status,
Expand Down
Loading