Switch to sokol
This commit is contained in:
61
build.zig
61
build.zig
@@ -1,64 +1,39 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
const cimgui = @import("cimgui");
|
||||||
const zaudio = b.dependency("zaudio", .{});
|
|
||||||
const zglfw = b.dependency("zglfw", .{});
|
|
||||||
const zgpu = b.dependency("zgpu", .{});
|
|
||||||
const zgui = b.dependency("zgui", .{
|
|
||||||
.shared = false,
|
|
||||||
.backend = .glfw_wgpu,
|
|
||||||
.with_implot = true,
|
|
||||||
});
|
|
||||||
const zmath = b.dependency("zmath", .{});
|
|
||||||
const znoise = b.dependency("znoise", .{});
|
|
||||||
const zpool = b.dependency("zpool", .{});
|
|
||||||
const zstbi = b.dependency("zstbi", .{});
|
|
||||||
const ztracy = b.dependency("ztracy", .{
|
|
||||||
.enable_ztracy = b.option(bool, "tracy", "Enable Tracy profile markers") orelse false,
|
|
||||||
.enable_fibers = b.option(bool, "tracy_fibers", "Enable Tracy fiber support") orelse false,
|
|
||||||
.on_demand = b.option(bool, "tracy_on_demand", "Build Tracy with TRACY_ON_DEMAND") orelse false,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
pub fn build(b: *std.Build) void {
|
||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
|
const cimgui_conf = cimgui.getConfig(false);
|
||||||
|
|
||||||
const exe_mod = b.createModule(.{
|
const exe_mod = b.createModule(.{
|
||||||
.root_source_file = b.path("src/main.zig"),
|
.root_source_file = b.path("src/main.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
||||||
exe_mod.addImport("zaudio", zaudio.module("root"));
|
const cimgui_dep = b.dependency("cimgui", .{
|
||||||
exe_mod.addImport("zglfw", zglfw.module("root"));
|
.target = target,
|
||||||
exe_mod.addImport("zgpu", zgpu.module("root"));
|
.optimize = optimize,
|
||||||
exe_mod.addImport("zgui", zgui.module("root"));
|
});
|
||||||
exe_mod.addImport("zmath", zmath.module("root"));
|
|
||||||
exe_mod.addImport("znoise", znoise.module("root"));
|
const sokol_dep = b.dependency("sokol", .{
|
||||||
exe_mod.addImport("zpool", zpool.module("root"));
|
.target = target,
|
||||||
exe_mod.addImport("zstbi", zstbi.module("root"));
|
.optimize = optimize,
|
||||||
exe_mod.addImport("ztracy", ztracy.module("root"));
|
.with_sokol_imgui = true,
|
||||||
|
});
|
||||||
|
sokol_dep.artifact("sokol_clib").addIncludePath(cimgui_dep.path(cimgui_conf.include_dir));
|
||||||
|
|
||||||
|
exe_mod.addImport("cimgui", cimgui_dep.module(cimgui_conf.module_name));
|
||||||
|
exe_mod.addImport("sokol", sokol_dep.module("sokol"));
|
||||||
|
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "voxel-game",
|
.name = "voxel-game",
|
||||||
.root_module = exe_mod,
|
.root_module = exe_mod,
|
||||||
});
|
});
|
||||||
|
|
||||||
exe.linkLibrary(zaudio.artifact("miniaudio"));
|
|
||||||
exe.linkLibrary(zgui.artifact("imgui"));
|
|
||||||
exe.linkLibrary(znoise.artifact("FastNoiseLite"));
|
|
||||||
exe.linkLibrary(zstbi.artifact("zstbi"));
|
|
||||||
exe.linkLibrary(ztracy.artifact("tracy"));
|
|
||||||
if (target.result.os.tag != .emscripten) {
|
|
||||||
exe.linkLibrary(zglfw.artifact("glfw"));
|
|
||||||
exe.linkLibrary(zgpu.artifact("zdawn"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (optimize != .Debug) {
|
|
||||||
exe.subsystem = .Windows;
|
|
||||||
}
|
|
||||||
|
|
||||||
@import("zgpu").addLibraryPathsTo(exe);
|
|
||||||
|
|
||||||
b.installArtifact(exe);
|
b.installArtifact(exe);
|
||||||
|
|
||||||
const run_cmd = b.addRunArtifact(exe);
|
const run_cmd = b.addRunArtifact(exe);
|
||||||
|
|||||||
@@ -1,75 +1,17 @@
|
|||||||
.{
|
.{
|
||||||
.name = "voxel-game",
|
.name = .voxel_game,
|
||||||
.version = "0.0.0",
|
.version = "0.0.0",
|
||||||
|
.fingerprint = 0xfa26431018c1674c,
|
||||||
|
.minimum_zig_version = "0.15.2",
|
||||||
|
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.zaudio = .{
|
.sokol = .{
|
||||||
.url = "https://github.com/zig-gamedev/zaudio/archive/496da32757767b31f389554e1e5c668796755fe2.tar.gz",
|
.url = "git+https://github.com/floooh/sokol-zig.git#1c217971533e3aa634ecbfbe13ff776e05701e0a",
|
||||||
.hash = "12203f6ab72861cd7e36ebd1590f9cc7fd036366e2ff96122002a395f628e813d999",
|
.hash = "sokol-0.1.0-pb1HK3TYLgCx8lOxdLVWIVDcAzacxO8YDfyw2Er-_2nN",
|
||||||
},
|
},
|
||||||
.zglfw = .{
|
.cimgui = .{
|
||||||
.url = "https://github.com/zig-gamedev/zglfw/archive/5aaf806521bbda4385b1041d9448bd0c40192a1c.tar.gz",
|
.url = "git+https://github.com/floooh/dcimgui.git#d5fb4e3d27b79062dc5981db3631dadc4f204654",
|
||||||
.hash = "12202db5d18aa92ae61b0e47c11ec517eeb5984d8e2647ff513807ff30a444fef49a",
|
.hash = "cimgui-0.1.0-44Clkd6YlAAYULKHDwsDX9EPmka-VAVEjUl-o6ve307E",
|
||||||
},
|
|
||||||
// Needed to be vendored, because it depends on zpool, which itself
|
|
||||||
// needs to be vendored.
|
|
||||||
.zgpu = .{
|
|
||||||
.path = "vendor/zgpu",
|
|
||||||
},
|
|
||||||
.zgui = .{
|
|
||||||
.url = "https://github.com/zig-gamedev/zgui/archive/5fb1c3b935b311e88352b0ffee29e7ad56da9722.tar.gz",
|
|
||||||
.hash = "12204f82e0475ddfd6a57d97f74bcf9052452c0eb2fa863cf0e3bce1071d2603e9f4",
|
|
||||||
},
|
|
||||||
.zjobs = .{
|
|
||||||
.url = "https://github.com/zig-gamedev/zjobs/archive/19743327b06209a8041f7840ec13a9b794767d32.tar.gz",
|
|
||||||
.hash = "12203322a6cbf36b797c78833fae7391b736f3808ee59d7ce092981d02bbde941a07",
|
|
||||||
},
|
|
||||||
.zmath = .{
|
|
||||||
.url = "https://github.com/zig-gamedev/zmath/archive/24cdd20f9da09bd1ce7b552907eeaba9bafea59d.tar.gz",
|
|
||||||
.hash = "1220081d55b58b968d953db1afc2fb01b2f5733929144e69522461ce25fa6450d84e",
|
|
||||||
},
|
|
||||||
.znoise = .{
|
|
||||||
.url = "https://github.com/zig-gamedev/znoise/archive/b6e7a24c9bfa4bae63521664e191a728b5b18805.tar.gz",
|
|
||||||
.hash = "12208e16c80366e2a2f8bd3f1c676b09bf47c157f4d0f0d6440555f9b74d8a9d79f7",
|
|
||||||
},
|
|
||||||
// Needed to be vendored due to breaking changes in zig's type info
|
|
||||||
// structs, which upstream hasn't caught up to.
|
|
||||||
.zpool = .{
|
|
||||||
.path = "vendor/zpool",
|
|
||||||
},
|
|
||||||
.zstbi = .{
|
|
||||||
.url = "https://github.com/zig-gamedev/zstbi/archive/bcbd249f3f57fb84d6d76f1bc621c7bd3bfaa4a2.tar.gz",
|
|
||||||
.hash = "12208b7d15a730294a7d8ee3a9d3ef145e109f94d0a68be7f0ee282e0630ede093d5",
|
|
||||||
},
|
|
||||||
.ztracy = .{
|
|
||||||
.url = "https://github.com/zig-gamedev/ztracy/archive/5af60074f355ecda6114d08dcc8c931c3d163c94.tar.gz",
|
|
||||||
.hash = "1220293b509e9238e43828b00ee18e38eeace190ef844b74bf54e3db6e7da7398f4b",
|
|
||||||
},
|
|
||||||
|
|
||||||
.dawn_x86_64_windows_gnu = .{
|
|
||||||
.url = "https://github.com/michal-z/webgpu_dawn-x86_64-windows-gnu/archive/d3a68014e6b6b53fd330a0ccba99e4dcfffddae5.tar.gz",
|
|
||||||
.hash = "1220f9448cde02ef3cd51bde2e0850d4489daa0541571d748154e89c6eb46c76a267",
|
|
||||||
.lazy = true,
|
|
||||||
},
|
|
||||||
.dawn_x86_64_linux_gnu = .{
|
|
||||||
.url = "https://github.com/michal-z/webgpu_dawn-x86_64-linux-gnu/archive/7d70db023bf254546024629cbec5ee6113e12a42.tar.gz",
|
|
||||||
.hash = "12204a3519efd49ea2d7cf63b544492a3a771d37eda320f86380813376801e4cfa73",
|
|
||||||
.lazy = true,
|
|
||||||
},
|
|
||||||
.dawn_aarch64_linux_gnu = .{
|
|
||||||
.url = "https://github.com/michal-z/webgpu_dawn-aarch64-linux-gnu/archive/c1f55e740a62f6942ff046e709ecd509a005dbeb.tar.gz",
|
|
||||||
.hash = "12205cd13f6849f94ef7688ee88c6b74c7918a5dfb514f8a403fcc2929a0aa342627",
|
|
||||||
.lazy = true,
|
|
||||||
},
|
|
||||||
.dawn_aarch64_macos = .{
|
|
||||||
.url = "https://github.com/michal-z/webgpu_dawn-aarch64-macos/archive/d2360cdfff0cf4a780cb77aa47c57aca03cc6dfe.tar.gz",
|
|
||||||
.hash = "12201fe677e9c7cfb8984a36446b329d5af23d03dc1e4f79a853399529e523a007fa",
|
|
||||||
.lazy = true,
|
|
||||||
},
|
|
||||||
.dawn_x86_64_macos = .{
|
|
||||||
.url = "https://github.com/michal-z/webgpu_dawn-x86_64-macos/archive/901716b10b31ce3e0d3fe479326b41e91d59c661.tar.gz",
|
|
||||||
.hash = "1220b1f02f2f7edd98a078c64e3100907d90311d94880a3cc5927e1ac009d002667a",
|
|
||||||
.lazy = true,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
11
src/Log.zig
11
src/Log.zig
@@ -1,11 +0,0 @@
|
|||||||
const std = @import("std");
|
|
||||||
|
|
||||||
level: std.log.Level,
|
|
||||||
message: []const u8,
|
|
||||||
|
|
||||||
pub fn init(level: std.log.Level, message: []const u8) @This() {
|
|
||||||
return .{
|
|
||||||
.level = level,
|
|
||||||
.message = message,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
110
src/game.zig
110
src/game.zig
@@ -1,110 +0,0 @@
|
|||||||
const std = @import("std");
|
|
||||||
|
|
||||||
const zglfw = @import("zglfw");
|
|
||||||
const zgui = @import("zgui");
|
|
||||||
|
|
||||||
const main = @import("main.zig");
|
|
||||||
|
|
||||||
var show_console: bool = false;
|
|
||||||
var show_demo_window: bool = false;
|
|
||||||
|
|
||||||
pub fn init() void {}
|
|
||||||
|
|
||||||
pub fn update(dt: f32) void {
|
|
||||||
_ = dt;
|
|
||||||
|
|
||||||
if (show_console) {
|
|
||||||
showConsole();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (show_demo_window) {
|
|
||||||
zgui.showDemoWindow(&show_demo_window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn charCallback(
|
|
||||||
_: *zglfw.Window,
|
|
||||||
codepoint: u32,
|
|
||||||
) callconv(.C) void {
|
|
||||||
_ = codepoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn cursorPosCallback(
|
|
||||||
_: *zglfw.Window,
|
|
||||||
xpos: f64,
|
|
||||||
ypos: f64,
|
|
||||||
) callconv(.C) void {
|
|
||||||
_ = xpos;
|
|
||||||
_ = ypos;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn keyCallback(
|
|
||||||
_: *zglfw.Window,
|
|
||||||
key: zglfw.Key,
|
|
||||||
scancode: c_int,
|
|
||||||
action: zglfw.Action,
|
|
||||||
mods: zglfw.Mods,
|
|
||||||
) callconv(.C) void {
|
|
||||||
_ = scancode;
|
|
||||||
|
|
||||||
const no_mods = @as(c_int, @bitCast(mods)) == 0;
|
|
||||||
|
|
||||||
if (key == .grave_accent and action == .press and no_mods) {
|
|
||||||
show_console = !show_console;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key == .F1 and action == .press and no_mods) {
|
|
||||||
show_demo_window = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn mouseButtonCallback(
|
|
||||||
_: *zglfw.Window,
|
|
||||||
button: zglfw.MouseButton,
|
|
||||||
action: zglfw.Action,
|
|
||||||
mods: zglfw.Mods,
|
|
||||||
) callconv(.C) void {
|
|
||||||
_ = button;
|
|
||||||
_ = action;
|
|
||||||
_ = mods;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn scrollCallback(
|
|
||||||
_: *zglfw.Window,
|
|
||||||
xoffset: f64,
|
|
||||||
yoffset: f64,
|
|
||||||
) callconv(.C) void {
|
|
||||||
_ = xoffset;
|
|
||||||
_ = yoffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn deinit() void {}
|
|
||||||
|
|
||||||
fn showConsole() void {
|
|
||||||
const display_size = zgui.io.getDisplaySize();
|
|
||||||
zgui.setNextWindowPos(.{
|
|
||||||
.x = 0,
|
|
||||||
.y = 0,
|
|
||||||
});
|
|
||||||
zgui.setNextWindowSize(.{
|
|
||||||
.w = display_size[0],
|
|
||||||
.h = main.min_window_height,
|
|
||||||
.cond = .once,
|
|
||||||
});
|
|
||||||
if (zgui.begin("Console", .{ .flags = .{
|
|
||||||
.no_title_bar = true,
|
|
||||||
.no_resize = true,
|
|
||||||
.no_move = true,
|
|
||||||
.no_collapse = true,
|
|
||||||
} })) {
|
|
||||||
for (main.logs.items) |log| {
|
|
||||||
zgui.textUnformattedColored(switch (log.level) {
|
|
||||||
.err => .{ 1, 0, 0, 1 },
|
|
||||||
.warn => .{ 1, 1, 0, 1 },
|
|
||||||
.info => .{ 1, 1, 1, 1 },
|
|
||||||
.debug => .{ 0.5, 0.5, 0.5, 1 },
|
|
||||||
}, log.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
zgui.end();
|
|
||||||
}
|
|
||||||
208
src/main.zig
208
src/main.zig
@@ -1,202 +1,8 @@
|
|||||||
const std = @import("std");
|
const sokol = @import("sokol");
|
||||||
|
const slog = sokol.log;
|
||||||
|
const sg = sokol.gfx;
|
||||||
|
const sapp = sokol.app;
|
||||||
|
const sglue = sokol.glue;
|
||||||
|
const simgui = sokol.imgui;
|
||||||
|
|
||||||
const zaudio = @import("zaudio");
|
pub fn main() void {}
|
||||||
const zglfw = @import("zglfw");
|
|
||||||
const zgpu = @import("zgpu");
|
|
||||||
const zgui = @import("zgui");
|
|
||||||
const ztracy = @import("ztracy");
|
|
||||||
|
|
||||||
const game = @import("game.zig");
|
|
||||||
const Log = @import("Log.zig");
|
|
||||||
|
|
||||||
pub const min_framerate = 30.0;
|
|
||||||
pub const min_frametime = 1.0 / min_framerate;
|
|
||||||
pub const min_window_height = 360;
|
|
||||||
pub const min_window_width = 640;
|
|
||||||
pub const temp_allocator_capacity = 16 * 1024 * 1024;
|
|
||||||
pub const window_title = "voxel-game";
|
|
||||||
|
|
||||||
pub var allocator: std.mem.Allocator = undefined;
|
|
||||||
pub var audio_engine: *zaudio.Engine = undefined;
|
|
||||||
pub var gctx: *zgpu.GraphicsContext = undefined;
|
|
||||||
pub var logs: std.ArrayListUnmanaged(Log) = undefined;
|
|
||||||
pub var temp_allocator: std.mem.Allocator = undefined;
|
|
||||||
pub var window: *zglfw.Window = undefined;
|
|
||||||
|
|
||||||
pub const std_options: std.Options = .{
|
|
||||||
.logFn = logFn,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn main() !void {
|
|
||||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
|
||||||
defer _ = gpa.deinit();
|
|
||||||
|
|
||||||
var ta = ztracy.TracyAllocator.init(gpa.allocator());
|
|
||||||
|
|
||||||
var fba = std.heap.FixedBufferAllocator.init(&struct {
|
|
||||||
pub var buffer: [temp_allocator_capacity]u8 = undefined;
|
|
||||||
}.buffer);
|
|
||||||
|
|
||||||
allocator = ta.allocator();
|
|
||||||
temp_allocator = fba.threadSafeAllocator();
|
|
||||||
|
|
||||||
defer {
|
|
||||||
for (logs.items) |log| {
|
|
||||||
allocator.free(log.message);
|
|
||||||
}
|
|
||||||
logs.deinit(allocator);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- zaudio --------------------------------------------------------------
|
|
||||||
|
|
||||||
const zone_init_zaudio = ztracy.ZoneN(@src(), "Init zaudio");
|
|
||||||
|
|
||||||
zaudio.init(allocator);
|
|
||||||
defer zaudio.deinit();
|
|
||||||
|
|
||||||
audio_engine = try zaudio.Engine.create(null);
|
|
||||||
defer audio_engine.destroy();
|
|
||||||
|
|
||||||
zone_init_zaudio.End();
|
|
||||||
|
|
||||||
// --- zglfw ---------------------------------------------------------------
|
|
||||||
|
|
||||||
const zone_init_zglfw = ztracy.ZoneN(@src(), "Init zglfw");
|
|
||||||
|
|
||||||
try zglfw.init();
|
|
||||||
defer zglfw.terminate();
|
|
||||||
|
|
||||||
const monitor = zglfw.getPrimaryMonitor() orelse return error.PrimaryMonitorNotFound;
|
|
||||||
const video_mode = try monitor.getVideoMode();
|
|
||||||
|
|
||||||
zglfw.windowHint(.client_api, .no_api);
|
|
||||||
window = try zglfw.Window.create(video_mode.width, video_mode.height, window_title, monitor);
|
|
||||||
window.setSizeLimits(
|
|
||||||
min_window_width,
|
|
||||||
min_window_height,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
);
|
|
||||||
defer window.destroy();
|
|
||||||
|
|
||||||
std.debug.assert(zglfw.setCharCallback(window, game.charCallback) == null);
|
|
||||||
std.debug.assert(zglfw.setCursorPosCallback(window, game.cursorPosCallback) == null);
|
|
||||||
std.debug.assert(zglfw.setKeyCallback(window, game.keyCallback) == null);
|
|
||||||
std.debug.assert(zglfw.setMouseButtonCallback(window, game.mouseButtonCallback) == null);
|
|
||||||
std.debug.assert(zglfw.setScrollCallback(window, game.scrollCallback) == null);
|
|
||||||
|
|
||||||
zone_init_zglfw.End();
|
|
||||||
|
|
||||||
// --- zgpu ----------------------------------------------------------------
|
|
||||||
|
|
||||||
const zone_init_zgpu = ztracy.ZoneN(@src(), "Init zgpu");
|
|
||||||
|
|
||||||
gctx = try zgpu.GraphicsContext.create(allocator, .{
|
|
||||||
.window = window,
|
|
||||||
.fn_getTime = @ptrCast(&zglfw.getTime),
|
|
||||||
.fn_getFramebufferSize = @ptrCast(&zglfw.Window.getFramebufferSize),
|
|
||||||
.fn_getWin32Window = @ptrCast(&zglfw.getWin32Window),
|
|
||||||
.fn_getX11Display = @ptrCast(&zglfw.getX11Display),
|
|
||||||
.fn_getX11Window = @ptrCast(&zglfw.getX11Window),
|
|
||||||
.fn_getWaylandDisplay = @ptrCast(&zglfw.getWaylandDisplay),
|
|
||||||
.fn_getWaylandSurface = @ptrCast(&zglfw.getWaylandWindow),
|
|
||||||
.fn_getCocoaWindow = @ptrCast(&zglfw.getCocoaWindow),
|
|
||||||
}, .{});
|
|
||||||
defer gctx.destroy(allocator);
|
|
||||||
|
|
||||||
zone_init_zgpu.End();
|
|
||||||
|
|
||||||
// --- zgui ----------------------------------------------------------------
|
|
||||||
|
|
||||||
const zone_init_zgui = ztracy.ZoneN(@src(), "Init zgui");
|
|
||||||
|
|
||||||
zgui.init(allocator);
|
|
||||||
defer zgui.deinit();
|
|
||||||
|
|
||||||
zgui.backend.init(
|
|
||||||
window,
|
|
||||||
gctx.device,
|
|
||||||
@intFromEnum(zgpu.GraphicsContext.swapchain_format),
|
|
||||||
@intFromEnum(zgpu.wgpu.TextureFormat.undef),
|
|
||||||
);
|
|
||||||
defer zgui.backend.deinit();
|
|
||||||
|
|
||||||
zgui.io.setIniFilename(null);
|
|
||||||
|
|
||||||
zone_init_zgui.End();
|
|
||||||
|
|
||||||
// --- game ----------------------------------------------------------------
|
|
||||||
|
|
||||||
const zone_init_game = ztracy.ZoneN(@src(), "Init game");
|
|
||||||
|
|
||||||
game.init();
|
|
||||||
defer game.deinit();
|
|
||||||
|
|
||||||
zone_init_game.End();
|
|
||||||
|
|
||||||
// --- main loop -----------------------------------------------------------
|
|
||||||
|
|
||||||
const zone_main_loop = ztracy.ZoneN(@src(), "Main loop");
|
|
||||||
|
|
||||||
var t2 = zglfw.getTime();
|
|
||||||
|
|
||||||
while (!window.shouldClose()) {
|
|
||||||
ztracy.FrameMark();
|
|
||||||
|
|
||||||
fba.reset();
|
|
||||||
|
|
||||||
const t1 = zglfw.getTime();
|
|
||||||
const dt: f32 = @floatCast(@max(t2 - t1, min_frametime));
|
|
||||||
t2 = t1;
|
|
||||||
|
|
||||||
zglfw.pollEvents();
|
|
||||||
zgui.backend.newFrame(
|
|
||||||
gctx.swapchain_descriptor.width,
|
|
||||||
gctx.swapchain_descriptor.height,
|
|
||||||
);
|
|
||||||
|
|
||||||
game.update(dt);
|
|
||||||
|
|
||||||
const swapchain_texture_view = gctx.swapchain.getCurrentTextureView();
|
|
||||||
defer swapchain_texture_view.release();
|
|
||||||
|
|
||||||
const commands = commands: {
|
|
||||||
const encoder = gctx.device.createCommandEncoder(null);
|
|
||||||
defer encoder.release();
|
|
||||||
|
|
||||||
{
|
|
||||||
const pass = zgpu.beginRenderPassSimple(
|
|
||||||
encoder,
|
|
||||||
.load,
|
|
||||||
swapchain_texture_view,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
);
|
|
||||||
defer zgpu.endReleasePass(pass);
|
|
||||||
zgui.backend.draw(pass);
|
|
||||||
}
|
|
||||||
|
|
||||||
break :commands encoder.finish(null);
|
|
||||||
};
|
|
||||||
defer commands.release();
|
|
||||||
|
|
||||||
gctx.submit(&.{commands});
|
|
||||||
_ = gctx.present();
|
|
||||||
}
|
|
||||||
|
|
||||||
zone_main_loop.End();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn logFn(
|
|
||||||
comptime level: std.log.Level,
|
|
||||||
comptime _: @Type(.enum_literal),
|
|
||||||
comptime fmt: []const u8,
|
|
||||||
args: anytype,
|
|
||||||
) void {
|
|
||||||
const message = std.fmt.allocPrint(allocator, fmt, args) catch return;
|
|
||||||
logs.append(allocator, Log.init(level, message)) catch {
|
|
||||||
allocator.free(message);
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
22
vendor/zgpu/LICENSE
vendored
22
vendor/zgpu/LICENSE
vendored
@@ -1,22 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2022 Michal Ziulek
|
|
||||||
Copyright (c) 2024 zig-gamedev contributors
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
183
vendor/zgpu/README.md
vendored
183
vendor/zgpu/README.md
vendored
@@ -1,183 +0,0 @@
|
|||||||
# [zgpu](https://github.com/zig-gamedev/zgpu)
|
|
||||||
|
|
||||||
Cross-platform graphics lib for Zig built on top of [Dawn](https://github.com/zig-gamedev/dawn) native WebGPU implementation.
|
|
||||||
|
|
||||||
Supports Windows 10+ (DirectX 12), macOS 12+ (Metal) and Linux (Vulkan).
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- Zero-overhead wgpu API bindings ([source code](https://github.com/zig-gamedev/zgpu/blob/main/src/wgpu.zig))
|
|
||||||
- Uniform buffer pool for fast CPU->GPU transfers
|
|
||||||
- Resource pools and handle-based GPU resources
|
|
||||||
- Async shader compilation
|
|
||||||
- GPU mipmap generator
|
|
||||||
|
|
||||||
## Getting started
|
|
||||||
|
|
||||||
Example `build.zig`:
|
|
||||||
|
|
||||||
```zig
|
|
||||||
pub fn build(b: *std.Build) void {
|
|
||||||
const exe = b.addExecutable(.{ ... });
|
|
||||||
|
|
||||||
@import("zgpu").addLibraryPathsTo(exe);
|
|
||||||
|
|
||||||
const zgpu = b.dependency("zgpu", .{});
|
|
||||||
exe.root_module.addImport("zgpu", zgpu.module("root"));
|
|
||||||
|
|
||||||
if (target.result.os.tag != .emscripten) {
|
|
||||||
exe.linkLibrary(zgpu.artifact("zdawn"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Sample applications
|
|
||||||
|
|
||||||
- [gui test (wgpu)](https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/gui_test_wgpu)
|
|
||||||
- [physically based rendering (wgpu)](https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/physically_based_rendering_wgpu)
|
|
||||||
- [bullet physics test (wgpu)](https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/bullet_physics_test_wgpu)
|
|
||||||
- [procedural mesh (wgpu)](https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/procedural_mesh_wgpu)
|
|
||||||
- [textured quad (wgpu)](https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/textured_quad_wgpu)
|
|
||||||
- [triangle (wgpu)](https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/triangle_wgpu)
|
|
||||||
|
|
||||||
## Library overview
|
|
||||||
|
|
||||||
Below you can find an overview of main `zgpu` features.
|
|
||||||
|
|
||||||
### Compile-time options
|
|
||||||
|
|
||||||
You can override default options in your `build.zig`:
|
|
||||||
|
|
||||||
```zig
|
|
||||||
pub fn build(b: *std.Build) void {
|
|
||||||
...
|
|
||||||
|
|
||||||
const zgpu = @import("zgpu").package(b, target, optimize, .{
|
|
||||||
.options = .{
|
|
||||||
.uniforms_buffer_size = 4 * 1024 * 1024,
|
|
||||||
.dawn_skip_validation = false,
|
|
||||||
.buffer_pool_size = 256,
|
|
||||||
.texture_pool_size = 256,
|
|
||||||
.texture_view_pool_size = 256,
|
|
||||||
.sampler_pool_size = 16,
|
|
||||||
.render_pipeline_pool_size = 128,
|
|
||||||
.compute_pipeline_pool_size = 128,
|
|
||||||
.bind_group_pool_size = 32,
|
|
||||||
.bind_group_layout_pool_size = 32,
|
|
||||||
.pipeline_layout_pool_size = 32,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
zgpu.link(exe);
|
|
||||||
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Graphics Context
|
|
||||||
|
|
||||||
Create a `GraphicsContext` using a `WindowProvider`. For example, using [zglfw](https://github.com/zig-gamedev/zglfw):
|
|
||||||
|
|
||||||
```zig
|
|
||||||
const gctx = try zgpu.GraphicsContext.create(
|
|
||||||
allocator,
|
|
||||||
.{
|
|
||||||
.window = window,
|
|
||||||
.fn_getTime = @ptrCast(&zglfw.getTime),
|
|
||||||
.fn_getFramebufferSize = @ptrCast(&zglfw.Window.getFramebufferSize),
|
|
||||||
|
|
||||||
// optional fields
|
|
||||||
.fn_getWin32Window = @ptrCast(&zglfw.getWin32Window),
|
|
||||||
.fn_getX11Display = @ptrCast(&zglfw.getX11Display),
|
|
||||||
.fn_getX11Window = @ptrCast(&zglfw.getX11Window),
|
|
||||||
.fn_getWaylandDisplay = @ptrCast(&zglfw.getWaylandDisplay),
|
|
||||||
.fn_getWaylandSurface = @ptrCast(&zglfw.getWaylandWindow),
|
|
||||||
.fn_getCocoaWindow = @ptrCast(&zglfw.getCocoaWindow),
|
|
||||||
},
|
|
||||||
.{}, // default context creation options
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
### Uniforms
|
|
||||||
|
|
||||||
- Implemented as a uniform buffer pool
|
|
||||||
- Easy to use
|
|
||||||
- Efficient - only one copy operation per frame
|
|
||||||
|
|
||||||
```zig
|
|
||||||
struct DrawUniforms = extern struct {
|
|
||||||
object_to_world: zm.Mat,
|
|
||||||
};
|
|
||||||
const mem = gctx.uniformsAllocate(DrawUniforms, 1);
|
|
||||||
mem.slice[0] = .{ .object_to_world = zm.transpose(zm.translation(...)) };
|
|
||||||
|
|
||||||
pass.setBindGroup(0, bind_group, &.{mem.offset});
|
|
||||||
pass.drawIndexed(...);
|
|
||||||
|
|
||||||
// When you are done encoding all commands for a frame:
|
|
||||||
gctx.submit(...); // Injects *one* copy operation to transfer *all* allocated uniforms
|
|
||||||
```
|
|
||||||
|
|
||||||
### Resource pools
|
|
||||||
|
|
||||||
- Every GPU resource is identified by 32-bit integer handle
|
|
||||||
- All resources are stored in one system
|
|
||||||
- We keep basic info about each resource (size of the buffer, format of the texture, etc.)
|
|
||||||
- You can always check if resource is valid (very useful for async operations)
|
|
||||||
- System keeps basic info about resource dependencies, for example, `TextureViewHandle` knows about its
|
|
||||||
parent texture and becomes invalid when parent texture becomes invalid; `BindGroupHandle` knows
|
|
||||||
about all resources it binds so it becomes invalid if any of those resources become invalid
|
|
||||||
|
|
||||||
```zig
|
|
||||||
const buffer_handle = gctx.createBuffer(...);
|
|
||||||
|
|
||||||
if (gctx.isResourceValid(buffer_handle)) {
|
|
||||||
const buffer = gctx.lookupResource(buffer_handle).?; // Returns `wgpu.Buffer`
|
|
||||||
|
|
||||||
const buffer_info = gctx.lookupResourceInfo(buffer_handle).?; // Returns `zgpu.BufferInfo`
|
|
||||||
std.debug.print("Buffer size is: {d}", .{buffer_info.size});
|
|
||||||
}
|
|
||||||
|
|
||||||
// If you want to destroy a resource before shutting down graphics context:
|
|
||||||
gctx.destroyResource(buffer_handle);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
### Async shader compilation
|
|
||||||
|
|
||||||
- Thanks to resource pools and resources identified by handles we can easily async compile all our shaders
|
|
||||||
|
|
||||||
```zig
|
|
||||||
const DemoState = struct {
|
|
||||||
pipeline_handle: zgpu.PipelineLayoutHandle = .{},
|
|
||||||
...
|
|
||||||
};
|
|
||||||
const demo = try allocator.create(DemoState);
|
|
||||||
|
|
||||||
// Below call schedules pipeline compilation and returns immediately. When compilation is complete
|
|
||||||
// valid pipeline handle will be stored in `demo.pipeline_handle`.
|
|
||||||
gctx.createRenderPipelineAsync(allocator, pipeline_layout, pipeline_descriptor, &demo.pipeline_handle);
|
|
||||||
|
|
||||||
// Pass using our pipeline will be skipped until compilation is ready
|
|
||||||
pass: {
|
|
||||||
const pipeline = gctx.lookupResource(demo.pipeline_handle) orelse break :pass;
|
|
||||||
...
|
|
||||||
|
|
||||||
pass.setPipeline(pipeline);
|
|
||||||
pass.drawIndexed(...);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Mipmap generation on the GPU
|
|
||||||
|
|
||||||
- wgpu API does not provide mipmap generator
|
|
||||||
- zgpu provides decent mipmap generator implemented in a compute shader
|
|
||||||
- It supports 2D textures, array textures and cubemap textures of any format
|
|
||||||
(`rgba8_unorm`, `rg16_float`, `rgba32_float`, etc.)
|
|
||||||
- Currently it requires that: `texture_width == texture_height and isPowerOfTwo(texture_width)`
|
|
||||||
- It takes ~260 microsec to generate all mips for 1024x1024 `rgba8_unorm` texture on GTX 1660
|
|
||||||
|
|
||||||
```zig
|
|
||||||
// Usage:
|
|
||||||
gctx.generateMipmaps(arena, command_encoder, texture_handle);
|
|
||||||
```
|
|
||||||
253
vendor/zgpu/build.zig
vendored
253
vendor/zgpu/build.zig
vendored
@@ -1,253 +0,0 @@
|
|||||||
const std = @import("std");
|
|
||||||
const log = std.log.scoped(.zgpu);
|
|
||||||
|
|
||||||
const default_options = struct {
|
|
||||||
const uniforms_buffer_size = 4 * 1024 * 1024;
|
|
||||||
const dawn_skip_validation = false;
|
|
||||||
const dawn_allow_unsafe_apis = false;
|
|
||||||
const buffer_pool_size = 256;
|
|
||||||
const texture_pool_size = 256;
|
|
||||||
const texture_view_pool_size = 256;
|
|
||||||
const sampler_pool_size = 16;
|
|
||||||
const render_pipeline_pool_size = 128;
|
|
||||||
const compute_pipeline_pool_size = 128;
|
|
||||||
const bind_group_pool_size = 32;
|
|
||||||
const bind_group_layout_pool_size = 32;
|
|
||||||
const pipeline_layout_pool_size = 32;
|
|
||||||
const max_num_bindings_per_group = 10;
|
|
||||||
const max_num_bind_groups_per_pipeline = 4;
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
|
||||||
const target = b.standardTargetOptions(.{});
|
|
||||||
|
|
||||||
const options = .{
|
|
||||||
.uniforms_buffer_size = b.option(
|
|
||||||
u64,
|
|
||||||
"uniforms_buffer_size",
|
|
||||||
"Set uniforms buffer size",
|
|
||||||
) orelse default_options.uniforms_buffer_size,
|
|
||||||
.dawn_skip_validation = b.option(
|
|
||||||
bool,
|
|
||||||
"dawn_skip_validation",
|
|
||||||
"Disable Dawn validation",
|
|
||||||
) orelse default_options.dawn_skip_validation,
|
|
||||||
.dawn_allow_unsafe_apis = b.option(
|
|
||||||
bool,
|
|
||||||
"dawn_allow_unsafe_apis",
|
|
||||||
"Allow unsafe WebGPU APIs (e.g. timestamp queries)",
|
|
||||||
) orelse default_options.dawn_allow_unsafe_apis,
|
|
||||||
.buffer_pool_size = b.option(
|
|
||||||
u32,
|
|
||||||
"buffer_pool_size",
|
|
||||||
"Set buffer pool size",
|
|
||||||
) orelse default_options.buffer_pool_size,
|
|
||||||
.texture_pool_size = b.option(
|
|
||||||
u32,
|
|
||||||
"texture_pool_size",
|
|
||||||
"Set texture pool size",
|
|
||||||
) orelse default_options.texture_pool_size,
|
|
||||||
.texture_view_pool_size = b.option(
|
|
||||||
u32,
|
|
||||||
"texture_view_pool_size",
|
|
||||||
"Set texture view pool size",
|
|
||||||
) orelse default_options.texture_view_pool_size,
|
|
||||||
.sampler_pool_size = b.option(
|
|
||||||
u32,
|
|
||||||
"sampler_pool_size",
|
|
||||||
"Set sample pool size",
|
|
||||||
) orelse default_options.sampler_pool_size,
|
|
||||||
.render_pipeline_pool_size = b.option(
|
|
||||||
u32,
|
|
||||||
"render_pipeline_pool_size",
|
|
||||||
"Set render pipeline pool size",
|
|
||||||
) orelse default_options.render_pipeline_pool_size,
|
|
||||||
.compute_pipeline_pool_size = b.option(
|
|
||||||
u32,
|
|
||||||
"compute_pipeline_pool_size",
|
|
||||||
"Set compute pipeline pool size",
|
|
||||||
) orelse default_options.compute_pipeline_pool_size,
|
|
||||||
.bind_group_pool_size = b.option(
|
|
||||||
u32,
|
|
||||||
"bind_group_pool_size",
|
|
||||||
"Set bind group pool size",
|
|
||||||
) orelse default_options.bind_group_pool_size,
|
|
||||||
.bind_group_layout_pool_size = b.option(
|
|
||||||
u32,
|
|
||||||
"bind_group_layout_pool_size",
|
|
||||||
"Set bind group layout pool size",
|
|
||||||
) orelse default_options.bind_group_layout_pool_size,
|
|
||||||
.pipeline_layout_pool_size = b.option(
|
|
||||||
u32,
|
|
||||||
"pipeline_layout_pool_size",
|
|
||||||
"Set pipeline layout pool size",
|
|
||||||
) orelse default_options.pipeline_layout_pool_size,
|
|
||||||
.max_num_bindings_per_group = b.option(
|
|
||||||
u32,
|
|
||||||
"max_num_bindings_per_group",
|
|
||||||
"Set maximum number of bindings per bind group",
|
|
||||||
) orelse default_options.max_num_bindings_per_group,
|
|
||||||
.max_num_bind_groups_per_pipeline = b.option(
|
|
||||||
u32,
|
|
||||||
"max_num_bind_groups_per_pipeline",
|
|
||||||
"Set maximum number of bindings groups per pipeline",
|
|
||||||
) orelse default_options.max_num_bind_groups_per_pipeline,
|
|
||||||
};
|
|
||||||
|
|
||||||
const options_step = b.addOptions();
|
|
||||||
inline for (std.meta.fields(@TypeOf(options))) |field| {
|
|
||||||
options_step.addOption(field.type, field.name, @field(options, field.name));
|
|
||||||
}
|
|
||||||
|
|
||||||
const options_module = options_step.createModule();
|
|
||||||
|
|
||||||
_ = b.addModule("root", .{
|
|
||||||
.root_source_file = b.path("src/zgpu.zig"),
|
|
||||||
.imports = &.{
|
|
||||||
.{ .name = "zgpu_options", .module = options_module },
|
|
||||||
.{ .name = "zpool", .module = b.dependency("zpool", .{}).module("root") },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const zdawn = b.addStaticLibrary(.{
|
|
||||||
.name = "zdawn",
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
});
|
|
||||||
b.installArtifact(zdawn);
|
|
||||||
|
|
||||||
linkSystemDeps(b, zdawn);
|
|
||||||
addLibraryPathsTo(zdawn);
|
|
||||||
|
|
||||||
zdawn.linkSystemLibrary("dawn");
|
|
||||||
zdawn.linkLibC();
|
|
||||||
if (target.result.abi != .msvc)
|
|
||||||
zdawn.linkLibCpp();
|
|
||||||
|
|
||||||
zdawn.addIncludePath(b.path("libs/dawn/include"));
|
|
||||||
zdawn.addIncludePath(b.path("src"));
|
|
||||||
|
|
||||||
zdawn.addCSourceFile(.{
|
|
||||||
.file = b.path("src/dawn.cpp"),
|
|
||||||
.flags = &.{ "-std=c++17", "-fno-sanitize=undefined" },
|
|
||||||
});
|
|
||||||
zdawn.addCSourceFile(.{
|
|
||||||
.file = b.path("src/dawn_proc.c"),
|
|
||||||
.flags = &.{"-fno-sanitize=undefined"},
|
|
||||||
});
|
|
||||||
|
|
||||||
const test_step = b.step("test", "Run zgpu tests");
|
|
||||||
|
|
||||||
const tests = b.addTest(.{
|
|
||||||
.name = "zgpu-tests",
|
|
||||||
.root_source_file = b.path("src/zgpu.zig"),
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
});
|
|
||||||
tests.addIncludePath(b.path("libs/dawn/include"));
|
|
||||||
tests.linkLibrary(zdawn);
|
|
||||||
linkSystemDeps(b, tests);
|
|
||||||
addLibraryPathsTo(tests);
|
|
||||||
b.installArtifact(tests);
|
|
||||||
|
|
||||||
test_step.dependOn(&b.addRunArtifact(tests).step);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn linkSystemDeps(b: *std.Build, compile_step: *std.Build.Step.Compile) void {
|
|
||||||
switch (compile_step.rootModuleTarget().os.tag) {
|
|
||||||
.windows => {
|
|
||||||
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
|
|
||||||
compile_step.addLibraryPath(system_sdk.path("windows/lib/x86_64-windows-gnu"));
|
|
||||||
}
|
|
||||||
compile_step.linkSystemLibrary("ole32");
|
|
||||||
compile_step.linkSystemLibrary("dxguid");
|
|
||||||
},
|
|
||||||
.macos => {
|
|
||||||
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
|
|
||||||
compile_step.addLibraryPath(system_sdk.path("macos12/usr/lib"));
|
|
||||||
compile_step.addFrameworkPath(system_sdk.path("macos12/System/Library/Frameworks"));
|
|
||||||
}
|
|
||||||
compile_step.linkSystemLibrary("objc");
|
|
||||||
compile_step.linkFramework("Metal");
|
|
||||||
compile_step.linkFramework("CoreGraphics");
|
|
||||||
compile_step.linkFramework("Foundation");
|
|
||||||
compile_step.linkFramework("IOKit");
|
|
||||||
compile_step.linkFramework("IOSurface");
|
|
||||||
compile_step.linkFramework("QuartzCore");
|
|
||||||
},
|
|
||||||
else => {},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn addLibraryPathsTo(compile_step: *std.Build.Step.Compile) void {
|
|
||||||
const b = compile_step.step.owner;
|
|
||||||
const target = compile_step.rootModuleTarget();
|
|
||||||
switch (target.os.tag) {
|
|
||||||
.windows => {
|
|
||||||
if (b.lazyDependency("dawn_x86_64_windows_gnu", .{})) |dawn_prebuilt| {
|
|
||||||
compile_step.addLibraryPath(dawn_prebuilt.path(""));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.linux => {
|
|
||||||
if (target.cpu.arch.isX86()) {
|
|
||||||
if (b.lazyDependency("dawn_x86_64_linux_gnu", .{})) |dawn_prebuilt| {
|
|
||||||
compile_step.addLibraryPath(dawn_prebuilt.path(""));
|
|
||||||
}
|
|
||||||
} else if (target.cpu.arch.isAARCH64()) {
|
|
||||||
if (b.lazyDependency("dawn_aarch64_linux_gnu", .{})) |dawn_prebuilt| {
|
|
||||||
compile_step.addLibraryPath(dawn_prebuilt.path(""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.macos => {
|
|
||||||
if (target.cpu.arch.isX86()) {
|
|
||||||
if (b.lazyDependency("dawn_x86_64_macos", .{})) |dawn_prebuilt| {
|
|
||||||
compile_step.addLibraryPath(dawn_prebuilt.path(""));
|
|
||||||
}
|
|
||||||
} else if (target.cpu.arch.isAARCH64()) {
|
|
||||||
if (b.lazyDependency("dawn_aarch64_macos", .{})) |dawn_prebuilt| {
|
|
||||||
compile_step.addLibraryPath(dawn_prebuilt.path(""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
else => {},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn checkTargetSupported(target: std.Target) bool {
|
|
||||||
const supported = switch (target.os.tag) {
|
|
||||||
.windows => target.cpu.arch.isX86() and target.abi.isGnu(),
|
|
||||||
.linux => (target.cpu.arch.isX86() or target.cpu.arch.isAARCH64()) and target.abi.isGnu(),
|
|
||||||
.macos => blk: {
|
|
||||||
if (!target.cpu.arch.isX86() and !target.cpu.arch.isAARCH64()) break :blk false;
|
|
||||||
|
|
||||||
// If min. target macOS version is lesser than the min version we have available, then
|
|
||||||
// our Dawn binary is incompatible with the target.
|
|
||||||
if (target.os.version_range.semver.min.order(
|
|
||||||
.{ .major = 12, .minor = 0, .patch = 0 },
|
|
||||||
) == .lt) break :blk false;
|
|
||||||
break :blk true;
|
|
||||||
},
|
|
||||||
else => false,
|
|
||||||
};
|
|
||||||
if (supported == false) {
|
|
||||||
log.warn("\n" ++
|
|
||||||
\\---------------------------------------------------------------------------
|
|
||||||
\\
|
|
||||||
\\Dawn/WebGPU binary for this target is not available.
|
|
||||||
\\
|
|
||||||
\\Following targets are supported:
|
|
||||||
\\
|
|
||||||
\\x86_64-windows-gnu
|
|
||||||
\\x86_64-linux-gnu
|
|
||||||
\\x86_64-macos.12.0.0-none
|
|
||||||
\\aarch64-linux-gnu
|
|
||||||
\\aarch64-macos.12.0.0-none
|
|
||||||
\\
|
|
||||||
\\---------------------------------------------------------------------------
|
|
||||||
\\
|
|
||||||
, .{});
|
|
||||||
}
|
|
||||||
return supported;
|
|
||||||
}
|
|
||||||
48
vendor/zgpu/build.zig.zon
vendored
48
vendor/zgpu/build.zig.zon
vendored
@@ -1,48 +0,0 @@
|
|||||||
.{
|
|
||||||
.name = "zgpu",
|
|
||||||
.version = "0.12.0-dev",
|
|
||||||
.paths = .{
|
|
||||||
"build.zig",
|
|
||||||
"build.zig.zon",
|
|
||||||
"libs",
|
|
||||||
"src",
|
|
||||||
"README.md",
|
|
||||||
"LICENSE",
|
|
||||||
},
|
|
||||||
.dependencies = .{
|
|
||||||
// Needed to be vendored due to breaking changes in zig's type info
|
|
||||||
// structs, which upstream hasn't caught up to.
|
|
||||||
.zpool = .{
|
|
||||||
.path = "../zpool",
|
|
||||||
},
|
|
||||||
.system_sdk = .{
|
|
||||||
.url = "https://github.com/zig-gamedev/system_sdk/archive/bf49d627a191e339f70e72668c8333717fb969b0.tar.gz",
|
|
||||||
.hash = "122047a9298c4c9dd43389d418d6826d469b192246ba0944102964cdc57f94c562df",
|
|
||||||
},
|
|
||||||
.dawn_x86_64_windows_gnu = .{
|
|
||||||
.url = "https://github.com/michal-z/webgpu_dawn-x86_64-windows-gnu/archive/d3a68014e6b6b53fd330a0ccba99e4dcfffddae5.tar.gz",
|
|
||||||
.hash = "1220f9448cde02ef3cd51bde2e0850d4489daa0541571d748154e89c6eb46c76a267",
|
|
||||||
.lazy = true,
|
|
||||||
},
|
|
||||||
.dawn_x86_64_linux_gnu = .{
|
|
||||||
.url = "https://github.com/michal-z/webgpu_dawn-x86_64-linux-gnu/archive/7d70db023bf254546024629cbec5ee6113e12a42.tar.gz",
|
|
||||||
.hash = "12204a3519efd49ea2d7cf63b544492a3a771d37eda320f86380813376801e4cfa73",
|
|
||||||
.lazy = true,
|
|
||||||
},
|
|
||||||
.dawn_aarch64_linux_gnu = .{
|
|
||||||
.url = "https://github.com/michal-z/webgpu_dawn-aarch64-linux-gnu/archive/c1f55e740a62f6942ff046e709ecd509a005dbeb.tar.gz",
|
|
||||||
.hash = "12205cd13f6849f94ef7688ee88c6b74c7918a5dfb514f8a403fcc2929a0aa342627",
|
|
||||||
.lazy = true,
|
|
||||||
},
|
|
||||||
.dawn_aarch64_macos = .{
|
|
||||||
.url = "https://github.com/michal-z/webgpu_dawn-aarch64-macos/archive/d2360cdfff0cf4a780cb77aa47c57aca03cc6dfe.tar.gz",
|
|
||||||
.hash = "12201fe677e9c7cfb8984a36446b329d5af23d03dc1e4f79a853399529e523a007fa",
|
|
||||||
.lazy = true,
|
|
||||||
},
|
|
||||||
.dawn_x86_64_macos = .{
|
|
||||||
.url = "https://github.com/michal-z/webgpu_dawn-x86_64-macos/archive/901716b10b31ce3e0d3fe479326b41e91d59c661.tar.gz",
|
|
||||||
.hash = "1220b1f02f2f7edd98a078c64e3100907d90311d94880a3cc5927e1ac009d002667a",
|
|
||||||
.lazy = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,148 +0,0 @@
|
|||||||
// Copyright 2017 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_ENUMCLASSBITMASKS_H_
|
|
||||||
#define INCLUDE_DAWN_ENUMCLASSBITMASKS_H_
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
// The operators in dawn:: namespace need be introduced into other namespaces with
|
|
||||||
// using-declarations for C++ Argument Dependent Lookup to work.
|
|
||||||
#define DAWN_IMPORT_BITMASK_OPERATORS \
|
|
||||||
using dawn::operator|; \
|
|
||||||
using dawn::operator&; \
|
|
||||||
using dawn::operator^; \
|
|
||||||
using dawn::operator~; \
|
|
||||||
using dawn::operator&=; \
|
|
||||||
using dawn::operator|=; \
|
|
||||||
using dawn::operator^=; \
|
|
||||||
using dawn::HasZeroOrOneBits;
|
|
||||||
|
|
||||||
namespace dawn {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct IsDawnBitmask {
|
|
||||||
static constexpr bool enable = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, typename Enable = void>
|
|
||||||
struct LowerBitmask {
|
|
||||||
static constexpr bool enable = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct LowerBitmask<T, typename std::enable_if<IsDawnBitmask<T>::enable>::type> {
|
|
||||||
static constexpr bool enable = true;
|
|
||||||
using type = T;
|
|
||||||
constexpr static T Lower(T t) { return t; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct BoolConvertible {
|
|
||||||
using Integral = typename std::underlying_type<T>::type;
|
|
||||||
|
|
||||||
// NOLINTNEXTLINE(runtime/explicit)
|
|
||||||
explicit constexpr BoolConvertible(Integral value) : value(value) {}
|
|
||||||
constexpr operator bool() const { return value != 0; }
|
|
||||||
constexpr operator T() const { return static_cast<T>(value); }
|
|
||||||
|
|
||||||
Integral value;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct LowerBitmask<BoolConvertible<T>> {
|
|
||||||
static constexpr bool enable = true;
|
|
||||||
using type = T;
|
|
||||||
static constexpr type Lower(BoolConvertible<T> t) { return t; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <
|
|
||||||
typename T1,
|
|
||||||
typename T2,
|
|
||||||
typename = typename std::enable_if<LowerBitmask<T1>::enable && LowerBitmask<T2>::enable>::type>
|
|
||||||
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator|(T1 left, T2 right) {
|
|
||||||
using T = typename LowerBitmask<T1>::type;
|
|
||||||
using Integral = typename std::underlying_type<T>::type;
|
|
||||||
return BoolConvertible<T>(static_cast<Integral>(LowerBitmask<T1>::Lower(left)) |
|
|
||||||
static_cast<Integral>(LowerBitmask<T2>::Lower(right)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <
|
|
||||||
typename T1,
|
|
||||||
typename T2,
|
|
||||||
typename = typename std::enable_if<LowerBitmask<T1>::enable && LowerBitmask<T2>::enable>::type>
|
|
||||||
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator&(T1 left, T2 right) {
|
|
||||||
using T = typename LowerBitmask<T1>::type;
|
|
||||||
using Integral = typename std::underlying_type<T>::type;
|
|
||||||
return BoolConvertible<T>(static_cast<Integral>(LowerBitmask<T1>::Lower(left)) &
|
|
||||||
static_cast<Integral>(LowerBitmask<T2>::Lower(right)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <
|
|
||||||
typename T1,
|
|
||||||
typename T2,
|
|
||||||
typename = typename std::enable_if<LowerBitmask<T1>::enable && LowerBitmask<T2>::enable>::type>
|
|
||||||
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator^(T1 left, T2 right) {
|
|
||||||
using T = typename LowerBitmask<T1>::type;
|
|
||||||
using Integral = typename std::underlying_type<T>::type;
|
|
||||||
return BoolConvertible<T>(static_cast<Integral>(LowerBitmask<T1>::Lower(left)) ^
|
|
||||||
static_cast<Integral>(LowerBitmask<T2>::Lower(right)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T1>
|
|
||||||
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator~(T1 t) {
|
|
||||||
using T = typename LowerBitmask<T1>::type;
|
|
||||||
using Integral = typename std::underlying_type<T>::type;
|
|
||||||
return BoolConvertible<T>(~static_cast<Integral>(LowerBitmask<T1>::Lower(t)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <
|
|
||||||
typename T,
|
|
||||||
typename T2,
|
|
||||||
typename = typename std::enable_if<IsDawnBitmask<T>::enable && LowerBitmask<T2>::enable>::type>
|
|
||||||
constexpr T& operator&=(T& l, T2 right) {
|
|
||||||
T r = LowerBitmask<T2>::Lower(right);
|
|
||||||
l = l & r;
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <
|
|
||||||
typename T,
|
|
||||||
typename T2,
|
|
||||||
typename = typename std::enable_if<IsDawnBitmask<T>::enable && LowerBitmask<T2>::enable>::type>
|
|
||||||
constexpr T& operator|=(T& l, T2 right) {
|
|
||||||
T r = LowerBitmask<T2>::Lower(right);
|
|
||||||
l = l | r;
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <
|
|
||||||
typename T,
|
|
||||||
typename T2,
|
|
||||||
typename = typename std::enable_if<IsDawnBitmask<T>::enable && LowerBitmask<T2>::enable>::type>
|
|
||||||
constexpr T& operator^=(T& l, T2 right) {
|
|
||||||
T r = LowerBitmask<T2>::Lower(right);
|
|
||||||
l = l ^ r;
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
constexpr bool HasZeroOrOneBits(T value) {
|
|
||||||
using Integral = typename std::underlying_type<T>::type;
|
|
||||||
return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace dawn
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_ENUMCLASSBITMASKS_H_
|
|
||||||
36
vendor/zgpu/libs/dawn/include/dawn/dawn_proc.h
vendored
36
vendor/zgpu/libs/dawn/include/dawn/dawn_proc.h
vendored
@@ -1,36 +0,0 @@
|
|||||||
// Copyright 2019 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_DAWN_PROC_H_
|
|
||||||
#define INCLUDE_DAWN_DAWN_PROC_H_
|
|
||||||
|
|
||||||
#include "dawn/dawn_proc_table.h"
|
|
||||||
#include "dawn/webgpu.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Sets the static proctable used by libdawn_proc to implement the Dawn entrypoints. Passing NULL
|
|
||||||
// for `procs` sets up the null proctable that contains only null function pointers. It is the
|
|
||||||
// default value of the proctable. Setting the proctable back to null is good practice when you
|
|
||||||
// are done using libdawn_proc since further usage will cause a segfault instead of calling an
|
|
||||||
// unexpected function.
|
|
||||||
WGPU_EXPORT void dawnProcSetProcs(const DawnProcTable* procs);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} // extern "C"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_DAWN_PROC_H_
|
|
||||||
245
vendor/zgpu/libs/dawn/include/dawn/dawn_proc_table.h
vendored
245
vendor/zgpu/libs/dawn/include/dawn/dawn_proc_table.h
vendored
@@ -1,245 +0,0 @@
|
|||||||
|
|
||||||
#ifndef DAWN_DAWN_PROC_TABLE_H_
|
|
||||||
#define DAWN_DAWN_PROC_TABLE_H_
|
|
||||||
|
|
||||||
#include "dawn/webgpu.h"
|
|
||||||
|
|
||||||
// Note: Often allocated as a static global. Do not add a complex constructor.
|
|
||||||
typedef struct DawnProcTable {
|
|
||||||
WGPUProcCreateInstance createInstance;
|
|
||||||
WGPUProcGetProcAddress getProcAddress;
|
|
||||||
|
|
||||||
WGPUProcAdapterCreateDevice adapterCreateDevice;
|
|
||||||
WGPUProcAdapterEnumerateFeatures adapterEnumerateFeatures;
|
|
||||||
WGPUProcAdapterGetInstance adapterGetInstance;
|
|
||||||
WGPUProcAdapterGetLimits adapterGetLimits;
|
|
||||||
WGPUProcAdapterGetProperties adapterGetProperties;
|
|
||||||
WGPUProcAdapterHasFeature adapterHasFeature;
|
|
||||||
WGPUProcAdapterRequestDevice adapterRequestDevice;
|
|
||||||
WGPUProcAdapterReference adapterReference;
|
|
||||||
WGPUProcAdapterRelease adapterRelease;
|
|
||||||
|
|
||||||
WGPUProcBindGroupSetLabel bindGroupSetLabel;
|
|
||||||
WGPUProcBindGroupReference bindGroupReference;
|
|
||||||
WGPUProcBindGroupRelease bindGroupRelease;
|
|
||||||
|
|
||||||
WGPUProcBindGroupLayoutSetLabel bindGroupLayoutSetLabel;
|
|
||||||
WGPUProcBindGroupLayoutReference bindGroupLayoutReference;
|
|
||||||
WGPUProcBindGroupLayoutRelease bindGroupLayoutRelease;
|
|
||||||
|
|
||||||
WGPUProcBufferDestroy bufferDestroy;
|
|
||||||
WGPUProcBufferGetConstMappedRange bufferGetConstMappedRange;
|
|
||||||
WGPUProcBufferGetMapState bufferGetMapState;
|
|
||||||
WGPUProcBufferGetMappedRange bufferGetMappedRange;
|
|
||||||
WGPUProcBufferGetSize bufferGetSize;
|
|
||||||
WGPUProcBufferGetUsage bufferGetUsage;
|
|
||||||
WGPUProcBufferMapAsync bufferMapAsync;
|
|
||||||
WGPUProcBufferSetLabel bufferSetLabel;
|
|
||||||
WGPUProcBufferUnmap bufferUnmap;
|
|
||||||
WGPUProcBufferReference bufferReference;
|
|
||||||
WGPUProcBufferRelease bufferRelease;
|
|
||||||
|
|
||||||
WGPUProcCommandBufferSetLabel commandBufferSetLabel;
|
|
||||||
WGPUProcCommandBufferReference commandBufferReference;
|
|
||||||
WGPUProcCommandBufferRelease commandBufferRelease;
|
|
||||||
|
|
||||||
WGPUProcCommandEncoderBeginComputePass commandEncoderBeginComputePass;
|
|
||||||
WGPUProcCommandEncoderBeginRenderPass commandEncoderBeginRenderPass;
|
|
||||||
WGPUProcCommandEncoderClearBuffer commandEncoderClearBuffer;
|
|
||||||
WGPUProcCommandEncoderCopyBufferToBuffer commandEncoderCopyBufferToBuffer;
|
|
||||||
WGPUProcCommandEncoderCopyBufferToTexture commandEncoderCopyBufferToTexture;
|
|
||||||
WGPUProcCommandEncoderCopyTextureToBuffer commandEncoderCopyTextureToBuffer;
|
|
||||||
WGPUProcCommandEncoderCopyTextureToTexture commandEncoderCopyTextureToTexture;
|
|
||||||
WGPUProcCommandEncoderCopyTextureToTextureInternal commandEncoderCopyTextureToTextureInternal;
|
|
||||||
WGPUProcCommandEncoderFinish commandEncoderFinish;
|
|
||||||
WGPUProcCommandEncoderInjectValidationError commandEncoderInjectValidationError;
|
|
||||||
WGPUProcCommandEncoderInsertDebugMarker commandEncoderInsertDebugMarker;
|
|
||||||
WGPUProcCommandEncoderPopDebugGroup commandEncoderPopDebugGroup;
|
|
||||||
WGPUProcCommandEncoderPushDebugGroup commandEncoderPushDebugGroup;
|
|
||||||
WGPUProcCommandEncoderResolveQuerySet commandEncoderResolveQuerySet;
|
|
||||||
WGPUProcCommandEncoderSetLabel commandEncoderSetLabel;
|
|
||||||
WGPUProcCommandEncoderWriteBuffer commandEncoderWriteBuffer;
|
|
||||||
WGPUProcCommandEncoderWriteTimestamp commandEncoderWriteTimestamp;
|
|
||||||
WGPUProcCommandEncoderReference commandEncoderReference;
|
|
||||||
WGPUProcCommandEncoderRelease commandEncoderRelease;
|
|
||||||
|
|
||||||
WGPUProcComputePassEncoderDispatchWorkgroups computePassEncoderDispatchWorkgroups;
|
|
||||||
WGPUProcComputePassEncoderDispatchWorkgroupsIndirect computePassEncoderDispatchWorkgroupsIndirect;
|
|
||||||
WGPUProcComputePassEncoderEnd computePassEncoderEnd;
|
|
||||||
WGPUProcComputePassEncoderInsertDebugMarker computePassEncoderInsertDebugMarker;
|
|
||||||
WGPUProcComputePassEncoderPopDebugGroup computePassEncoderPopDebugGroup;
|
|
||||||
WGPUProcComputePassEncoderPushDebugGroup computePassEncoderPushDebugGroup;
|
|
||||||
WGPUProcComputePassEncoderSetBindGroup computePassEncoderSetBindGroup;
|
|
||||||
WGPUProcComputePassEncoderSetLabel computePassEncoderSetLabel;
|
|
||||||
WGPUProcComputePassEncoderSetPipeline computePassEncoderSetPipeline;
|
|
||||||
WGPUProcComputePassEncoderWriteTimestamp computePassEncoderWriteTimestamp;
|
|
||||||
WGPUProcComputePassEncoderReference computePassEncoderReference;
|
|
||||||
WGPUProcComputePassEncoderRelease computePassEncoderRelease;
|
|
||||||
|
|
||||||
WGPUProcComputePipelineGetBindGroupLayout computePipelineGetBindGroupLayout;
|
|
||||||
WGPUProcComputePipelineSetLabel computePipelineSetLabel;
|
|
||||||
WGPUProcComputePipelineReference computePipelineReference;
|
|
||||||
WGPUProcComputePipelineRelease computePipelineRelease;
|
|
||||||
|
|
||||||
WGPUProcDeviceCreateBindGroup deviceCreateBindGroup;
|
|
||||||
WGPUProcDeviceCreateBindGroupLayout deviceCreateBindGroupLayout;
|
|
||||||
WGPUProcDeviceCreateBuffer deviceCreateBuffer;
|
|
||||||
WGPUProcDeviceCreateCommandEncoder deviceCreateCommandEncoder;
|
|
||||||
WGPUProcDeviceCreateComputePipeline deviceCreateComputePipeline;
|
|
||||||
WGPUProcDeviceCreateComputePipelineAsync deviceCreateComputePipelineAsync;
|
|
||||||
WGPUProcDeviceCreateErrorBuffer deviceCreateErrorBuffer;
|
|
||||||
WGPUProcDeviceCreateErrorExternalTexture deviceCreateErrorExternalTexture;
|
|
||||||
WGPUProcDeviceCreateErrorShaderModule deviceCreateErrorShaderModule;
|
|
||||||
WGPUProcDeviceCreateErrorTexture deviceCreateErrorTexture;
|
|
||||||
WGPUProcDeviceCreateExternalTexture deviceCreateExternalTexture;
|
|
||||||
WGPUProcDeviceCreatePipelineLayout deviceCreatePipelineLayout;
|
|
||||||
WGPUProcDeviceCreateQuerySet deviceCreateQuerySet;
|
|
||||||
WGPUProcDeviceCreateRenderBundleEncoder deviceCreateRenderBundleEncoder;
|
|
||||||
WGPUProcDeviceCreateRenderPipeline deviceCreateRenderPipeline;
|
|
||||||
WGPUProcDeviceCreateRenderPipelineAsync deviceCreateRenderPipelineAsync;
|
|
||||||
WGPUProcDeviceCreateSampler deviceCreateSampler;
|
|
||||||
WGPUProcDeviceCreateShaderModule deviceCreateShaderModule;
|
|
||||||
WGPUProcDeviceCreateSwapChain deviceCreateSwapChain;
|
|
||||||
WGPUProcDeviceCreateTexture deviceCreateTexture;
|
|
||||||
WGPUProcDeviceDestroy deviceDestroy;
|
|
||||||
WGPUProcDeviceEnumerateFeatures deviceEnumerateFeatures;
|
|
||||||
WGPUProcDeviceForceLoss deviceForceLoss;
|
|
||||||
WGPUProcDeviceGetAdapter deviceGetAdapter;
|
|
||||||
WGPUProcDeviceGetLimits deviceGetLimits;
|
|
||||||
WGPUProcDeviceGetQueue deviceGetQueue;
|
|
||||||
WGPUProcDeviceGetSupportedSurfaceUsage deviceGetSupportedSurfaceUsage;
|
|
||||||
WGPUProcDeviceHasFeature deviceHasFeature;
|
|
||||||
WGPUProcDeviceInjectError deviceInjectError;
|
|
||||||
WGPUProcDevicePopErrorScope devicePopErrorScope;
|
|
||||||
WGPUProcDevicePushErrorScope devicePushErrorScope;
|
|
||||||
WGPUProcDeviceSetDeviceLostCallback deviceSetDeviceLostCallback;
|
|
||||||
WGPUProcDeviceSetLabel deviceSetLabel;
|
|
||||||
WGPUProcDeviceSetLoggingCallback deviceSetLoggingCallback;
|
|
||||||
WGPUProcDeviceSetUncapturedErrorCallback deviceSetUncapturedErrorCallback;
|
|
||||||
WGPUProcDeviceTick deviceTick;
|
|
||||||
WGPUProcDeviceValidateTextureDescriptor deviceValidateTextureDescriptor;
|
|
||||||
WGPUProcDeviceReference deviceReference;
|
|
||||||
WGPUProcDeviceRelease deviceRelease;
|
|
||||||
|
|
||||||
WGPUProcExternalTextureDestroy externalTextureDestroy;
|
|
||||||
WGPUProcExternalTextureExpire externalTextureExpire;
|
|
||||||
WGPUProcExternalTextureRefresh externalTextureRefresh;
|
|
||||||
WGPUProcExternalTextureSetLabel externalTextureSetLabel;
|
|
||||||
WGPUProcExternalTextureReference externalTextureReference;
|
|
||||||
WGPUProcExternalTextureRelease externalTextureRelease;
|
|
||||||
|
|
||||||
WGPUProcInstanceCreateSurface instanceCreateSurface;
|
|
||||||
WGPUProcInstanceProcessEvents instanceProcessEvents;
|
|
||||||
WGPUProcInstanceRequestAdapter instanceRequestAdapter;
|
|
||||||
WGPUProcInstanceReference instanceReference;
|
|
||||||
WGPUProcInstanceRelease instanceRelease;
|
|
||||||
|
|
||||||
WGPUProcPipelineLayoutSetLabel pipelineLayoutSetLabel;
|
|
||||||
WGPUProcPipelineLayoutReference pipelineLayoutReference;
|
|
||||||
WGPUProcPipelineLayoutRelease pipelineLayoutRelease;
|
|
||||||
|
|
||||||
WGPUProcQuerySetDestroy querySetDestroy;
|
|
||||||
WGPUProcQuerySetGetCount querySetGetCount;
|
|
||||||
WGPUProcQuerySetGetType querySetGetType;
|
|
||||||
WGPUProcQuerySetSetLabel querySetSetLabel;
|
|
||||||
WGPUProcQuerySetReference querySetReference;
|
|
||||||
WGPUProcQuerySetRelease querySetRelease;
|
|
||||||
|
|
||||||
WGPUProcQueueCopyExternalTextureForBrowser queueCopyExternalTextureForBrowser;
|
|
||||||
WGPUProcQueueCopyTextureForBrowser queueCopyTextureForBrowser;
|
|
||||||
WGPUProcQueueOnSubmittedWorkDone queueOnSubmittedWorkDone;
|
|
||||||
WGPUProcQueueSetLabel queueSetLabel;
|
|
||||||
WGPUProcQueueSubmit queueSubmit;
|
|
||||||
WGPUProcQueueWriteBuffer queueWriteBuffer;
|
|
||||||
WGPUProcQueueWriteTexture queueWriteTexture;
|
|
||||||
WGPUProcQueueReference queueReference;
|
|
||||||
WGPUProcQueueRelease queueRelease;
|
|
||||||
|
|
||||||
WGPUProcRenderBundleSetLabel renderBundleSetLabel;
|
|
||||||
WGPUProcRenderBundleReference renderBundleReference;
|
|
||||||
WGPUProcRenderBundleRelease renderBundleRelease;
|
|
||||||
|
|
||||||
WGPUProcRenderBundleEncoderDraw renderBundleEncoderDraw;
|
|
||||||
WGPUProcRenderBundleEncoderDrawIndexed renderBundleEncoderDrawIndexed;
|
|
||||||
WGPUProcRenderBundleEncoderDrawIndexedIndirect renderBundleEncoderDrawIndexedIndirect;
|
|
||||||
WGPUProcRenderBundleEncoderDrawIndirect renderBundleEncoderDrawIndirect;
|
|
||||||
WGPUProcRenderBundleEncoderFinish renderBundleEncoderFinish;
|
|
||||||
WGPUProcRenderBundleEncoderInsertDebugMarker renderBundleEncoderInsertDebugMarker;
|
|
||||||
WGPUProcRenderBundleEncoderPopDebugGroup renderBundleEncoderPopDebugGroup;
|
|
||||||
WGPUProcRenderBundleEncoderPushDebugGroup renderBundleEncoderPushDebugGroup;
|
|
||||||
WGPUProcRenderBundleEncoderSetBindGroup renderBundleEncoderSetBindGroup;
|
|
||||||
WGPUProcRenderBundleEncoderSetIndexBuffer renderBundleEncoderSetIndexBuffer;
|
|
||||||
WGPUProcRenderBundleEncoderSetLabel renderBundleEncoderSetLabel;
|
|
||||||
WGPUProcRenderBundleEncoderSetPipeline renderBundleEncoderSetPipeline;
|
|
||||||
WGPUProcRenderBundleEncoderSetVertexBuffer renderBundleEncoderSetVertexBuffer;
|
|
||||||
WGPUProcRenderBundleEncoderReference renderBundleEncoderReference;
|
|
||||||
WGPUProcRenderBundleEncoderRelease renderBundleEncoderRelease;
|
|
||||||
|
|
||||||
WGPUProcRenderPassEncoderBeginOcclusionQuery renderPassEncoderBeginOcclusionQuery;
|
|
||||||
WGPUProcRenderPassEncoderDraw renderPassEncoderDraw;
|
|
||||||
WGPUProcRenderPassEncoderDrawIndexed renderPassEncoderDrawIndexed;
|
|
||||||
WGPUProcRenderPassEncoderDrawIndexedIndirect renderPassEncoderDrawIndexedIndirect;
|
|
||||||
WGPUProcRenderPassEncoderDrawIndirect renderPassEncoderDrawIndirect;
|
|
||||||
WGPUProcRenderPassEncoderEnd renderPassEncoderEnd;
|
|
||||||
WGPUProcRenderPassEncoderEndOcclusionQuery renderPassEncoderEndOcclusionQuery;
|
|
||||||
WGPUProcRenderPassEncoderExecuteBundles renderPassEncoderExecuteBundles;
|
|
||||||
WGPUProcRenderPassEncoderInsertDebugMarker renderPassEncoderInsertDebugMarker;
|
|
||||||
WGPUProcRenderPassEncoderPopDebugGroup renderPassEncoderPopDebugGroup;
|
|
||||||
WGPUProcRenderPassEncoderPushDebugGroup renderPassEncoderPushDebugGroup;
|
|
||||||
WGPUProcRenderPassEncoderSetBindGroup renderPassEncoderSetBindGroup;
|
|
||||||
WGPUProcRenderPassEncoderSetBlendConstant renderPassEncoderSetBlendConstant;
|
|
||||||
WGPUProcRenderPassEncoderSetIndexBuffer renderPassEncoderSetIndexBuffer;
|
|
||||||
WGPUProcRenderPassEncoderSetLabel renderPassEncoderSetLabel;
|
|
||||||
WGPUProcRenderPassEncoderSetPipeline renderPassEncoderSetPipeline;
|
|
||||||
WGPUProcRenderPassEncoderSetScissorRect renderPassEncoderSetScissorRect;
|
|
||||||
WGPUProcRenderPassEncoderSetStencilReference renderPassEncoderSetStencilReference;
|
|
||||||
WGPUProcRenderPassEncoderSetVertexBuffer renderPassEncoderSetVertexBuffer;
|
|
||||||
WGPUProcRenderPassEncoderSetViewport renderPassEncoderSetViewport;
|
|
||||||
WGPUProcRenderPassEncoderWriteTimestamp renderPassEncoderWriteTimestamp;
|
|
||||||
WGPUProcRenderPassEncoderReference renderPassEncoderReference;
|
|
||||||
WGPUProcRenderPassEncoderRelease renderPassEncoderRelease;
|
|
||||||
|
|
||||||
WGPUProcRenderPipelineGetBindGroupLayout renderPipelineGetBindGroupLayout;
|
|
||||||
WGPUProcRenderPipelineSetLabel renderPipelineSetLabel;
|
|
||||||
WGPUProcRenderPipelineReference renderPipelineReference;
|
|
||||||
WGPUProcRenderPipelineRelease renderPipelineRelease;
|
|
||||||
|
|
||||||
WGPUProcSamplerSetLabel samplerSetLabel;
|
|
||||||
WGPUProcSamplerReference samplerReference;
|
|
||||||
WGPUProcSamplerRelease samplerRelease;
|
|
||||||
|
|
||||||
WGPUProcShaderModuleGetCompilationInfo shaderModuleGetCompilationInfo;
|
|
||||||
WGPUProcShaderModuleSetLabel shaderModuleSetLabel;
|
|
||||||
WGPUProcShaderModuleReference shaderModuleReference;
|
|
||||||
WGPUProcShaderModuleRelease shaderModuleRelease;
|
|
||||||
|
|
||||||
WGPUProcSurfaceReference surfaceReference;
|
|
||||||
WGPUProcSurfaceRelease surfaceRelease;
|
|
||||||
|
|
||||||
WGPUProcSwapChainGetCurrentTexture swapChainGetCurrentTexture;
|
|
||||||
WGPUProcSwapChainGetCurrentTextureView swapChainGetCurrentTextureView;
|
|
||||||
WGPUProcSwapChainPresent swapChainPresent;
|
|
||||||
WGPUProcSwapChainReference swapChainReference;
|
|
||||||
WGPUProcSwapChainRelease swapChainRelease;
|
|
||||||
|
|
||||||
WGPUProcTextureCreateView textureCreateView;
|
|
||||||
WGPUProcTextureDestroy textureDestroy;
|
|
||||||
WGPUProcTextureGetDepthOrArrayLayers textureGetDepthOrArrayLayers;
|
|
||||||
WGPUProcTextureGetDimension textureGetDimension;
|
|
||||||
WGPUProcTextureGetFormat textureGetFormat;
|
|
||||||
WGPUProcTextureGetHeight textureGetHeight;
|
|
||||||
WGPUProcTextureGetMipLevelCount textureGetMipLevelCount;
|
|
||||||
WGPUProcTextureGetSampleCount textureGetSampleCount;
|
|
||||||
WGPUProcTextureGetUsage textureGetUsage;
|
|
||||||
WGPUProcTextureGetWidth textureGetWidth;
|
|
||||||
WGPUProcTextureSetLabel textureSetLabel;
|
|
||||||
WGPUProcTextureReference textureReference;
|
|
||||||
WGPUProcTextureRelease textureRelease;
|
|
||||||
|
|
||||||
WGPUProcTextureViewSetLabel textureViewSetLabel;
|
|
||||||
WGPUProcTextureViewReference textureViewReference;
|
|
||||||
WGPUProcTextureViewRelease textureViewRelease;
|
|
||||||
|
|
||||||
} DawnProcTable;
|
|
||||||
|
|
||||||
#endif // DAWN_DAWN_PROC_TABLE_H_
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
// Copyright 2020 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_DAWN_THREAD_DISPATCH_PROC_H_
|
|
||||||
#define INCLUDE_DAWN_DAWN_THREAD_DISPATCH_PROC_H_
|
|
||||||
|
|
||||||
#include "dawn/dawn_proc.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Call dawnProcSetProcs(&dawnThreadDispatchProcTable) and then use dawnProcSetPerThreadProcs
|
|
||||||
// to set per-thread procs.
|
|
||||||
WGPU_EXPORT extern DawnProcTable dawnThreadDispatchProcTable;
|
|
||||||
WGPU_EXPORT void dawnProcSetPerThreadProcs(const DawnProcTable* procs);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} // extern "C"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_DAWN_THREAD_DISPATCH_PROC_H_
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
// Copyright 2023 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_NATIVE_D3D11BACKEND_H_
|
|
||||||
#define INCLUDE_DAWN_NATIVE_D3D11BACKEND_H_
|
|
||||||
|
|
||||||
#include <d3d11_1.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include <wrl/client.h>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "dawn/native/D3DBackend.h"
|
|
||||||
|
|
||||||
namespace dawn::native::d3d11 {
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
|
|
||||||
: public d3d::PhysicalDeviceDiscoveryOptions {
|
|
||||||
PhysicalDeviceDiscoveryOptions();
|
|
||||||
explicit PhysicalDeviceDiscoveryOptions(Microsoft::WRL::ComPtr<IDXGIAdapter> adapter);
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO(dawn:1774): Deprecated.
|
|
||||||
using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions;
|
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D11Device> GetD3D11Device(WGPUDevice device);
|
|
||||||
|
|
||||||
} // namespace dawn::native::d3d11
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_NATIVE_D3D11BACKEND_H_
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
// Copyright 2018 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_
|
|
||||||
#define INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_
|
|
||||||
|
|
||||||
#include <DXGI1_4.h>
|
|
||||||
#include <d3d12.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include <wrl/client.h>
|
|
||||||
|
|
||||||
#include "dawn/native/D3DBackend.h"
|
|
||||||
|
|
||||||
struct ID3D12Device;
|
|
||||||
struct ID3D12Resource;
|
|
||||||
|
|
||||||
namespace dawn::native::d3d12 {
|
|
||||||
|
|
||||||
class Device;
|
|
||||||
|
|
||||||
enum MemorySegment {
|
|
||||||
Local,
|
|
||||||
NonLocal,
|
|
||||||
};
|
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT uint64_t SetExternalMemoryReservation(WGPUDevice device,
|
|
||||||
uint64_t requestedReservationSize,
|
|
||||||
MemorySegment memorySegment);
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
|
|
||||||
: public d3d::PhysicalDeviceDiscoveryOptions {
|
|
||||||
PhysicalDeviceDiscoveryOptions();
|
|
||||||
explicit PhysicalDeviceDiscoveryOptions(Microsoft::WRL::ComPtr<IDXGIAdapter> adapter);
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO(dawn:1774): Deprecated.
|
|
||||||
using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions;
|
|
||||||
|
|
||||||
} // namespace dawn::native::d3d12
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
// Copyright 2023 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_NATIVE_D3DBACKEND_H_
|
|
||||||
#define INCLUDE_DAWN_NATIVE_D3DBACKEND_H_
|
|
||||||
|
|
||||||
#include <dxgi1_4.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include <wrl/client.h>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "dawn/native/DawnNative.h"
|
|
||||||
#include "dawn/webgpu_cpp_chained_struct.h"
|
|
||||||
|
|
||||||
namespace dawn::native::d3d {
|
|
||||||
|
|
||||||
class ExternalImageDXGIImpl;
|
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<IDXGIAdapter> GetDXGIAdapter(WGPUAdapter adapter);
|
|
||||||
|
|
||||||
// Can be chained in WGPURequestAdapterOptions
|
|
||||||
struct DAWN_NATIVE_EXPORT RequestAdapterOptionsLUID : wgpu::ChainedStruct {
|
|
||||||
RequestAdapterOptionsLUID();
|
|
||||||
|
|
||||||
::LUID adapterLUID;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
|
|
||||||
: public PhysicalDeviceDiscoveryOptionsBase {
|
|
||||||
PhysicalDeviceDiscoveryOptions(WGPUBackendType type,
|
|
||||||
Microsoft::WRL::ComPtr<IDXGIAdapter> adapter);
|
|
||||||
Microsoft::WRL::ComPtr<IDXGIAdapter> dxgiAdapter;
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO(dawn:1774): Deprecated.
|
|
||||||
using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions;
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDXGISharedHandle : ExternalImageDescriptor {
|
|
||||||
public:
|
|
||||||
ExternalImageDescriptorDXGISharedHandle();
|
|
||||||
|
|
||||||
// Note: SharedHandle must be a handle to a texture object.
|
|
||||||
HANDLE sharedHandle = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageDXGIFenceDescriptor {
|
|
||||||
// Shared handle for the fence. This never passes ownership to the callee (when used as an input
|
|
||||||
// parameter) or to the caller (when used as a return value or output parameter).
|
|
||||||
HANDLE fenceHandle = nullptr;
|
|
||||||
|
|
||||||
// The value that was previously signaled on this fence and should be waited on.
|
|
||||||
uint64_t fenceValue = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageDXGIBeginAccessDescriptor {
|
|
||||||
bool isInitialized = false; // Whether the texture is initialized on import
|
|
||||||
WGPUTextureUsageFlags usage = WGPUTextureUsage_None;
|
|
||||||
|
|
||||||
// A list of fences to wait on before accessing the texture.
|
|
||||||
std::vector<ExternalImageDXGIFenceDescriptor> waitFences;
|
|
||||||
|
|
||||||
// Whether the texture is for a WebGPU swap chain.
|
|
||||||
bool isSwapChainTexture = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DAWN_NATIVE_EXPORT ExternalImageDXGI {
|
|
||||||
public:
|
|
||||||
~ExternalImageDXGI();
|
|
||||||
|
|
||||||
static std::unique_ptr<ExternalImageDXGI> Create(
|
|
||||||
WGPUDevice device,
|
|
||||||
const ExternalImageDescriptorDXGISharedHandle* descriptor);
|
|
||||||
|
|
||||||
// Returns true if the external image resources are still valid, otherwise BeginAccess() is
|
|
||||||
// guaranteed to fail e.g. after device destruction.
|
|
||||||
bool IsValid() const;
|
|
||||||
|
|
||||||
// Creates WGPUTexture wrapping the DXGI shared handle. The provided wait fences will be
|
|
||||||
// synchronized before using the texture in any command lists. Empty fences (nullptr handle) are
|
|
||||||
// ignored for convenience (EndAccess can return such fences).
|
|
||||||
WGPUTexture BeginAccess(const ExternalImageDXGIBeginAccessDescriptor* descriptor);
|
|
||||||
|
|
||||||
// Returns the signalFence that the client must wait on for correct synchronization. Can return
|
|
||||||
// an empty fence (nullptr handle) if the texture wasn't accessed by Dawn.
|
|
||||||
// Note that merely calling Destroy() on the WGPUTexture does not ensure synchronization.
|
|
||||||
void EndAccess(WGPUTexture texture, ExternalImageDXGIFenceDescriptor* signalFence);
|
|
||||||
|
|
||||||
private:
|
|
||||||
explicit ExternalImageDXGI(std::unique_ptr<ExternalImageDXGIImpl> impl);
|
|
||||||
|
|
||||||
std::unique_ptr<ExternalImageDXGIImpl> mImpl;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace dawn::native::d3d
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_NATIVE_D3DBACKEND_H_
|
|
||||||
@@ -1,309 +0,0 @@
|
|||||||
// Copyright 2018 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_NATIVE_DAWNNATIVE_H_
|
|
||||||
#define INCLUDE_DAWN_NATIVE_DAWNNATIVE_H_
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "dawn/dawn_proc_table.h"
|
|
||||||
#include "dawn/native/dawn_native_export.h"
|
|
||||||
#include "dawn/webgpu.h"
|
|
||||||
#include "dawn/webgpu_cpp_chained_struct.h"
|
|
||||||
|
|
||||||
namespace dawn::platform {
|
|
||||||
class Platform;
|
|
||||||
} // namespace dawn::platform
|
|
||||||
|
|
||||||
namespace wgpu {
|
|
||||||
struct AdapterProperties;
|
|
||||||
struct DeviceDescriptor;
|
|
||||||
struct RequestAdapterOptions;
|
|
||||||
} // namespace wgpu
|
|
||||||
|
|
||||||
namespace dawn::native {
|
|
||||||
|
|
||||||
class InstanceBase;
|
|
||||||
class AdapterBase;
|
|
||||||
|
|
||||||
// Each toggle is assigned with a TogglesStage, indicating the validation and earliest usage
|
|
||||||
// time of the toggle.
|
|
||||||
enum class ToggleStage { Instance, Adapter, Device };
|
|
||||||
|
|
||||||
// A struct to record the information of a toggle. A toggle is a code path in Dawn device that
|
|
||||||
// can be manually configured to run or not outside Dawn, including workarounds, special
|
|
||||||
// features and optimizations.
|
|
||||||
struct ToggleInfo {
|
|
||||||
const char* name;
|
|
||||||
const char* description;
|
|
||||||
const char* url;
|
|
||||||
ToggleStage stage;
|
|
||||||
};
|
|
||||||
|
|
||||||
// A struct to record the information of a feature. A feature is a GPU feature that is not
|
|
||||||
// required to be supported by all Dawn backends and can only be used when it is enabled on the
|
|
||||||
// creation of device.
|
|
||||||
struct FeatureInfo {
|
|
||||||
const char* name;
|
|
||||||
const char* description;
|
|
||||||
const char* url;
|
|
||||||
// The enum of feature state, could be stable or experimental. Using an experimental feature
|
|
||||||
// requires the AllowUnsafeAPIs toggle to be enabled.
|
|
||||||
enum class FeatureState { Stable = 0, Experimental };
|
|
||||||
FeatureState featureState;
|
|
||||||
};
|
|
||||||
|
|
||||||
// An adapter is an object that represent on possibility of creating devices in the system.
|
|
||||||
// Most of the time it will represent a combination of a physical GPU and an API. Not that the
|
|
||||||
// same GPU can be represented by multiple adapters but on different APIs.
|
|
||||||
//
|
|
||||||
// The underlying Dawn adapter is owned by the Dawn instance so this class is not RAII but just
|
|
||||||
// a reference to an underlying adapter.
|
|
||||||
class DAWN_NATIVE_EXPORT Adapter {
|
|
||||||
public:
|
|
||||||
Adapter();
|
|
||||||
// NOLINTNEXTLINE(runtime/explicit)
|
|
||||||
Adapter(AdapterBase* impl);
|
|
||||||
~Adapter();
|
|
||||||
|
|
||||||
Adapter(const Adapter& other);
|
|
||||||
Adapter& operator=(const Adapter& other);
|
|
||||||
|
|
||||||
// Essentially webgpu.h's wgpuAdapterGetProperties while we don't have WGPUAdapter in
|
|
||||||
// dawn.json
|
|
||||||
void GetProperties(wgpu::AdapterProperties* properties) const;
|
|
||||||
void GetProperties(WGPUAdapterProperties* properties) const;
|
|
||||||
|
|
||||||
std::vector<const char*> GetSupportedExtensions() const;
|
|
||||||
std::vector<const char*> GetSupportedFeatures() const;
|
|
||||||
bool GetLimits(WGPUSupportedLimits* limits) const;
|
|
||||||
|
|
||||||
void SetUseTieredLimits(bool useTieredLimits);
|
|
||||||
|
|
||||||
// Check that the Adapter is able to support importing external images. This is necessary
|
|
||||||
// to implement the swapchain and interop APIs in Chromium.
|
|
||||||
bool SupportsExternalImages() const;
|
|
||||||
|
|
||||||
explicit operator bool() const;
|
|
||||||
|
|
||||||
// Create a device on this adapter. On an error, nullptr is returned.
|
|
||||||
WGPUDevice CreateDevice(const wgpu::DeviceDescriptor* deviceDescriptor);
|
|
||||||
WGPUDevice CreateDevice(const WGPUDeviceDescriptor* deviceDescriptor = nullptr);
|
|
||||||
|
|
||||||
void RequestDevice(const wgpu::DeviceDescriptor* descriptor,
|
|
||||||
WGPURequestDeviceCallback callback,
|
|
||||||
void* userdata);
|
|
||||||
void RequestDevice(const WGPUDeviceDescriptor* descriptor,
|
|
||||||
WGPURequestDeviceCallback callback,
|
|
||||||
void* userdata);
|
|
||||||
void RequestDevice(std::nullptr_t descriptor,
|
|
||||||
WGPURequestDeviceCallback callback,
|
|
||||||
void* userdata) {
|
|
||||||
RequestDevice(static_cast<const wgpu::DeviceDescriptor*>(descriptor), callback, userdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the underlying WGPUAdapter object.
|
|
||||||
WGPUAdapter Get() const;
|
|
||||||
|
|
||||||
// Reset the backend device object for testing purposes.
|
|
||||||
void ResetInternalDeviceForTesting();
|
|
||||||
|
|
||||||
private:
|
|
||||||
AdapterBase* mImpl = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Base class for options passed to Instance::DiscoverPhysicalDevices.
|
|
||||||
struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptionsBase {
|
|
||||||
public:
|
|
||||||
const WGPUBackendType backendType;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
explicit PhysicalDeviceDiscoveryOptionsBase(WGPUBackendType type);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Deprecated, use PhysicalDeviceDiscoveryOptionsBase instead.
|
|
||||||
// TODO(dawn:1774): Remove this.
|
|
||||||
using AdapterDiscoveryOptionsBase = PhysicalDeviceDiscoveryOptionsBase;
|
|
||||||
|
|
||||||
enum BackendValidationLevel { Full, Partial, Disabled };
|
|
||||||
|
|
||||||
// Can be chained in InstanceDescriptor
|
|
||||||
struct DAWN_NATIVE_EXPORT DawnInstanceDescriptor : wgpu::ChainedStruct {
|
|
||||||
DawnInstanceDescriptor();
|
|
||||||
static constexpr size_t kFirstMemberAlignment =
|
|
||||||
wgpu::detail::ConstexprMax(alignof(wgpu::ChainedStruct), alignof(uint32_t));
|
|
||||||
alignas(kFirstMemberAlignment) uint32_t additionalRuntimeSearchPathsCount = 0;
|
|
||||||
const char* const* additionalRuntimeSearchPaths;
|
|
||||||
dawn::platform::Platform* platform = nullptr;
|
|
||||||
|
|
||||||
// Equality operators, mostly for testing. Note that this tests
|
|
||||||
// strict pointer-pointer equality if the struct contains member pointers.
|
|
||||||
bool operator==(const DawnInstanceDescriptor& rhs) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Represents a connection to dawn_native and is used for dependency injection, discovering
|
|
||||||
// system adapters and injecting custom adapters (like a Swiftshader Vulkan adapter).
|
|
||||||
//
|
|
||||||
// This is an RAII class for Dawn instances and also controls the lifetime of all adapters
|
|
||||||
// for this instance.
|
|
||||||
class DAWN_NATIVE_EXPORT Instance {
|
|
||||||
public:
|
|
||||||
explicit Instance(const WGPUInstanceDescriptor* desc = nullptr);
|
|
||||||
~Instance();
|
|
||||||
|
|
||||||
Instance(const Instance& other) = delete;
|
|
||||||
Instance& operator=(const Instance& other) = delete;
|
|
||||||
|
|
||||||
// Gather all physical devices in the system that can be accessed with no special options.
|
|
||||||
void DiscoverDefaultPhysicalDevices();
|
|
||||||
|
|
||||||
// Adds physical devices that can be discovered with the options provided (like a
|
|
||||||
// getProcAddress). The backend is chosen based on the type of the options used. Returns true on
|
|
||||||
// success.
|
|
||||||
bool DiscoverPhysicalDevices(const PhysicalDeviceDiscoveryOptionsBase* options);
|
|
||||||
|
|
||||||
// Deprecated, use DiscoverDefaultPhysicalDevices and DiscoverPhysicalDevices instead.
|
|
||||||
// TODO(Dawn:1774): Remove these.
|
|
||||||
void DiscoverDefaultAdapters();
|
|
||||||
bool DiscoverAdapters(const AdapterDiscoveryOptionsBase* options);
|
|
||||||
|
|
||||||
// Discovers and returns a vector of adapters.
|
|
||||||
// All systems adapters that can be found are returned if no options are passed.
|
|
||||||
// Otherwise, returns adapters based on the `options`. Adapter toggles descriptor can chained
|
|
||||||
// after options.
|
|
||||||
std::vector<Adapter> EnumerateAdapters(const WGPURequestAdapterOptions* options) const;
|
|
||||||
std::vector<Adapter> EnumerateAdapters(
|
|
||||||
const wgpu::RequestAdapterOptions* options = nullptr) const;
|
|
||||||
|
|
||||||
// Deprecated. Call EnumerateAdapters instead.
|
|
||||||
std::vector<Adapter> GetAdapters() const;
|
|
||||||
|
|
||||||
const ToggleInfo* GetToggleInfo(const char* toggleName);
|
|
||||||
const FeatureInfo* GetFeatureInfo(WGPUFeatureName feature);
|
|
||||||
|
|
||||||
// Enables backend validation layers
|
|
||||||
void EnableBackendValidation(bool enableBackendValidation);
|
|
||||||
void SetBackendValidationLevel(BackendValidationLevel validationLevel);
|
|
||||||
|
|
||||||
// Enable debug capture on Dawn startup
|
|
||||||
void EnableBeginCaptureOnStartup(bool beginCaptureOnStartup);
|
|
||||||
|
|
||||||
// Enable / disable the adapter blocklist.
|
|
||||||
void EnableAdapterBlocklist(bool enable);
|
|
||||||
|
|
||||||
uint64_t GetDeviceCountForTesting() const;
|
|
||||||
|
|
||||||
// Returns the underlying WGPUInstance object.
|
|
||||||
WGPUInstance Get() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
InstanceBase* mImpl = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Backend-agnostic API for dawn_native
|
|
||||||
DAWN_NATIVE_EXPORT const DawnProcTable& GetProcs();
|
|
||||||
|
|
||||||
// Query the names of all the toggles that are enabled in device
|
|
||||||
DAWN_NATIVE_EXPORT std::vector<const char*> GetTogglesUsed(WGPUDevice device);
|
|
||||||
|
|
||||||
// Backdoor to get the number of lazy clears for testing
|
|
||||||
DAWN_NATIVE_EXPORT size_t GetLazyClearCountForTesting(WGPUDevice device);
|
|
||||||
|
|
||||||
// Backdoor to get the number of deprecation warnings for testing
|
|
||||||
DAWN_NATIVE_EXPORT size_t GetDeprecationWarningCountForTesting(WGPUDevice device);
|
|
||||||
|
|
||||||
// Backdoor to get the number of physical devices an instance knows about for testing
|
|
||||||
DAWN_NATIVE_EXPORT size_t GetPhysicalDeviceCountForTesting(WGPUInstance instance);
|
|
||||||
|
|
||||||
// Query if texture has been initialized
|
|
||||||
DAWN_NATIVE_EXPORT bool IsTextureSubresourceInitialized(
|
|
||||||
WGPUTexture texture,
|
|
||||||
uint32_t baseMipLevel,
|
|
||||||
uint32_t levelCount,
|
|
||||||
uint32_t baseArrayLayer,
|
|
||||||
uint32_t layerCount,
|
|
||||||
WGPUTextureAspect aspect = WGPUTextureAspect_All);
|
|
||||||
|
|
||||||
// Backdoor to get the order of the ProcMap for testing
|
|
||||||
DAWN_NATIVE_EXPORT std::vector<const char*> GetProcMapNamesForTesting();
|
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT bool DeviceTick(WGPUDevice device);
|
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT bool InstanceProcessEvents(WGPUInstance instance);
|
|
||||||
|
|
||||||
// ErrorInjector functions used for testing only. Defined in dawn_native/ErrorInjector.cpp
|
|
||||||
DAWN_NATIVE_EXPORT void EnableErrorInjector();
|
|
||||||
DAWN_NATIVE_EXPORT void DisableErrorInjector();
|
|
||||||
DAWN_NATIVE_EXPORT void ClearErrorInjector();
|
|
||||||
DAWN_NATIVE_EXPORT uint64_t AcquireErrorInjectorCallCount();
|
|
||||||
DAWN_NATIVE_EXPORT void InjectErrorAt(uint64_t index);
|
|
||||||
|
|
||||||
// The different types of external images
|
|
||||||
enum ExternalImageType {
|
|
||||||
OpaqueFD,
|
|
||||||
DmaBuf,
|
|
||||||
IOSurface,
|
|
||||||
DXGISharedHandle,
|
|
||||||
EGLImage,
|
|
||||||
AHardwareBuffer,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Common properties of external images
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageDescriptor {
|
|
||||||
public:
|
|
||||||
const WGPUTextureDescriptor* cTextureDescriptor; // Must match image creation params
|
|
||||||
bool isInitialized; // Whether the texture is initialized on import
|
|
||||||
ExternalImageType GetType() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
explicit ExternalImageDescriptor(ExternalImageType type);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ExternalImageType mType;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageExportInfo {
|
|
||||||
public:
|
|
||||||
bool isInitialized = false; // Whether the texture is initialized after export
|
|
||||||
ExternalImageType GetType() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
explicit ExternalImageExportInfo(ExternalImageType type);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ExternalImageType mType;
|
|
||||||
};
|
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT bool CheckIsErrorForTesting(void* objectHandle);
|
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT const char* GetObjectLabelForTesting(void* objectHandle);
|
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT uint64_t GetAllocatedSizeForTesting(WGPUBuffer buffer);
|
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT bool BindGroupLayoutBindingsEqualForTesting(WGPUBindGroupLayout a,
|
|
||||||
WGPUBindGroupLayout b);
|
|
||||||
|
|
||||||
} // namespace dawn::native
|
|
||||||
|
|
||||||
// Alias the DawnInstanceDescriptor up to wgpu.
|
|
||||||
// TODO(dawn:1374) Remove this aliasing once the usages are updated.
|
|
||||||
namespace wgpu {
|
|
||||||
using dawn::native::DawnInstanceDescriptor;
|
|
||||||
} // namespace wgpu
|
|
||||||
|
|
||||||
// TODO(dawn:824): Remove once the deprecation period is passed.
|
|
||||||
namespace dawn_native = dawn::native;
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_NATIVE_DAWNNATIVE_H_
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
// Copyright 2018 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_NATIVE_METALBACKEND_H_
|
|
||||||
#define INCLUDE_DAWN_NATIVE_METALBACKEND_H_
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "dawn/native/DawnNative.h"
|
|
||||||
|
|
||||||
// The specifics of the Metal backend expose types in function signatures that might not be
|
|
||||||
// available in dependent's minimum supported SDK version. Suppress all availability errors using
|
|
||||||
// clang's pragmas. Dependents using the types without guarded availability will still get errors
|
|
||||||
// when using the types.
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
|
||||||
|
|
||||||
struct __IOSurface;
|
|
||||||
typedef __IOSurface* IOSurfaceRef;
|
|
||||||
|
|
||||||
#ifdef __OBJC__
|
|
||||||
#import <Metal/Metal.h>
|
|
||||||
#endif // __OBJC__
|
|
||||||
|
|
||||||
namespace dawn::native::metal {
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
|
|
||||||
: public PhysicalDeviceDiscoveryOptionsBase {
|
|
||||||
PhysicalDeviceDiscoveryOptions();
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO(dawn:1774): Deprecated.
|
|
||||||
using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions;
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageMTLSharedEventDescriptor {
|
|
||||||
// Shared event handle `id<MTLSharedEvent>`.
|
|
||||||
// This never passes ownership to the callee (when used as an input
|
|
||||||
// parameter) or to the caller (when used as a return value or output parameter).
|
|
||||||
#ifdef __OBJC__
|
|
||||||
id<MTLSharedEvent> sharedEvent = nil;
|
|
||||||
static_assert(sizeof(id<MTLSharedEvent>) == sizeof(void*));
|
|
||||||
static_assert(alignof(id<MTLSharedEvent>) == alignof(void*));
|
|
||||||
#else
|
|
||||||
void* sharedEvent = nullptr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// The value that was previously signaled on this event and should be waited on.
|
|
||||||
uint64_t signaledValue = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageDescriptorIOSurface : ExternalImageDescriptor {
|
|
||||||
public:
|
|
||||||
ExternalImageDescriptorIOSurface();
|
|
||||||
~ExternalImageDescriptorIOSurface();
|
|
||||||
|
|
||||||
IOSurfaceRef ioSurface;
|
|
||||||
|
|
||||||
// A list of events to wait on before accessing the texture.
|
|
||||||
std::vector<ExternalImageMTLSharedEventDescriptor> waitEvents;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageIOSurfaceEndAccessDescriptor
|
|
||||||
: ExternalImageMTLSharedEventDescriptor {
|
|
||||||
bool isInitialized;
|
|
||||||
};
|
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT WGPUTexture WrapIOSurface(WGPUDevice device,
|
|
||||||
const ExternalImageDescriptorIOSurface* descriptor);
|
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT void IOSurfaceEndAccess(WGPUTexture texture,
|
|
||||||
ExternalImageIOSurfaceEndAccessDescriptor* descriptor);
|
|
||||||
|
|
||||||
// When making Metal interop with other APIs, we need to be careful that QueueSubmit doesn't
|
|
||||||
// mean that the operations will be visible to other APIs/Metal devices right away. macOS
|
|
||||||
// does have a global queue of graphics operations, but the command buffers are inserted there
|
|
||||||
// when they are "scheduled". Submitting other operations before the command buffer is
|
|
||||||
// scheduled could lead to races in who gets scheduled first and incorrect rendering.
|
|
||||||
DAWN_NATIVE_EXPORT void WaitForCommandsToBeScheduled(WGPUDevice device);
|
|
||||||
|
|
||||||
} // namespace dawn::native::metal
|
|
||||||
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_NATIVE_METALBACKEND_H_
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
// Copyright 2018 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_NATIVE_NULLBACKEND_H_
|
|
||||||
#define INCLUDE_DAWN_NATIVE_NULLBACKEND_H_
|
|
||||||
|
|
||||||
#include "dawn/native/DawnNative.h"
|
|
||||||
|
|
||||||
namespace dawn::native::null {
|
|
||||||
|
|
||||||
// Nothing for now \o/
|
|
||||||
|
|
||||||
} // namespace dawn::native::null
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_NATIVE_NULLBACKEND_H_
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
// Copyright 2018 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_NATIVE_OPENGLBACKEND_H_
|
|
||||||
#define INCLUDE_DAWN_NATIVE_OPENGLBACKEND_H_
|
|
||||||
|
|
||||||
typedef void* EGLImage;
|
|
||||||
|
|
||||||
#include "dawn/native/DawnNative.h"
|
|
||||||
#include "dawn/webgpu_cpp_chained_struct.h"
|
|
||||||
|
|
||||||
namespace dawn::native::opengl {
|
|
||||||
|
|
||||||
// Can be chained in WGPURequestAdapterOptions
|
|
||||||
struct DAWN_NATIVE_EXPORT RequestAdapterOptionsGetGLProc : wgpu::ChainedStruct {
|
|
||||||
RequestAdapterOptionsGetGLProc();
|
|
||||||
|
|
||||||
void* (*getProc)(const char*);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
|
|
||||||
: public PhysicalDeviceDiscoveryOptionsBase {
|
|
||||||
explicit PhysicalDeviceDiscoveryOptions(WGPUBackendType type);
|
|
||||||
|
|
||||||
void* (*getProc)(const char*);
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO(dawn:1774): Deprecated.
|
|
||||||
using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions;
|
|
||||||
|
|
||||||
// TODO(crbug.com/dawn/810): This struct can be removed once Chrome is no longer using it.
|
|
||||||
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsES : public PhysicalDeviceDiscoveryOptions {
|
|
||||||
AdapterDiscoveryOptionsES();
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageDescriptorEGLImage : ExternalImageDescriptor {
|
|
||||||
public:
|
|
||||||
ExternalImageDescriptorEGLImage();
|
|
||||||
|
|
||||||
::EGLImage image;
|
|
||||||
};
|
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT WGPUTexture
|
|
||||||
WrapExternalEGLImage(WGPUDevice device, const ExternalImageDescriptorEGLImage* descriptor);
|
|
||||||
|
|
||||||
} // namespace dawn::native::opengl
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_NATIVE_OPENGLBACKEND_H_
|
|
||||||
@@ -1,180 +0,0 @@
|
|||||||
// Copyright 2018 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_NATIVE_VULKANBACKEND_H_
|
|
||||||
#define INCLUDE_DAWN_NATIVE_VULKANBACKEND_H_
|
|
||||||
|
|
||||||
#include <vulkan/vulkan.h>
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "dawn/native/DawnNative.h"
|
|
||||||
|
|
||||||
namespace dawn::native::vulkan {
|
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT VkInstance GetInstance(WGPUDevice device);
|
|
||||||
|
|
||||||
DAWN_NATIVE_EXPORT PFN_vkVoidFunction GetInstanceProcAddr(WGPUDevice device, const char* pName);
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
|
|
||||||
: public PhysicalDeviceDiscoveryOptionsBase {
|
|
||||||
PhysicalDeviceDiscoveryOptions();
|
|
||||||
|
|
||||||
bool forceSwiftShader = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO(dawn:1774): Deprecated.
|
|
||||||
using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions;
|
|
||||||
|
|
||||||
enum class NeedsDedicatedAllocation {
|
|
||||||
Yes,
|
|
||||||
No,
|
|
||||||
// Use Vulkan reflection to detect whether a dedicated allocation is needed.
|
|
||||||
Detect,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageDescriptorVk : ExternalImageDescriptor {
|
|
||||||
public:
|
|
||||||
// The following members may be ignored if |ExternalImageDescriptor::isInitialized| is false
|
|
||||||
// since the import does not need to preserve texture contents.
|
|
||||||
|
|
||||||
// See https://www.khronos.org/registry/vulkan/specs/1.1/html/chap7.html. The acquire
|
|
||||||
// operation old/new layouts must match exactly the layouts in the release operation. So
|
|
||||||
// we may need to issue two barriers releasedOldLayout -> releasedNewLayout ->
|
|
||||||
// cTextureDescriptor.usage if the new layout is not compatible with the desired usage.
|
|
||||||
// The first barrier is the queue transfer, the second is the layout transition to our
|
|
||||||
// desired usage.
|
|
||||||
VkImageLayout releasedOldLayout = VK_IMAGE_LAYOUT_GENERAL;
|
|
||||||
VkImageLayout releasedNewLayout = VK_IMAGE_LAYOUT_GENERAL;
|
|
||||||
|
|
||||||
// Try to detect the need to use a dedicated allocation for imported images by default but let
|
|
||||||
// the application override this as drivers have bugs and forget to require a dedicated
|
|
||||||
// allocation.
|
|
||||||
NeedsDedicatedAllocation dedicatedAllocation = NeedsDedicatedAllocation::Detect;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
using ExternalImageDescriptor::ExternalImageDescriptor;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ExternalImageExportInfoVk : ExternalImageExportInfo {
|
|
||||||
public:
|
|
||||||
// See comments in |ExternalImageDescriptorVk|
|
|
||||||
// Contains the old/new layouts used in the queue release operation.
|
|
||||||
VkImageLayout releasedOldLayout;
|
|
||||||
VkImageLayout releasedNewLayout;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
using ExternalImageExportInfo::ExternalImageExportInfo;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Can't use DAWN_PLATFORM_IS(LINUX) since header included in both Dawn and Chrome
|
|
||||||
#ifdef __linux__
|
|
||||||
|
|
||||||
// Common properties of external images represented by FDs. On successful import the file
|
|
||||||
// descriptor's ownership is transferred to the Dawn implementation and they shouldn't be
|
|
||||||
// used outside of Dawn again. TODO(enga): Also transfer ownership in the error case so the
|
|
||||||
// caller can assume the FD is always consumed.
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageDescriptorFD : ExternalImageDescriptorVk {
|
|
||||||
public:
|
|
||||||
int memoryFD; // A file descriptor from an export of the memory of the image
|
|
||||||
std::vector<int> waitFDs; // File descriptors of semaphores which will be waited on
|
|
||||||
|
|
||||||
protected:
|
|
||||||
using ExternalImageDescriptorVk::ExternalImageDescriptorVk;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Descriptor for opaque file descriptor image import
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageDescriptorOpaqueFD : ExternalImageDescriptorFD {
|
|
||||||
ExternalImageDescriptorOpaqueFD();
|
|
||||||
|
|
||||||
VkDeviceSize allocationSize; // Must match VkMemoryAllocateInfo from image creation
|
|
||||||
uint32_t memoryTypeIndex; // Must match VkMemoryAllocateInfo from image creation
|
|
||||||
};
|
|
||||||
|
|
||||||
// The plane-wise offset and stride.
|
|
||||||
struct DAWN_NATIVE_EXPORT PlaneLayout {
|
|
||||||
uint64_t offset;
|
|
||||||
uint32_t stride;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Descriptor for dma-buf file descriptor image import
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDmaBuf : ExternalImageDescriptorFD {
|
|
||||||
ExternalImageDescriptorDmaBuf();
|
|
||||||
|
|
||||||
static constexpr uint32_t kMaxPlanes = 3;
|
|
||||||
std::array<PlaneLayout, kMaxPlanes> planeLayouts;
|
|
||||||
uint64_t drmModifier; // DRM modifier of the buffer
|
|
||||||
};
|
|
||||||
|
|
||||||
// Info struct that is written to in |ExportVulkanImage|.
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageExportInfoFD : ExternalImageExportInfoVk {
|
|
||||||
public:
|
|
||||||
// Contains the exported semaphore handles.
|
|
||||||
std::vector<int> semaphoreHandles;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
using ExternalImageExportInfoVk::ExternalImageExportInfoVk;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageExportInfoOpaqueFD : ExternalImageExportInfoFD {
|
|
||||||
ExternalImageExportInfoOpaqueFD();
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageExportInfoDmaBuf : ExternalImageExportInfoFD {
|
|
||||||
ExternalImageExportInfoDmaBuf();
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
|
|
||||||
// Descriptor for AHardwareBuffer image import
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageDescriptorAHardwareBuffer : ExternalImageDescriptorVk {
|
|
||||||
public:
|
|
||||||
ExternalImageDescriptorAHardwareBuffer();
|
|
||||||
|
|
||||||
struct AHardwareBuffer* handle; // The AHardwareBuffer which contains the memory of the image
|
|
||||||
std::vector<int> waitFDs; // File descriptors of semaphores which will be waited on
|
|
||||||
|
|
||||||
protected:
|
|
||||||
using ExternalImageDescriptorVk::ExternalImageDescriptorVk;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DAWN_NATIVE_EXPORT ExternalImageExportInfoAHardwareBuffer : ExternalImageExportInfoFD {
|
|
||||||
ExternalImageExportInfoAHardwareBuffer();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // __ANDROID__
|
|
||||||
|
|
||||||
#endif // __linux__
|
|
||||||
|
|
||||||
// Imports external memory into a Vulkan image. Internally, this uses external memory /
|
|
||||||
// semaphore extensions to import the image and wait on the provided synchronizaton
|
|
||||||
// primitives before the texture can be used.
|
|
||||||
// On failure, returns a nullptr.
|
|
||||||
DAWN_NATIVE_EXPORT WGPUTexture WrapVulkanImage(WGPUDevice device,
|
|
||||||
const ExternalImageDescriptorVk* descriptor);
|
|
||||||
|
|
||||||
// Exports external memory from a Vulkan image. This must be called on wrapped textures
|
|
||||||
// before they are destroyed. It writes the semaphore to wait on and the old/new image
|
|
||||||
// layouts to |info|. Pass VK_IMAGE_LAYOUT_UNDEFINED as |desiredLayout| if you don't want to
|
|
||||||
// perform a layout transition.
|
|
||||||
DAWN_NATIVE_EXPORT bool ExportVulkanImage(WGPUTexture texture,
|
|
||||||
VkImageLayout desiredLayout,
|
|
||||||
ExternalImageExportInfoVk* info);
|
|
||||||
// |ExportVulkanImage| with default desiredLayout of VK_IMAGE_LAYOUT_UNDEFINED.
|
|
||||||
DAWN_NATIVE_EXPORT bool ExportVulkanImage(WGPUTexture texture, ExternalImageExportInfoVk* info);
|
|
||||||
|
|
||||||
} // namespace dawn::native::vulkan
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_NATIVE_VULKANBACKEND_H_
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
// Copyright 2018 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_NATIVE_DAWN_NATIVE_EXPORT_H_
|
|
||||||
#define INCLUDE_DAWN_NATIVE_DAWN_NATIVE_EXPORT_H_
|
|
||||||
|
|
||||||
#if defined(DAWN_NATIVE_SHARED_LIBRARY)
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#if defined(DAWN_NATIVE_IMPLEMENTATION)
|
|
||||||
#define DAWN_NATIVE_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define DAWN_NATIVE_EXPORT __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#else // defined(_WIN32)
|
|
||||||
#if defined(DAWN_NATIVE_IMPLEMENTATION)
|
|
||||||
#define DAWN_NATIVE_EXPORT __attribute__((visibility("default")))
|
|
||||||
#else
|
|
||||||
#define DAWN_NATIVE_EXPORT
|
|
||||||
#endif
|
|
||||||
#endif // defined(_WIN32)
|
|
||||||
#else // defined(DAWN_NATIVE_SHARED_LIBRARY)
|
|
||||||
#define DAWN_NATIVE_EXPORT
|
|
||||||
#endif // defined(DAWN_NATIVE_SHARED_LIBRARY)
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_NATIVE_DAWN_NATIVE_EXPORT_H_
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
// Copyright 2019 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_PLATFORM_DAWNPLATFORM_H_
|
|
||||||
#define INCLUDE_DAWN_PLATFORM_DAWNPLATFORM_H_
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "dawn/platform/dawn_platform_export.h"
|
|
||||||
#include "dawn/webgpu.h"
|
|
||||||
|
|
||||||
namespace dawn::platform {
|
|
||||||
|
|
||||||
enum class TraceCategory {
|
|
||||||
General, // General trace events
|
|
||||||
Validation, // Dawn validation
|
|
||||||
Recording, // Native command recording
|
|
||||||
GPUWork, // Actual GPU work
|
|
||||||
};
|
|
||||||
|
|
||||||
class DAWN_PLATFORM_EXPORT CachingInterface {
|
|
||||||
public:
|
|
||||||
CachingInterface();
|
|
||||||
virtual ~CachingInterface();
|
|
||||||
|
|
||||||
// LoadData has two modes. The first mode is used to get a value which
|
|
||||||
// corresponds to the |key|. The |valueOut| is a caller provided buffer
|
|
||||||
// allocated to the size |valueSize| which is loaded with data of the
|
|
||||||
// size returned. The second mode is used to query for the existence of
|
|
||||||
// the |key| where |valueOut| is nullptr and |valueSize| must be 0.
|
|
||||||
// The return size is non-zero if the |key| exists.
|
|
||||||
virtual size_t LoadData(const void* key, size_t keySize, void* valueOut, size_t valueSize) = 0;
|
|
||||||
|
|
||||||
// StoreData puts a |value| in the cache which corresponds to the |key|.
|
|
||||||
virtual void StoreData(const void* key,
|
|
||||||
size_t keySize,
|
|
||||||
const void* value,
|
|
||||||
size_t valueSize) = 0;
|
|
||||||
|
|
||||||
private:
|
|
||||||
CachingInterface(const CachingInterface&) = delete;
|
|
||||||
CachingInterface& operator=(const CachingInterface&) = delete;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DAWN_PLATFORM_EXPORT WaitableEvent {
|
|
||||||
public:
|
|
||||||
WaitableEvent() = default;
|
|
||||||
virtual ~WaitableEvent() = default;
|
|
||||||
virtual void Wait() = 0; // Wait for completion
|
|
||||||
virtual bool IsComplete() = 0; // Non-blocking check if the event is complete
|
|
||||||
};
|
|
||||||
|
|
||||||
using PostWorkerTaskCallback = void (*)(void* userdata);
|
|
||||||
|
|
||||||
class DAWN_PLATFORM_EXPORT WorkerTaskPool {
|
|
||||||
public:
|
|
||||||
WorkerTaskPool() = default;
|
|
||||||
virtual ~WorkerTaskPool() = default;
|
|
||||||
virtual std::unique_ptr<WaitableEvent> PostWorkerTask(PostWorkerTaskCallback,
|
|
||||||
void* userdata) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DAWN_PLATFORM_EXPORT Platform {
|
|
||||||
public:
|
|
||||||
Platform();
|
|
||||||
virtual ~Platform();
|
|
||||||
|
|
||||||
virtual const unsigned char* GetTraceCategoryEnabledFlag(TraceCategory category);
|
|
||||||
|
|
||||||
virtual double MonotonicallyIncreasingTime();
|
|
||||||
|
|
||||||
virtual uint64_t AddTraceEvent(char phase,
|
|
||||||
const unsigned char* categoryGroupEnabled,
|
|
||||||
const char* name,
|
|
||||||
uint64_t id,
|
|
||||||
double timestamp,
|
|
||||||
int numArgs,
|
|
||||||
const char** argNames,
|
|
||||||
const unsigned char* argTypes,
|
|
||||||
const uint64_t* argValues,
|
|
||||||
unsigned char flags);
|
|
||||||
|
|
||||||
// Invoked to add a UMA histogram count-based sample
|
|
||||||
virtual void HistogramCustomCounts(const char* name,
|
|
||||||
int sample,
|
|
||||||
int min,
|
|
||||||
int max,
|
|
||||||
int bucketCount);
|
|
||||||
|
|
||||||
// Invoked to add a UMA histogram enumeration sample
|
|
||||||
virtual void HistogramEnumeration(const char* name, int sample, int boundaryValue);
|
|
||||||
|
|
||||||
// Invoked to add a UMA histogram sparse sample
|
|
||||||
virtual void HistogramSparse(const char* name, int sample);
|
|
||||||
|
|
||||||
// Invoked to add a UMA histogram boolean sample
|
|
||||||
virtual void HistogramBoolean(const char* name, bool sample);
|
|
||||||
|
|
||||||
// The returned CachingInterface is expected to outlive the device which uses it to persistently
|
|
||||||
// cache objects.
|
|
||||||
virtual CachingInterface* GetCachingInterface();
|
|
||||||
|
|
||||||
virtual std::unique_ptr<WorkerTaskPool> CreateWorkerTaskPool();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Platform(const Platform&) = delete;
|
|
||||||
Platform& operator=(const Platform&) = delete;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace dawn::platform
|
|
||||||
|
|
||||||
// TODO(dawn:824): Remove once the deprecation period is passed.
|
|
||||||
namespace dawn_platform = dawn::platform;
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_PLATFORM_DAWNPLATFORM_H_
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
// Copyright 2020 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_PLATFORM_DAWN_PLATFORM_EXPORT_H_
|
|
||||||
#define INCLUDE_DAWN_PLATFORM_DAWN_PLATFORM_EXPORT_H_
|
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_SHARED_LIBRARY)
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#if defined(DAWN_PLATFORM_IMPLEMENTATION)
|
|
||||||
#define DAWN_PLATFORM_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define DAWN_PLATFORM_EXPORT __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#else // defined(_WIN32)
|
|
||||||
#if defined(DAWN_PLATFORM_IMPLEMENTATION)
|
|
||||||
#define DAWN_PLATFORM_EXPORT __attribute__((visibility("default")))
|
|
||||||
#else
|
|
||||||
#define DAWN_PLATFORM_EXPORT
|
|
||||||
#endif
|
|
||||||
#endif // defined(_WIN32)
|
|
||||||
#else // defined(DAWN_PLATFORM_SHARED_LIBRARY)
|
|
||||||
#define DAWN_PLATFORM_EXPORT
|
|
||||||
#endif // defined(DAWN_PLATFORM_SHARED_LIBRARY)
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_PLATFORM_DAWN_PLATFORM_EXPORT_H_
|
|
||||||
2034
vendor/zgpu/libs/dawn/include/dawn/webgpu.h
vendored
2034
vendor/zgpu/libs/dawn/include/dawn/webgpu.h
vendored
File diff suppressed because it is too large
Load Diff
2012
vendor/zgpu/libs/dawn/include/dawn/webgpu_cpp.h
vendored
2012
vendor/zgpu/libs/dawn/include/dawn/webgpu_cpp.h
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,35 +0,0 @@
|
|||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
#error "Do not include this header. Emscripten already provides headers needed for WebGPU."
|
|
||||||
#endif
|
|
||||||
#ifndef WEBGPU_CPP_CHAINED_STRUCT_H_
|
|
||||||
#define WEBGPU_CPP_CHAINED_STRUCT_H_
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
// This header file declares the ChainedStruct structures separately from the WebGPU
|
|
||||||
// headers so that dependencies can directly extend structures without including the larger header
|
|
||||||
// which exposes capabilities that may require correctly set proc tables.
|
|
||||||
namespace wgpu {
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
constexpr size_t ConstexprMax(size_t a, size_t b) {
|
|
||||||
return a > b ? a : b;
|
|
||||||
}
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
enum class SType : uint32_t;
|
|
||||||
|
|
||||||
struct ChainedStruct {
|
|
||||||
ChainedStruct const * nextInChain = nullptr;
|
|
||||||
SType sType = SType(0u);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ChainedStructOut {
|
|
||||||
ChainedStructOut * nextInChain = nullptr;
|
|
||||||
SType sType = SType(0u);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace wgpu}
|
|
||||||
|
|
||||||
#endif // WEBGPU_CPP_CHAINED_STRUCT_H_
|
|
||||||
1825
vendor/zgpu/libs/dawn/include/dawn/webgpu_cpp_print.h
vendored
1825
vendor/zgpu/libs/dawn/include/dawn/webgpu_cpp_print.h
vendored
File diff suppressed because it is too large
Load Diff
58
vendor/zgpu/libs/dawn/include/dawn/wire/Wire.h
vendored
58
vendor/zgpu/libs/dawn/include/dawn/wire/Wire.h
vendored
@@ -1,58 +0,0 @@
|
|||||||
// Copyright 2017 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_WIRE_WIRE_H_
|
|
||||||
#define INCLUDE_DAWN_WIRE_WIRE_H_
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
#include "dawn/webgpu.h"
|
|
||||||
#include "dawn/wire/dawn_wire_export.h"
|
|
||||||
|
|
||||||
namespace dawn::wire {
|
|
||||||
|
|
||||||
class DAWN_WIRE_EXPORT CommandSerializer {
|
|
||||||
public:
|
|
||||||
CommandSerializer();
|
|
||||||
virtual ~CommandSerializer();
|
|
||||||
CommandSerializer(const CommandSerializer& rhs) = delete;
|
|
||||||
CommandSerializer& operator=(const CommandSerializer& rhs) = delete;
|
|
||||||
|
|
||||||
// Get space for serializing commands.
|
|
||||||
// GetCmdSpace will never be called with a value larger than
|
|
||||||
// what GetMaximumAllocationSize returns. Return nullptr to indicate
|
|
||||||
// a fatal error.
|
|
||||||
virtual void* GetCmdSpace(size_t size) = 0;
|
|
||||||
virtual bool Flush() = 0;
|
|
||||||
virtual size_t GetMaximumAllocationSize() const = 0;
|
|
||||||
virtual void OnSerializeError();
|
|
||||||
};
|
|
||||||
|
|
||||||
class DAWN_WIRE_EXPORT CommandHandler {
|
|
||||||
public:
|
|
||||||
CommandHandler();
|
|
||||||
virtual ~CommandHandler();
|
|
||||||
CommandHandler(const CommandHandler& rhs) = delete;
|
|
||||||
CommandHandler& operator=(const CommandHandler& rhs) = delete;
|
|
||||||
|
|
||||||
virtual const volatile char* HandleCommands(const volatile char* commands, size_t size) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace dawn::wire
|
|
||||||
|
|
||||||
// TODO(dawn:824): Remove once the deprecation period is passed.
|
|
||||||
namespace dawn_wire = dawn::wire;
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_WIRE_WIRE_H_
|
|
||||||
181
vendor/zgpu/libs/dawn/include/dawn/wire/WireClient.h
vendored
181
vendor/zgpu/libs/dawn/include/dawn/wire/WireClient.h
vendored
@@ -1,181 +0,0 @@
|
|||||||
// Copyright 2019 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_WIRE_WIRECLIENT_H_
|
|
||||||
#define INCLUDE_DAWN_WIRE_WIRECLIENT_H_
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "dawn/dawn_proc_table.h"
|
|
||||||
#include "dawn/wire/Wire.h"
|
|
||||||
|
|
||||||
namespace dawn::wire {
|
|
||||||
|
|
||||||
namespace client {
|
|
||||||
class Client;
|
|
||||||
class MemoryTransferService;
|
|
||||||
|
|
||||||
DAWN_WIRE_EXPORT const DawnProcTable& GetProcs();
|
|
||||||
} // namespace client
|
|
||||||
|
|
||||||
struct ReservedTexture {
|
|
||||||
WGPUTexture texture;
|
|
||||||
uint32_t id;
|
|
||||||
uint32_t generation;
|
|
||||||
uint32_t deviceId;
|
|
||||||
uint32_t deviceGeneration;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ReservedSwapChain {
|
|
||||||
WGPUSwapChain swapchain;
|
|
||||||
uint32_t id;
|
|
||||||
uint32_t generation;
|
|
||||||
uint32_t deviceId;
|
|
||||||
uint32_t deviceGeneration;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ReservedDevice {
|
|
||||||
WGPUDevice device;
|
|
||||||
uint32_t id;
|
|
||||||
uint32_t generation;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ReservedInstance {
|
|
||||||
WGPUInstance instance;
|
|
||||||
uint32_t id;
|
|
||||||
uint32_t generation;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DAWN_WIRE_EXPORT WireClientDescriptor {
|
|
||||||
CommandSerializer* serializer;
|
|
||||||
client::MemoryTransferService* memoryTransferService = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DAWN_WIRE_EXPORT WireClient : public CommandHandler {
|
|
||||||
public:
|
|
||||||
explicit WireClient(const WireClientDescriptor& descriptor);
|
|
||||||
~WireClient() override;
|
|
||||||
|
|
||||||
const volatile char* HandleCommands(const volatile char* commands, size_t size) override;
|
|
||||||
|
|
||||||
ReservedTexture ReserveTexture(WGPUDevice device, const WGPUTextureDescriptor* descriptor);
|
|
||||||
ReservedSwapChain ReserveSwapChain(WGPUDevice device,
|
|
||||||
const WGPUSwapChainDescriptor* descriptor);
|
|
||||||
ReservedDevice ReserveDevice();
|
|
||||||
ReservedInstance ReserveInstance();
|
|
||||||
|
|
||||||
void ReclaimTextureReservation(const ReservedTexture& reservation);
|
|
||||||
void ReclaimSwapChainReservation(const ReservedSwapChain& reservation);
|
|
||||||
void ReclaimDeviceReservation(const ReservedDevice& reservation);
|
|
||||||
void ReclaimInstanceReservation(const ReservedInstance& reservation);
|
|
||||||
|
|
||||||
// Disconnects the client.
|
|
||||||
// Commands allocated after this point will not be sent.
|
|
||||||
void Disconnect();
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unique_ptr<client::Client> mImpl;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace client {
|
|
||||||
class DAWN_WIRE_EXPORT MemoryTransferService {
|
|
||||||
public:
|
|
||||||
MemoryTransferService();
|
|
||||||
virtual ~MemoryTransferService();
|
|
||||||
|
|
||||||
class ReadHandle;
|
|
||||||
class WriteHandle;
|
|
||||||
|
|
||||||
// Create a handle for reading server data.
|
|
||||||
// This may fail and return nullptr.
|
|
||||||
virtual ReadHandle* CreateReadHandle(size_t) = 0;
|
|
||||||
|
|
||||||
// Create a handle for writing server data.
|
|
||||||
// This may fail and return nullptr.
|
|
||||||
virtual WriteHandle* CreateWriteHandle(size_t) = 0;
|
|
||||||
|
|
||||||
class DAWN_WIRE_EXPORT ReadHandle {
|
|
||||||
public:
|
|
||||||
ReadHandle();
|
|
||||||
virtual ~ReadHandle();
|
|
||||||
|
|
||||||
// Get the required serialization size for SerializeCreate
|
|
||||||
virtual size_t SerializeCreateSize() = 0;
|
|
||||||
|
|
||||||
// Serialize the handle into |serializePointer| so it can be received by the server.
|
|
||||||
virtual void SerializeCreate(void* serializePointer) = 0;
|
|
||||||
|
|
||||||
// Simply return the base address of the allocation (without applying any offset)
|
|
||||||
// Returns nullptr if the allocation failed.
|
|
||||||
// The data must live at least until the ReadHandle is destructued
|
|
||||||
virtual const void* GetData() = 0;
|
|
||||||
|
|
||||||
// Gets called when a MapReadCallback resolves.
|
|
||||||
// deserialize the data update and apply
|
|
||||||
// it to the range (offset, offset + size) of allocation
|
|
||||||
// There could be nothing to be deserialized (if using shared memory)
|
|
||||||
// Needs to check potential offset/size OOB and overflow
|
|
||||||
virtual bool DeserializeDataUpdate(const void* deserializePointer,
|
|
||||||
size_t deserializeSize,
|
|
||||||
size_t offset,
|
|
||||||
size_t size) = 0;
|
|
||||||
|
|
||||||
private:
|
|
||||||
ReadHandle(const ReadHandle&) = delete;
|
|
||||||
ReadHandle& operator=(const ReadHandle&) = delete;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DAWN_WIRE_EXPORT WriteHandle {
|
|
||||||
public:
|
|
||||||
WriteHandle();
|
|
||||||
virtual ~WriteHandle();
|
|
||||||
|
|
||||||
// Get the required serialization size for SerializeCreate
|
|
||||||
virtual size_t SerializeCreateSize() = 0;
|
|
||||||
|
|
||||||
// Serialize the handle into |serializePointer| so it can be received by the server.
|
|
||||||
virtual void SerializeCreate(void* serializePointer) = 0;
|
|
||||||
|
|
||||||
// Simply return the base address of the allocation (without applying any offset)
|
|
||||||
// The data returned should be zero-initialized.
|
|
||||||
// The data returned must live at least until the WriteHandle is destructed.
|
|
||||||
// On failure, the pointer returned should be null.
|
|
||||||
virtual void* GetData() = 0;
|
|
||||||
|
|
||||||
// Get the required serialization size for SerializeDataUpdate
|
|
||||||
virtual size_t SizeOfSerializeDataUpdate(size_t offset, size_t size) = 0;
|
|
||||||
|
|
||||||
// Serialize a command to send the modified contents of
|
|
||||||
// the subrange (offset, offset + size) of the allocation at buffer unmap
|
|
||||||
// This subrange is always the whole mapped region for now
|
|
||||||
// There could be nothing to be serialized (if using shared memory)
|
|
||||||
virtual void SerializeDataUpdate(void* serializePointer, size_t offset, size_t size) = 0;
|
|
||||||
|
|
||||||
private:
|
|
||||||
WriteHandle(const WriteHandle&) = delete;
|
|
||||||
WriteHandle& operator=(const WriteHandle&) = delete;
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
MemoryTransferService(const MemoryTransferService&) = delete;
|
|
||||||
MemoryTransferService& operator=(const MemoryTransferService&) = delete;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Backdoor to get the order of the ProcMap for testing
|
|
||||||
DAWN_WIRE_EXPORT std::vector<const char*> GetProcMapNamesForTesting();
|
|
||||||
} // namespace client
|
|
||||||
} // namespace dawn::wire
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_WIRE_WIRECLIENT_H_
|
|
||||||
154
vendor/zgpu/libs/dawn/include/dawn/wire/WireServer.h
vendored
154
vendor/zgpu/libs/dawn/include/dawn/wire/WireServer.h
vendored
@@ -1,154 +0,0 @@
|
|||||||
// Copyright 2019 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_WIRE_WIRESERVER_H_
|
|
||||||
#define INCLUDE_DAWN_WIRE_WIRESERVER_H_
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "dawn/wire/Wire.h"
|
|
||||||
|
|
||||||
struct DawnProcTable;
|
|
||||||
|
|
||||||
namespace dawn::wire {
|
|
||||||
|
|
||||||
namespace server {
|
|
||||||
class Server;
|
|
||||||
class MemoryTransferService;
|
|
||||||
} // namespace server
|
|
||||||
|
|
||||||
struct DAWN_WIRE_EXPORT WireServerDescriptor {
|
|
||||||
const DawnProcTable* procs;
|
|
||||||
CommandSerializer* serializer;
|
|
||||||
server::MemoryTransferService* memoryTransferService = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DAWN_WIRE_EXPORT WireServer : public CommandHandler {
|
|
||||||
public:
|
|
||||||
explicit WireServer(const WireServerDescriptor& descriptor);
|
|
||||||
~WireServer() override;
|
|
||||||
|
|
||||||
const volatile char* HandleCommands(const volatile char* commands, size_t size) override;
|
|
||||||
|
|
||||||
bool InjectTexture(WGPUTexture texture,
|
|
||||||
uint32_t id,
|
|
||||||
uint32_t generation,
|
|
||||||
uint32_t deviceId,
|
|
||||||
uint32_t deviceGeneration);
|
|
||||||
bool InjectSwapChain(WGPUSwapChain swapchain,
|
|
||||||
uint32_t id,
|
|
||||||
uint32_t generation,
|
|
||||||
uint32_t deviceId,
|
|
||||||
uint32_t deviceGeneration);
|
|
||||||
|
|
||||||
bool InjectDevice(WGPUDevice device, uint32_t id, uint32_t generation);
|
|
||||||
|
|
||||||
bool InjectInstance(WGPUInstance instance, uint32_t id, uint32_t generation);
|
|
||||||
|
|
||||||
// Look up a device by (id, generation) pair. Returns nullptr if the generation
|
|
||||||
// has expired or the id is not found.
|
|
||||||
// The Wire does not have destroy hooks to allow an embedder to observe when an object
|
|
||||||
// has been destroyed, but in Chrome, we need to know the list of live devices so we
|
|
||||||
// can call device.Tick() on all of them periodically to ensure progress on asynchronous
|
|
||||||
// work is made. Getting this list can be done by tracking the (id, generation) of
|
|
||||||
// previously injected devices, and observing if GetDevice(id, generation) returns non-null.
|
|
||||||
WGPUDevice GetDevice(uint32_t id, uint32_t generation);
|
|
||||||
|
|
||||||
// Check if a device handle is known by the wire.
|
|
||||||
// In Chrome, we need to know the list of live devices so we can call device.Tick() on all of
|
|
||||||
// them periodically to ensure progress on asynchronous work is made.
|
|
||||||
bool IsDeviceKnown(WGPUDevice device) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unique_ptr<server::Server> mImpl;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace server {
|
|
||||||
class DAWN_WIRE_EXPORT MemoryTransferService {
|
|
||||||
public:
|
|
||||||
MemoryTransferService();
|
|
||||||
virtual ~MemoryTransferService();
|
|
||||||
|
|
||||||
class ReadHandle;
|
|
||||||
class WriteHandle;
|
|
||||||
|
|
||||||
// Deserialize data to create Read/Write handles. These handles are for the client
|
|
||||||
// to Read/Write data.
|
|
||||||
virtual bool DeserializeReadHandle(const void* deserializePointer,
|
|
||||||
size_t deserializeSize,
|
|
||||||
ReadHandle** readHandle) = 0;
|
|
||||||
virtual bool DeserializeWriteHandle(const void* deserializePointer,
|
|
||||||
size_t deserializeSize,
|
|
||||||
WriteHandle** writeHandle) = 0;
|
|
||||||
|
|
||||||
class DAWN_WIRE_EXPORT ReadHandle {
|
|
||||||
public:
|
|
||||||
ReadHandle();
|
|
||||||
virtual ~ReadHandle();
|
|
||||||
|
|
||||||
// Return the size of the command serialized if
|
|
||||||
// SerializeDataUpdate is called with the same offset/size args
|
|
||||||
virtual size_t SizeOfSerializeDataUpdate(size_t offset, size_t size) = 0;
|
|
||||||
|
|
||||||
// Gets called when a MapReadCallback resolves.
|
|
||||||
// Serialize the data update for the range (offset, offset + size) into
|
|
||||||
// |serializePointer| to the client There could be nothing to be serialized (if
|
|
||||||
// using shared memory)
|
|
||||||
virtual void SerializeDataUpdate(const void* data,
|
|
||||||
size_t offset,
|
|
||||||
size_t size,
|
|
||||||
void* serializePointer) = 0;
|
|
||||||
|
|
||||||
private:
|
|
||||||
ReadHandle(const ReadHandle&) = delete;
|
|
||||||
ReadHandle& operator=(const ReadHandle&) = delete;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DAWN_WIRE_EXPORT WriteHandle {
|
|
||||||
public:
|
|
||||||
WriteHandle();
|
|
||||||
virtual ~WriteHandle();
|
|
||||||
|
|
||||||
// Set the target for writes from the client. DeserializeFlush should copy data
|
|
||||||
// into the target.
|
|
||||||
void SetTarget(void* data);
|
|
||||||
// Set Staging data length for OOB check
|
|
||||||
void SetDataLength(size_t dataLength);
|
|
||||||
|
|
||||||
// This function takes in the serialized result of
|
|
||||||
// client::MemoryTransferService::WriteHandle::SerializeDataUpdate.
|
|
||||||
// Needs to check potential offset/size OOB and overflow
|
|
||||||
virtual bool DeserializeDataUpdate(const void* deserializePointer,
|
|
||||||
size_t deserializeSize,
|
|
||||||
size_t offset,
|
|
||||||
size_t size) = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void* mTargetData = nullptr;
|
|
||||||
size_t mDataLength = 0;
|
|
||||||
|
|
||||||
private:
|
|
||||||
WriteHandle(const WriteHandle&) = delete;
|
|
||||||
WriteHandle& operator=(const WriteHandle&) = delete;
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
MemoryTransferService(const MemoryTransferService&) = delete;
|
|
||||||
MemoryTransferService& operator=(const MemoryTransferService&) = delete;
|
|
||||||
};
|
|
||||||
} // namespace server
|
|
||||||
|
|
||||||
} // namespace dawn::wire
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_WIRE_WIRESERVER_H_
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
// Copyright 2018 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_DAWN_WIRE_DAWN_WIRE_EXPORT_H_
|
|
||||||
#define INCLUDE_DAWN_WIRE_DAWN_WIRE_EXPORT_H_
|
|
||||||
|
|
||||||
#if defined(DAWN_WIRE_SHARED_LIBRARY)
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#if defined(DAWN_WIRE_IMPLEMENTATION)
|
|
||||||
#define DAWN_WIRE_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define DAWN_WIRE_EXPORT __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#else // defined(_WIN32)
|
|
||||||
#if defined(DAWN_WIRE_IMPLEMENTATION)
|
|
||||||
#define DAWN_WIRE_EXPORT __attribute__((visibility("default")))
|
|
||||||
#else
|
|
||||||
#define DAWN_WIRE_EXPORT
|
|
||||||
#endif
|
|
||||||
#endif // defined(_WIN32)
|
|
||||||
#else // defined(DAWN_WIRE_SHARED_LIBRARY)
|
|
||||||
#define DAWN_WIRE_EXPORT
|
|
||||||
#endif // defined(DAWN_WIRE_SHARED_LIBRARY)
|
|
||||||
|
|
||||||
#endif // INCLUDE_DAWN_WIRE_DAWN_WIRE_EXPORT_H_
|
|
||||||
66
vendor/zgpu/libs/dawn/include/tint/override_id.h
vendored
66
vendor/zgpu/libs/dawn/include/tint/override_id.h
vendored
@@ -1,66 +0,0 @@
|
|||||||
// Copyright 2022 The Tint Authors.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef SRC_TINT_OVERRIDE_ID_H_
|
|
||||||
#define SRC_TINT_OVERRIDE_ID_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
#include "src/tint/reflection.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
|
|
||||||
/// OverrideId is a numerical identifier for an override variable, unique per program.
|
|
||||||
struct OverrideId {
|
|
||||||
uint16_t value = 0;
|
|
||||||
|
|
||||||
/// Reflect the fields of this struct so that it can be used by tint::ForeachField()
|
|
||||||
TINT_REFLECT(value);
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Equality operator for OverrideId
|
|
||||||
/// @param lhs the OverrideId on the left of the '=' operator
|
|
||||||
/// @param rhs the OverrideId on the right of the '=' operator
|
|
||||||
/// @returns true if `lhs` is equal to `rhs`
|
|
||||||
inline bool operator==(OverrideId lhs, OverrideId rhs) {
|
|
||||||
return lhs.value == rhs.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Less-than operator for OverrideId
|
|
||||||
/// @param lhs the OverrideId on the left of the '<' operator
|
|
||||||
/// @param rhs the OverrideId on the right of the '<' operator
|
|
||||||
/// @returns true if `lhs` comes before `rhs`
|
|
||||||
inline bool operator<(OverrideId lhs, OverrideId rhs) {
|
|
||||||
return lhs.value < rhs.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace tint
|
|
||||||
|
|
||||||
namespace std {
|
|
||||||
|
|
||||||
/// Custom std::hash specialization for tint::OverrideId.
|
|
||||||
template <>
|
|
||||||
class hash<tint::OverrideId> {
|
|
||||||
public:
|
|
||||||
/// @param id the override identifier
|
|
||||||
/// @return the hash of the override identifier
|
|
||||||
inline std::size_t operator()(tint::OverrideId id) const {
|
|
||||||
return std::hash<decltype(tint::OverrideId::value)>()(id.value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#endif // SRC_TINT_OVERRIDE_ID_H_
|
|
||||||
82
vendor/zgpu/libs/dawn/include/tint/tint.h
vendored
82
vendor/zgpu/libs/dawn/include/tint/tint.h
vendored
@@ -1,82 +0,0 @@
|
|||||||
// Copyright 2020 The Tint Authors.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_TINT_TINT_H_
|
|
||||||
#define INCLUDE_TINT_TINT_H_
|
|
||||||
|
|
||||||
// Guard for accidental includes to private headers
|
|
||||||
#define CURRENTLY_IN_TINT_PUBLIC_HEADER
|
|
||||||
|
|
||||||
// TODO(tint:88): When implementing support for an install target, all of these
|
|
||||||
// headers will need to be moved to include/tint/.
|
|
||||||
|
|
||||||
#include "src/tint/ast/transform/first_index_offset.h"
|
|
||||||
#include "src/tint/ast/transform/renamer.h"
|
|
||||||
#include "src/tint/ast/transform/single_entry_point.h"
|
|
||||||
#include "src/tint/ast/transform/substitute_override.h"
|
|
||||||
#include "src/tint/ast/transform/vertex_pulling.h"
|
|
||||||
#include "src/tint/diagnostic/printer.h"
|
|
||||||
#include "src/tint/inspector/inspector.h"
|
|
||||||
#include "src/tint/reader/reader.h"
|
|
||||||
#include "src/tint/transform/manager.h"
|
|
||||||
#include "src/tint/type/manager.h"
|
|
||||||
#include "src/tint/utils/unicode.h"
|
|
||||||
#include "src/tint/writer/array_length_from_uniform_options.h"
|
|
||||||
#include "src/tint/writer/binding_point.h"
|
|
||||||
#include "src/tint/writer/binding_remapper_options.h"
|
|
||||||
#include "src/tint/writer/external_texture_options.h"
|
|
||||||
#include "src/tint/writer/flatten_bindings.h"
|
|
||||||
#include "src/tint/writer/writer.h"
|
|
||||||
|
|
||||||
#if TINT_BUILD_SPV_READER
|
|
||||||
#include "src/tint/reader/spirv/parser.h"
|
|
||||||
#endif // TINT_BUILD_SPV_READER
|
|
||||||
|
|
||||||
#if TINT_BUILD_WGSL_READER
|
|
||||||
#include "src/tint/reader/wgsl/parser.h"
|
|
||||||
#endif // TINT_BUILD_WGSL_READER
|
|
||||||
|
|
||||||
#if TINT_BUILD_SPV_WRITER
|
|
||||||
#include "src/tint/writer/spirv/generator.h"
|
|
||||||
#endif // TINT_BUILD_SPV_WRITER
|
|
||||||
|
|
||||||
#if TINT_BUILD_WGSL_WRITER
|
|
||||||
#include "src/tint/writer/wgsl/generator.h"
|
|
||||||
#endif // TINT_BUILD_WGSL_WRITER
|
|
||||||
|
|
||||||
#if TINT_BUILD_MSL_WRITER
|
|
||||||
#include "src/tint/writer/msl/generator.h"
|
|
||||||
#endif // TINT_BUILD_MSL_WRITER
|
|
||||||
|
|
||||||
#if TINT_BUILD_HLSL_WRITER
|
|
||||||
#include "src/tint/writer/hlsl/generator.h"
|
|
||||||
#endif // TINT_BUILD_HLSL_WRITER
|
|
||||||
|
|
||||||
#if TINT_BUILD_GLSL_WRITER
|
|
||||||
#include "src/tint/writer/glsl/generator.h"
|
|
||||||
#endif // TINT_BUILD_GLSL_WRITER
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
|
|
||||||
/// Initialize initializes the Tint library. Call before using the Tint API.
|
|
||||||
void Initialize();
|
|
||||||
|
|
||||||
/// Shutdown uninitializes the Tint library. Call after using the Tint API.
|
|
||||||
void Shutdown();
|
|
||||||
|
|
||||||
} // namespace tint
|
|
||||||
|
|
||||||
#undef CURRENTLY_IN_TINT_PUBLIC_HEADER
|
|
||||||
|
|
||||||
#endif // INCLUDE_TINT_TINT_H_
|
|
||||||
20
vendor/zgpu/libs/dawn/include/webgpu/webgpu.h
vendored
20
vendor/zgpu/libs/dawn/include/webgpu/webgpu.h
vendored
@@ -1,20 +0,0 @@
|
|||||||
// Copyright 2022 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_WEBGPU_WEBGPU_H_
|
|
||||||
#define INCLUDE_WEBGPU_WEBGPU_H_
|
|
||||||
|
|
||||||
#include "dawn/webgpu.h"
|
|
||||||
|
|
||||||
#endif // INCLUDE_WEBGPU_WEBGPU_H_
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
// Copyright 2022 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_WEBGPU_WEBGPU_CPP_H_
|
|
||||||
#define INCLUDE_WEBGPU_WEBGPU_CPP_H_
|
|
||||||
|
|
||||||
#include "dawn/webgpu_cpp.h"
|
|
||||||
|
|
||||||
#endif // INCLUDE_WEBGPU_WEBGPU_CPP_H_
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
// Copyright 2022 The Dawn Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef INCLUDE_WEBGPU_WEBGPU_GLFW_H_
|
|
||||||
#define INCLUDE_WEBGPU_WEBGPU_GLFW_H_
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "webgpu/webgpu_cpp.h"
|
|
||||||
|
|
||||||
#if defined(WGPU_GLFW_SHARED_LIBRARY)
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#if defined(WGPU_GLFW_IMPLEMENTATION)
|
|
||||||
#define WGPU_GLFW_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define WGPU_GLFW_EXPORT __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#else // defined(_WIN32)
|
|
||||||
#if defined(WGPU_GLFW_IMPLEMENTATION)
|
|
||||||
#define WGPU_GLFW_EXPORT __attribute__((visibility("default")))
|
|
||||||
#else
|
|
||||||
#define WGPU_GLFW_EXPORT
|
|
||||||
#endif
|
|
||||||
#endif // defined(_WIN32)
|
|
||||||
#else // defined(WGPU_GLFW_SHARED_LIBRARY)
|
|
||||||
#define WGPU_GLFW_EXPORT
|
|
||||||
#endif // defined(WGPU_GLFW_SHARED_LIBRARY)
|
|
||||||
|
|
||||||
struct GLFWwindow;
|
|
||||||
|
|
||||||
namespace wgpu::glfw {
|
|
||||||
|
|
||||||
// Does the necessary setup on the GLFWwindow to allow creating a wgpu::Surface with it and
|
|
||||||
// calls `instance.CreateSurface` with the correct descriptor for this window.
|
|
||||||
// Returns a null wgpu::Surface on failure.
|
|
||||||
WGPU_GLFW_EXPORT wgpu::Surface CreateSurfaceForWindow(const wgpu::Instance& instance,
|
|
||||||
GLFWwindow* window);
|
|
||||||
|
|
||||||
// Use for testing only. Does everything that CreateSurfaceForWindow does except the call to
|
|
||||||
// CreateSurface. Useful to be able to modify the descriptor for testing, or when trying to
|
|
||||||
// avoid using the global proc table.
|
|
||||||
WGPU_GLFW_EXPORT std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptor(
|
|
||||||
GLFWwindow* window);
|
|
||||||
|
|
||||||
} // namespace wgpu::glfw
|
|
||||||
|
|
||||||
#endif // INCLUDE_WEBGPU_WEBGPU_GLFW_H_
|
|
||||||
99
vendor/zgpu/src/common_wgsl.zig
vendored
99
vendor/zgpu/src/common_wgsl.zig
vendored
@@ -1,99 +0,0 @@
|
|||||||
const std = @import("std");
|
|
||||||
|
|
||||||
pub fn csGenerateMipmaps(allocator: std.mem.Allocator, format: []const u8) [:0]const u8 {
|
|
||||||
const s0 = std.fmt.allocPrint(
|
|
||||||
allocator,
|
|
||||||
\\ @group(0) @binding(2) var dst_mipmap1: texture_storage_2d<{s}, write>;
|
|
||||||
\\ @group(0) @binding(3) var dst_mipmap2: texture_storage_2d<{s}, write>;
|
|
||||||
\\ @group(0) @binding(4) var dst_mipmap3: texture_storage_2d<{s}, write>;
|
|
||||||
\\ @group(0) @binding(5) var dst_mipmap4: texture_storage_2d<{s}, write>;
|
|
||||||
,
|
|
||||||
.{ format, format, format, format },
|
|
||||||
) catch unreachable;
|
|
||||||
defer allocator.free(s0);
|
|
||||||
return std.mem.joinZ(allocator, "\n\n", &.{ s0, cs_generate_mipmaps }) catch unreachable;
|
|
||||||
}
|
|
||||||
|
|
||||||
// zig fmt: off
|
|
||||||
const cs_generate_mipmaps =
|
|
||||||
\\ struct Uniforms {
|
|
||||||
\\ src_mip_level: i32,
|
|
||||||
\\ num_mip_levels: u32,
|
|
||||||
\\ }
|
|
||||||
\\ @group(0) @binding(0) var<uniform> uniforms: Uniforms;
|
|
||||||
\\ @group(0) @binding(1) var src_image: texture_2d<f32>;
|
|
||||||
\\
|
|
||||||
\\ var<workgroup> red: array<f32, 64>;
|
|
||||||
\\ var<workgroup> green: array<f32, 64>;
|
|
||||||
\\ var<workgroup> blue: array<f32, 64>;
|
|
||||||
\\ var<workgroup> alpha: array<f32, 64>;
|
|
||||||
\\
|
|
||||||
\\ fn storeColor(index: u32, color: vec4<f32>) {
|
|
||||||
\\ red[index] = color.x;
|
|
||||||
\\ green[index] = color.y;
|
|
||||||
\\ blue[index] = color.z;
|
|
||||||
\\ alpha[index] = color.w;
|
|
||||||
\\ }
|
|
||||||
\\
|
|
||||||
\\ fn loadColor(index: u32) -> vec4<f32> {
|
|
||||||
\\ return vec4(red[index], green[index], blue[index], alpha[index]);
|
|
||||||
\\ }
|
|
||||||
\\
|
|
||||||
\\ @compute @workgroup_size(8, 8, 1)
|
|
||||||
\\ fn main(
|
|
||||||
\\ @builtin(global_invocation_id) global_invocation_id: vec3<u32>,
|
|
||||||
\\ @builtin(local_invocation_index) local_invocation_index : u32,
|
|
||||||
\\ ) {
|
|
||||||
\\ let x = i32(global_invocation_id.x * 2u);
|
|
||||||
\\ let y = i32(global_invocation_id.y * 2u);
|
|
||||||
\\
|
|
||||||
\\ var s00 = textureLoad(src_image, vec2(x, y), uniforms.src_mip_level);
|
|
||||||
\\ var s10 = textureLoad(src_image, vec2(x + 1, y), uniforms.src_mip_level);
|
|
||||||
\\ var s01 = textureLoad(src_image, vec2(x, y + 1), uniforms.src_mip_level);
|
|
||||||
\\ var s11 = textureLoad(src_image, vec2(x + 1, y + 1), uniforms.src_mip_level);
|
|
||||||
\\ s00 = 0.25 * (s00 + s01 + s10 + s11);
|
|
||||||
\\
|
|
||||||
\\ textureStore(dst_mipmap1, vec2<i32>(global_invocation_id.xy), s00);
|
|
||||||
\\ storeColor(local_invocation_index, s00);
|
|
||||||
\\ if (uniforms.num_mip_levels == 1u) {
|
|
||||||
\\ return;
|
|
||||||
\\ }
|
|
||||||
\\ workgroupBarrier();
|
|
||||||
\\
|
|
||||||
\\ if ((local_invocation_index & 0x9u) == 0u) {
|
|
||||||
\\ s10 = loadColor(local_invocation_index + 1u);
|
|
||||||
\\ s01 = loadColor(local_invocation_index + 8u);
|
|
||||||
\\ s11 = loadColor(local_invocation_index + 9u);
|
|
||||||
\\ s00 = 0.25 * (s00 + s01 + s10 + s11);
|
|
||||||
\\ textureStore(dst_mipmap2, vec2<i32>(global_invocation_id.xy / 2u), s00);
|
|
||||||
\\ storeColor(local_invocation_index, s00);
|
|
||||||
\\ }
|
|
||||||
\\ if (uniforms.num_mip_levels == 2u) {
|
|
||||||
\\ return;
|
|
||||||
\\ }
|
|
||||||
\\ workgroupBarrier();
|
|
||||||
\\
|
|
||||||
\\ if ((local_invocation_index & 0x1Bu) == 0u) {
|
|
||||||
\\ s10 = loadColor(local_invocation_index + 2u);
|
|
||||||
\\ s01 = loadColor(local_invocation_index + 16u);
|
|
||||||
\\ s11 = loadColor(local_invocation_index + 18u);
|
|
||||||
\\ s00 = 0.25 * (s00 + s01 + s10 + s11);
|
|
||||||
\\ textureStore(dst_mipmap3, vec2<i32>(global_invocation_id.xy / 4u), s00);
|
|
||||||
\\ storeColor(local_invocation_index, s00);
|
|
||||||
\\ }
|
|
||||||
\\ if (uniforms.num_mip_levels == 3u) {
|
|
||||||
\\ return;
|
|
||||||
\\ }
|
|
||||||
\\ workgroupBarrier();
|
|
||||||
\\
|
|
||||||
\\ if (local_invocation_index == 0u) {
|
|
||||||
\\ s10 = loadColor(local_invocation_index + 4u);
|
|
||||||
\\ s01 = loadColor(local_invocation_index + 32u);
|
|
||||||
\\ s11 = loadColor(local_invocation_index + 36u);
|
|
||||||
\\ s00 = 0.25 * (s00 + s01 + s10 + s11);
|
|
||||||
\\ textureStore(dst_mipmap4, vec2<i32>(global_invocation_id.xy / 8u), s00);
|
|
||||||
\\ storeColor(local_invocation_index, s00);
|
|
||||||
\\ }
|
|
||||||
\\ }
|
|
||||||
;
|
|
||||||
// zig fmt: on
|
|
||||||
37
vendor/zgpu/src/dawn.cpp
vendored
37
vendor/zgpu/src/dawn.cpp
vendored
@@ -1,37 +0,0 @@
|
|||||||
#include "dawn/native/DawnNative.h"
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct DawnNativeInstanceImpl* DawnNativeInstance;
|
|
||||||
|
|
||||||
DawnNativeInstance dniCreate(void) {
|
|
||||||
return reinterpret_cast<DawnNativeInstance>(new dawn::native::Instance());
|
|
||||||
}
|
|
||||||
|
|
||||||
void dniDestroy(DawnNativeInstance dni) {
|
|
||||||
assert(dni);
|
|
||||||
delete reinterpret_cast<dawn::native::Instance*>(dni);
|
|
||||||
}
|
|
||||||
|
|
||||||
WGPUInstance dniGetWgpuInstance(DawnNativeInstance dni) {
|
|
||||||
assert(dni);
|
|
||||||
return reinterpret_cast<dawn::native::Instance*>(dni)->Get();
|
|
||||||
}
|
|
||||||
|
|
||||||
void dniDiscoverDefaultAdapters(DawnNativeInstance dni) {
|
|
||||||
assert(dni);
|
|
||||||
dawn::native::Instance* instance = reinterpret_cast<dawn::native::Instance*>(dni);
|
|
||||||
instance->DiscoverDefaultAdapters();
|
|
||||||
}
|
|
||||||
|
|
||||||
const DawnProcTable* dnGetProcs(void) {
|
|
||||||
return &dawn::native::GetProcs();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
667
vendor/zgpu/src/dawn_proc.c
vendored
667
vendor/zgpu/src/dawn_proc.c
vendored
@@ -1,667 +0,0 @@
|
|||||||
|
|
||||||
#include "dawn/dawn_proc.h"
|
|
||||||
|
|
||||||
static DawnProcTable procs;
|
|
||||||
|
|
||||||
static DawnProcTable nullProcs;
|
|
||||||
|
|
||||||
void dawnProcSetProcs(const DawnProcTable* procs_) {
|
|
||||||
if (procs_) {
|
|
||||||
procs = *procs_;
|
|
||||||
} else {
|
|
||||||
procs = nullProcs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WGPUInstance wgpuCreateInstance(WGPUInstanceDescriptor const * descriptor) {
|
|
||||||
return procs.createInstance(descriptor);
|
|
||||||
}
|
|
||||||
WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName) {
|
|
||||||
return procs.getProcAddress(device, procName);
|
|
||||||
}
|
|
||||||
|
|
||||||
WGPUDevice wgpuAdapterCreateDevice(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor) {
|
|
||||||
return procs.adapterCreateDevice(adapter, descriptor);
|
|
||||||
}
|
|
||||||
size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName * features) {
|
|
||||||
return procs.adapterEnumerateFeatures(adapter, features);
|
|
||||||
}
|
|
||||||
WGPUInstance wgpuAdapterGetInstance(WGPUAdapter adapter) {
|
|
||||||
return procs.adapterGetInstance(adapter);
|
|
||||||
}
|
|
||||||
bool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits) {
|
|
||||||
return procs.adapterGetLimits(adapter, limits);
|
|
||||||
}
|
|
||||||
void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties) {
|
|
||||||
procs.adapterGetProperties(adapter, properties);
|
|
||||||
}
|
|
||||||
bool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature) {
|
|
||||||
return procs.adapterHasFeature(adapter, feature);
|
|
||||||
}
|
|
||||||
void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata) {
|
|
||||||
procs.adapterRequestDevice(adapter, descriptor, callback, userdata);
|
|
||||||
}
|
|
||||||
void wgpuAdapterReference(WGPUAdapter adapter) {
|
|
||||||
procs.adapterReference(adapter);
|
|
||||||
}
|
|
||||||
void wgpuAdapterRelease(WGPUAdapter adapter) {
|
|
||||||
procs.adapterRelease(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, char const * label) {
|
|
||||||
procs.bindGroupSetLabel(bindGroup, label);
|
|
||||||
}
|
|
||||||
void wgpuBindGroupReference(WGPUBindGroup bindGroup) {
|
|
||||||
procs.bindGroupReference(bindGroup);
|
|
||||||
}
|
|
||||||
void wgpuBindGroupRelease(WGPUBindGroup bindGroup) {
|
|
||||||
procs.bindGroupRelease(bindGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, char const * label) {
|
|
||||||
procs.bindGroupLayoutSetLabel(bindGroupLayout, label);
|
|
||||||
}
|
|
||||||
void wgpuBindGroupLayoutReference(WGPUBindGroupLayout bindGroupLayout) {
|
|
||||||
procs.bindGroupLayoutReference(bindGroupLayout);
|
|
||||||
}
|
|
||||||
void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout) {
|
|
||||||
procs.bindGroupLayoutRelease(bindGroupLayout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuBufferDestroy(WGPUBuffer buffer) {
|
|
||||||
procs.bufferDestroy(buffer);
|
|
||||||
}
|
|
||||||
void const * wgpuBufferGetConstMappedRange(WGPUBuffer buffer, size_t offset, size_t size) {
|
|
||||||
return procs.bufferGetConstMappedRange(buffer, offset, size);
|
|
||||||
}
|
|
||||||
WGPUBufferMapState wgpuBufferGetMapState(WGPUBuffer buffer) {
|
|
||||||
return procs.bufferGetMapState(buffer);
|
|
||||||
}
|
|
||||||
void * wgpuBufferGetMappedRange(WGPUBuffer buffer, size_t offset, size_t size) {
|
|
||||||
return procs.bufferGetMappedRange(buffer, offset, size);
|
|
||||||
}
|
|
||||||
uint64_t wgpuBufferGetSize(WGPUBuffer buffer) {
|
|
||||||
return procs.bufferGetSize(buffer);
|
|
||||||
}
|
|
||||||
WGPUBufferUsageFlags wgpuBufferGetUsage(WGPUBuffer buffer) {
|
|
||||||
return procs.bufferGetUsage(buffer);
|
|
||||||
}
|
|
||||||
void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata) {
|
|
||||||
procs.bufferMapAsync(buffer, mode, offset, size, callback, userdata);
|
|
||||||
}
|
|
||||||
void wgpuBufferSetLabel(WGPUBuffer buffer, char const * label) {
|
|
||||||
procs.bufferSetLabel(buffer, label);
|
|
||||||
}
|
|
||||||
void wgpuBufferUnmap(WGPUBuffer buffer) {
|
|
||||||
procs.bufferUnmap(buffer);
|
|
||||||
}
|
|
||||||
void wgpuBufferReference(WGPUBuffer buffer) {
|
|
||||||
procs.bufferReference(buffer);
|
|
||||||
}
|
|
||||||
void wgpuBufferRelease(WGPUBuffer buffer) {
|
|
||||||
procs.bufferRelease(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, char const * label) {
|
|
||||||
procs.commandBufferSetLabel(commandBuffer, label);
|
|
||||||
}
|
|
||||||
void wgpuCommandBufferReference(WGPUCommandBuffer commandBuffer) {
|
|
||||||
procs.commandBufferReference(commandBuffer);
|
|
||||||
}
|
|
||||||
void wgpuCommandBufferRelease(WGPUCommandBuffer commandBuffer) {
|
|
||||||
procs.commandBufferRelease(commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor) {
|
|
||||||
return procs.commandEncoderBeginComputePass(commandEncoder, descriptor);
|
|
||||||
}
|
|
||||||
WGPURenderPassEncoder wgpuCommandEncoderBeginRenderPass(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) {
|
|
||||||
return procs.commandEncoderBeginRenderPass(commandEncoder, descriptor);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderClearBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size) {
|
|
||||||
procs.commandEncoderClearBuffer(commandEncoder, buffer, offset, size);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderCopyBufferToBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size) {
|
|
||||||
procs.commandEncoderCopyBufferToBuffer(commandEncoder, source, sourceOffset, destination, destinationOffset, size);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) {
|
|
||||||
procs.commandEncoderCopyBufferToTexture(commandEncoder, source, destination, copySize);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize) {
|
|
||||||
procs.commandEncoderCopyTextureToBuffer(commandEncoder, source, destination, copySize);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) {
|
|
||||||
procs.commandEncoderCopyTextureToTexture(commandEncoder, source, destination, copySize);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderCopyTextureToTextureInternal(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) {
|
|
||||||
procs.commandEncoderCopyTextureToTextureInternal(commandEncoder, source, destination, copySize);
|
|
||||||
}
|
|
||||||
WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor) {
|
|
||||||
return procs.commandEncoderFinish(commandEncoder, descriptor);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderInjectValidationError(WGPUCommandEncoder commandEncoder, char const * message) {
|
|
||||||
procs.commandEncoderInjectValidationError(commandEncoder, message);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * markerLabel) {
|
|
||||||
procs.commandEncoderInsertDebugMarker(commandEncoder, markerLabel);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder) {
|
|
||||||
procs.commandEncoderPopDebugGroup(commandEncoder);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, char const * groupLabel) {
|
|
||||||
procs.commandEncoderPushDebugGroup(commandEncoder, groupLabel);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderResolveQuerySet(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset) {
|
|
||||||
procs.commandEncoderResolveQuerySet(commandEncoder, querySet, firstQuery, queryCount, destination, destinationOffset);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderSetLabel(WGPUCommandEncoder commandEncoder, char const * label) {
|
|
||||||
procs.commandEncoderSetLabel(commandEncoder, label);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderWriteBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t bufferOffset, uint8_t const * data, uint64_t size) {
|
|
||||||
procs.commandEncoderWriteBuffer(commandEncoder, buffer, bufferOffset, data, size);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderWriteTimestamp(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) {
|
|
||||||
procs.commandEncoderWriteTimestamp(commandEncoder, querySet, queryIndex);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderReference(WGPUCommandEncoder commandEncoder) {
|
|
||||||
procs.commandEncoderReference(commandEncoder);
|
|
||||||
}
|
|
||||||
void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder) {
|
|
||||||
procs.commandEncoderRelease(commandEncoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuComputePassEncoderDispatchWorkgroups(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ) {
|
|
||||||
procs.computePassEncoderDispatchWorkgroups(computePassEncoder, workgroupCountX, workgroupCountY, workgroupCountZ);
|
|
||||||
}
|
|
||||||
void wgpuComputePassEncoderDispatchWorkgroupsIndirect(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) {
|
|
||||||
procs.computePassEncoderDispatchWorkgroupsIndirect(computePassEncoder, indirectBuffer, indirectOffset);
|
|
||||||
}
|
|
||||||
void wgpuComputePassEncoderEnd(WGPUComputePassEncoder computePassEncoder) {
|
|
||||||
procs.computePassEncoderEnd(computePassEncoder);
|
|
||||||
}
|
|
||||||
void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, char const * markerLabel) {
|
|
||||||
procs.computePassEncoderInsertDebugMarker(computePassEncoder, markerLabel);
|
|
||||||
}
|
|
||||||
void wgpuComputePassEncoderPopDebugGroup(WGPUComputePassEncoder computePassEncoder) {
|
|
||||||
procs.computePassEncoderPopDebugGroup(computePassEncoder);
|
|
||||||
}
|
|
||||||
void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, char const * groupLabel) {
|
|
||||||
procs.computePassEncoderPushDebugGroup(computePassEncoder, groupLabel);
|
|
||||||
}
|
|
||||||
void wgpuComputePassEncoderSetBindGroup(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) {
|
|
||||||
procs.computePassEncoderSetBindGroup(computePassEncoder, groupIndex, group, dynamicOffsetCount, dynamicOffsets);
|
|
||||||
}
|
|
||||||
void wgpuComputePassEncoderSetLabel(WGPUComputePassEncoder computePassEncoder, char const * label) {
|
|
||||||
procs.computePassEncoderSetLabel(computePassEncoder, label);
|
|
||||||
}
|
|
||||||
void wgpuComputePassEncoderSetPipeline(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) {
|
|
||||||
procs.computePassEncoderSetPipeline(computePassEncoder, pipeline);
|
|
||||||
}
|
|
||||||
void wgpuComputePassEncoderWriteTimestamp(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex) {
|
|
||||||
procs.computePassEncoderWriteTimestamp(computePassEncoder, querySet, queryIndex);
|
|
||||||
}
|
|
||||||
void wgpuComputePassEncoderReference(WGPUComputePassEncoder computePassEncoder) {
|
|
||||||
procs.computePassEncoderReference(computePassEncoder);
|
|
||||||
}
|
|
||||||
void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePassEncoder) {
|
|
||||||
procs.computePassEncoderRelease(computePassEncoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex) {
|
|
||||||
return procs.computePipelineGetBindGroupLayout(computePipeline, groupIndex);
|
|
||||||
}
|
|
||||||
void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, char const * label) {
|
|
||||||
procs.computePipelineSetLabel(computePipeline, label);
|
|
||||||
}
|
|
||||||
void wgpuComputePipelineReference(WGPUComputePipeline computePipeline) {
|
|
||||||
procs.computePipelineReference(computePipeline);
|
|
||||||
}
|
|
||||||
void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline) {
|
|
||||||
procs.computePipelineRelease(computePipeline);
|
|
||||||
}
|
|
||||||
|
|
||||||
WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreateBindGroup(device, descriptor);
|
|
||||||
}
|
|
||||||
WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreateBindGroupLayout(device, descriptor);
|
|
||||||
}
|
|
||||||
WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreateBuffer(device, descriptor);
|
|
||||||
}
|
|
||||||
WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, WGPUCommandEncoderDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreateCommandEncoder(device, descriptor);
|
|
||||||
}
|
|
||||||
WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreateComputePipeline(device, descriptor);
|
|
||||||
}
|
|
||||||
void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallback callback, void * userdata) {
|
|
||||||
procs.deviceCreateComputePipelineAsync(device, descriptor, callback, userdata);
|
|
||||||
}
|
|
||||||
WGPUBuffer wgpuDeviceCreateErrorBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreateErrorBuffer(device, descriptor);
|
|
||||||
}
|
|
||||||
WGPUExternalTexture wgpuDeviceCreateErrorExternalTexture(WGPUDevice device) {
|
|
||||||
return procs.deviceCreateErrorExternalTexture(device);
|
|
||||||
}
|
|
||||||
WGPUShaderModule wgpuDeviceCreateErrorShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor, char const * errorMessage) {
|
|
||||||
return procs.deviceCreateErrorShaderModule(device, descriptor, errorMessage);
|
|
||||||
}
|
|
||||||
WGPUTexture wgpuDeviceCreateErrorTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreateErrorTexture(device, descriptor);
|
|
||||||
}
|
|
||||||
WGPUExternalTexture wgpuDeviceCreateExternalTexture(WGPUDevice device, WGPUExternalTextureDescriptor const * externalTextureDescriptor) {
|
|
||||||
return procs.deviceCreateExternalTexture(device, externalTextureDescriptor);
|
|
||||||
}
|
|
||||||
WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreatePipelineLayout(device, descriptor);
|
|
||||||
}
|
|
||||||
WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreateQuerySet(device, descriptor);
|
|
||||||
}
|
|
||||||
WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreateRenderBundleEncoder(device, descriptor);
|
|
||||||
}
|
|
||||||
WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreateRenderPipeline(device, descriptor);
|
|
||||||
}
|
|
||||||
void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata) {
|
|
||||||
procs.deviceCreateRenderPipelineAsync(device, descriptor, callback, userdata);
|
|
||||||
}
|
|
||||||
WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPUSamplerDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreateSampler(device, descriptor);
|
|
||||||
}
|
|
||||||
WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreateShaderModule(device, descriptor);
|
|
||||||
}
|
|
||||||
WGPUSwapChain wgpuDeviceCreateSwapChain(WGPUDevice device, WGPUSurface surface, WGPUSwapChainDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreateSwapChain(device, surface, descriptor);
|
|
||||||
}
|
|
||||||
WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor) {
|
|
||||||
return procs.deviceCreateTexture(device, descriptor);
|
|
||||||
}
|
|
||||||
void wgpuDeviceDestroy(WGPUDevice device) {
|
|
||||||
procs.deviceDestroy(device);
|
|
||||||
}
|
|
||||||
size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureName * features) {
|
|
||||||
return procs.deviceEnumerateFeatures(device, features);
|
|
||||||
}
|
|
||||||
void wgpuDeviceForceLoss(WGPUDevice device, WGPUDeviceLostReason type, char const * message) {
|
|
||||||
procs.deviceForceLoss(device, type, message);
|
|
||||||
}
|
|
||||||
WGPUAdapter wgpuDeviceGetAdapter(WGPUDevice device) {
|
|
||||||
return procs.deviceGetAdapter(device);
|
|
||||||
}
|
|
||||||
bool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits) {
|
|
||||||
return procs.deviceGetLimits(device, limits);
|
|
||||||
}
|
|
||||||
WGPUQueue wgpuDeviceGetQueue(WGPUDevice device) {
|
|
||||||
return procs.deviceGetQueue(device);
|
|
||||||
}
|
|
||||||
WGPUTextureUsageFlags wgpuDeviceGetSupportedSurfaceUsage(WGPUDevice device, WGPUSurface surface) {
|
|
||||||
return procs.deviceGetSupportedSurfaceUsage(device, surface);
|
|
||||||
}
|
|
||||||
bool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature) {
|
|
||||||
return procs.deviceHasFeature(device, feature);
|
|
||||||
}
|
|
||||||
void wgpuDeviceInjectError(WGPUDevice device, WGPUErrorType type, char const * message) {
|
|
||||||
procs.deviceInjectError(device, type, message);
|
|
||||||
}
|
|
||||||
void wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata) {
|
|
||||||
procs.devicePopErrorScope(device, callback, userdata);
|
|
||||||
}
|
|
||||||
void wgpuDevicePushErrorScope(WGPUDevice device, WGPUErrorFilter filter) {
|
|
||||||
procs.devicePushErrorScope(device, filter);
|
|
||||||
}
|
|
||||||
void wgpuDeviceSetDeviceLostCallback(WGPUDevice device, WGPUDeviceLostCallback callback, void * userdata) {
|
|
||||||
procs.deviceSetDeviceLostCallback(device, callback, userdata);
|
|
||||||
}
|
|
||||||
void wgpuDeviceSetLabel(WGPUDevice device, char const * label) {
|
|
||||||
procs.deviceSetLabel(device, label);
|
|
||||||
}
|
|
||||||
void wgpuDeviceSetLoggingCallback(WGPUDevice device, WGPULoggingCallback callback, void * userdata) {
|
|
||||||
procs.deviceSetLoggingCallback(device, callback, userdata);
|
|
||||||
}
|
|
||||||
void wgpuDeviceSetUncapturedErrorCallback(WGPUDevice device, WGPUErrorCallback callback, void * userdata) {
|
|
||||||
procs.deviceSetUncapturedErrorCallback(device, callback, userdata);
|
|
||||||
}
|
|
||||||
void wgpuDeviceTick(WGPUDevice device) {
|
|
||||||
procs.deviceTick(device);
|
|
||||||
}
|
|
||||||
void wgpuDeviceValidateTextureDescriptor(WGPUDevice device, WGPUTextureDescriptor const * descriptor) {
|
|
||||||
procs.deviceValidateTextureDescriptor(device, descriptor);
|
|
||||||
}
|
|
||||||
void wgpuDeviceReference(WGPUDevice device) {
|
|
||||||
procs.deviceReference(device);
|
|
||||||
}
|
|
||||||
void wgpuDeviceRelease(WGPUDevice device) {
|
|
||||||
procs.deviceRelease(device);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuExternalTextureDestroy(WGPUExternalTexture externalTexture) {
|
|
||||||
procs.externalTextureDestroy(externalTexture);
|
|
||||||
}
|
|
||||||
void wgpuExternalTextureExpire(WGPUExternalTexture externalTexture) {
|
|
||||||
procs.externalTextureExpire(externalTexture);
|
|
||||||
}
|
|
||||||
void wgpuExternalTextureRefresh(WGPUExternalTexture externalTexture) {
|
|
||||||
procs.externalTextureRefresh(externalTexture);
|
|
||||||
}
|
|
||||||
void wgpuExternalTextureSetLabel(WGPUExternalTexture externalTexture, char const * label) {
|
|
||||||
procs.externalTextureSetLabel(externalTexture, label);
|
|
||||||
}
|
|
||||||
void wgpuExternalTextureReference(WGPUExternalTexture externalTexture) {
|
|
||||||
procs.externalTextureReference(externalTexture);
|
|
||||||
}
|
|
||||||
void wgpuExternalTextureRelease(WGPUExternalTexture externalTexture) {
|
|
||||||
procs.externalTextureRelease(externalTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) {
|
|
||||||
return procs.instanceCreateSurface(instance, descriptor);
|
|
||||||
}
|
|
||||||
void wgpuInstanceProcessEvents(WGPUInstance instance) {
|
|
||||||
procs.instanceProcessEvents(instance);
|
|
||||||
}
|
|
||||||
void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata) {
|
|
||||||
procs.instanceRequestAdapter(instance, options, callback, userdata);
|
|
||||||
}
|
|
||||||
void wgpuInstanceReference(WGPUInstance instance) {
|
|
||||||
procs.instanceReference(instance);
|
|
||||||
}
|
|
||||||
void wgpuInstanceRelease(WGPUInstance instance) {
|
|
||||||
procs.instanceRelease(instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, char const * label) {
|
|
||||||
procs.pipelineLayoutSetLabel(pipelineLayout, label);
|
|
||||||
}
|
|
||||||
void wgpuPipelineLayoutReference(WGPUPipelineLayout pipelineLayout) {
|
|
||||||
procs.pipelineLayoutReference(pipelineLayout);
|
|
||||||
}
|
|
||||||
void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout) {
|
|
||||||
procs.pipelineLayoutRelease(pipelineLayout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuQuerySetDestroy(WGPUQuerySet querySet) {
|
|
||||||
procs.querySetDestroy(querySet);
|
|
||||||
}
|
|
||||||
uint32_t wgpuQuerySetGetCount(WGPUQuerySet querySet) {
|
|
||||||
return procs.querySetGetCount(querySet);
|
|
||||||
}
|
|
||||||
WGPUQueryType wgpuQuerySetGetType(WGPUQuerySet querySet) {
|
|
||||||
return procs.querySetGetType(querySet);
|
|
||||||
}
|
|
||||||
void wgpuQuerySetSetLabel(WGPUQuerySet querySet, char const * label) {
|
|
||||||
procs.querySetSetLabel(querySet, label);
|
|
||||||
}
|
|
||||||
void wgpuQuerySetReference(WGPUQuerySet querySet) {
|
|
||||||
procs.querySetReference(querySet);
|
|
||||||
}
|
|
||||||
void wgpuQuerySetRelease(WGPUQuerySet querySet) {
|
|
||||||
procs.querySetRelease(querySet);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuQueueCopyExternalTextureForBrowser(WGPUQueue queue, WGPUImageCopyExternalTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize, WGPUCopyTextureForBrowserOptions const * options) {
|
|
||||||
procs.queueCopyExternalTextureForBrowser(queue, source, destination, copySize, options);
|
|
||||||
}
|
|
||||||
void wgpuQueueCopyTextureForBrowser(WGPUQueue queue, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize, WGPUCopyTextureForBrowserOptions const * options) {
|
|
||||||
procs.queueCopyTextureForBrowser(queue, source, destination, copySize, options);
|
|
||||||
}
|
|
||||||
void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, uint64_t signalValue, WGPUQueueWorkDoneCallback callback, void * userdata) {
|
|
||||||
procs.queueOnSubmittedWorkDone(queue, signalValue, callback, userdata);
|
|
||||||
}
|
|
||||||
void wgpuQueueSetLabel(WGPUQueue queue, char const * label) {
|
|
||||||
procs.queueSetLabel(queue, label);
|
|
||||||
}
|
|
||||||
void wgpuQueueSubmit(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) {
|
|
||||||
procs.queueSubmit(queue, commandCount, commands);
|
|
||||||
}
|
|
||||||
void wgpuQueueWriteBuffer(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) {
|
|
||||||
procs.queueWriteBuffer(queue, buffer, bufferOffset, data, size);
|
|
||||||
}
|
|
||||||
void wgpuQueueWriteTexture(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize) {
|
|
||||||
procs.queueWriteTexture(queue, destination, data, dataSize, dataLayout, writeSize);
|
|
||||||
}
|
|
||||||
void wgpuQueueReference(WGPUQueue queue) {
|
|
||||||
procs.queueReference(queue);
|
|
||||||
}
|
|
||||||
void wgpuQueueRelease(WGPUQueue queue) {
|
|
||||||
procs.queueRelease(queue);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuRenderBundleSetLabel(WGPURenderBundle renderBundle, char const * label) {
|
|
||||||
procs.renderBundleSetLabel(renderBundle, label);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleReference(WGPURenderBundle renderBundle) {
|
|
||||||
procs.renderBundleReference(renderBundle);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleRelease(WGPURenderBundle renderBundle) {
|
|
||||||
procs.renderBundleRelease(renderBundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuRenderBundleEncoderDraw(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) {
|
|
||||||
procs.renderBundleEncoderDraw(renderBundleEncoder, vertexCount, instanceCount, firstVertex, firstInstance);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleEncoderDrawIndexed(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) {
|
|
||||||
procs.renderBundleEncoderDrawIndexed(renderBundleEncoder, indexCount, instanceCount, firstIndex, baseVertex, firstInstance);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleEncoderDrawIndexedIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) {
|
|
||||||
procs.renderBundleEncoderDrawIndexedIndirect(renderBundleEncoder, indirectBuffer, indirectOffset);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleEncoderDrawIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) {
|
|
||||||
procs.renderBundleEncoderDrawIndirect(renderBundleEncoder, indirectBuffer, indirectOffset);
|
|
||||||
}
|
|
||||||
WGPURenderBundle wgpuRenderBundleEncoderFinish(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderBundleDescriptor const * descriptor) {
|
|
||||||
return procs.renderBundleEncoderFinish(renderBundleEncoder, descriptor);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, char const * markerLabel) {
|
|
||||||
procs.renderBundleEncoderInsertDebugMarker(renderBundleEncoder, markerLabel);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleEncoderPopDebugGroup(WGPURenderBundleEncoder renderBundleEncoder) {
|
|
||||||
procs.renderBundleEncoderPopDebugGroup(renderBundleEncoder);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel) {
|
|
||||||
procs.renderBundleEncoderPushDebugGroup(renderBundleEncoder, groupLabel);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleEncoderSetBindGroup(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) {
|
|
||||||
procs.renderBundleEncoderSetBindGroup(renderBundleEncoder, groupIndex, group, dynamicOffsetCount, dynamicOffsets);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleEncoderSetIndexBuffer(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) {
|
|
||||||
procs.renderBundleEncoderSetIndexBuffer(renderBundleEncoder, buffer, format, offset, size);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleEncoderSetLabel(WGPURenderBundleEncoder renderBundleEncoder, char const * label) {
|
|
||||||
procs.renderBundleEncoderSetLabel(renderBundleEncoder, label);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleEncoderSetPipeline(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline) {
|
|
||||||
procs.renderBundleEncoderSetPipeline(renderBundleEncoder, pipeline);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleEncoderSetVertexBuffer(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size) {
|
|
||||||
procs.renderBundleEncoderSetVertexBuffer(renderBundleEncoder, slot, buffer, offset, size);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleEncoderReference(WGPURenderBundleEncoder renderBundleEncoder) {
|
|
||||||
procs.renderBundleEncoderReference(renderBundleEncoder);
|
|
||||||
}
|
|
||||||
void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBundleEncoder) {
|
|
||||||
procs.renderBundleEncoderRelease(renderBundleEncoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuRenderPassEncoderBeginOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex) {
|
|
||||||
procs.renderPassEncoderBeginOcclusionQuery(renderPassEncoder, queryIndex);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderDraw(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) {
|
|
||||||
procs.renderPassEncoderDraw(renderPassEncoder, vertexCount, instanceCount, firstVertex, firstInstance);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderDrawIndexed(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) {
|
|
||||||
procs.renderPassEncoderDrawIndexed(renderPassEncoder, indexCount, instanceCount, firstIndex, baseVertex, firstInstance);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderDrawIndexedIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) {
|
|
||||||
procs.renderPassEncoderDrawIndexedIndirect(renderPassEncoder, indirectBuffer, indirectOffset);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderDrawIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) {
|
|
||||||
procs.renderPassEncoderDrawIndirect(renderPassEncoder, indirectBuffer, indirectOffset);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderEnd(WGPURenderPassEncoder renderPassEncoder) {
|
|
||||||
procs.renderPassEncoderEnd(renderPassEncoder);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderEndOcclusionQuery(WGPURenderPassEncoder renderPassEncoder) {
|
|
||||||
procs.renderPassEncoderEndOcclusionQuery(renderPassEncoder);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderExecuteBundles(WGPURenderPassEncoder renderPassEncoder, size_t bundleCount, WGPURenderBundle const * bundles) {
|
|
||||||
procs.renderPassEncoderExecuteBundles(renderPassEncoder, bundleCount, bundles);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel) {
|
|
||||||
procs.renderPassEncoderInsertDebugMarker(renderPassEncoder, markerLabel);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderPopDebugGroup(WGPURenderPassEncoder renderPassEncoder) {
|
|
||||||
procs.renderPassEncoderPopDebugGroup(renderPassEncoder);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel) {
|
|
||||||
procs.renderPassEncoderPushDebugGroup(renderPassEncoder, groupLabel);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderSetBindGroup(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) {
|
|
||||||
procs.renderPassEncoderSetBindGroup(renderPassEncoder, groupIndex, group, dynamicOffsetCount, dynamicOffsets);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderSetBlendConstant(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) {
|
|
||||||
procs.renderPassEncoderSetBlendConstant(renderPassEncoder, color);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderSetIndexBuffer(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) {
|
|
||||||
procs.renderPassEncoderSetIndexBuffer(renderPassEncoder, buffer, format, offset, size);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderSetLabel(WGPURenderPassEncoder renderPassEncoder, char const * label) {
|
|
||||||
procs.renderPassEncoderSetLabel(renderPassEncoder, label);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderSetPipeline(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline) {
|
|
||||||
procs.renderPassEncoderSetPipeline(renderPassEncoder, pipeline);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderSetScissorRect(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
|
|
||||||
procs.renderPassEncoderSetScissorRect(renderPassEncoder, x, y, width, height);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderSetStencilReference(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) {
|
|
||||||
procs.renderPassEncoderSetStencilReference(renderPassEncoder, reference);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderSetVertexBuffer(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size) {
|
|
||||||
procs.renderPassEncoderSetVertexBuffer(renderPassEncoder, slot, buffer, offset, size);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderSetViewport(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) {
|
|
||||||
procs.renderPassEncoderSetViewport(renderPassEncoder, x, y, width, height, minDepth, maxDepth);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderWriteTimestamp(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex) {
|
|
||||||
procs.renderPassEncoderWriteTimestamp(renderPassEncoder, querySet, queryIndex);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderReference(WGPURenderPassEncoder renderPassEncoder) {
|
|
||||||
procs.renderPassEncoderReference(renderPassEncoder);
|
|
||||||
}
|
|
||||||
void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEncoder) {
|
|
||||||
procs.renderPassEncoderRelease(renderPassEncoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex) {
|
|
||||||
return procs.renderPipelineGetBindGroupLayout(renderPipeline, groupIndex);
|
|
||||||
}
|
|
||||||
void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, char const * label) {
|
|
||||||
procs.renderPipelineSetLabel(renderPipeline, label);
|
|
||||||
}
|
|
||||||
void wgpuRenderPipelineReference(WGPURenderPipeline renderPipeline) {
|
|
||||||
procs.renderPipelineReference(renderPipeline);
|
|
||||||
}
|
|
||||||
void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline) {
|
|
||||||
procs.renderPipelineRelease(renderPipeline);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuSamplerSetLabel(WGPUSampler sampler, char const * label) {
|
|
||||||
procs.samplerSetLabel(sampler, label);
|
|
||||||
}
|
|
||||||
void wgpuSamplerReference(WGPUSampler sampler) {
|
|
||||||
procs.samplerReference(sampler);
|
|
||||||
}
|
|
||||||
void wgpuSamplerRelease(WGPUSampler sampler) {
|
|
||||||
procs.samplerRelease(sampler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void * userdata) {
|
|
||||||
procs.shaderModuleGetCompilationInfo(shaderModule, callback, userdata);
|
|
||||||
}
|
|
||||||
void wgpuShaderModuleSetLabel(WGPUShaderModule shaderModule, char const * label) {
|
|
||||||
procs.shaderModuleSetLabel(shaderModule, label);
|
|
||||||
}
|
|
||||||
void wgpuShaderModuleReference(WGPUShaderModule shaderModule) {
|
|
||||||
procs.shaderModuleReference(shaderModule);
|
|
||||||
}
|
|
||||||
void wgpuShaderModuleRelease(WGPUShaderModule shaderModule) {
|
|
||||||
procs.shaderModuleRelease(shaderModule);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuSurfaceReference(WGPUSurface surface) {
|
|
||||||
procs.surfaceReference(surface);
|
|
||||||
}
|
|
||||||
void wgpuSurfaceRelease(WGPUSurface surface) {
|
|
||||||
procs.surfaceRelease(surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
WGPUTexture wgpuSwapChainGetCurrentTexture(WGPUSwapChain swapChain) {
|
|
||||||
return procs.swapChainGetCurrentTexture(swapChain);
|
|
||||||
}
|
|
||||||
WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain) {
|
|
||||||
return procs.swapChainGetCurrentTextureView(swapChain);
|
|
||||||
}
|
|
||||||
void wgpuSwapChainPresent(WGPUSwapChain swapChain) {
|
|
||||||
procs.swapChainPresent(swapChain);
|
|
||||||
}
|
|
||||||
void wgpuSwapChainReference(WGPUSwapChain swapChain) {
|
|
||||||
procs.swapChainReference(swapChain);
|
|
||||||
}
|
|
||||||
void wgpuSwapChainRelease(WGPUSwapChain swapChain) {
|
|
||||||
procs.swapChainRelease(swapChain);
|
|
||||||
}
|
|
||||||
|
|
||||||
WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor) {
|
|
||||||
return procs.textureCreateView(texture, descriptor);
|
|
||||||
}
|
|
||||||
void wgpuTextureDestroy(WGPUTexture texture) {
|
|
||||||
procs.textureDestroy(texture);
|
|
||||||
}
|
|
||||||
uint32_t wgpuTextureGetDepthOrArrayLayers(WGPUTexture texture) {
|
|
||||||
return procs.textureGetDepthOrArrayLayers(texture);
|
|
||||||
}
|
|
||||||
WGPUTextureDimension wgpuTextureGetDimension(WGPUTexture texture) {
|
|
||||||
return procs.textureGetDimension(texture);
|
|
||||||
}
|
|
||||||
WGPUTextureFormat wgpuTextureGetFormat(WGPUTexture texture) {
|
|
||||||
return procs.textureGetFormat(texture);
|
|
||||||
}
|
|
||||||
uint32_t wgpuTextureGetHeight(WGPUTexture texture) {
|
|
||||||
return procs.textureGetHeight(texture);
|
|
||||||
}
|
|
||||||
uint32_t wgpuTextureGetMipLevelCount(WGPUTexture texture) {
|
|
||||||
return procs.textureGetMipLevelCount(texture);
|
|
||||||
}
|
|
||||||
uint32_t wgpuTextureGetSampleCount(WGPUTexture texture) {
|
|
||||||
return procs.textureGetSampleCount(texture);
|
|
||||||
}
|
|
||||||
WGPUTextureUsageFlags wgpuTextureGetUsage(WGPUTexture texture) {
|
|
||||||
return procs.textureGetUsage(texture);
|
|
||||||
}
|
|
||||||
uint32_t wgpuTextureGetWidth(WGPUTexture texture) {
|
|
||||||
return procs.textureGetWidth(texture);
|
|
||||||
}
|
|
||||||
void wgpuTextureSetLabel(WGPUTexture texture, char const * label) {
|
|
||||||
procs.textureSetLabel(texture, label);
|
|
||||||
}
|
|
||||||
void wgpuTextureReference(WGPUTexture texture) {
|
|
||||||
procs.textureReference(texture);
|
|
||||||
}
|
|
||||||
void wgpuTextureRelease(WGPUTexture texture) {
|
|
||||||
procs.textureRelease(texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wgpuTextureViewSetLabel(WGPUTextureView textureView, char const * label) {
|
|
||||||
procs.textureViewSetLabel(textureView, label);
|
|
||||||
}
|
|
||||||
void wgpuTextureViewReference(WGPUTextureView textureView) {
|
|
||||||
procs.textureViewReference(textureView);
|
|
||||||
}
|
|
||||||
void wgpuTextureViewRelease(WGPUTextureView textureView) {
|
|
||||||
procs.textureViewRelease(textureView);
|
|
||||||
}
|
|
||||||
|
|
||||||
2974
vendor/zgpu/src/wgpu.zig
vendored
2974
vendor/zgpu/src/wgpu.zig
vendored
File diff suppressed because it is too large
Load Diff
1868
vendor/zgpu/src/zgpu.zig
vendored
1868
vendor/zgpu/src/zgpu.zig
vendored
File diff suppressed because it is too large
Load Diff
21
vendor/zpool/LICENSE
vendored
21
vendor/zpool/LICENSE
vendored
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2024 zig-gamedev contributors
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
96
vendor/zpool/README.md
vendored
96
vendor/zpool/README.md
vendored
@@ -1,96 +0,0 @@
|
|||||||
# [zpool](https://github.com/zig-gamedev/zpool)
|
|
||||||
|
|
||||||
Generic pool & handle implementation for Zig. Based on [Andre Weissflog's "Handles Are The Better Pointers"](https://floooh.github.io/2018/06/17/handles-vs-pointers.html).
|
|
||||||
|
|
||||||
Exposing API resources using pools and handles is a common way to avoid exposing
|
|
||||||
implementation details to calling code and providing some insulation against
|
|
||||||
stale references in data structures maintained by the caller.
|
|
||||||
|
|
||||||
When the caller is provided a handle instead of an opaque pointer, the API
|
|
||||||
implementation is free to move resources around, replace them, and even discard
|
|
||||||
them.
|
|
||||||
|
|
||||||
```zig
|
|
||||||
Pool(index_bits: u8, cycle_bits: u8, TResource: type, TColumns: type)
|
|
||||||
Handle(index_bits: u8, cycle_bits: u8, TResource: type)
|
|
||||||
```
|
|
||||||
|
|
||||||
The generic `Pool` type has configurable bit distribution for the
|
|
||||||
`Handle`'s `index`/`cycle` fields, and supports multiple columns of data to
|
|
||||||
be indexed by a handle, using `std.MultiArrayList` to store all of the pool
|
|
||||||
data in a single memory allocation. The `TResource` parameter ensures the pool
|
|
||||||
and handle types can be distinct types even when other parameters are the same.
|
|
||||||
|
|
||||||
## Getting started
|
|
||||||
|
|
||||||
Example `build.zig`:
|
|
||||||
|
|
||||||
```zig
|
|
||||||
pub fn build(b: *std.Build) void {
|
|
||||||
const exe = b.addExecutable(.{ ... });
|
|
||||||
|
|
||||||
const zpool = b.dependency("zpool", .{});
|
|
||||||
exe.root_module.addImport("zpool", zpool.module("root"));
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Now in your code you may import and use `zpool`:
|
|
||||||
|
|
||||||
```zig
|
|
||||||
const Pool = @import("zpool").Pool;
|
|
||||||
|
|
||||||
const ImagePtr = graphics.Image;
|
|
||||||
const ImageInfo = graphics.ImageInfo;
|
|
||||||
|
|
||||||
pub const ImagePool = Pool(16, 16, ImagePtr, struct {
|
|
||||||
ptr: ImagePtr,
|
|
||||||
info: ImageInfo,
|
|
||||||
});
|
|
||||||
pub const ImageHandle = ImagePool.Handle;
|
|
||||||
```
|
|
||||||
|
|
||||||
```zig
|
|
||||||
var imagePool = ImagePool.initMaxCapacity(allocator);
|
|
||||||
defer pool.deinit();
|
|
||||||
```
|
|
||||||
|
|
||||||
```zig
|
|
||||||
pub fn acquireImage(info: ImageInfo) !ImageHandle {
|
|
||||||
const handle : ImageHandle = try imagePool.add(.{
|
|
||||||
.ptr = graphics.createImage(info),
|
|
||||||
.info = info,
|
|
||||||
});
|
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn drawImage(handle: ImageHandle) !void {
|
|
||||||
// get the stored ImagePtr
|
|
||||||
const ptr : ImagePtr = try imagePool.getColumn(handle, .ptr);
|
|
||||||
graphics.drawImage(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn resizeImage(handle: ImageHandle, width: u16, height: u16) !void {
|
|
||||||
// get a pointer to the stored ImageInfo
|
|
||||||
const info : *ImageInfo = try imagePool.getColumnPtr(handle, .info);
|
|
||||||
const old_width = info.width;
|
|
||||||
const old_height = info.height;
|
|
||||||
const old_pixels = // allocate memory to store old pixels
|
|
||||||
|
|
||||||
// get the stored ImagePtr
|
|
||||||
const ptr = try imagePool.getColumn(handle, .ptr);
|
|
||||||
graphics.readPixels(ptr, old_pixels);
|
|
||||||
|
|
||||||
const new_pixels = // allocate memory to store new pixels
|
|
||||||
|
|
||||||
super_eagle.resizeImage(
|
|
||||||
old_width, old_height, old_pixels,
|
|
||||||
new_width, new_height, new_pixels);
|
|
||||||
|
|
||||||
graphics.writePixels(ptr, new_width, new_height, new_pixels);
|
|
||||||
|
|
||||||
// update the stored ImageInfo
|
|
||||||
info.width = new_width;
|
|
||||||
info.height = new_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
22
vendor/zpool/build.zig
vendored
22
vendor/zpool/build.zig
vendored
@@ -1,22 +0,0 @@
|
|||||||
const std = @import("std");
|
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
|
||||||
const target = b.standardTargetOptions(.{});
|
|
||||||
|
|
||||||
_ = b.addModule("root", .{
|
|
||||||
.root_source_file = b.path("src/main.zig"),
|
|
||||||
});
|
|
||||||
|
|
||||||
const test_step = b.step("test", "Run zpool tests");
|
|
||||||
|
|
||||||
const tests = b.addTest(.{
|
|
||||||
.name = "zpool-tests",
|
|
||||||
.root_source_file = b.path("src/main.zig"),
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
});
|
|
||||||
b.installArtifact(tests);
|
|
||||||
|
|
||||||
test_step.dependOn(&b.addRunArtifact(tests).step);
|
|
||||||
}
|
|
||||||
11
vendor/zpool/build.zig.zon
vendored
11
vendor/zpool/build.zig.zon
vendored
@@ -1,11 +0,0 @@
|
|||||||
.{
|
|
||||||
.name = "zpool",
|
|
||||||
.version = "0.11.0-dev",
|
|
||||||
.paths = .{
|
|
||||||
"build.zig",
|
|
||||||
"build.zig.zon",
|
|
||||||
"src",
|
|
||||||
"README.md",
|
|
||||||
"LICENSE",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
174
vendor/zpool/src/embedded_ring_queue.zig
vendored
174
vendor/zpool/src/embedded_ring_queue.zig
vendored
@@ -1,174 +0,0 @@
|
|||||||
const std = @import("std");
|
|
||||||
|
|
||||||
pub fn EmbeddedRingQueue(comptime TElement: type) type {
|
|
||||||
const assert = std.debug.assert;
|
|
||||||
|
|
||||||
return struct {
|
|
||||||
const Self = @This();
|
|
||||||
|
|
||||||
pub const Error = error{
|
|
||||||
Empty,
|
|
||||||
Full,
|
|
||||||
};
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
pub const Element = TElement;
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
head: usize = 0,
|
|
||||||
tail: usize = 0,
|
|
||||||
storage: []Element = &.{},
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
pub fn init(buffer: []Element) Self {
|
|
||||||
return .{ .storage = buffer };
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
pub fn capacity(self: Self) usize {
|
|
||||||
return self.storage.len;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn len(self: Self) usize {
|
|
||||||
return self.tail -% self.head;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn empty(self: Self) bool {
|
|
||||||
return self.len() == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn full(self: Self) bool {
|
|
||||||
return self.len() == self.capacity();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn clear(self: *Self) void {
|
|
||||||
self.head = 0;
|
|
||||||
self.tail = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
pub fn enqueue(self: *Self, value: Element) Error!void {
|
|
||||||
if (self.enqueueIfNotFull(value)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return Error.Full;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn dequeue(self: *Self) Error!Element {
|
|
||||||
var value: Element = undefined;
|
|
||||||
if (self.dequeueIfNotEmpty(&value)) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
return Error.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
pub fn enqueueIfNotFull(self: *Self, value: Element) bool {
|
|
||||||
if (self.full()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
self.enqueueUnchecked(value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn dequeueIfNotEmpty(self: *Self, value: *Element) bool {
|
|
||||||
if (self.empty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
self.dequeueUnchecked(value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
pub fn enqueueAssumeNotFull(self: *Self, value: Element) void {
|
|
||||||
assert(!self.full());
|
|
||||||
self.enqueueUnchecked(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn dequeueAssumeNotEmpty(self: *Self) Element {
|
|
||||||
assert(!self.empty());
|
|
||||||
var value: Element = undefined;
|
|
||||||
self.dequeueUnchecked(&value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
pub fn enqueueUnchecked(self: *Self, value: Element) void {
|
|
||||||
const tail_index = self.tail % self.storage.len;
|
|
||||||
self.storage[tail_index] = value;
|
|
||||||
self.tail +%= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn dequeueUnchecked(self: *Self, value: *Element) void {
|
|
||||||
const head_index = self.head % self.storage.len;
|
|
||||||
value.* = self.storage[head_index];
|
|
||||||
self.head +%= 1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const expectEqual = std.testing.expectEqual;
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
test "EmbeddedRingQueue basics" {
|
|
||||||
var buffer: [16]usize = undefined;
|
|
||||||
var queue = EmbeddedRingQueue(usize).init(buffer[0..]);
|
|
||||||
|
|
||||||
try expectEqual(buffer.len, queue.capacity());
|
|
||||||
try expectEqual(@as(usize, 0), queue.len());
|
|
||||||
try expectEqual(true, queue.empty());
|
|
||||||
try expectEqual(false, queue.full());
|
|
||||||
|
|
||||||
for (buffer, 0..) |_, i| {
|
|
||||||
try expectEqual(i, queue.len());
|
|
||||||
try queue.enqueue(i);
|
|
||||||
try expectEqual(i, buffer[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
try expectEqual(buffer.len, queue.capacity());
|
|
||||||
try expectEqual(buffer.len, queue.len());
|
|
||||||
try expectEqual(false, queue.empty());
|
|
||||||
try expectEqual(true, queue.full());
|
|
||||||
|
|
||||||
for (buffer, 0..) |_, i| {
|
|
||||||
try expectEqual(buffer.len - i, queue.len());
|
|
||||||
const j = try queue.dequeue();
|
|
||||||
try expectEqual(i, j);
|
|
||||||
}
|
|
||||||
|
|
||||||
try expectEqual(buffer.len, queue.capacity());
|
|
||||||
try expectEqual(@as(usize, 0), queue.len());
|
|
||||||
try expectEqual(true, queue.empty());
|
|
||||||
try expectEqual(false, queue.full());
|
|
||||||
|
|
||||||
for (buffer, 0..) |_, i| {
|
|
||||||
try expectEqual(i, queue.len());
|
|
||||||
try queue.enqueue(i);
|
|
||||||
try expectEqual(i, buffer[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
try expectEqual(buffer.len, queue.capacity());
|
|
||||||
try expectEqual(buffer.len, queue.len());
|
|
||||||
try expectEqual(false, queue.empty());
|
|
||||||
try expectEqual(true, queue.full());
|
|
||||||
|
|
||||||
queue.clear();
|
|
||||||
|
|
||||||
try expectEqual(buffer.len, queue.capacity());
|
|
||||||
try expectEqual(@as(usize, 0), queue.len());
|
|
||||||
try expectEqual(true, queue.empty());
|
|
||||||
try expectEqual(false, queue.full());
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
278
vendor/zpool/src/handle.zig
vendored
278
vendor/zpool/src/handle.zig
vendored
@@ -1,278 +0,0 @@
|
|||||||
const std = @import("std");
|
|
||||||
|
|
||||||
/// Returns a struct consisting of an array `index` and a semi-unique `cycle`,
|
|
||||||
/// which exists to distinguish handles with the same array `index`.
|
|
||||||
///
|
|
||||||
/// The `cycle` value is only unique within the incremental period of an
|
|
||||||
/// unsigned integer with `cycle_bits`, so a larger number of `cycle_bits`
|
|
||||||
/// provides a larger scope of identifiable conflicts between handles for the
|
|
||||||
/// same `index`.
|
|
||||||
///
|
|
||||||
/// `Handle` is generic because while the `{ index, cycle }` pattern is widely
|
|
||||||
/// applicable, a good distribution of bits between `index` and `cycle` and the
|
|
||||||
/// overall size of a handle are highly dependent on the lifecycle of the
|
|
||||||
/// resource being identified by a handle and the systems consuming handles.
|
|
||||||
///
|
|
||||||
/// Reasonable values for `index_bits` depend on the maximum number of
|
|
||||||
/// uniquely identifiable resources your API will to identify with handles.
|
|
||||||
/// Generally this is directly tied to the length of the array(s) in which
|
|
||||||
/// you will store data to be referenced by a handle's `index`.
|
|
||||||
///
|
|
||||||
/// Reasonable values for `cycle_bits` depend on the frequency with which your
|
|
||||||
/// API expects to be issuing handles, and how many cycles of your application
|
|
||||||
/// are likely to elapse before an expired handle will likely no longer be
|
|
||||||
/// retained by the API caller's data structures.
|
|
||||||
///
|
|
||||||
/// For example, a `Handle(16, 16)` may be sufficient for a GPU resource like
|
|
||||||
/// a texture or buffer, where 64k instances of that resource is a reasonable
|
|
||||||
/// upper bound.
|
|
||||||
///
|
|
||||||
/// A `Handle(22, 10)` may be more appropriate to identify an entity in a
|
|
||||||
/// system where we can safely assume that 4 million entities, is a lot, and
|
|
||||||
/// that API callers can discover and discard expired entity handles within
|
|
||||||
/// 1024 frames of an entity being destroyed and its handle's `index` being
|
|
||||||
/// reissued for use by a distinct entity.
|
|
||||||
///
|
|
||||||
/// `TResource` identifies type of resource referenced by a handle, and
|
|
||||||
/// provides a type-safe distinction between two otherwise equivalently
|
|
||||||
/// configured `Handle` types, such as:
|
|
||||||
/// * `const BufferHandle = Handle(16, 16, Buffer);`
|
|
||||||
/// * `const TextureHandle = Handle(16, 16, Texture);`
|
|
||||||
///
|
|
||||||
/// The total size of a handle will always be the size of an addressable
|
|
||||||
/// unsigned integer of type `u8`, `u16`, `u32`, `u64`, `u128`, or `u256`.
|
|
||||||
pub fn Handle(
|
|
||||||
comptime index_bits: u8,
|
|
||||||
comptime cycle_bits: u8,
|
|
||||||
comptime TResource: type,
|
|
||||||
) type {
|
|
||||||
if (index_bits == 0) @compileError("index_bits must be greater than 0");
|
|
||||||
if (cycle_bits == 0) @compileError("cycle_bits must be greater than 0");
|
|
||||||
|
|
||||||
const id_bits: u16 = @as(u16, index_bits) + @as(u16, cycle_bits);
|
|
||||||
const Id = switch (id_bits) {
|
|
||||||
8 => u8,
|
|
||||||
16 => u16,
|
|
||||||
32 => u32,
|
|
||||||
64 => u64,
|
|
||||||
128 => u128,
|
|
||||||
256 => u256,
|
|
||||||
else => @compileError("index_bits + cycle_bits must sum to exactly " ++
|
|
||||||
"8, 16, 32, 64, 128, or 256 bits"),
|
|
||||||
};
|
|
||||||
|
|
||||||
const field_bits = @max(index_bits, cycle_bits);
|
|
||||||
|
|
||||||
const utils = @import("utils.zig");
|
|
||||||
const UInt = utils.UInt;
|
|
||||||
const AddressableUInt = utils.AddressableUInt;
|
|
||||||
|
|
||||||
return extern struct {
|
|
||||||
const Self = @This();
|
|
||||||
|
|
||||||
const HandleType = Self;
|
|
||||||
const IndexType = UInt(index_bits);
|
|
||||||
const CycleType = UInt(cycle_bits);
|
|
||||||
const HandleUnion = extern union {
|
|
||||||
id: Id,
|
|
||||||
bits: packed struct {
|
|
||||||
cycle: CycleType, // least significant bits
|
|
||||||
index: IndexType, // most significant bits
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const Resource = TResource;
|
|
||||||
|
|
||||||
pub const AddressableCycle = AddressableUInt(field_bits);
|
|
||||||
pub const AddressableIndex = AddressableUInt(field_bits);
|
|
||||||
|
|
||||||
pub const max_cycle = ~@as(CycleType, 0);
|
|
||||||
pub const max_index = ~@as(IndexType, 0);
|
|
||||||
pub const max_count = @as(Id, max_index - 1) + 2;
|
|
||||||
|
|
||||||
id: Id = 0,
|
|
||||||
|
|
||||||
pub const nil = Self{ .id = 0 };
|
|
||||||
|
|
||||||
pub fn init(i: IndexType, c: CycleType) Self {
|
|
||||||
const u = HandleUnion{ .bits = .{
|
|
||||||
.cycle = c,
|
|
||||||
.index = i,
|
|
||||||
} };
|
|
||||||
return .{ .id = u.id };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn cycle(self: Self) CycleType {
|
|
||||||
const u = HandleUnion{ .id = self.id };
|
|
||||||
return u.bits.cycle;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn index(self: Self) IndexType {
|
|
||||||
const u = HandleUnion{ .id = self.id };
|
|
||||||
return u.bits.index;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Unpacks the `index` and `cycle` bit fields that comprise
|
|
||||||
/// `Handle.id` into an `AddressableHandle`, which stores
|
|
||||||
/// the `index` and `cycle` values in pointer-addressable fields.
|
|
||||||
pub fn addressable(self: Self) AddressableHandle {
|
|
||||||
const u = HandleUnion{ .id = self.id };
|
|
||||||
return .{
|
|
||||||
.cycle = u.bits.cycle,
|
|
||||||
.index = u.bits.index,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// When you want to directly access the `index` and `cycle` of a
|
|
||||||
/// handle, first convert it to an `AddressableHandle` by calling
|
|
||||||
/// `Handle.addressable()`.
|
|
||||||
/// An `AddressableHandle` can be converted back into a "compact"
|
|
||||||
/// `Handle` by calling `AddressableHandle.compact()`.
|
|
||||||
pub const AddressableHandle = struct {
|
|
||||||
cycle: AddressableCycle = 0,
|
|
||||||
index: AddressableIndex = 0,
|
|
||||||
|
|
||||||
/// Returns the corresponding `Handle`
|
|
||||||
pub fn handle(self: AddressableHandle) HandleType {
|
|
||||||
const u = HandleUnion{ .bits = .{
|
|
||||||
.cycle = @as(CycleType, @intCast(self.cycle)),
|
|
||||||
.index = @as(IndexType, @intCast(self.index)),
|
|
||||||
} };
|
|
||||||
return .{ .id = u.id };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn format(
|
|
||||||
self: Self,
|
|
||||||
comptime fmt: []const u8,
|
|
||||||
options: std.fmt.FormatOptions,
|
|
||||||
writer: anytype,
|
|
||||||
) !void {
|
|
||||||
_ = fmt;
|
|
||||||
_ = options;
|
|
||||||
const n = @typeName(Resource);
|
|
||||||
const a = self.addressable();
|
|
||||||
return writer.print("{s}[{}#{}]", .{ n, a.index, a.cycle });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
test "Handle sizes and alignments" {
|
|
||||||
const expectEqual = std.testing.expectEqual;
|
|
||||||
|
|
||||||
{
|
|
||||||
const H = Handle(4, 4, void);
|
|
||||||
try expectEqual(@sizeOf(u8), @sizeOf(H));
|
|
||||||
try expectEqual(@alignOf(u8), @alignOf(H));
|
|
||||||
try expectEqual(4, @bitSizeOf(H.IndexType));
|
|
||||||
try expectEqual(4, @bitSizeOf(H.CycleType));
|
|
||||||
try expectEqual(8, @bitSizeOf(H.AddressableIndex));
|
|
||||||
try expectEqual(8, @bitSizeOf(H.AddressableCycle));
|
|
||||||
|
|
||||||
const A = H.AddressableHandle;
|
|
||||||
try expectEqual(@sizeOf(u16), @sizeOf(A));
|
|
||||||
try expectEqual(@alignOf(u8), @alignOf(A));
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const H = Handle(6, 2, void);
|
|
||||||
try expectEqual(@sizeOf(u8), @sizeOf(H));
|
|
||||||
try expectEqual(@alignOf(u8), @alignOf(H));
|
|
||||||
try expectEqual(6, @bitSizeOf(H.IndexType));
|
|
||||||
try expectEqual(2, @bitSizeOf(H.CycleType));
|
|
||||||
try expectEqual(8, @bitSizeOf(H.AddressableIndex));
|
|
||||||
try expectEqual(8, @bitSizeOf(H.AddressableCycle));
|
|
||||||
|
|
||||||
const A = H.AddressableHandle;
|
|
||||||
try expectEqual(@sizeOf(u16), @sizeOf(A));
|
|
||||||
try expectEqual(@alignOf(u8), @alignOf(A));
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const H = Handle(8, 8, void);
|
|
||||||
try expectEqual(@sizeOf(u16), @sizeOf(H));
|
|
||||||
try expectEqual(@alignOf(u16), @alignOf(H));
|
|
||||||
try expectEqual(8, @bitSizeOf(H.IndexType));
|
|
||||||
try expectEqual(8, @bitSizeOf(H.CycleType));
|
|
||||||
try expectEqual(8, @bitSizeOf(H.AddressableIndex));
|
|
||||||
try expectEqual(8, @bitSizeOf(H.AddressableCycle));
|
|
||||||
|
|
||||||
const A = H.AddressableHandle;
|
|
||||||
try expectEqual(@sizeOf(u16), @sizeOf(A));
|
|
||||||
try expectEqual(@alignOf(u8), @alignOf(A));
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const H = Handle(12, 4, void);
|
|
||||||
try expectEqual(@sizeOf(u16), @sizeOf(H));
|
|
||||||
try expectEqual(@alignOf(u16), @alignOf(H));
|
|
||||||
try expectEqual(12, @bitSizeOf(H.IndexType));
|
|
||||||
try expectEqual(4, @bitSizeOf(H.CycleType));
|
|
||||||
try expectEqual(16, @bitSizeOf(H.AddressableIndex));
|
|
||||||
try expectEqual(16, @bitSizeOf(H.AddressableCycle));
|
|
||||||
|
|
||||||
const A = H.AddressableHandle;
|
|
||||||
try expectEqual(@sizeOf(u32), @sizeOf(A));
|
|
||||||
try expectEqual(@alignOf(u16), @alignOf(A));
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const H = Handle(16, 16, void);
|
|
||||||
try expectEqual(@sizeOf(u32), @sizeOf(H));
|
|
||||||
try expectEqual(@alignOf(u32), @alignOf(H));
|
|
||||||
try expectEqual(16, @bitSizeOf(H.IndexType));
|
|
||||||
try expectEqual(16, @bitSizeOf(H.CycleType));
|
|
||||||
try expectEqual(16, @bitSizeOf(H.AddressableIndex));
|
|
||||||
try expectEqual(16, @bitSizeOf(H.AddressableCycle));
|
|
||||||
|
|
||||||
const A = H.AddressableHandle;
|
|
||||||
try expectEqual(@sizeOf(u32), @sizeOf(A));
|
|
||||||
try expectEqual(@alignOf(u16), @alignOf(A));
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const H = Handle(22, 10, void);
|
|
||||||
try expectEqual(@sizeOf(u32), @sizeOf(H));
|
|
||||||
try expectEqual(@alignOf(u32), @alignOf(H));
|
|
||||||
try expectEqual(22, @bitSizeOf(H.IndexType));
|
|
||||||
try expectEqual(10, @bitSizeOf(H.CycleType));
|
|
||||||
try expectEqual(32, @bitSizeOf(H.AddressableIndex));
|
|
||||||
try expectEqual(32, @bitSizeOf(H.AddressableCycle));
|
|
||||||
|
|
||||||
const A = H.AddressableHandle;
|
|
||||||
try expectEqual(@sizeOf(u64), @sizeOf(A));
|
|
||||||
try expectEqual(@alignOf(u32), @alignOf(A));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
test "Handle sort order" {
|
|
||||||
const expect = std.testing.expect;
|
|
||||||
|
|
||||||
const handle = Handle(4, 4, void).init;
|
|
||||||
const a = handle(0, 3);
|
|
||||||
const b = handle(1, 1);
|
|
||||||
|
|
||||||
// id order is consistent with index order, even when cycle order is not
|
|
||||||
try expect(a.id < b.id);
|
|
||||||
try expect(a.index() < b.index());
|
|
||||||
try expect(a.cycle() > b.cycle());
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
test "Handle.format()" {
|
|
||||||
const bufPrint = std.fmt.bufPrint;
|
|
||||||
const expectEqualStrings = std.testing.expectEqualStrings;
|
|
||||||
|
|
||||||
const Foo = struct {};
|
|
||||||
const H = Handle(12, 4, Foo);
|
|
||||||
const h = H.init(0, 1);
|
|
||||||
|
|
||||||
var buffer = [_]u8{0} ** 128;
|
|
||||||
const s = try bufPrint(buffer[0..], "{}", .{h});
|
|
||||||
try expectEqualStrings("handle.test.Handle.format().Foo[0#1]", s);
|
|
||||||
}
|
|
||||||
8
vendor/zpool/src/main.zig
vendored
8
vendor/zpool/src/main.zig
vendored
@@ -1,8 +0,0 @@
|
|||||||
pub const Handle = @import("handle.zig").Handle;
|
|
||||||
pub const Pool = @import("pool.zig").Pool;
|
|
||||||
|
|
||||||
// ensure transitive closure of test coverage
|
|
||||||
comptime {
|
|
||||||
_ = Handle;
|
|
||||||
_ = Pool;
|
|
||||||
}
|
|
||||||
1430
vendor/zpool/src/pool.zig
vendored
1430
vendor/zpool/src/pool.zig
vendored
File diff suppressed because it is too large
Load Diff
106
vendor/zpool/src/utils.zig
vendored
106
vendor/zpool/src/utils.zig
vendored
@@ -1,106 +0,0 @@
|
|||||||
const std = @import("std");
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
pub fn asTypeId(comptime typeInfo: std.builtin.Type) std.builtin.TypeId {
|
|
||||||
return @as(std.builtin.TypeId, typeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn typeIdOf(comptime T: type) std.builtin.TypeId {
|
|
||||||
return asTypeId(@typeInfo(T));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn isStruct(comptime T: type) bool {
|
|
||||||
return typeIdOf(T) == std.builtin.TypeId.@"struct";
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
/// UInt(bits) returns an unsigned integer type of the requested bit width.
|
|
||||||
pub fn UInt(comptime bits: u8) type {
|
|
||||||
const unsigned = std.builtin.Signedness.unsigned;
|
|
||||||
return @Type(.{ .int = .{ .signedness = unsigned, .bits = bits } });
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
/// Returns an unsigned integer type with ***at least*** `min_bits`,
|
|
||||||
/// that is also large enough to be addressable by a normal pointer.
|
|
||||||
/// The returned type will always be one of the following:
|
|
||||||
/// * `u8`
|
|
||||||
/// * `u16`
|
|
||||||
/// * `u32`
|
|
||||||
/// * `u64`
|
|
||||||
/// * `u128`
|
|
||||||
/// * `u256`
|
|
||||||
pub fn AddressableUInt(comptime min_bits: u8) type {
|
|
||||||
return switch (min_bits) {
|
|
||||||
0...8 => u8,
|
|
||||||
9...16 => u16,
|
|
||||||
17...32 => u32,
|
|
||||||
33...64 => u64,
|
|
||||||
65...128 => u128,
|
|
||||||
129...255 => u256,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
/// Given: `Struct = struct { foo: u32, bar: u64 }`
|
|
||||||
/// Returns: `StructOfSlices = struct { foo: []u32, bar: []u64 }`
|
|
||||||
pub fn StructOfSlices(comptime Struct: type) type {
|
|
||||||
const StructField = std.builtin.Type.StructField;
|
|
||||||
|
|
||||||
// same number of fields in the new struct
|
|
||||||
const struct_fields = @typeInfo(Struct).@"struct".fields;
|
|
||||||
|
|
||||||
comptime var struct_of_slices_fields: []const StructField = &.{};
|
|
||||||
inline for (struct_fields) |struct_field| {
|
|
||||||
// u32 -> []u32
|
|
||||||
const element_type = struct_field.type;
|
|
||||||
|
|
||||||
const slice_type_info = std.builtin.Type{
|
|
||||||
.pointer = .{
|
|
||||||
.child = element_type,
|
|
||||||
.alignment = @alignOf(element_type),
|
|
||||||
.size = .slice,
|
|
||||||
.is_const = false,
|
|
||||||
.is_volatile = false,
|
|
||||||
.address_space = .generic,
|
|
||||||
.is_allowzero = false,
|
|
||||||
.sentinel_ptr = null,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const FieldType = @Type(slice_type_info);
|
|
||||||
|
|
||||||
// Struct.foo: u32 -> StructOfSlices.foo : []u32
|
|
||||||
const slice_field = std.builtin.Type.StructField{
|
|
||||||
.name = struct_field.name,
|
|
||||||
.type = FieldType,
|
|
||||||
.default_value_ptr = null,
|
|
||||||
.is_comptime = false,
|
|
||||||
.alignment = @alignOf(FieldType),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Struct.foo: u32 -> StructOfSlices.foo : []u32
|
|
||||||
struct_of_slices_fields = struct_of_slices_fields ++ [1]StructField{slice_field};
|
|
||||||
}
|
|
||||||
|
|
||||||
return @Type(.{ .@"struct" = .{
|
|
||||||
.layout = .auto,
|
|
||||||
.fields = struct_of_slices_fields,
|
|
||||||
.decls = &.{},
|
|
||||||
.is_tuple = false,
|
|
||||||
} });
|
|
||||||
}
|
|
||||||
|
|
||||||
test "StructOfSlices" {
|
|
||||||
const expectEqual = std.testing.expectEqual;
|
|
||||||
|
|
||||||
const Struct = struct { a: u16, b: u16, c: u16 };
|
|
||||||
try expectEqual(@sizeOf(u16) * 3, @sizeOf(Struct));
|
|
||||||
|
|
||||||
const SOS = StructOfSlices(Struct);
|
|
||||||
try expectEqual(@sizeOf([]u16) * 3, @sizeOf(SOS));
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user