gpu: remove Queue.WorkDownCallback lifetime footgun

The previous implementation required the specific Queue struct that
submit() was called on to be valid when the callback is triggered. By
storing a pointer instead, the Queue does not need to be valid, only the
callback itself.
This commit is contained in:
dweiller 2022-06-23 14:10:32 +10:00 committed by Stephen Gutekanst
parent 7bb877bd55
commit 134c2019b1
2 changed files with 5 additions and 2 deletions

View file

@ -902,7 +902,7 @@ const queue_vtable = Queue.VTable{
wgpu_queue,
signal_value,
cCallback,
&queue.on_submitted_work_done,
queue.on_submitted_work_done,
);
}

View file

@ -8,7 +8,10 @@ const Texture = @import("Texture.zig");
const Queue = @This();
on_submitted_work_done: ?WorkDoneCallback = null,
/// Callback to executed when all work has been done
/// This field must be set before calling `submit()` on the commands the callback waits for.
/// Note that the address stored must be valid when the callback is executed.
on_submitted_work_done: ?*WorkDoneCallback = null,
/// The type erased pointer to the Queue implementation
/// Equal to c.WGPUQueue for NativeInstance.