• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"
12 
13 #include "include/core/SkRefCnt.h"
14 #include "include/gpu/graphite/dawn/DawnTypes.h"
15 #include "src/gpu/graphite/Buffer.h"
16 #include "src/gpu/graphite/dawn/DawnSharedContext.h"
17 
18 namespace skgpu::graphite {
19 
20 class DawnBuffer : public Buffer {
21 public:
22     static sk_sp<Buffer> Make(const DawnSharedContext*,
23                               size_t size,
24                               BufferType type,
25                               PrioritizeGpuReads);
26 
dawnBuffer()27     const wgpu::Buffer& dawnBuffer() const { return fBuffer; }
28 
29 private:
30     DawnBuffer(const DawnSharedContext*,
31                size_t size,
32                wgpu::Buffer);
33 
34     void onMap() override;
35     void onUnmap() override;
36 
37     void freeGpuData() override;
38 
dawnSharedContext()39     const DawnSharedContext* dawnSharedContext() const {
40         return static_cast<const DawnSharedContext*>(this->sharedContext());
41     }
42 
43     wgpu::Buffer fBuffer;
44 };
45 
46 } // namespace skgpu::graphite
47 
48 #endif // skgpu_graphite_DawnBuffer_DEFINED
49 
50