gpu: implement Device.hasFeature

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-03-18 19:03:14 -07:00 committed by Stephen Gutekanst
parent 37d8113e24
commit 12a0772654

View file

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