gpu: correct sending of pointer to a local var to a callback function (#271)

This commit is contained in:
Michal Ziulek 2022-05-09 00:04:25 +02:00 committed by GitHub
parent a1daf399a3
commit 5a2aebb14b
Failed to generate hash of commit
2 changed files with 10 additions and 6 deletions

View file

@ -879,10 +879,10 @@ const queue_vtable = Queue.VTable{
}
}).release,
.submit = (struct {
pub fn submit(queue: Queue, cmds: []const CommandBuffer) void {
pub fn submit(queue: *Queue, cmds: []const CommandBuffer) void {
const wgpu_queue = @ptrCast(c.WGPUQueue, queue.ptr);
if (queue.on_submitted_work_done) |on_submitted_work_done| {
if (queue.on_submitted_work_done) |_| {
// Note: signalValue is not available in the web API, and it's usage is undocumented
// kainino says "It's basically reserved for future use, though it's been suggested
// to remove it instead"
@ -898,8 +898,12 @@ const queue_vtable = Queue.VTable{
}
}).cCallback;
var mut_on_submitted_work_done = on_submitted_work_done;
c.wgpuQueueOnSubmittedWorkDone(wgpu_queue, signal_value, cCallback, &mut_on_submitted_work_done);
c.wgpuQueueOnSubmittedWorkDone(
wgpu_queue,
signal_value,
cCallback,
&queue.on_submitted_work_done,
);
}
var few_commands: [16]c.WGPUCommandBuffer = undefined;

View file

@ -20,7 +20,7 @@ pub const VTable = struct {
release: fn (ptr: *anyopaque) void,
// TODO: dawn specific?
// copyTextureForBrowser: fn (ptr: *anyopaque, source: *const ImageCopyTexture, destination: *const ImageCopyTexture, copy_size: *const Extent3D, options: *const CopyTextureForBrowserOptions) void,
submit: fn (queue: Queue, commands: []const CommandBuffer) void,
submit: fn (queue: *Queue, commands: []const CommandBuffer) void,
writeBuffer: fn (
ptr: *anyopaque,
buffer: Buffer,
@ -46,7 +46,7 @@ pub inline fn release(queue: Queue) void {
queue.vtable.release(queue.ptr);
}
pub inline fn submit(queue: Queue, commands: []const CommandBuffer) void {
pub inline fn submit(queue: *Queue, commands: []const CommandBuffer) void {
queue.vtable.submit(queue, commands);
}