gpu: add getProcAddress
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
c0ad349a12
commit
2d6dbd3351
3 changed files with 17 additions and 2 deletions
|
|
@ -10,8 +10,6 @@ typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus status, void *
|
|||
typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const * message, void * userdata);
|
||||
typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, char const * message, void * userdata);
|
||||
|
||||
WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName);
|
||||
|
||||
// Methods of Adapter
|
||||
WGPU_EXPORT WGPUDevice wgpuAdapterCreateDevice(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor /* nullable */);
|
||||
WGPU_EXPORT size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName * features);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
const Instance = @import("instance.zig").Instance;
|
||||
const InstanceDescriptor = @import("instance.zig").InstanceDescriptor;
|
||||
const gpu = @import("main.zig");
|
||||
|
||||
/// Verifies that a gpu.Interface implementation exposes the expected function declarations.
|
||||
pub fn Interface(comptime Impl: type) type {
|
||||
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);
|
||||
return Impl;
|
||||
}
|
||||
|
||||
|
|
@ -21,6 +23,11 @@ pub fn Export(comptime Impl: type) type {
|
|||
export fn wgpuCreateInstance(descriptor: *const InstanceDescriptor) ?Instance {
|
||||
return Impl.createInstance(descriptor);
|
||||
}
|
||||
|
||||
// WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName);
|
||||
export fn getProcAddress(device: gpu.Device, proc_name: [*:0]const u8) ?gpu.Proc {
|
||||
return Impl.getProcAddress(device, proc_name);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -30,6 +37,12 @@ pub const NullInterface = Interface(struct {
|
|||
_ = descriptor;
|
||||
return null;
|
||||
}
|
||||
|
||||
pub inline fn getProcAddress(device: gpu.Device, proc_name: [*:0]const u8) ?gpu.Proc {
|
||||
_ = device;
|
||||
_ = proc_name;
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
test "null" {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@ const query_set = @import("query_set.zig");
|
|||
const texture_view = @import("texture_view.zig");
|
||||
const surface = @import("surface.zig");
|
||||
|
||||
/// Generic function pointer type, used for returning API function pointers. Must be
|
||||
/// cast to a `fn (...) callconv(.C) T` before use.
|
||||
pub const Proc = *anyopaque;
|
||||
|
||||
pub const ComputePassTimestampWrite = extern struct {
|
||||
query_set: query_set.QuerySet,
|
||||
query_index: u32,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue