gpu: prepare Device limits/features

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-03-18 19:02:11 -07:00 committed by Stephen Gutekanst
parent e7526a868d
commit 37d8113e24
2 changed files with 13 additions and 4 deletions

View file

@ -32,6 +32,12 @@ const Texture = @import("Texture.zig");
const Device = @This(); const Device = @This();
/// The features supported by the device (i.e. the ones with which it was created).
features: []Feature,
/// The limits supported by the device (which are exactly the ones with which it was created).
limits: Limits,
/// The type erased pointer to the Device implementation /// The type erased pointer to the Device implementation
/// Equal to c.WGPUDevice for NativeInstance. /// Equal to c.WGPUDevice for NativeInstance.
ptr: *anyopaque, ptr: *anyopaque,
@ -66,10 +72,6 @@ pub const VTable = struct {
nativeCreateSwapChain: fn (ptr: *anyopaque, surface: ?Surface, descriptor: *const SwapChain.Descriptor) SwapChain, nativeCreateSwapChain: fn (ptr: *anyopaque, surface: ?Surface, descriptor: *const SwapChain.Descriptor) SwapChain,
createTexture: fn (ptr: *anyopaque, descriptor: *const Texture.Descriptor) Texture, createTexture: fn (ptr: *anyopaque, descriptor: *const Texture.Descriptor) Texture,
destroy: fn (ptr: *anyopaque) void, destroy: fn (ptr: *anyopaque) void,
// TODO: should features be exposed as static slice?
// WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeature * features);
// TODO: should limits be exposed as static slice?
// WGPU_EXPORT bool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits);
getQueue: fn (ptr: *anyopaque) Queue, getQueue: fn (ptr: *anyopaque) Queue,
// TODO: should hasFeature be a helper method? // TODO: should hasFeature be a helper method?
// WGPU_EXPORT bool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeature feature); // WGPU_EXPORT bool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeature feature);

View file

@ -304,7 +304,14 @@ const adapter_vtable = Adapter.VTable{
fn wrapDevice(device: c.WGPUDevice) Device { fn wrapDevice(device: c.WGPUDevice) Device {
// TODO: implement Device interface // TODO: implement Device interface
// WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeature * features);
// WGPU_EXPORT bool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits);
return .{ return .{
// TODO:
.features = undefined,
// TODO:
.limits = undefined,
.ptr = device.?, .ptr = device.?,
.vtable = &device_vtable, .vtable = &device_vtable,
}; };