gpu: add adapter.enumerateFeaturesOwned helper
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
9568bff8ab
commit
185a4231e6
1 changed files with 13 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
const testing = @import("std").testing;
|
||||
const std = @import("std");
|
||||
const testing = std.testing;
|
||||
const ChainedStructOut = @import("types.zig").ChainedStructOut;
|
||||
const Device = @import("device.zig").Device;
|
||||
const FeatureName = @import("types.zig").FeatureName;
|
||||
|
|
@ -42,10 +43,21 @@ pub const Adapter = opaque {
|
|||
}
|
||||
|
||||
/// 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(adapter: *Adapter, features: ?[*]FeatureName) usize {
|
||||
return Impl.adapterEnumerateFeatures(adapter, features);
|
||||
}
|
||||
|
||||
/// Enumerates the adapter features, storing the result in an allocated slice which is owned by
|
||||
/// the caller.
|
||||
pub inline fn enumerateFeaturesOwned(adapter: *Adapter, allocator: std.mem.Allocator) ![]FeatureName {
|
||||
const count = adapter.enumerateFeatures(null);
|
||||
var data = try allocator.alloc(FeatureName, count);
|
||||
_ = adapter.enumerateFeatures(data.ptr);
|
||||
return data;
|
||||
}
|
||||
|
||||
pub inline fn getLimits(adapter: *Adapter, limits: *SupportedLimits) bool {
|
||||
return Impl.adapterGetLimits(adapter, limits);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue