From 37d8113e2407c8689aa0849ad42e53518e69e35c Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 18 Mar 2022 19:02:11 -0700 Subject: [PATCH] gpu: prepare Device limits/features Signed-off-by: Stephen Gutekanst --- gpu/src/Device.zig | 10 ++++++---- gpu/src/NativeInstance.zig | 7 +++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gpu/src/Device.zig b/gpu/src/Device.zig index 86d710a8..520e3635 100644 --- a/gpu/src/Device.zig +++ b/gpu/src/Device.zig @@ -32,6 +32,12 @@ const Texture = @import("Texture.zig"); 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 /// Equal to c.WGPUDevice for NativeInstance. ptr: *anyopaque, @@ -66,10 +72,6 @@ pub const VTable = struct { nativeCreateSwapChain: fn (ptr: *anyopaque, surface: ?Surface, descriptor: *const SwapChain.Descriptor) SwapChain, createTexture: fn (ptr: *anyopaque, descriptor: *const Texture.Descriptor) Texture, 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, // TODO: should hasFeature be a helper method? // WGPU_EXPORT bool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeature feature); diff --git a/gpu/src/NativeInstance.zig b/gpu/src/NativeInstance.zig index 179d8875..770b8ceb 100644 --- a/gpu/src/NativeInstance.zig +++ b/gpu/src/NativeInstance.zig @@ -304,7 +304,14 @@ const adapter_vtable = Adapter.VTable{ fn wrapDevice(device: c.WGPUDevice) Device { // TODO: implement Device interface + // WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeature * features); + // WGPU_EXPORT bool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits); + return .{ + // TODO: + .features = undefined, + // TODO: + .limits = undefined, .ptr = device.?, .vtable = &device_vtable, };