gpu: add Adapter.getLimits
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
60496259b2
commit
2b7241be0a
3 changed files with 61 additions and 11 deletions
|
|
@ -10,23 +10,51 @@ typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus status, WGPU
|
|||
typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, char const * message, void * userdata);
|
||||
|
||||
// Methods of Adapter
|
||||
WGPU_EXPORT bool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits);
|
||||
WGPU_EXPORT void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties);
|
||||
WGPU_EXPORT bool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature);
|
||||
WGPU_EXPORT void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata);
|
||||
WGPU_EXPORT void wgpuAdapterReference(WGPUAdapter adapter);
|
||||
WGPU_EXPORT void wgpuAdapterRelease(WGPUAdapter adapter);
|
||||
// WGPU_EXPORT void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties);
|
||||
export fn wgpuAdapterGetProperties(adapter: gpu.Adapter, properties: *gpu.AdapterProperties) void {
|
||||
assertDecl(Impl, "adapterGetProperties", fn (adapter: gpu.Adapter, properties: *gpu.AdapterProperties) callconv(.Inline) void);
|
||||
|
||||
// WGPU_EXPORT bool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature);
|
||||
export fn wgpuAdapterHasFeature(adapter: gpu.Adapter, feature: gpu.FeatureName) bool {
|
||||
assertDecl(Impl, "adapterHasFeature", fn (adapter: gpu.Adapter, feature: gpu.FeatureName) callconv(.Inline) bool);
|
||||
|
||||
// NOTE: descriptor is nullable, see https://bugs.chromium.org/p/dawn/issues/detail?id=1502
|
||||
// WGPU_EXPORT void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata);
|
||||
export fn wgpuAdapterRequestDevice(adapter: gpu.Adapter, descriptor: ?*const gpu.DeviceDescriptor, callback: gpu.RequestDeviceCallback, userdata: *anyopaque) void {
|
||||
assertDecl(Impl, "adapterRequestDevice", fn (adapter: gpu.Adapter, descriptor: ?*const gpu.DeviceDescriptor, callback: gpu.RequestDeviceCallback, userdata: *anyopaque) callconv(.Inline) void);
|
||||
|
||||
// WGPU_EXPORT void wgpuAdapterReference(WGPUAdapter adapter);
|
||||
export fn wgpuAdapterReference(adapter: gpu.Adapter) void {
|
||||
assertDecl(Impl, "adapterReference", fn (adapter: gpu.Adapter) callconv(.Inline) void);
|
||||
|
||||
// WGPU_EXPORT void wgpuAdapterRelease(WGPUAdapter adapter);
|
||||
export fn wgpuAdapterRelease(adapter: gpu.Adapter) void {
|
||||
assertDecl(Impl, "adapterRelease", fn (adapter: gpu.Adapter) callconv(.Inline) void);
|
||||
|
||||
|
||||
// Methods of BindGroup
|
||||
WGPU_EXPORT void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, char const * label);
|
||||
WGPU_EXPORT void wgpuBindGroupReference(WGPUBindGroup bindGroup);
|
||||
WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup);
|
||||
// WGPU_EXPORT void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, char const * label);
|
||||
export fn wgpuBindGroupSetLabel(bind_group: gpu.BindGroup, label: [*:0]const u8) void {
|
||||
assertDecl(Impl, "bindGroupSetLabel", fn (bind_group: gpu.BindGroup, label: [*:0]const u8) callconv(.Inline) void);
|
||||
|
||||
// WGPU_EXPORT void wgpuBindGroupReference(WGPUBindGroup bindGroup);
|
||||
export fn wgpuBindGroupReference(bind_group: gpu.BindGroup) void {
|
||||
assertDecl(Impl, "bindGroupReference", fn (bind_group: gpu.BindGroup) callconv(.Inline) void);
|
||||
|
||||
// WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup);
|
||||
export fn wgpuBindGroupRelease(bind_group: gpu.BindGroup) void {
|
||||
assertDecl(Impl, "bindGroupRelease", fn (bind_group: gpu.BindGroup) callconv(.Inline) void);
|
||||
|
||||
|
||||
// Methods of BindGroupLayout
|
||||
WGPU_EXPORT void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, char const * label);
|
||||
// WGPU_EXPORT void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, char const * label);
|
||||
export fn wgpuBindGroupLayoutSetLabel(bind_group_layout: gpu.BindGroupLayout, label: [*:0]const u8) void {
|
||||
assertDecl(Impl, "bindGroupLayoutSetLabel", fn (bind_group_layout: gpu.BindGroupLayout, label: [*:0]const u8) callconv(.Inline) void);
|
||||
|
||||
WGPU_EXPORT void wgpuBindGroupLayoutReference(WGPUBindGroupLayout bindGroupLayout);
|
||||
WGPU_EXPORT void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout);
|
||||
|
||||
|
||||
// Methods of Buffer
|
||||
WGPU_EXPORT void wgpuBufferDestroy(WGPUBuffer buffer);
|
||||
WGPU_EXPORT void const * wgpuBufferGetConstMappedRange(WGPUBuffer buffer, size_t offset, size_t size);
|
||||
|
|
@ -34,11 +62,16 @@ WGPU_EXPORT void * wgpuBufferGetMappedRange(WGPUBuffer buffer, size_t offset, si
|
|||
WGPU_EXPORT uint64_t wgpuBufferGetSize(WGPUBuffer buffer);
|
||||
WGPU_EXPORT WGPUBufferUsage wgpuBufferGetUsage(WGPUBuffer buffer);
|
||||
WGPU_EXPORT void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata);
|
||||
WGPU_EXPORT void wgpuBufferSetLabel(WGPUBuffer buffer, char const * label);
|
||||
|
||||
// WGPU_EXPORT void wgpuBufferSetLabel(WGPUBuffer buffer, char const * label);
|
||||
export fn wgpuBufferSetLabel(buffer: gpu.Buffer, label: [*:0]const u8) void {
|
||||
assertDecl(Impl, "BufferSetLabel", fn (buffer: gpu.Buffer, label: [*:0]const u8) callconv(.Inline) void);
|
||||
|
||||
WGPU_EXPORT void wgpuBufferUnmap(WGPUBuffer buffer);
|
||||
WGPU_EXPORT void wgpuBufferReference(WGPUBuffer buffer);
|
||||
WGPU_EXPORT void wgpuBufferRelease(WGPUBuffer buffer);
|
||||
|
||||
|
||||
// Methods of CommandBuffer
|
||||
WGPU_EXPORT void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, char const * label);
|
||||
WGPU_EXPORT void wgpuCommandBufferReference(WGPUCommandBuffer commandBuffer);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ const ChainedStructOut = @import("types.zig").ChainedStructOut;
|
|||
const Device = @import("device.zig").Device;
|
||||
const DeviceDescriptor = @import("device.zig").DeviceDescriptor;
|
||||
const FeatureName = @import("types.zig").FeatureName;
|
||||
const SupportedLimits = @import("types.zig").SupportedLimits;
|
||||
const impl = @import("interface.zig").impl;
|
||||
|
||||
pub const Adapter = *opaque {
|
||||
|
|
@ -14,6 +15,10 @@ pub const Adapter = *opaque {
|
|||
pub inline fn enumerateFeatures(adapter: Adapter, features: ?[*]FeatureName) usize {
|
||||
return impl.adapterEnumerateFeatures(adapter, features);
|
||||
}
|
||||
|
||||
pub inline fn getLimits(adapter: Adapter, limits: *SupportedLimits) bool {
|
||||
return impl.adapterGetLimits(adapter, limits);
|
||||
}
|
||||
};
|
||||
|
||||
pub const AdapterType = enum(u32) {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ pub fn Interface(comptime Impl: type) type {
|
|||
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, "adapterEnumerateFeatures", fn (adapter: gpu.Adapter, features: ?[*]gpu.FeatureName) callconv(.Inline) usize);
|
||||
assertDecl(Impl, "adapterGetLimits", fn (adapter: gpu.Adapter, limits: *gpu.SupportedLimits) callconv(.Inline) bool);
|
||||
return Impl;
|
||||
}
|
||||
|
||||
|
|
@ -53,6 +54,11 @@ pub fn Export(comptime Impl: type) type {
|
|||
export fn wgpuAdapterEnumerateFeatures(adapter: gpu.Adapter, features: ?[*]gpu.FeatureName) usize {
|
||||
return Impl.adapterEnumerateFeatures(adapter, features);
|
||||
}
|
||||
|
||||
// WGPU_EXPORT bool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits);
|
||||
export fn wgpuAdapterGetLimits(adapter: gpu.Adapter, limits: *gpu.SupportedLimits) bool {
|
||||
return Impl.adapterGetLimits(adapter, limits);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -80,6 +86,12 @@ pub const NullInterface = Interface(struct {
|
|||
_ = features;
|
||||
return 0;
|
||||
}
|
||||
|
||||
pub inline fn adapterGetLimits(adapter: gpu.Adapter, limits: *gpu.SupportedLimits) bool {
|
||||
_ = adapter;
|
||||
_ = limits;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
test "null" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue