gpu: add basic Device implementation

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-03-07 22:39:44 -07:00 committed by Stephen Gutekanst
parent 32de278709
commit 93d6e5dedf

View file

@ -6,11 +6,17 @@
//!
//! https://gpuweb.github.io/gpuweb/#devices
//! https://gpuweb.github.io/gpuweb/#gpuadapter
const FeatureName = @import("feature_name.zig").FeatureName;
const Device = @This();
/// The type erased pointer to the Device implementation
/// Equal to c.WGPUDevice for NativeInstance.
ptr: *anyopaque,
vtable: *const VTable,
pub const VTable = struct {
// TODO:
// typedef struct WGPUDeviceImpl* WGPUDevice;
// Methods of Device
// WGPU_EXPORT WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor);
// WGPU_EXPORT WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor);
// WGPU_EXPORT WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor);
@ -41,5 +47,19 @@
// WGPU_EXPORT void wgpuDeviceSetLoggingCallback(WGPUDevice device, WGPULoggingCallback callback, void * userdata);
// WGPU_EXPORT void wgpuDeviceSetUncapturedErrorCallback(WGPUDevice device, WGPUErrorCallback callback, void * userdata);
// WGPU_EXPORT void wgpuDeviceTick(WGPUDevice device);
// WGPU_EXPORT void wgpuDeviceReference(WGPUDevice device);
// WGPU_EXPORT void wgpuDeviceRelease(WGPUDevice device);
reference: fn (ptr: *anyopaque) void,
release: fn (ptr: *anyopaque) void,
};
pub const Descriptor = struct {
label: ?[]const u8 = null,
required_features: ?[]FeatureName = null,
// TODO:
//required_limits: ?RequiredLimits = null,
};
test "syntax" {
_ = VTable;
_ = Descriptor;
}