gpu: expose API and begin using in example
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
d32be19c8b
commit
8f5e9f89e5
4 changed files with 13 additions and 9 deletions
|
|
@ -27,6 +27,7 @@ pub fn build(b: *std.build.Builder) void {
|
||||||
example.setBuildMode(mode);
|
example.setBuildMode(mode);
|
||||||
example.install();
|
example.install();
|
||||||
example.linkLibC();
|
example.linkLibC();
|
||||||
|
example.addPackagePath("gpu", "src/main.zig");
|
||||||
example.addPackagePath("glfw", "libs/mach-glfw/src/main.zig");
|
example.addPackagePath("glfw", "libs/mach-glfw/src/main.zig");
|
||||||
glfw.link(b, example, .{});
|
glfw.link(b, example, .{});
|
||||||
gpu_dawn.link(b, example, .{});
|
gpu_dawn.link(b, example, .{});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
const glfw = @import("glfw");
|
const glfw = @import("glfw");
|
||||||
|
const gpu = @import("gpu");
|
||||||
const c = @import("c.zig").c;
|
const c = @import("c.zig").c;
|
||||||
const objc = @cImport({
|
const objc = @cImport({
|
||||||
@cInclude("objc/message.h");
|
@cInclude("objc/message.h");
|
||||||
|
|
@ -17,6 +18,7 @@ fn printDeviceError(error_type: c.WGPUErrorType, message: [*c]const u8, _: ?*any
|
||||||
}
|
}
|
||||||
|
|
||||||
const Setup = struct {
|
const Setup = struct {
|
||||||
|
native_instance: gpu.NativeInstance,
|
||||||
instance: c.WGPUInstance,
|
instance: c.WGPUInstance,
|
||||||
backend_type: c.WGPUBackendType,
|
backend_type: c.WGPUBackendType,
|
||||||
device: c.WGPUDevice,
|
device: c.WGPUDevice,
|
||||||
|
|
@ -97,6 +99,7 @@ pub fn setup(allocator: std.mem.Allocator) !Setup {
|
||||||
c.dawnProcSetProcs(backend_procs);
|
c.dawnProcSetProcs(backend_procs);
|
||||||
backend_procs.*.deviceSetUncapturedErrorCallback.?(backend_device, printDeviceError, null);
|
backend_procs.*.deviceSetUncapturedErrorCallback.?(backend_device, printDeviceError, null);
|
||||||
return Setup{
|
return Setup{
|
||||||
|
.native_instance = gpu.NativeInstance.wrap(c.machDawnNativeInstance_get(instance).?),
|
||||||
.instance = c.machDawnNativeInstance_get(instance),
|
.instance = c.machDawnNativeInstance_get(instance),
|
||||||
.backend_type = backend_type,
|
.backend_type = backend_type,
|
||||||
.device = backend_device,
|
.device = backend_device,
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ instance: c.WGPUInstance,
|
||||||
vtable: Interface.VTable,
|
vtable: Interface.VTable,
|
||||||
|
|
||||||
/// Wraps a native WGPUInstance to provide an implementation of the gpu.Interface.
|
/// Wraps a native WGPUInstance to provide an implementation of the gpu.Interface.
|
||||||
pub fn wrap(instance: c.WGPUInstance) NativeInstance {
|
pub fn wrap(instance: *anyopaque) NativeInstance {
|
||||||
return .{
|
return .{
|
||||||
.instance = instance,
|
.instance = @ptrCast(c.WGPUInstance, instance),
|
||||||
.vtable = undefined, // TODO
|
.vtable = undefined, // TODO
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,15 +16,15 @@
|
||||||
//!
|
//!
|
||||||
//!
|
//!
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Interface = @import("Interface.zig");
|
pub const Interface = @import("Interface.zig");
|
||||||
const NativeInstance = @import("NativeInstance.zig");
|
pub const NativeInstance = @import("NativeInstance.zig");
|
||||||
|
|
||||||
const Adapter = @import("Adapter.zig");
|
pub const Adapter = @import("Adapter.zig");
|
||||||
const Device = @import("Device.zig");
|
pub const Device = @import("Device.zig");
|
||||||
const Surface = @import("Surface.zig");
|
pub const Surface = @import("Surface.zig");
|
||||||
|
|
||||||
const FeatureName = @import("feature_name.zig").FeatureName;
|
pub const FeatureName = @import("feature_name.zig").FeatureName;
|
||||||
const SupportedLimits = @import("supported_limits.zig").SupportedLimits;
|
pub const SupportedLimits = @import("supported_limits.zig").SupportedLimits;
|
||||||
|
|
||||||
test "syntax" {
|
test "syntax" {
|
||||||
_ = Interface;
|
_ = Interface;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue