linux: update to latest vulkan-zig API; fix build

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-06-02 17:21:15 -07:00 committed by Stephen Gutekanst
parent 130c474874
commit 2a7e6049fd
10 changed files with 188 additions and 175 deletions

View file

@ -84,7 +84,7 @@ const LibXkbCommon = struct {
pub fn load() !LibXkbCommon { pub fn load() !LibXkbCommon {
var lib: LibXkbCommon = undefined; var lib: LibXkbCommon = undefined;
lib.handle = std.DynLib.openZ("libxkbcommon.so.0") catch return error.LibraryNotFound; lib.handle = std.DynLib.open("libxkbcommon.so.0") catch return error.LibraryNotFound;
inline for (@typeInfo(LibXkbCommon).Struct.fields[1..]) |field| { inline for (@typeInfo(LibXkbCommon).Struct.fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name}); const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]); const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);
@ -139,7 +139,7 @@ const LibWaylandClient = struct {
pub fn load() !LibWaylandClient { pub fn load() !LibWaylandClient {
var lib: LibWaylandClient = undefined; var lib: LibWaylandClient = undefined;
lib.handle = std.DynLib.openZ("libwayland-client.so.0") catch return error.LibraryNotFound; lib.handle = std.DynLib.open("libwayland-client.so.0") catch return error.LibraryNotFound;
inline for (@typeInfo(LibWaylandClient).Struct.fields[1..]) |field| { inline for (@typeInfo(LibWaylandClient).Struct.fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name}); const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]); const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);
@ -590,7 +590,7 @@ fn keyboardHandleKeymap(user_data: *GlobalState, keyboard: ?*c.struct_wl_keyboar
//Unmap the keymap //Unmap the keymap
std.os.munmap(map_str); std.os.munmap(map_str);
//Close the fd //Close the fd
std.os.close(fd); std.posix.close(fd);
const state = user_data.libxkbcommon.xkb_state_new(keymap).?; const state = user_data.libxkbcommon.xkb_state_new(keymap).?;
// defer user_data.libxkbcommon.xkb_state_unref(state); // defer user_data.libxkbcommon.xkb_state_unref(state);
@ -1061,21 +1061,21 @@ pub fn update(self: *Core, app: anytype) !bool {
} }
// while (libwaylandclient.wl_display_flush(self.display) == -1) { // while (libwaylandclient.wl_display_flush(self.display) == -1) {
// // if (std.os.errno() == std.os.E.AGAIN) { // // if (std.os.errno() == std.posix.E.AGAIN) {
// // log.err("flush error", .{}); // // log.err("flush error", .{});
// // return true; // // return true;
// // } // // }
// var pollfd = [_]std.os.pollfd{ // var pollfd = [_]std.posix.pollfd{
// std.os.pollfd{ // std.posix.pollfd{
// .fd = libwaylandclient.wl_display_get_fd(self.display), // .fd = libwaylandclient.wl_display_get_fd(self.display),
// .events = std.os.POLL.OUT, // .events = std.posix.POLL.OUT,
// .revents = 0, // .revents = 0,
// }, // },
// }; // };
// while (try std.os.poll(&pollfd, -1) != 0) { // while (try std.posix.poll(&pollfd, -1) != 0) {
// // if (std.os.errno() == std.os.E.INTR or std.os.errno() == std.os.E.AGAIN) { // // if (std.os.errno() == std.posix.E.INTR or std.os.errno() == std.posix.E.AGAIN) {
// // log.err("poll error", .{}); // // log.err("poll error", .{});
// // return true; // // return true;
// // } // // }

View file

