This commit is contained in:
2025-02-26 22:05:06 +01:00
parent 39794a27d9
commit 726bbdf389
8 changed files with 125 additions and 23 deletions

View File

@@ -2,9 +2,12 @@
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <stdatomic.h>
#include <Pulse.h>
#include "WebGPU.h"
#include "WebGPUDevice.h"
#include "WebGPUFence.h"
#include "WebGPUCommandList.h"
#include "WebGPUComputePass.h"
#include "../../PulseInternal.h"
@@ -38,6 +41,17 @@ PulseCommandList WebGPURequestCommandList(PulseDevice device, PulseCommandListUs
return cmd;
}
#include <stdio.h>
static void WebGPUFenceCallback(WGPUQueueWorkDoneStatus status, void* userdata1, void* userdata2)
{
PULSE_UNUSED(userdata2);
WebGPUFence* webgpu_fence = (WebGPUFence*)userdata1;
if(status == WGPUQueueWorkDoneStatus_Success)
atomic_store(&webgpu_fence->signal, true);
puts("test");
}
bool WebGPUSubmitCommandList(PulseDevice device, PulseCommandList cmd, PulseFence fence)
{
WebGPUDevice* webgpu_device = WEBGPU_RETRIEVE_DRIVER_DATA_AS(device, WebGPUDevice*);
@@ -48,6 +62,15 @@ bool WebGPUSubmitCommandList(PulseDevice device, PulseCommandList cmd, PulseFenc
wgpuQueueSubmit(webgpu_device->queue, 1, &command_buffer);
WebGPUFence* webgpu_fence = WEBGPU_RETRIEVE_DRIVER_DATA_AS(fence, WebGPUFence*);
atomic_store(&webgpu_fence->signal, false);
WGPUQueueWorkDoneCallbackInfo callback = { 0 };
callback.mode = WGPUCallbackMode_AllowSpontaneous;
callback.callback = WebGPUFenceCallback;
callback.userdata1 = webgpu_fence;
wgpuQueueOnSubmittedWorkDone(webgpu_device->queue, callback);
wgpuCommandBufferRelease(command_buffer);
return true;
}