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); }