@ -90,7 +90,7 @@ const LibX11 = struct {
pub fn load() !LibX11 { pub fn load() !LibX11 {
var lib: LibX11 = undefined; var lib: LibX11 = undefined;
lib.handle = std.DynLib.openZ("libX11.so.6") catch return error.LibraryNotFound; lib.handle = std.DynLib.open("libX11.so.6") catch return error.LibraryNotFound;
inline for (@typeInfo(LibX11).Struct.fields[1..]) |field| { inline for (@typeInfo(LibX11).Struct.fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name}); const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]); const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);
@ -112,7 +112,7 @@ const LibXCursor = struct {
pub fn load() !LibXCursor { pub fn load() !LibXCursor {
var lib: LibXCursor = undefined; var lib: LibXCursor = undefined;
lib.handle = std.DynLib.openZ("libXcursor.so.1") catch return error.LibraryNotFound; lib.handle = std.DynLib.open("libXcursor.so.1") catch return error.LibraryNotFound;
inline for (@typeInfo(LibXCursor).Struct.fields[1..]) |field| { inline for (@typeInfo(LibXCursor).Struct.fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name}); const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]); const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);
@ -130,7 +130,7 @@ const LibXRR = struct {
pub fn load() !LibXRR { pub fn load() !LibXRR {
var lib: LibXRR = undefined; var lib: LibXRR = undefined;
lib.handle = std.DynLib.openZ("libXrandr.so.1") catch return error.LibraryNotFound; lib.handle = std.DynLib.open("libXrandr.so.1") catch return error.LibraryNotFound;
inline for (@typeInfo(LibXRR).Struct.fields[1..]) |field| { inline for (@typeInfo(LibXRR).Struct.fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name}); const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]); const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);
@ -165,7 +165,7 @@ const LibGL = struct {
pub fn load() !LibGL { pub fn load() !LibGL {
var lib: LibGL = undefined; var lib: LibGL = undefined;
lib.handle = std.DynLib.openZ("libGL.so.1") catch return error.LibraryNotFound; lib.handle = std.DynLib.open("libGL.so.1") catch return error.LibraryNotFound;
inline for (@typeInfo(LibGL).Struct.fields[1..]) |field| { inline for (@typeInfo(LibGL).Struct.fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name}); const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]); const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);
@ -191,7 +191,7 @@ libgl: ?LibGL,
libxcursor: ?LibXCursor, libxcursor: ?LibXCursor,
width: c_int, width: c_int,
height: c_int, height: c_int,
empty_event_pipe: [2]std.os.fd_t, empty_event_pipe: [2]std.c.fd_t,
gl_ctx: ?*LibGL.Context, gl_ctx: ?*LibGL.Context,
wm_protocols: c.Atom, wm_protocols: c.Atom,
wm_delete_window: c.Atom, wm_delete_window: c.Atom,
@ -340,7 +340,7 @@ pub fn init(
}; };
defer _ = libx11.XFreeColormap(display, colormap); defer _ = libx11.XFreeColormap(display, colormap);
const empty_event_pipe = try std.os.pipe(); const empty_event_pipe = try std.posix.pipe();
for (0..2) |i| { for (0..2) |i| {
const sf = try std.os.fcntl(empty_event_pipe[i], std.os.F.GETFL, 0); const sf = try std.os.fcntl(empty_event_pipe[i], std.os.F.GETFL, 0);
const df = try std.os.fcntl(empty_event_pipe[i], std.os.F.GETFD, 0); const df = try std.os.fcntl(empty_event_pipe[i], std.os.F.GETFD, 0);
@ -657,8 +657,8 @@ pub fn deinit(self: *Core) void {
_ = self.libx11.XCloseDisplay(self.display); _ = self.libx11.XCloseDisplay(self.display);
self.libx11.handle.close(); self.libx11.handle.close();
std.os.close(self.empty_event_pipe[0]); std.posix.close(self.empty_event_pipe[0]);
std.os.close(self.empty_event_pipe[1]); std.posix.close(self.empty_event_pipe[1]);
} }
// Secondary app-update thread // Secondary app-update thread
@ -1096,7 +1096,7 @@ pub inline fn outOfMemory(self: *Core) bool {
// May be called from any thread. // May be called from any thread.
pub inline fn wakeMainThread(self: *Core) void { pub inline fn wakeMainThread(self: *Core) void {
while (true) { while (true) {
const result = std.os.write(self.empty_event_pipe[1], &.{0}) catch break; const result = std.posix.write(self.empty_event_pipe[1], &.{0}) catch break;
if (result == 1) break; if (result == 1) break;
} }
} }

View file

@ -100,9 +100,9 @@ const linux_impl = struct {
pub fn tryInit() LoadError!void { pub fn tryInit() LoadError!void {
if (state == .init) return; if (state == .init) return;
var dl = std.DynLib.openZ("libgamemode.so.0") catch |e| switch (e) { var dl = std.DynLib.open("libgamemode.so.0") catch |e| switch (e) {
// backwards-compatibility for old gamemode versions // backwards-compatibility for old gamemode versions
error.FileNotFound => try std.DynLib.openZ("libgamemode.so"), error.FileNotFound => try std.DynLib.open("libgamemode.so"),
else => return e, else => return e,
}; };
errdefer dl.close(); errdefer dl.close();
@ -116,7 +116,7 @@ const linux_impl = struct {
}; };
} }
state = .{ .init = .{ .lib = dl, .syms = sym_table } }; state = State{ .init = .{ .lib = dl, .syms = sym_table } };
} }
/// Initialize gamemode, logging a possible failure. /// Initialize gamemode, logging a possible failure.

