Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 std::string_view label);
30
31 bool isUnmappable() const override;
32
33 const wgpu::Buffer& dawnBuffer() const { return fBuffer; }
34
35private:
37 size_t size,
38 wgpu::Buffer,
40 void* mapAtCreationPtr,
41 std::string_view label);
42
43#if defined(__EMSCRIPTEN__)
44 void prepareForReturnToCache(const std::function<void()>& takeRef) override;
46#endif
47 void onMap() override;
48 void onUnmap() override;
49
50 void mapCallback(WGPUBufferMapAsyncStatus status);
51
52 void freeGpuData() override;
53
54 void onDumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump,
55 const char* dumpName) const override;
56
57 const DawnSharedContext* dawnSharedContext() const {
58 return static_cast<const DawnSharedContext*>(this->sharedContext());
59 }
60
61 wgpu::Buffer fBuffer;
62 const BufferType fType;
63 SkMutex fAsyncMutex;
64 skia_private::TArray<sk_sp<RefCntedCallback>> fAsyncMapCallbacks SK_GUARDED_BY(fAsyncMutex);
65};
66
67} // namespace skgpu::graphite
68
69#endif // skgpu_graphite_DawnBuffer_DEFINED
70
#define SK_GUARDED_BY(x)
virtual void onAsyncMap(GpuFinishedProc, GpuFinishedContext)
Definition Buffer.cpp:35
size_t size() const
Definition Buffer.h:19
bool isUnmappable() const override
void onDumpMemoryStatistics(SkTraceMemoryDump *traceMemoryDump, const char *dumpName) const override
static sk_sp< DawnBuffer > Make(const DawnSharedContext *, size_t size, BufferType type, AccessPattern, std::string_view label)
const wgpu::Buffer & dawnBuffer() const
Definition DawnBuffer.h:33
virtual void prepareForReturnToCache(const std::function< void()> &takeRef)
Definition Resource.h:170
const SharedContext * sharedContext() const
Definition Resource.h:187
void * GpuFinishedContext
void(*)(GpuFinishedContext finishedContext, CallbackResult) GpuFinishedProc