gpu: implement Device.loseForTesting

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-03-18 17:59:06 -07:00 committed by Stephen Gutekanst
parent 85d5de1077
commit 311f2967a5
2 changed files with 11 additions and 2 deletions

View file

@ -70,8 +70,7 @@ pub const VTable = struct {
// TODO: should hasFeature be a helper method?
// WGPU_EXPORT bool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeature feature);
injectError: fn (ptr: *anyopaque, type: ErrorType, message: [*:0]const u8) void,
// loseForTesting: fn (ptr: *anyopaque) void,
// WGPU_EXPORT void wgpuDeviceLoseForTesting(WGPUDevice device);
loseForTesting: fn (ptr: *anyopaque) void,
// TODO: callback
// popErrorScope: fn (ptr: *anyopaque, callback: ErrorCallback) bool,
// WGPU_EXPORT bool wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata);
@ -105,6 +104,10 @@ pub inline fn injectError(device: Device, typ: ErrorType, message: [*:0]const u8
device.vtable.injectError(device.ptr, typ, message);
}
pub inline fn loseForTesting(device: Device) void {
device.vtable.loseForTesting(device.ptr);
}
pub inline fn createBindGroup(device: Device, descriptor: *const BindGroup.Descriptor) BindGroup {
return device.vtable.createBindGroup(device.ptr, descriptor);
}
@ -209,6 +212,7 @@ test {
_ = release;
_ = getQueue;
_ = injectError;
_ = loseForTesting;
_ = createBindGroup;
_ = createBindGroupLayout;
_ = createSampler;

View file

@ -327,6 +327,11 @@ const device_vtable = Device.VTable{
c.wgpuDeviceInjectError(@ptrCast(c.WGPUDevice, ptr), @enumToInt(typ), message);
}
}).injectError,
.loseForTesting = (struct {
pub fn loseForTesting(ptr: *anyopaque) void {
c.wgpuDeviceLoseForTesting(@ptrCast(c.WGPUDevice, ptr));
}
}).loseForTesting,
.createBindGroup = (struct {
pub fn createBindGroup(ptr: *anyopaque, descriptor: *const BindGroup.Descriptor) BindGroup {
var few_entries: [16]c.WGPUBindGroupEntry = undefined;