update to Zig 2024.05

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-06-02 16:16:03 -07:00 committed by Stephen Gutekanst
parent c64bc513b9
commit 707e5cc756
16 changed files with 102 additions and 93 deletions

View file

@ -72,7 +72,7 @@ pub fn build(b: *std.Build) !void {
build_options.addOption(CoreApp.Platform, "core_platform", core_platform); build_options.addOption(CoreApp.Platform, "core_platform", core_platform);
const module = b.addModule("mach", .{ const module = b.addModule("mach", .{
.root_source_file = .{ .path = "src/main.zig" }, .root_source_file = b.path("src/main.zig"),
.optimize = optimize, .optimize = optimize,
.target = target, .target = target,
}); });
@ -107,7 +107,7 @@ pub fn build(b: *std.Build) !void {
// TODO: for some reason this is not functional, a Zig bug (only when using this Zig package // TODO: for some reason this is not functional, a Zig bug (only when using this Zig package
// externally): // externally):
// //
// module.addCSourceFile(.{ .file = .{ .path = sdkPath("src/core/platform/wayland/wayland.c" } }); // module.addCSourceFile(.{ .file = b.path("src/core/platform/wayland/wayland.c" });
// //
// error: unable to check cache: stat file '/Volumes/data/hexops/mach-core-starter-project/zig-cache//Volumes/data/hexops/mach-core-starter-project/src/core/platform/wayland/wayland.c' failed: FileNotFound // error: unable to check cache: stat file '/Volumes/data/hexops/mach-core-starter-project/zig-cache//Volumes/data/hexops/mach-core-starter-project/src/core/platform/wayland/wayland.c' failed: FileNotFound
// //
@ -118,7 +118,7 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize, .optimize = optimize,
}); });
lib.addCSourceFile(.{ lib.addCSourceFile(.{
.file = .{ .path = "src/core/platform/wayland/wayland.c" }, .file = b.path("src/core/platform/wayland/wayland.c"),
}); });
lib.linkLibC(); lib.linkLibC();
module.linkLibrary(lib); module.linkLibrary(lib);
@ -154,7 +154,7 @@ pub fn build(b: *std.Build) !void {
}) |example| { }) |example| {
const example_exe = b.addExecutable(.{ const example_exe = b.addExecutable(.{
.name = "sysaudio-" ++ example, .name = "sysaudio-" ++ example,
.root_source_file = .{ .path = "src/sysaudio/examples/" ++ example ++ ".zig" }, .root_source_file = b.path("src/sysaudio/examples/" ++ example ++ ".zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}); });
@ -198,7 +198,7 @@ pub fn build(b: *std.Build) !void {
// externally): // externally):
// //
// module.addCSourceFile(.{ // module.addCSourceFile(.{
// .file = .{ .path = "src/sysaudio/pipewire/sysaudio.c" }, // .file = b.path("src/sysaudio/pipewire/sysaudio.c"),
// .flags = &.{"-std=gnu99"}, // .flags = &.{"-std=gnu99"},
// }); // });
// //
@ -212,7 +212,7 @@ pub fn build(b: *std.Build) !void {
}); });
lib.linkLibC(); lib.linkLibC();
lib.addCSourceFile(.{ lib.addCSourceFile(.{
.file = .{ .path = "src/sysaudio/pipewire/sysaudio.c" }, .file = b.path("src/sysaudio/pipewire/sysaudio.c"),
.flags = &.{"-std=gnu99"}, .flags = &.{"-std=gnu99"},
}); });
module.linkLibrary(lib); module.linkLibrary(lib);
@ -259,13 +259,13 @@ pub fn build(b: *std.Build) !void {
_ = dep; _ = dep;
const gpu_dawn = @import("mach_gpu_dawn"); const gpu_dawn = @import("mach_gpu_dawn");
gpu_dawn.addPathsToModule(b, module, .{}); gpu_dawn.addPathsToModule(b, module, .{});
module.addIncludePath(.{ .path = sdkPath("/src/gpu") }); module.addIncludePath(b.path("src/gpu"));
} }
if (want_examples) { if (want_examples) {
const example_exe = b.addExecutable(.{ const example_exe = b.addExecutable(.{
.name = "dawn-gpu-hello-triangle", .name = "dawn-gpu-hello-triangle",
.root_source_file = .{ .path = "src/gpu/example/main.zig" }, .root_source_file = b.path("src/gpu/example/main.zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}); });
@ -293,7 +293,7 @@ pub fn build(b: *std.Build) !void {
// Creates a step for unit testing. This only builds the test executable // Creates a step for unit testing. This only builds the test executable
// but does not run it. // but does not run it.
const unit_tests = b.addTest(.{ const unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" }, .root_source_file = b.path("src/main.zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}); });
@ -373,7 +373,7 @@ pub const CoreApp = struct {
if (options.deps) |app_deps| try imports.appendSlice(app_deps); if (options.deps) |app_deps| try imports.appendSlice(app_deps);
const app_module = app_builder.createModule(.{ const app_module = app_builder.createModule(.{
.root_source_file = .{ .path = options.src }, .root_source_file = app_builder.path(options.src),
.imports = try imports.toOwnedSlice(), .imports = try imports.toOwnedSlice(),
}); });
@ -389,7 +389,10 @@ pub const CoreApp = struct {
const lib = app_builder.addStaticLibrary(.{ const lib = app_builder.addStaticLibrary(.{
.name = options.name, .name = options.name,
.root_source_file = .{ .path = options.custom_entrypoint orelse sdkPath("/src/core/platform/wasm/entrypoint.zig") }, .root_source_file = if (options.custom_entrypoint) |e|
app_builder.path(e)
else
mach_builder.path("src/core/platform/wasm/entrypoint.zig"),
.target = options.target, .target = options.target,
.optimize = options.optimize, .optimize = options.optimize,
}); });
@ -399,7 +402,10 @@ pub const CoreApp = struct {
} else { } else {
const exe = app_builder.addExecutable(.{ const exe = app_builder.addExecutable(.{
.name = options.name, .name = options.name,
.root_source_file = .{ .path = options.custom_entrypoint orelse sdkPath("/src/core/platform/native_entrypoint.zig") }, .root_source_file = if (options.custom_entrypoint) |e|
app_builder.path(e)
else
mach_builder.path("src/core/platform/native_entrypoint.zig"),
.target = options.target, .target = options.target,
.optimize = options.optimize, .optimize = options.optimize,
}); });
@ -418,7 +424,7 @@ pub const CoreApp = struct {
if (options.res_dirs) |res_dirs| { if (options.res_dirs) |res_dirs| {
for (res_dirs) |res| { for (res_dirs) |res| {
const install_res = app_builder.addInstallDirectory(.{ const install_res = app_builder.addInstallDirectory(.{
.source_dir = .{ .path = res }, .source_dir = app_builder.path(res),
.install_dir = install.dest_dir.?, .install_dir = install.dest_dir.?,
.install_subdir = std.fs.path.basename(res), .install_subdir = std.fs.path.basename(res),
.exclude_extensions = &.{}, .exclude_extensions = &.{},
@ -427,9 +433,9 @@ pub const CoreApp = struct {
} }
} }
if (platform == .web) { if (platform == .web) {
inline for (.{ sdkPath("/src/core/platform/wasm/mach.js"), sdkPath("/src/sysjs/mach-sysjs.js") }) |js| { inline for (.{ "src/core/platform/wasm/mach.js", "src/sysjs/mach-sysjs.js" }) |js| {
const install_js = app_builder.addInstallFileWithDir( const install_js = app_builder.addInstallFileWithDir(
.{ .path = js }, mach_builder.path(js),
std.Build.InstallDir{ .custom = "www" }, std.Build.InstallDir{ .custom = "www" },
std.fs.path.basename(js), std.fs.path.basename(js),
); );
@ -480,8 +486,11 @@ pub fn link(mach_builder: *std.Build, step: *std.Build.Step.Compile) void {
&step.root_module, &step.root_module,
options.gpu_dawn_options, options.gpu_dawn_options,
); );
step.addCSourceFile(.{ .file = .{ .path = sdkPath("/src/gpu/mach_dawn.cpp") }, .flags = &.{"-std=c++17"} }); step.addCSourceFile(.{
step.addIncludePath(.{ .path = sdkPath("/src/gpu") }); .file = mach_builder.path("src/gpu/mach_dawn.cpp"),
.flags = &.{"-std=c++17"},
});
step.addIncludePath(mach_builder.path("src/gpu"));
} }
} }
@ -581,9 +590,9 @@ fn buildExamples(
const exe = b.addExecutable(.{ const exe = b.addExecutable(.{
.name = if (example.core) b.fmt("core-{s}", .{example.name}) else example.name, .name = if (example.core) b.fmt("core-{s}", .{example.name}) else example.name,
.root_source_file = if (example.core) .root_source_file = if (example.core)
.{ .path = b.fmt("examples/core/{s}/main.zig", .{example.name}) } b.path(b.fmt("examples/core/{s}/main.zig", .{example.name}))
else else
.{ .path = b.fmt("examples/{s}/main.zig", .{example.name}) }, b.path(b.fmt("examples/{s}/main.zig", .{example.name})),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}); });
@ -735,7 +744,7 @@ fn buildCoreExamples(
}, },
.zmath => { .zmath => {
const zmath = b.createModule(.{ const zmath = b.createModule(.{
.root_source_file = .{ .path = "src/core/examples/zmath.zig" }, .root_source_file = b.path("src/core/examples/zmath.zig"),
}); });
app.module.addImport("zmath", zmath); app.module.addImport("zmath", zmath);
}, },

View file

@ -12,83 +12,83 @@
}, },
.dependencies = .{ .dependencies = .{
.mach_freetype = .{ .mach_freetype = .{
.url = "https://pkg.machengine.org/mach-freetype/309be0cf11a2f617d06ee5c5bb1a88d5197d8b46.tar.gz", .url = "https://pkg.machengine.org/mach-freetype/86fc8024d4ddd53df75dfa4f3ad4eebe0b1b4284.tar.gz",
.hash = "1220fcebb0b1a4561f9d116182e30d0a91d2a556dad8564c8f425fd729556dedc7cf", .hash = "12206251ed342f400b80abf3c338521f5d8c83eb596899abf77a2afe0cfd46e61ff0",
.lazy = true, .lazy = true,
}, },
.font_assets = .{ .font_assets = .{
.url = "https://github.com/hexops/font-assets/archive/7977df057e855140a207de49039114f1ab8e6c2d.tar.gz", .url = "https://github.com/hexops/font-assets/archive/899f16b815fde126ba8f6fb781e65253f461b7bf.tar.gz",
.hash = "12208106eef051bc730bac17c2d10f7e42ea63b579b919480fec86b7c75a620c75d4", .hash = "12202b816e7c31c516bd87218fd56f9b1f93671e4ab42a2a98110d586c4b3bdd2730",
.lazy = true, .lazy = true,
}, },
.mach_gpu_dawn = .{ .mach_gpu_dawn = .{
.url = "https://pkg.machengine.org/mach-gpu-dawn/cce4d19945ca6102162b0cbbc546648edb38dc41.tar.gz", .url = "https://pkg.machengine.org/mach-gpu-dawn/d0a1e11ac96401108ba7c35bf99101c0756ded2d.tar.gz",
.hash = "1220a6e3f4772fed665bb5b1792cf5cff8ac51af42a57ad8d276e394ae19f310a92e", .hash = "122060fbe61aa4a828002ca8949d9c3ef1b6b7ae3fa92558af7ccea7182e8d9d516c",
// TODO(build): be able to mark this dependency as lazy // TODO(build): be able to mark this dependency as lazy
// .lazy = true, // .lazy = true,
}, },
.mach_glfw = .{ .mach_glfw = .{
.url = "https://pkg.machengine.org/mach-glfw/e57190c095097810980703aa26d4f0669a21dbab.tar.gz", .url = "https://pkg.machengine.org/mach-glfw/8da44b719e345097664ff2e0a7620474eb11db5f.tar.gz",
.hash = "12205a32c8e6ca23c68191b1e95405d2bd5f8e3055cba1c8ce0738d673ef49aef913", .hash = "1220e5343c2fe2a490aa90dc52d92fd34ebfd7d0ffc7d246dd4720bb5c339ead4d7b",
.lazy = true, .lazy = true,
}, },
.mach_objc = .{ .mach_objc = .{
.url = "https://pkg.machengine.org/mach-objc/a7c3483702998aa0e960a788b9f611389f17d402.tar.gz", .url = "https://pkg.machengine.org/mach-objc/055619a732ae50ba24eb04399613be87f8432f0f.tar.gz",
.hash = "1220049052fca861248fa6fb8bc24ecdb038049be0a3b22352bebc40e4dc2d2c981b", .hash = "1220211475420584a552b461dd569f891d29cb8e9e485b97053be604680c8d6e2a3e",
.lazy = true, .lazy = true,
}, },
.xcode_frameworks = .{ .xcode_frameworks = .{
.url = "https://pkg.machengine.org/xcode-frameworks/2fca968efa90a4060803c56dd0f027890353f0a9.tar.gz", .url = "https://pkg.machengine.org/xcode-frameworks/122b43323db27b2082a2d44ed2121de21c9ccf75.tar.gz",
.hash = "122010c1a745ea06dee3012fbd3b311bd3d75ec39ded6bf566b36ebe3cd8da482347", .hash = "12205d131983601cdb3500f38e9d8adaed5574fb0211b8b39291d2e9b90c6555ce59",
// TODO(build): be able to mark this dependency as lazy // TODO(build): be able to mark this dependency as lazy
// .lazy = true, // .lazy = true,
}, },
.direct3d_headers = .{ .direct3d_headers = .{
.url = "https://pkg.machengine.org/direct3d-headers/bc2fafe176dbd36bff6d1c036488c015bd4c0f7b.tar.gz", .url = "https://pkg.machengine.org/direct3d-headers/9417c58f11628b7072f0c63b687282de83592891.tar.gz",
.hash = "12201f3096410a22af7978c7c57636f251669c335919740e42fc1785180435f63f1c", .hash = "12203594c3c97220742be1cc5343547bb25d8947e77bd52c50ef713da676d6f6d31f",
// TODO(build): be able to mark this dependency as lazy // TODO(build): be able to mark this dependency as lazy
// .lazy = true, // .lazy = true,
}, },
.opengl_headers = .{ .opengl_headers = .{
.url = "https://pkg.machengine.org/opengl-headers/6d2f01d92576d23d1ff5fe6dfe1e448190c09bb7.tar.gz", .url = "https://pkg.machengine.org/opengl-headers/96c7c6eca973240a503016ca9d270d76e75dc590.tar.gz",
.hash = "122007972c24513e1478bba5b628f294c43a710437356f1a3194fe42e17a36e42a3a", .hash = "12209f5ec4fa073c3b5b5129a72b7b230596af48a732bed539e35161395ed590095d",
.lazy = true, .lazy = true,
}, },
.vulkan_zig_generated = .{ .vulkan_zig_generated = .{
.url = "https://pkg.machengine.org/vulkan-zig-generated/78b3c3838ffcb64d537b4af340c9d3fcc41944ce.tar.gz", .url = "https://pkg.machengine.org/vulkan-zig-generated/b97664ad438782f723020efb07c3e59e0b3c90c0.tar.gz",
.hash = "1220c4a2a02e0bd81827225deea58b18f5ea9373cf932c073b977469e298eef1f54f", .hash = "1220d2b6789b71a94e692cb2f060bff4ffa4edfe196216cd573da68e74ab884eb34e",
.lazy = true, .lazy = true,
}, },
.linux_audio_headers = .{ .linux_audio_headers = .{
.url = "https://pkg.machengine.org/linux-audio-headers/c22324c2be215b49078d369cff9b0c49b0282e40.tar.gz", .url = "https://pkg.machengine.org/linux-audio-headers/55524472876fe73bac0dcaa11b38f92958751ad4.tar.gz",
.hash = "12207c50df3073e15cd0e8a1530937e0f8e224e02eda05953c703a6c69076576494a", .hash = "122042c20087cc1e40d24a61c9d725be36ac5914d6e87e1776cc3cfaecedbcc0be16",
.lazy = true, .lazy = true,
}, },
.wayland_headers = .{ .wayland_headers = .{
.url = "https://pkg.machengine.org/wayland-headers/4926b8c635aa2f215b0d5382060fc4091aa7b705.tar.gz", .url = "https://pkg.machengine.org/wayland-headers/ed5542501a548ac23841c8f22cec0af89f46325a.tar.gz",
.hash = "12207decf58bee217ae9c5340a6852a62e7f5af9901bef9b1468d93e480798898285", .hash = "1220f350a0782d20a6618ea4e2884f7d0205a4e9b02c2d65fe3bf7b8113e7860fadf",
.lazy = true, .lazy = true,
}, },
.x11_headers = .{ .x11_headers = .{
.url = "https://pkg.machengine.org/x11-headers/ad1c4891f70302c61ba956cfd565758dc1ca9d28.tar.gz", .url = "https://pkg.machengine.org/x11-headers/22bb51a939722a819bf52aba100ac6c25acfbaff.tar.gz",
.hash = "1220ce35d8f1556afd5bf4796a7899d459f9c628b989f247eaf6aa00fbad10a88c9f", .hash = "1220ddf168c855cf69b4f8c5284403106a3c681913e34453df10cc5a588d9bd1d005",
.lazy = true, .lazy = true,
}, },
// Dependencies used by examples only // Dependencies used by examples only
.zigimg = .{ .zigimg = .{
.url = "https://github.com/slimsag/zigimg/archive/19a49a7e44fb4b1c22341dfbd6566019de742055.tar.gz", .url = "https://github.com/zigimg/zigimg/archive/588f11f24cdc3b12f46082217dc830436b7f325e.tar.gz",
.hash = "1220ebfa8587cfd644995fc08e218dbb3ebd7344fb8e129ff02bc5a6d52a2325370d", .hash = "1220dc313944ea71a87b4f54f26b1427ad2992a721a221cb42f7f80b8eee4e4944b7",
.lazy = true, .lazy = true,
}, },
.mach_opus = .{ .mach_opus = .{
.url = "https://pkg.machengine.org/mach-opus/58a22201881d7639339f3c029d13a00bbfe005e2.tar.gz", .url = "https://pkg.machengine.org/mach-opus/9dafde653d4c5f1610f84f8f40df370bce9c6439.tar.gz",
.hash = "1220821426e087874779f8d76a6bb74844aa3934648aad5b7331701e5f386791c51e", .hash = "12203e942ae6563c5fb05dff8e8a406b71fe6682342ae5d8d26093e6f9e3d2e02777",
.lazy = true, .lazy = true,
}, },
.mach_example_assets = .{ .mach_example_assets = .{
.url = "https://pkg.machengine.org/mach-example-assets/9fef2d88fa31cda58a829fa620593bb8d6d84e7f.tar.gz", .url = "https://pkg.machengine.org/mach-example-assets/c2b0aae2b0f359d3d9bd6eea4560ef294126d1e5.tar.gz",
.hash = "122068f781d131e31726bae92057130492953b3276c272388a4e078f94d16b197b6b", .hash = "12204101e99906bee0fde5f82682bc822744a6f879dbf45374bebd92458492313df9",
.lazy = true, .lazy = true,
}, },
}, },

View file

@ -13,7 +13,7 @@ pub inline fn printUnhandledErrorCallback(_: void, ty: gpu.ErrorType, message: [
.unknown => std.log.err("gpu: unknown error: {s}\n", .{message}), .unknown => std.log.err("gpu: unknown error: {s}\n", .{message}),
else => unreachable, else => unreachable,
} }
std.os.exit(1); std.process.exit(1);
} }
pub fn detectBackendType(allocator: std.mem.Allocator) !gpu.BackendType { pub fn detectBackendType(allocator: std.mem.Allocator) !gpu.BackendType {

View file

@ -1308,7 +1308,7 @@ inline fn printUnhandledErrorCallback(_: void, ty: gpu.ErrorType, message: [*:0]
.unknown => std.log.err("gpu: unknown error: {s}\n", .{message}), .unknown => std.log.err("gpu: unknown error: {s}\n", .{message}),
else => unreachable, else => unreachable,
} }
std.os.exit(1); std.process.exit(1);
} }
fn detectBackendType(allocator: std.mem.Allocator) !gpu.BackendType { fn detectBackendType(allocator: std.mem.Allocator) !gpu.BackendType {

View file

@ -24,7 +24,7 @@ pub fn main() !void {
// Run from the directory where the executable is located so relative assets can be found. // Run from the directory where the executable is located so relative assets can be found.
var buffer: [1024]u8 = undefined; var buffer: [1024]u8 = undefined;
const path = std.fs.selfExeDirPath(buffer[0..]) catch "."; const path = std.fs.selfExeDirPath(buffer[0..]) catch ".";
std.os.chdir(path) catch {}; std.posix.chdir(path) catch {};
var gpa = std.heap.GeneralPurposeAllocator(.{}){}; var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit(); defer _ = gpa.deinit();

View file

@ -87,9 +87,9 @@ const linux_impl = struct {
real_gamemode_request_end: *const fn () callconv(.C) c_int, real_gamemode_request_end: *const fn () callconv(.C) c_int,
real_gamemode_query_status: *const fn () callconv(.C) c_int, real_gamemode_query_status: *const fn () callconv(.C) c_int,
real_gamemode_request_start_for: *const fn (std.os.pid_t) callconv(.C) c_int, real_gamemode_request_start_for: *const fn (std.c.pid_t) callconv(.C) c_int,
real_gamemode_request_end_for: *const fn (std.os.pid_t) callconv(.C) c_int, real_gamemode_request_end_for: *const fn (std.c.pid_t) callconv(.C) c_int,
real_gamemode_query_status_for: *const fn (std.os.pid_t) callconv(.C) c_int, real_gamemode_query_status_for: *const fn (std.c.pid_t) callconv(.C) c_int,
}; };
/// Try to load libgamemode, returning an error when loading fails. /// Try to load libgamemode, returning an error when loading fails.
@ -169,7 +169,7 @@ const linux_impl = struct {
/// Query the status of gamemode for a given PID. /// Query the status of gamemode for a given PID.
/// This does blocking IO! /// This does blocking IO!
pub fn queryStatusFor(pid: std.os.pid_t) Error!Status { pub fn queryStatusFor(pid: std.c.pid_t) Error!Status {
if (!init()) return .inactive; if (!init()) return .inactive;
const ret = state.init.syms.real_gamemode_query_status_for(pid); const ret = state.init.syms.real_gamemode_query_status_for(pid);
@ -192,7 +192,7 @@ const linux_impl = struct {
/// Request starting gamemode for a given PID. /// Request starting gamemode for a given PID.
/// This does blocking IO! /// This does blocking IO!
pub fn requestStartFor(pid: std.os.pid_t) Error!void { pub fn requestStartFor(pid: std.c.pid_t) Error!void {
if (!init()) return; if (!init()) return;
const ret = state.init.syms.real_gamemode_request_start_for(pid); const ret = state.init.syms.real_gamemode_request_start_for(pid);
@ -215,7 +215,7 @@ const linux_impl = struct {
/// Request stopping gamemode for a given PID. /// Request stopping gamemode for a given PID.
/// This does blocking IO! /// This does blocking IO!
pub fn requestEndFor(pid: std.os.pid_t) Error!void { pub fn requestEndFor(pid: std.c.pid_t) Error!void {
if (!init()) return; if (!init()) return;
const ret = state.init.syms.real_gamemode_request_end_for(pid); const ret = state.init.syms.real_gamemode_request_end_for(pid);
@ -244,20 +244,20 @@ const noop_impl = struct {
return .inactive; return .inactive;
} }
pub fn queryStatusFor(pid: std.os.pid_t) Error!Status { pub fn queryStatusFor(pid: std.c.pid_t) Error!Status {
_ = pid; _ = pid;
return .inactive; return .inactive;
} }
pub fn requestStart() Error!void {} pub fn requestStart() Error!void {}
pub fn requestStartFor(pid: std.os.pid_t) Error!void { pub fn requestStartFor(pid: std.c.pid_t) Error!void {
_ = pid; _ = pid;
} }
pub fn requestEnd() Error!void {} pub fn requestEnd() Error!void {}
pub fn requestEndFor(pid: std.os.pid_t) Error!void { pub fn requestEndFor(pid: std.c.pid_t) Error!void {
_ = pid; _ = pid;
} }
}; };

View file

@ -12,7 +12,7 @@ pub inline fn printUnhandledErrorCallback(_: void, typ: gpu.ErrorType, message:
.unknown => std.log.err("gpu: unknown error: {s}\n", .{message}), .unknown => std.log.err("gpu: unknown error: {s}\n", .{message}),
else => unreachable, else => unreachable,
} }
std.os.exit(1); std.process.exit(1);
} }
fn getEnvVarOwned(allocator: std.mem.Allocator, key: []const u8) error{ OutOfMemory, InvalidUtf8, InvalidWtf8 }!?[]u8 { fn getEnvVarOwned(allocator: std.mem.Allocator, key: []const u8) error{ OutOfMemory, InvalidUtf8, InvalidWtf8 }!?[]u8 {

View file

@ -1013,7 +1013,7 @@ test "projection2D_model_to_clip_space" {
try testing.expect(math.Vec4, math.vec4(0, 0, 1.0, 1)).eql(mvp.mulVec(&math.vec4(0, 0, 0, 1))); try testing.expect(math.Vec4, math.vec4(0, 0, 1.0, 1)).eql(mvp.mulVec(&math.vec4(0, 0, 0, 1)));
try testing.expect(math.Vec4, math.vec4(0, 0, 0.5, 1)).eql(mvp.mulVec(&math.vec4(0, 0, 50, 1))); try testing.expect(math.Vec4, math.vec4(0, 0, 0.5, 1)).eql(mvp.mulVec(&math.vec4(0, 0, 50, 1)));
try testing.expect(math.Vec4, math.vec4(0, -1, 1, 1)).eql(mvp.mul(&math.Mat4x4.rotateX(math.degreesToRadians(f32, 90))).mulVec(&math.vec4(0, 0, 50, 1))); try testing.expect(math.Vec4, math.vec4(0, -1, 1, 1)).eql(mvp.mul(&math.Mat4x4.rotateX(math.degreesToRadians(90))).mulVec(&math.vec4(0, 0, 50, 1)));
try testing.expect(math.Vec4, math.vec4(1, 0, 1, 1)).eql(mvp.mul(&math.Mat4x4.rotateY(math.degreesToRadians(f32, 90))).mulVec(&math.vec4(0, 0, 50, 1))); try testing.expect(math.Vec4, math.vec4(1, 0, 1, 1)).eql(mvp.mul(&math.Mat4x4.rotateY(math.degreesToRadians(90))).mulVec(&math.vec4(0, 0, 50, 1)));
try testing.expect(math.Vec4, math.vec4(0, 0, 0.5, 1)).eql(mvp.mul(&math.Mat4x4.rotateZ(math.degreesToRadians(f32, 90))).mulVec(&math.vec4(0, 0, 50, 1))); try testing.expect(math.Vec4, math.vec4(0, 0, 0.5, 1)).eql(mvp.mul(&math.Mat4x4.rotateZ(math.degreesToRadians(90))).mulVec(&math.vec4(0, 0, 50, 1)));
} }

View file

@ -785,7 +785,7 @@ pub fn Database(comptime modules: anytype) type {
} }
break :blk @Type(.{ break :blk @Type(.{
.Struct = .{ .Struct = .{
.layout = .Auto, .layout = .auto,
.is_tuple = false, .is_tuple = false,
.fields = fields, .fields = fields,
.decls = &[_]std.builtin.Type.Declaration{}, .decls = &[_]std.builtin.Type.Declaration{},

View file

@ -87,7 +87,7 @@ pub fn Merge(comptime tuple: anytype) type {
return @Type(.{ return @Type(.{
.Struct = .{ .Struct = .{
.is_tuple = true, .is_tuple = true,
.layout = .Auto, .layout = .auto,
.decls = &.{}, .decls = &.{},
.fields = tuple_fields, .fields = tuple_fields,
}, },
@ -439,7 +439,7 @@ pub fn ModsByName(comptime modules: anytype) type {
} }
return @Type(.{ return @Type(.{
.Struct = .{ .Struct = .{
.layout = .Auto, .layout = .auto,
.is_tuple = false, .is_tuple = false,
.fields = fields, .fields = fields,
.decls = &[_]std.builtin.Type.Declaration{}, .decls = &[_]std.builtin.Type.Declaration{},
@ -619,8 +619,8 @@ pub fn ModSet(comptime modules: anytype) type {
pub inline fn scheduleWithArgs(m: *@This(), comptime system_name: SystemEnumM(M), args: SystemArgsM(M, system_name)) void { pub inline fn scheduleWithArgs(m: *@This(), comptime system_name: SystemEnumM(M), args: SystemArgsM(M, system_name)) void {
const ModulesT = Modules(modules); const ModulesT = Modules(modules);
const MByName = ModsByName(modules); const MByName = ModsByName(modules);
const mod_ptr: *MByName = @alignCast(@fieldParentPtr(MByName, @tagName(module_tag), m)); const mod_ptr: *MByName = @alignCast(@fieldParentPtr(@tagName(module_tag), m));
const mods = @fieldParentPtr(ModulesT, "mod", mod_ptr); const mods: *ModulesT = @fieldParentPtr("mod", mod_ptr);
mods.scheduleWithArgs(module_tag, system_name, args); mods.scheduleWithArgs(module_tag, system_name, args);
} }
@ -641,8 +641,8 @@ pub fn ModSet(comptime modules: anytype) type {
pub inline fn scheduleAny(m: *@This(), sys: AnySystem) void { pub inline fn scheduleAny(m: *@This(), sys: AnySystem) void {
const ModulesT = Modules(modules); const ModulesT = Modules(modules);
const MByName = ModsByName(modules); const MByName = ModsByName(modules);
const mod_ptr: *MByName = @alignCast(@fieldParentPtr(MByName, @tagName(module_tag), m)); const mod_ptr: *MByName = @alignCast(@fieldParentPtr(@tagName(module_tag), m));
const mods = @fieldParentPtr(ModulesT, "mod", mod_ptr); const mods: *ModulesT = @fieldParentPtr("mod", mod_ptr);
mods.scheduleDynamic(sys.module_id, sys.system_id); mods.scheduleDynamic(sys.module_id, sys.system_id);
} }
}; };
@ -867,7 +867,7 @@ fn NamespacedModules(comptime modules: anytype) type {
} }
return @Type(.{ return @Type(.{
.Struct = .{ .Struct = .{
.layout = .Auto, .layout = .auto,
.is_tuple = false, .is_tuple = false,
.fields = fields, .fields = fields,
.decls = &[_]std.builtin.Type.Declaration{}, .decls = &[_]std.builtin.Type.Declaration{},
@ -942,7 +942,7 @@ pub fn ComponentTypesByName(comptime modules: anytype) type {
} }
return @Type(.{ return @Type(.{
.Struct = .{ .Struct = .{
.layout = .Auto, .layout = .auto,
.is_tuple = false, .is_tuple = false,
.fields = fields, .fields = fields,
.decls = &[_]std.builtin.Type.Declaration{}, .decls = &[_]std.builtin.Type.Declaration{},
@ -1012,7 +1012,7 @@ fn ComponentTypesM(comptime M: anytype) type {
} }
return @Type(.{ return @Type(.{
.Struct = .{ .Struct = .{
.layout = .Auto, .layout = .auto,
.is_tuple = false, .is_tuple = false,
.fields = fields, .fields = fields,
.decls = &[_]std.builtin.Type.Declaration{}, .decls = &[_]std.builtin.Type.Declaration{},

View file

@ -117,31 +117,31 @@ pub const Context = struct {
} }
fn onDeviceStateChangedCB(ctx: *const win32.IMMNotificationClient, _: ?[*:0]const u16, _: u32) callconv(std.os.windows.WINAPI) win32.HRESULT { fn onDeviceStateChangedCB(ctx: *const win32.IMMNotificationClient, _: ?[*:0]const u16, _: u32) callconv(std.os.windows.WINAPI) win32.HRESULT {
var watcher = @fieldParentPtr(Watcher, "notif_client", ctx); var watcher: *Watcher = @fieldParentPtr("notif_client", ctx);
watcher.deviceChangeFn(watcher.user_data); watcher.deviceChangeFn(watcher.user_data);
return win32.S_OK; return win32.S_OK;
} }
fn onDeviceAddedCB(ctx: *const win32.IMMNotificationClient, _: ?[*:0]const u16) callconv(std.os.windows.WINAPI) win32.HRESULT { fn onDeviceAddedCB(ctx: *const win32.IMMNotificationClient, _: ?[*:0]const u16) callconv(std.os.windows.WINAPI) win32.HRESULT {
var watcher = @fieldParentPtr(Watcher, "notif_client", ctx); var watcher: *Watcher = @fieldParentPtr("notif_client", ctx);
watcher.deviceChangeFn(watcher.user_data); watcher.deviceChangeFn(watcher.user_data);
return win32.S_OK; return win32.S_OK;
} }
fn onDeviceRemovedCB(ctx: *const win32.IMMNotificationClient, _: ?[*:0]const u16) callconv(std.os.windows.WINAPI) win32.HRESULT { fn onDeviceRemovedCB(ctx: *const win32.IMMNotificationClient, _: ?[*:0]const u16) callconv(std.os.windows.WINAPI) win32.HRESULT {
var watcher = @fieldParentPtr(Watcher, "notif_client", ctx); var watcher: *Watcher = @fieldParentPtr("notif_client", ctx);
watcher.deviceChangeFn(watcher.user_data); watcher.deviceChangeFn(watcher.user_data);
return win32.S_OK; return win32.S_OK;
} }
fn onDefaultDeviceChangedCB(ctx: *const win32.IMMNotificationClient, _: win32.DataFlow, _: win32.Role, _: ?[*:0]const u16) callconv(std.os.windows.WINAPI) win32.HRESULT { fn onDefaultDeviceChangedCB(ctx: *const win32.IMMNotificationClient, _: win32.DataFlow, _: win32.Role, _: ?[*:0]const u16) callconv(std.os.windows.WINAPI) win32.HRESULT {
var watcher = @fieldParentPtr(Watcher, "notif_client", ctx); var watcher: *Watcher = @fieldParentPtr("notif_client", ctx);
watcher.deviceChangeFn(watcher.user_data); watcher.deviceChangeFn(watcher.user_data);
return win32.S_OK; return win32.S_OK;
} }
fn onPropertyValueChangedCB(ctx: *const win32.IMMNotificationClient, _: ?[*:0]const u16, _: win32.PROPERTYKEY) callconv(std.os.windows.WINAPI) win32.HRESULT { fn onPropertyValueChangedCB(ctx: *const win32.IMMNotificationClient, _: ?[*:0]const u16, _: win32.PROPERTYKEY) callconv(std.os.windows.WINAPI) win32.HRESULT {
var watcher = @fieldParentPtr(Watcher, "notif_client", ctx); var watcher: *Watcher = @fieldParentPtr("notif_client", ctx);
watcher.deviceChangeFn(watcher.user_data); watcher.deviceChangeFn(watcher.user_data);
return win32.S_OK; return win32.S_OK;
} }

View file

@ -288,7 +288,7 @@ pub const Device = struct {
pub fn processQueuedOperations(device: *Device) void { pub fn processQueuedOperations(device: *Device) void {
// Reference trackers // Reference trackers
if (device.queue) |queue| { if (device.queue) |queue| {
const completed_value = queue.completed_value.load(.Acquire); const completed_value = queue.completed_value.load(.acquire);
var i: usize = 0; var i: usize = 0;
while (i < device.reference_trackers.items.len) { while (i < device.reference_trackers.items.len) {
@ -2191,7 +2191,7 @@ pub const Queue = struct {
// Internal // Internal
pub fn waitUntil(queue: *Queue, fence_value: u64) void { pub fn waitUntil(queue: *Queue, fence_value: u64) void {
// TODO - avoid spin loop // TODO - avoid spin loop
while (queue.completed_value.load(.Acquire) < fence_value) {} while (queue.completed_value.load(.acquire) < fence_value) {}
} }
// Private // Private
@ -2220,7 +2220,7 @@ pub const Queue = struct {
fn completedHandler(ctx: CompletedContext, mtl_command_buffer: *mtl.CommandBuffer) void { fn completedHandler(ctx: CompletedContext, mtl_command_buffer: *mtl.CommandBuffer) void {
_ = mtl_command_buffer; _ = mtl_command_buffer;
ctx.queue.completed_value.store(ctx.fence_value, .Release); ctx.queue.completed_value.store(ctx.fence_value, .release);
} }
}; };

View file

@ -298,7 +298,7 @@ pub const Tag = enum {
} }
}; };
pub const keywords = std.ComptimeStringMap(Tag, .{ pub const keywords = std.StaticStringMap(Tag).initComptime(.{
.{ "enable", .k_enable }, .{ "enable", .k_enable },
.{ "requires", .k_requires }, .{ "requires", .k_requires },
.{ "fn", .k_fn }, .{ "fn", .k_fn },
@ -368,7 +368,7 @@ pub const keywords = std.ComptimeStringMap(Tag, .{
pub const reserved = blk: { pub const reserved = blk: {
@setEvalBranchQuota(3000); @setEvalBranchQuota(3000);
break :blk std.ComptimeStringMap(void, .{ break :blk std.StaticStringMap(void).initComptime(.{
.{ "NULL", {} }, .{ "NULL", {} },
.{ "Self", {} }, .{ "Self", {} },
.{ "abstract", {} }, .{ "abstract", {} },

View file

@ -130,7 +130,7 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand)
} }
}, },
.Struct => |info| { .Struct => |info| {
if (info.layout == .Packed) { if (info.layout == .@"packed") {
section.writeWord(@bitCast(operand)); section.writeWord(@bitCast(operand));
} else { } else {
section.writeExtendedMask(Operand, operand); section.writeExtendedMask(Operand, operand);
@ -262,7 +262,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {
} }
break :blk total; break :blk total;
}, },
.Struct => |info| if (info.layout == .Packed) 1 else extendedMaskSize(Operand, operand), .Struct => |info| if (info.layout == .@"packed") 1 else extendedMaskSize(Operand, operand),
.Union => extendedUnionSize(Operand, operand), .Union => extendedUnionSize(Operand, operand),
else => unreachable, else => unreachable,
}, },

View file

@ -290,5 +290,5 @@ fn expectCodegen(
defer allocator.free(out); defer allocator.free(out);
try std.fs.cwd().makePath("zig-out/shader/"); try std.fs.cwd().makePath("zig-out/shader/");
try std.fs.cwd().writeFile("zig-out/shader/" ++ file_name, out); try std.fs.cwd().writeFile(.{ .sub_path = "zig-out/shader/" ++ file_name, .data = out });
} }

View file

@ -8,13 +8,13 @@ pub fn Manager(comptime T: type) type {
count: u32 = 1, count: u32 = 1,
pub fn reference(manager: *@This()) void { pub fn reference(manager: *@This()) void {
_ = @atomicRmw(u32, &manager.count, .Add, 1, .Monotonic); _ = @atomicRmw(u32, &manager.count, .Add, 1, .monotonic);
} }
pub fn release(manager: *@This()) void { pub fn release(manager: *@This()) void {
if (@atomicRmw(u32, &manager.count, .Sub, 1, .Release) == 1) { if (@atomicRmw(u32, &manager.count, .Sub, 1, .release) == 1) {
@fence(.Acquire); @fence(.acquire);
const parent = @fieldParentPtr(T, "manager", manager); const parent: *T = @alignCast(@fieldParentPtr("manager", manager));
parent.deinit(); parent.deinit();
} }
} }