gpu: add Adapter.enumerateFeatures
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
4d5809cc16
commit
60496259b2
3 changed files with 18 additions and 1 deletions
|
|
@ -10,7 +10,6 @@ typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus status, WGPU
|
||||||
typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, char const * message, void * userdata);
|
typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, char const * message, void * userdata);
|
||||||
|
|
||||||
// Methods of Adapter
|
// Methods of Adapter
|
||||||
WGPU_EXPORT size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName * features);
|
|
||||||
WGPU_EXPORT bool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits);
|
WGPU_EXPORT bool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits);
|
||||||
WGPU_EXPORT void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties);
|
WGPU_EXPORT void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties);
|
||||||
WGPU_EXPORT bool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature);
|
WGPU_EXPORT bool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature);
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,18 @@ const testing = @import("std").testing;
|
||||||
const ChainedStructOut = @import("types.zig").ChainedStructOut;
|
const ChainedStructOut = @import("types.zig").ChainedStructOut;
|
||||||
const Device = @import("device.zig").Device;
|
const Device = @import("device.zig").Device;
|
||||||
const DeviceDescriptor = @import("device.zig").DeviceDescriptor;
|
const DeviceDescriptor = @import("device.zig").DeviceDescriptor;
|
||||||
|
const FeatureName = @import("types.zig").FeatureName;
|
||||||
const impl = @import("interface.zig").impl;
|
const impl = @import("interface.zig").impl;
|
||||||
|
|
||||||
pub const Adapter = *opaque {
|
pub const Adapter = *opaque {
|
||||||
pub inline fn createDevice(adapter: Adapter, descriptor: ?*const DeviceDescriptor) ?Device {
|
pub inline fn createDevice(adapter: Adapter, descriptor: ?*const DeviceDescriptor) ?Device {
|
||||||
return impl.createDevice(adapter, descriptor);
|
return impl.createDevice(adapter, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Call once with null to determine the array length, and again to fetch the feature list.
|
||||||
|
pub inline fn enumerateFeatures(adapter: Adapter, features: ?[*]FeatureName) usize {
|
||||||
|
return impl.adapterEnumerateFeatures(adapter, features);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const AdapterType = enum(u32) {
|
pub const AdapterType = enum(u32) {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ pub fn Interface(comptime Impl: type) type {
|
||||||
assertDecl(Impl, "createInstance", fn (descriptor: *const InstanceDescriptor) callconv(.Inline) ?Instance);
|
assertDecl(Impl, "createInstance", fn (descriptor: *const InstanceDescriptor) callconv(.Inline) ?Instance);
|
||||||
assertDecl(Impl, "getProcAddress", fn (device: gpu.Device, proc_name: [*:0]const u8) callconv(.Inline) ?gpu.Proc);
|
assertDecl(Impl, "getProcAddress", fn (device: gpu.Device, proc_name: [*:0]const u8) callconv(.Inline) ?gpu.Proc);
|
||||||
assertDecl(Impl, "adapterCreateDevice", fn (adapter: gpu.Adapter, descriptor: ?*const gpu.DeviceDescriptor) callconv(.Inline) ?gpu.Device);
|
assertDecl(Impl, "adapterCreateDevice", fn (adapter: gpu.Adapter, descriptor: ?*const gpu.DeviceDescriptor) callconv(.Inline) ?gpu.Device);
|
||||||
|
assertDecl(Impl, "adapterEnumerateFeatures", fn (adapter: gpu.Adapter, features: ?[*]gpu.FeatureName) callconv(.Inline) usize);
|
||||||
return Impl;
|
return Impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,6 +48,11 @@ pub fn Export(comptime Impl: type) type {
|
||||||
export fn wgpuAdapterCreateDevice(adapter: gpu.Adapter, descriptor: ?*const gpu.DeviceDescriptor) ?gpu.Device {
|
export fn wgpuAdapterCreateDevice(adapter: gpu.Adapter, descriptor: ?*const gpu.DeviceDescriptor) ?gpu.Device {
|
||||||
return Impl.adapterCreateDevice(adapter, descriptor);
|
return Impl.adapterCreateDevice(adapter, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WGPU_EXPORT size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName * features);
|
||||||
|
export fn wgpuAdapterEnumerateFeatures(adapter: gpu.Adapter, features: ?[*]gpu.FeatureName) usize {
|
||||||
|
return Impl.adapterEnumerateFeatures(adapter, features);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,6 +74,12 @@ pub const NullInterface = Interface(struct {
|
||||||
_ = descriptor;
|
_ = descriptor;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub inline fn adapterEnumerateFeatures(adapter: gpu.Adapter, features: ?[*]gpu.FeatureName) usize {
|
||||||
|
_ = adapter;
|
||||||
|
_ = features;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test "null" {
|
test "null" {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue