gpu: expose API and begin using in example

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-03-06 21:38:36 -07:00 committed by Stephen Gutekanst
parent d32be19c8b
commit 8f5e9f89e5
4 changed files with 13 additions and 9 deletions

View file

@ -1,6 +1,7 @@
const std = @import("std");
const assert = std.debug.assert;
const glfw = @import("glfw");
const gpu = @import("gpu");
const c = @import("c.zig").c;
const objc = @cImport({
@cInclude("objc/message.h");
@ -17,6 +18,7 @@ fn printDeviceError(error_type: c.WGPUErrorType, message: [*c]const u8, _: ?*any
}
const Setup = struct {
native_instance: gpu.NativeInstance,
instance: c.WGPUInstance,
backend_type: c.WGPUBackendType,
device: c.WGPUDevice,
@ -97,6 +99,7 @@ pub fn setup(allocator: std.mem.Allocator) !Setup {
c.dawnProcSetProcs(backend_procs);
backend_procs.*.deviceSetUncapturedErrorCallback.?(backend_device, printDeviceError, null);
return Setup{
.native_instance = gpu.NativeInstance.wrap(c.machDawnNativeInstance_get(instance).?),
.instance = c.machDawnNativeInstance_get(instance),
.backend_type = backend_type,
.device = backend_device,