From 12a0772654667b57ccc6deeebe20f66ca4837184 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 18 Mar 2022 19:03:14 -0700 Subject: [PATCH] gpu: implement Device.hasFeature Signed-off-by: Stephen Gutekanst --- gpu/src/Device.zig | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gpu/src/Device.zig b/gpu/src/Device.zig index 520e3635..ec98ee0d 100644 --- a/gpu/src/Device.zig +++ b/gpu/src/Device.zig @@ -73,8 +73,6 @@ pub const VTable = struct { createTexture: fn (ptr: *anyopaque, descriptor: *const Texture.Descriptor) Texture, destroy: fn (ptr: *anyopaque) void, getQueue: fn (ptr: *anyopaque) Queue, - // TODO: should hasFeature be a helper method? - // WGPU_EXPORT bool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeature feature); injectError: fn (ptr: *anyopaque, type: ErrorType, message: [*:0]const u8) void, loseForTesting: fn (ptr: *anyopaque) void, popErrorScope: fn (ptr: *anyopaque, callback: *ErrorCallback) bool, @@ -93,6 +91,14 @@ pub inline fn release(device: Device) void { device.vtable.release(device.ptr); } +/// Tests of the device has this feature & was created with it. +pub fn hasFeature(device: Device, feature: Feature) bool { + for (device.features) |f| { + if (f == feature) return true; + } + return false; +} + pub inline fn getQueue(device: Device) Queue { return device.vtable.getQueue(device.ptr); }