Implement GPUDeviceWebGPU::WaitForGPU
This commit is contained in:
@@ -561,6 +561,7 @@ void GPUContextWebGPU::Flush()
|
||||
{
|
||||
wgpuQueueSubmit(_device->Queue, 1, &commandBuffer);
|
||||
wgpuCommandBufferRelease(commandBuffer);
|
||||
_device->QueueSubmits++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1075,6 +1076,7 @@ void GPUContextWebGPU::FlushRenderPass()
|
||||
_blendFactorDirty = true;
|
||||
_scissorRectDirty |= _scissorRect != Rectangle(0, 0, attachmentSize.Width, attachmentSize.Height);
|
||||
_viewportDirty |= _viewport != Viewport(Float2(attachmentSize.Width, attachmentSize.Height));
|
||||
ASSERT_LOW_LAYER(_scissorRect.GetWidth() <= attachmentSize.Width && _scissorRect.GetHeight() <= attachmentSize.Height);
|
||||
}
|
||||
|
||||
void GPUContextWebGPU::FlushBindGroup()
|
||||
|
||||
@@ -796,7 +796,27 @@ void GPUDeviceWebGPU::Dispose()
|
||||
|
||||
void GPUDeviceWebGPU::WaitForGPU()
|
||||
{
|
||||
// TODO: this could use onSubmittedWorkDone (assuming any submit has been already done)
|
||||
if (QueueSubmits == 0)
|
||||
return;
|
||||
QueueSubmits = 0;
|
||||
AsyncCallbackWebGPU<WGPUQueueWorkDoneCallbackInfo> workDone(WGPU_QUEUE_WORK_DONE_CALLBACK_INFO_INIT);
|
||||
workDone.Info.callback = [](WGPUQueueWorkDoneStatus status, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2)
|
||||
{
|
||||
AsyncCallbackDataWebGPU& userData = *reinterpret_cast<AsyncCallbackDataWebGPU*>(userdata1);
|
||||
userData.Call(status == WGPUQueueWorkDoneStatus_Success, status, message);
|
||||
};
|
||||
wgpuQueueOnSubmittedWorkDone(Queue, workDone.Info);
|
||||
auto workDoneResult = workDone.Wait();
|
||||
if (workDoneResult == WGPUWaitStatus_TimedOut)
|
||||
{
|
||||
LOG(Error, "WebGPU queue wait has timed out after {}s", workDone.Data.WaitTime);
|
||||
return;
|
||||
}
|
||||
if (workDoneResult == WGPUWaitStatus_Error)
|
||||
{
|
||||
LOG(Error, "Failed to wait for WebGPU queue. Error: {}, 0x{:x}", workDone.Data.Message, workDone.Data.Status);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
GPUQueryWebGPU GPUDeviceWebGPU::AllocateQuery(GPUQueryType type)
|
||||
|
||||
@@ -141,6 +141,7 @@ public:
|
||||
WGPUBuffer DefaultBuffer = nullptr;
|
||||
GPUDataUploaderWebGPU DataUploader;
|
||||
uint32 MinUniformBufferOffsetAlignment = 1;
|
||||
uint32 QueueSubmits = 0;
|
||||
bool TimestampQuery = false;
|
||||
uint32 QuerySetsCount = 0;
|
||||
GPUQuerySetWebGPU* QuerySets[WEBGPU_MAX_QUERY_SETS] = {};
|
||||
|
||||
Reference in New Issue
Block a user