20class [[maybe_unused]] DawnWorkSubmissionWithAsyncWait final :
public GpuWorkSubmission {
22 DawnWorkSubmissionWithAsyncWait(std::unique_ptr<CommandBuffer> cmdBuffer,
23 DawnQueueManager* queueManager,
24 const DawnSharedContext* sharedContext);
27 bool onIsFinished(
const SharedContext* sharedContext)
override;
28 void onWaitUntilFinished(
const SharedContext* sharedContext)
override;
30 DawnAsyncWait fAsyncWait;
33DawnWorkSubmissionWithAsyncWait::DawnWorkSubmissionWithAsyncWait(
34 std::unique_ptr<CommandBuffer> cmdBuffer,
35 DawnQueueManager* queueManager,
36 const DawnSharedContext* sharedContext)
37 : GpuWorkSubmission(
std::move(cmdBuffer), queueManager), fAsyncWait(sharedContext) {
38 queueManager->dawnQueue().OnSubmittedWorkDone(
39#
if defined(__EMSCRIPTEN__)
44 [](WGPUQueueWorkDoneStatus,
void* userData) {
45 auto asyncWaitPtr =
static_cast<DawnAsyncWait*
>(userData);
46 asyncWaitPtr->signal();
51bool DawnWorkSubmissionWithAsyncWait::onIsFinished(
const SharedContext*) {
52 return fAsyncWait.yieldAndCheck();
55void DawnWorkSubmissionWithAsyncWait::onWaitUntilFinished(
const SharedContext*) {
56 fAsyncWait.busyWait();
59#if !defined(__EMSCRIPTEN__)
63class DawnWorkSubmissionWithFuture final :
public GpuWorkSubmission {
65 DawnWorkSubmissionWithFuture(std::unique_ptr<CommandBuffer> cmdBuffer,
66 DawnQueueManager* queueManager);
69 bool onIsFinished(
const SharedContext* sharedContext)
override;
70 void onWaitUntilFinished(
const SharedContext* sharedContext)
override;
72 wgpu::Future fSubmittedWorkDoneFuture;
75DawnWorkSubmissionWithFuture::DawnWorkSubmissionWithFuture(std::unique_ptr<CommandBuffer> cmdBuffer,
76 DawnQueueManager* queueManager)
77 : GpuWorkSubmission(
std::move(cmdBuffer), queueManager) {
78 fSubmittedWorkDoneFuture = queueManager->dawnQueue().OnSubmittedWorkDone(
79 wgpu::CallbackMode::WaitAnyOnly, [](wgpu::QueueWorkDoneStatus) {});
82bool DawnWorkSubmissionWithFuture::onIsFinished(
const SharedContext* sharedContext) {
83 wgpu::FutureWaitInfo waitInfo{};
84 waitInfo.future = fSubmittedWorkDoneFuture;
85 const auto&
instance =
static_cast<const DawnSharedContext*
>(sharedContext)
89 if (
instance.WaitAny(1, &waitInfo, 0) != wgpu::WaitStatus::Success) {
93 return waitInfo.completed;
96void DawnWorkSubmissionWithFuture::onWaitUntilFinished(
const SharedContext* sharedContext) {
97 wgpu::FutureWaitInfo waitInfo{};
98 waitInfo.future = fSubmittedWorkDoneFuture;
99 const auto&
instance =
static_cast<const DawnSharedContext*
>(sharedContext)
103 [[maybe_unused]]
auto status =
105 SkASSERT(status == wgpu::WaitStatus::Success);
122std::unique_ptr<CommandBuffer> DawnQueueManager::getNewCommandBuffer(
125 static_cast<DawnResourceProvider*
>(resourceProvider));
131 auto wgpuCmdBuffer = dawnCmdBuffer->finishEncoding();
132 if (!wgpuCmdBuffer) {
137 fQueue.Submit(1, &wgpuCmdBuffer);
139#if defined(__EMSCRIPTEN__)
140 return std::make_unique<DawnWorkSubmissionWithAsyncWait>(
147#if defined(GRAPHITE_TEST_UTILS)
148void DawnQueueManager::startCapture() {
152void DawnQueueManager::stopCapture() {
static std::unique_ptr< DawnCommandBuffer > Make(const DawnSharedContext *, DawnResourceProvider *)
void tick() const override
const SharedContext * fSharedContext
std::unique_ptr< GpuWorkSubmission > OutstandingSubmission
std::unique_ptr< CommandBuffer > fCurrentCommandBuffer
static float max(float r, float g, float b)