Flutter Engine
The Flutter Engine
DawnBuffer.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef skgpu_graphite_DawnBuffer_DEFINED
9#define skgpu_graphite_DawnBuffer_DEFINED
10
11#include "webgpu/webgpu_cpp.h" // NO_G3_REWRITE
12
20
21namespace skgpu::graphite {
22
23class DawnBuffer : public Buffer {
24public:
26 size_t size,
29
30 bool isUnmappable() const override;
31
32 const wgpu::Buffer& dawnBuffer() const { return fBuffer; }
33
34private:
35 DawnBuffer(const DawnSharedContext*, size_t size, wgpu::Buffer, void* mapAtCreationPtr);
36
37#if defined(__EMSCRIPTEN__)
38 void prepareForReturnToCache(const std::function<void()>& takeRef) override;
40#endif
41 void onMap() override;
42 void onUnmap() override;
43
44 void mapCallback(WGPUBufferMapAsyncStatus status);
45
46 void freeGpuData() override;
47
48 const DawnSharedContext* dawnSharedContext() const {
49 return static_cast<const DawnSharedContext*>(this->sharedContext());
50 }
51
52 void setBackendLabel(char const* label) override;
53
54 wgpu::Buffer fBuffer;
55 SkMutex fAsyncMutex;
56 skia_private::TArray<sk_sp<RefCntedCallback>> fAsyncMapCallbacks SK_GUARDED_BY(fAsyncMutex);
57};
58
59} // namespace skgpu::graphite
60
61#endif // skgpu_graphite_DawnBuffer_DEFINED
62
GLenum type
virtual void onAsyncMap(GpuFinishedProc, GpuFinishedContext)
Definition: Buffer.cpp:35
size_t size() const
Definition: Buffer.h:19
bool isUnmappable() const override
Definition: DawnBuffer.cpp:285
static sk_sp< DawnBuffer > Make(const DawnSharedContext *, size_t size, BufferType type, AccessPattern)
Definition: DawnBuffer.cpp:18
const wgpu::Buffer & dawnBuffer() const
Definition: DawnBuffer.h:32
virtual void prepareForReturnToCache(const std::function< void()> &takeRef)
Definition: Resource.h:173
const SharedContext * sharedContext() const
Definition: Resource.h:189
Dart_NativeFunction function
Definition: fuchsia.cc:51
void * GpuFinishedContext
Definition: GraphiteTypes.h:29
void(*)(GpuFinishedContext finishedContext, CallbackResult) GpuFinishedProc
Definition: GraphiteTypes.h:30