gpu: add Device.enumerateFeaturesOwned helper

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-11 12:52:28 -07:00 committed by Stephen Gutekanst
parent 94568052f5
commit b369635193
2 changed files with 13 additions and 1 deletions

View file

@ -181,10 +181,22 @@ pub const Device = opaque {
Impl.deviceDestroy(device);
}
/// Call once with null to determine the array length, and again to fetch the feature list.
///
/// Consider using the enumerateFeaturesOwned helper.
pub inline fn enumerateFeatures(device: *Device, features: [*]FeatureName) usize {
return Impl.deviceEnumerateFeatures(device, features);
}
/// Enumerates the adapter features, storing the result in an allocated slice which is owned by
/// the caller.
pub inline fn enumerateFeaturesOwned(device: *Device, allocator: std.mem.Allocator) ![]FeatureName {
const count = device.enumerateFeatures(null);
var data = try allocator.alloc(FeatureName, count);
_ = device.enumerateFeatures(data.ptr);
return data;
}
pub inline fn getLimits(device: *Device, limits: *SupportedLimits) bool {
return Impl.deviceGetLimits(device, limits);
}