View file

@ -69,7 +69,7 @@ const Lib = struct {
snd_mixer_selem_has_capture_channel: *const fn (?*c.snd_mixer_elem_t, c.snd_mixer_selem_channel_id_t) callconv(.C) c_int, snd_mixer_selem_has_capture_channel: *const fn (?*c.snd_mixer_elem_t, c.snd_mixer_selem_channel_id_t) callconv(.C) c_int,
pub fn load() !void { pub fn load() !void {
lib.handle = std.DynLib.openZ("libasound.so") catch return error.LibraryNotFound; lib.handle = std.DynLib.open("libasound.so") catch return error.LibraryNotFound;
inline for (@typeInfo(Lib).Struct.fields[1..]) |field| { inline for (@typeInfo(Lib).Struct.fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name}); const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]); const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);
@ -88,9 +88,9 @@ pub const Context = struct {
user_data: ?*anyopaque, user_data: ?*anyopaque,
thread: std.Thread, thread: std.Thread,
aborted: std.atomic.Value(bool), aborted: std.atomic.Value(bool),
notify_fd: std.os.fd_t, notify_fd: std.c.fd_t,
notify_wd: std.os.fd_t, notify_wd: std.c.fd_t,
notify_pipe_fd: [2]std.os.fd_t, notify_pipe_fd: [2]std.c.fd_t,
}; };
pub fn init(allocator: std.mem.Allocator, options: main.Context.Options) !backends.Context { pub fn init(allocator: std.mem.Allocator, options: main.Context.Options) !backends.Context {
@ -105,16 +105,16 @@ pub const Context = struct {
.devices_info = util.DevicesInfo.init(), .devices_info = util.DevicesInfo.init(),
.watcher = blk: { .watcher = blk: {
if (options.deviceChangeFn) |deviceChangeFn| { if (options.deviceChangeFn) |deviceChangeFn| {
const notify_fd = std.os.inotify_init1(std.os.linux.IN.NONBLOCK) catch |err| switch (err) { const notify_fd = std.posix.inotify_init1(std.os.linux.IN.NONBLOCK) catch |err| switch (err) {
error.ProcessFdQuotaExceeded, error.ProcessFdQuotaExceeded,
error.SystemFdQuotaExceeded, error.SystemFdQuotaExceeded,
error.SystemResources, error.SystemResources,
=> return error.SystemResources, => return error.SystemResources,
error.Unexpected => unreachable, error.Unexpected => unreachable,
}; };
errdefer std.os.close(notify_fd); errdefer std.posix.close(notify_fd);
const notify_wd = std.os.inotify_add_watch( const notify_wd = std.posix.inotify_add_watch(
notify_fd, notify_fd,
"/dev/snd", "/dev/snd",
std.os.linux.IN.CREATE | std.os.linux.IN.DELETE, std.os.linux.IN.CREATE | std.os.linux.IN.DELETE,
@ -130,17 +130,17 @@ pub const Context = struct {
error.Unexpected, error.Unexpected,
=> unreachable, => unreachable,
}; };
errdefer std.os.inotify_rm_watch(notify_fd, notify_wd); errdefer std.posix.inotify_rm_watch(notify_fd, notify_wd);
const notify_pipe_fd = std.os.pipe2(.{ .NONBLOCK = true }) catch |err| switch (err) { const notify_pipe_fd = std.posix.pipe2(.{ .NONBLOCK = true }) catch |err| switch (err) {
error.ProcessFdQuotaExceeded, error.ProcessFdQuotaExceeded,
error.SystemFdQuotaExceeded, error.SystemFdQuotaExceeded,
=> return error.SystemResources, => return error.SystemResources,
error.Unexpected => unreachable, error.Unexpected => unreachable,
}; };
errdefer { errdefer {
std.os.close(notify_pipe_fd[0]); std.posix.close(notify_pipe_fd[0]);
std.os.close(notify_pipe_fd[1]); std.posix.close(notify_pipe_fd[1]);
} }
break :blk .{ break :blk .{
@ -170,14 +170,14 @@ pub const Context = struct {
pub fn deinit(ctx: *Context) void { pub fn deinit(ctx: *Context) void {
if (ctx.watcher) |*watcher| { if (ctx.watcher) |*watcher| {
watcher.aborted.store(true, .Unordered); watcher.aborted.store(true, .unordered);
_ = std.os.write(watcher.notify_pipe_fd[1], "a") catch {}; _ = std.posix.write(watcher.notify_pipe_fd[1], "a") catch {};
watcher.thread.join(); watcher.thread.join();
std.os.close(watcher.notify_pipe_fd[0]); std.posix.close(watcher.notify_pipe_fd[0]);
std.os.close(watcher.notify_pipe_fd[1]); std.posix.close(watcher.notify_pipe_fd[1]);
std.os.inotify_rm_watch(watcher.notify_fd, watcher.notify_wd); std.posix.inotify_rm_watch(watcher.notify_fd, watcher.notify_wd);
std.os.close(watcher.notify_fd); std.posix.close(watcher.notify_fd);
} }
for (ctx.devices_info.list.items) |d| for (ctx.devices_info.list.items) |d|
@ -192,21 +192,21 @@ pub const Context = struct {
var scan = false; var scan = false;
var last_crash: ?i64 = null; var last_crash: ?i64 = null;
var buf: [2048]u8 = undefined; var buf: [2048]u8 = undefined;
var fds = [2]std.os.pollfd{ var fds = [2]std.posix.pollfd{
.{ .{
.fd = watcher.notify_fd, .fd = watcher.notify_fd,
.events = std.os.POLL.IN, .events = std.posix.POLL.IN,
.revents = 0, .revents = 0,
}, },
.{ .{
.fd = watcher.notify_pipe_fd[0], .fd = watcher.notify_pipe_fd[0],
.events = std.os.POLL.IN, .events = std.posix.POLL.IN,
.revents = 0, .revents = 0,
}, },
}; };
while (!watcher.aborted.load(.Unordered)) { while (!watcher.aborted.load(.unordered)) {
_ = std.os.poll(&fds, -1) catch |err| switch (err) { _ = std.posix.poll(&fds, -1) catch |err| switch (err) {
error.NetworkSubsystemFailed, error.NetworkSubsystemFailed,
error.SystemResources, error.SystemResources,
=> { => {
@ -219,9 +219,9 @@ pub const Context = struct {
}, },
error.Unexpected => unreachable, error.Unexpected => unreachable,
}; };
if (watcher.notify_fd & std.os.POLL.IN != 0) { if (watcher.notify_fd & std.posix.POLL.IN != 0) {
while (true) { while (true) {
const len = std.os.read(watcher.notify_fd, &buf) catch |err| { const len = std.posix.read(watcher.notify_fd, &buf) catch |err| {
if (err == error.WouldBlock) break; if (err == error.WouldBlock) break;
const ts = std.time.milliTimestamp(); const ts = std.time.milliTimestamp();
if (last_crash) |lc| { if (last_crash) |lc| {
@ -273,7 +273,7 @@ pub const Context = struct {
var ctl: ?*c.snd_ctl_t = undefined; var ctl: ?*c.snd_ctl_t = undefined;
_ = switch (-lib.snd_ctl_open(&ctl, card_id.ptr, 0)) { _ = switch (-lib.snd_ctl_open(&ctl, card_id.ptr, 0)) {
0 => {}, 0 => {},
@intFromEnum(std.os.E.NOENT) => break, @intFromEnum(std.posix.E.NOENT) => break,
else => return error.OpeningDevice, else => return error.OpeningDevice,
}; };
defer _ = lib.snd_ctl_close(ctl); defer _ = lib.snd_ctl_close(ctl);
@ -290,7 +290,7 @@ pub const Context = struct {
const snd_stream = modeToStream(mode); const snd_stream = modeToStream(mode);
lib.snd_pcm_info_set_stream(pcm_info, snd_stream); lib.snd_pcm_info_set_stream(pcm_info, snd_stream);
const err = lib.snd_ctl_pcm_info(ctl, pcm_info); const err = lib.snd_ctl_pcm_info(ctl, pcm_info);
switch (@as(std.os.E, @enumFromInt(-err))) { switch (@as(std.posix.E, @enumFromInt(-err))) {
.SUCCESS => {}, .SUCCESS => {},
.NOENT, .NOENT,
.NXIO, .NXIO,
@ -554,7 +554,7 @@ pub const Player = struct {
sample_rate: u24, sample_rate: u24,
pub fn deinit(player: *Player) void { pub fn deinit(player: *Player) void {
player.aborted.store(true, .Unordered); player.aborted.store(true, .unordered);
player.thread.join(); player.thread.join();
_ = lib.snd_mixer_close(player.mixer); _ = lib.snd_mixer_close(player.mixer);
@ -579,7 +579,7 @@ pub const Player = struct {
fn writeThread(player: *Player) void { fn writeThread(player: *Player) void {
var underrun = false; var underrun = false;
while (!player.aborted.load(.Unordered)) { while (!player.aborted.load(.unordered)) {
if (!underrun) { if (!underrun) {
player.writeFn( player.writeFn(
player.user_data, player.user_data,
@ -668,7 +668,7 @@ pub const Recorder = struct {
sample_rate: u24, sample_rate: u24,
pub fn deinit(recorder: *Recorder) void { pub fn deinit(recorder: *Recorder) void {
recorder.aborted.store(true, .Unordered); recorder.aborted.store(true, .unordered);
recorder.thread.join(); recorder.thread.join();
_ = lib.snd_mixer_close(recorder.mixer); _ = lib.snd_mixer_close(recorder.mixer);
@ -693,7 +693,7 @@ pub const Recorder = struct {
fn readThread(recorder: *Recorder) void { fn readThread(recorder: *Recorder) void {
var underrun = false; var underrun = false;
while (!recorder.aborted.load(.Unordered)) { while (!recorder.aborted.load(.unordered)) {
if (!underrun) { if (!underrun) {
recorder.readFn(recorder.user_data, recorder.sample_buffer[0..recorder.period_size]); recorder.readFn(recorder.user_data, recorder.sample_buffer[0..recorder.period_size]);
} }

View file

@ -33,7 +33,7 @@ const Lib = struct {
jack_port_type_size: *const fn () c_int, jack_port_type_size: *const fn () c_int,
pub fn load() !void { pub fn load() !void {
lib.handle = std.DynLib.openZ("libjack.so") catch return error.LibraryNotFound; lib.handle = std.DynLib.open("libjack.so") catch return error.LibraryNotFound;
inline for (@typeInfo(Lib).Struct.fields[1..]) |field| { inline for (@typeInfo(Lib).Struct.fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name}); const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]); const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);

View file

@ -33,7 +33,7 @@ const Lib = struct {
pw_stream_get_state: *const fn (?*c.pw_stream, [*c][*c]const u8) callconv(.C) c.pw_stream_state, pw_stream_get_state: *const fn (?*c.pw_stream, [*c][*c]const u8) callconv(.C) c.pw_stream_state,
pub fn load() !void { pub fn load() !void {
lib.handle = std.DynLib.openZ("libpipewire-0.3.so") catch return error.LibraryNotFound; lib.handle = std.DynLib.open("libpipewire-0.3.so") catch return error.LibraryNotFound;
inline for (@typeInfo(Lib).Struct.fields[1..]) |field| { inline for (@typeInfo(Lib).Struct.fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name}); const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]); const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);
@ -395,7 +395,7 @@ pub const Player = struct {
defer _ = lib.pw_stream_queue_buffer(player.stream, buf); defer _ = lib.pw_stream_queue_buffer(player.stream, buf);
buf.*.buffer.*.datas[0].chunk.*.offset = 0; buf.*.buffer.*.datas[0].chunk.*.offset = 0;
if (player.is_paused.load(.Unordered)) { if (player.is_paused.load(.unordered)) {
buf.*.buffer.*.datas[0].chunk.*.stride = 0; buf.*.buffer.*.datas[0].chunk.*.stride = 0;
buf.*.buffer.*.datas[0].chunk.*.size = 0; buf.*.buffer.*.datas[0].chunk.*.size = 0;
return; return;
@ -429,15 +429,15 @@ pub const Player = struct {
} }
pub fn play(player: *Player) !void { pub fn play(player: *Player) !void {
player.is_paused.store(false, .Unordered); player.is_paused.store(false, .unordered);
} }
pub fn pause(player: *Player) !void { pub fn pause(player: *Player) !void {
player.is_paused.store(true, .Unordered); player.is_paused.store(true, .unordered);
} }
pub fn paused(player: *Player) bool { pub fn paused(player: *Player) bool {
return player.is_paused.load(.Unordered); return player.is_paused.load(.unordered);
} }
pub fn setVolume(player: *Player, vol: f32) !void { pub fn setVolume(player: *Player, vol: f32) !void {
@ -470,7 +470,7 @@ pub const Recorder = struct {
defer _ = lib.pw_stream_queue_buffer(recorder.stream, buf); defer _ = lib.pw_stream_queue_buffer(recorder.stream, buf);
buf.*.buffer.*.datas[0].chunk.*.offset = 0; buf.*.buffer.*.datas[0].chunk.*.offset = 0;
if (recorder.is_paused.load(.Unordered)) { if (recorder.is_paused.load(.unordered)) {
buf.*.buffer.*.datas[0].chunk.*.stride = 0; buf.*.buffer.*.datas[0].chunk.*.stride = 0;
buf.*.buffer.*.datas[0].chunk.*.size = 0; buf.*.buffer.*.datas[0].chunk.*.size = 0;
return; return;
@ -500,15 +500,15 @@ pub const Recorder = struct {
} }
pub fn record(recorder: *Recorder) !void { pub fn record(recorder: *Recorder) !void {
recorder.is_paused.store(false, .Unordered); recorder.is_paused.store(false, .unordered);
} }
pub fn pause(recorder: *Recorder) !void { pub fn pause(recorder: *Recorder) !void {
recorder.is_paused.store(true, .Unordered); recorder.is_paused.store(true, .unordered);
} }
pub fn paused(recorder: *Recorder) bool { pub fn paused(recorder: *Recorder) bool {
return recorder.is_paused.load(.Unordered); return recorder.is_paused.load(.unordered);
} }
pub fn setVolume(recorder: *Recorder, vol: f32) !void { pub fn setVolume(recorder: *Recorder, vol: f32) !void {

View file

@ -61,7 +61,7 @@ const Lib = struct {
pa_stream_get_sample_spec: *const fn (s: ?*c.pa_stream) [*c]const c.pa_sample_spec, pa_stream_get_sample_spec: *const fn (s: ?*c.pa_stream) [*c]const c.pa_sample_spec,
pub fn load() !void { pub fn load() !void {
lib.handle = std.DynLib.openZ("libpulse.so") catch return error.LibraryNotFound; lib.handle = std.DynLib.open("libpulse.so") catch return error.LibraryNotFound;
inline for (@typeInfo(Lib).Struct.fields[1..]) |field| { inline for (@typeInfo(Lib).Struct.fields[1..]) |field| {
const name = std.fmt.comptimePrint("{s}\x00", .{field.name}); const name = std.fmt.comptimePrint("{s}\x00", .{field.name});
const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]); const name_z: [:0]const u8 = @ptrCast(name[0 .. name.len - 1]);

View file

@ -16,7 +16,7 @@ fn getProcAddress(name_ptr: [*:0]const u8) c.PROC {
} }
pub fn init() !void { pub fn init() !void {
libgl = try std.DynLib.openZ("opengl32.dll"); libgl = try std.DynLib.open("opengl32.dll");
} }
pub fn deinit() void { pub fn deinit() void {

View file

@ -28,7 +28,7 @@ pub fn init(alloc: std.mem.Allocator, options: InitOptions) !void {
if (options.baseLoader) |baseLoader| { if (options.baseLoader) |baseLoader| {
vkb = try proc.loadBase(baseLoader); vkb = try proc.loadBase(baseLoader);
} else { } else {
libvulkan = try std.DynLib.openZ(switch (builtin.target.os.tag) { libvulkan = try std.DynLib.open(switch (builtin.target.os.tag) {
.windows => "vulkan-1.dll", .windows => "vulkan-1.dll",
.linux => "libvulkan.so.1", .linux => "libvulkan.so.1",
.macos => "libvulkan.1.dylib", .macos => "libvulkan.1.dylib",
@ -132,24 +132,24 @@ pub const Instance = struct {
&.{}; &.{};
const instance_extensions: []const [*:0]const u8 = switch (builtin.target.os.tag) { const instance_extensions: []const [*:0]const u8 = switch (builtin.target.os.tag) {
.linux => &.{ .linux => &.{
vk.extension_info.khr_surface.name, vk.extensions.khr_surface.name,
vk.extension_info.khr_xlib_surface.name, vk.extensions.khr_xlib_surface.name,
vk.extension_info.khr_xcb_surface.name, vk.extensions.khr_xcb_surface.name,
// TODO: renderdoc will not work with this extension // TODO: renderdoc will not work with this extension
// vk.extension_info.khr_wayland_surface.name, // vk.extensions.khr_wayland_surface.name,
}, },
.windows => &.{ .windows => &.{
vk.extension_info.khr_surface.name, vk.extensions.khr_surface.name,
vk.extension_info.khr_win_32_surface.name, vk.extensions.khr_win_32_surface.name,
}, },
.macos, .ios => &.{ .macos, .ios => &.{
vk.extension_info.khr_surface.name, vk.extensions.khr_surface.name,
vk.extension_info.ext_metal_surface.name, vk.extensions.ext_metal_surface.name,
}, },
else => |tag| if (builtin.target.abi == .android) else => |tag| if (builtin.target.abi == .android)
&.{ &.{
vk.extension_info.khr_surface.name, vk.extensions.khr_surface.name,
vk.extension_info.khr_android_surface.name, vk.extensions.khr_android_surface.name,
} }
else else
@compileError(std.fmt.comptimePrint("unsupported platform ({s})", .{@tagName(tag)})), @compileError(std.fmt.comptimePrint("unsupported platform ({s})", .{@tagName(tag)})),
@ -490,7 +490,8 @@ pub const Device = struct {
.indirect_first_instance => features.features.draw_indirect_first_instance = vk.TRUE, .indirect_first_instance => features.features.draw_indirect_first_instance = vk.TRUE,
.shader_f16 => { .shader_f16 => {
var feature = vk.PhysicalDeviceShaderFloat16Int8FeaturesKHR{ var feature = vk.PhysicalDeviceShaderFloat16Int8FeaturesKHR{
.s_type = .physical_device_shader_float16_int8_features_khr, // physical_device_shader_float16_int8_features_khr
.s_type = vk.StructureType.physical_device_shader_float16_int8_features_khr,
.shader_float_16 = vk.TRUE, .shader_float_16 = vk.TRUE,
}; };
features.p_next = @ptrCast(&feature); features.p_next = @ptrCast(&feature);
@ -716,7 +717,7 @@ pub const Device = struct {
&[_][*:0]const u8{"VK_LAYER_KHRONOS_validation"} &[_][*:0]const u8{"VK_LAYER_KHRONOS_validation"}
else else
&.{}; &.{};
const device_extensions = &[_][*:0]const u8{vk.extension_info.khr_swapchain.name}; const device_extensions = &[_][*:0]const u8{vk.extensions.khr_swapchain.name};
pub const ResolveKey = struct { pub const ResolveKey = struct {
format: vk.Format, format: vk.Format,

View file

@ -2,14 +2,20 @@ const std = @import("std");
const builtin = @import("builtin"); const builtin = @import("builtin");
const vk = @import("vulkan"); const vk = @import("vulkan");
pub const BaseFunctions = vk.BaseWrapper(.{ pub const BaseFunctions = vk.BaseWrapper(&.{
.{
.base_commands = .{
.createInstance = true, .createInstance = true,
.enumerateInstanceExtensionProperties = true, .enumerateInstanceExtensionProperties = true,
.enumerateInstanceLayerProperties = true, .enumerateInstanceLayerProperties = true,
.getInstanceProcAddr = true, .getInstanceProcAddr = true,
},
},
}); });
pub const InstanceFunctions = vk.InstanceWrapper(.{ pub const InstanceFunctions = vk.InstanceWrapper(&.{
.{
.instance_commands = .{
.createDevice = true, .createDevice = true,
// TODO: renderdoc will not work with wayland // TODO: renderdoc will not work with wayland
// .createWaylandSurfaceKHR = builtin.target.os.tag == .linux, // .createWaylandSurfaceKHR = builtin.target.os.tag == .linux,
@ -28,9 +34,13 @@ pub const InstanceFunctions = vk.InstanceWrapper(.{
.getPhysicalDeviceQueueFamilyProperties = true, .getPhysicalDeviceQueueFamilyProperties = true,
.getPhysicalDeviceSurfaceCapabilitiesKHR = true, .getPhysicalDeviceSurfaceCapabilitiesKHR = true,
.getPhysicalDeviceSurfaceFormatsKHR = true, .getPhysicalDeviceSurfaceFormatsKHR = true,
},
},
}); });
pub const DeviceFunctions = vk.DeviceWrapper(.{ pub const DeviceFunctions = vk.DeviceWrapper(&.{
.{
.device_commands = .{
.acquireNextImageKHR = true, .acquireNextImageKHR = true,
.allocateCommandBuffers = true, .allocateCommandBuffers = true,
.allocateDescriptorSets = true, .allocateDescriptorSets = true,
@ -105,6 +115,8 @@ pub const DeviceFunctions = vk.DeviceWrapper(.{
.unmapMemory = true, .unmapMemory = true,
.updateDescriptorSets = true, .updateDescriptorSets = true,
.waitForFences = true, .waitForFences = true,
},
},
}); });
pub const BaseLoader = *const fn (vk.Instance, [*:0]const u8) vk.PfnVoidFunction; pub const BaseLoader = *const fn (vk.Instance, [*:0]const u8) vk.PfnVoidFunction;