• 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_DawnSharedContext_DEFINED
9 #define skgpu_graphite_DawnSharedContext_DEFINED
10 
11 #include "webgpu/webgpu_cpp.h"
12 
13 #include "src/gpu/graphite/SharedContext.h"
14 #include "src/gpu/graphite/dawn/DawnCaps.h"
15 
16 namespace skgpu::graphite {
17 
18 struct DawnBackendContext;
19 struct ContextOptions;
20 
21 class DawnSharedContext final : public SharedContext {
22 public:
23     static sk_sp<SharedContext> Make(const DawnBackendContext&, const ContextOptions&);
24     ~DawnSharedContext() override;
25 
26     std::unique_ptr<ResourceProvider> makeResourceProvider(SingleOwner*) override;
27 
dawnCaps()28     const DawnCaps* dawnCaps() const { return static_cast<const DawnCaps*>(this->caps()); }
device()29     const wgpu::Device& device() const { return fDevice; }
queue()30     const wgpu::Queue& queue() const { return fQueue; }
noopFragment()31     const wgpu::ShaderModule& noopFragment() const { return fNoopFragment; }
32 private:
33     DawnSharedContext(const DawnBackendContext&,
34                       std::unique_ptr<const DawnCaps> caps,
35                       wgpu::ShaderModule noopFragment);
36 
37     wgpu::Device       fDevice;
38     wgpu::Queue        fQueue;
39     // A noop fragment shader, it is used to workaround dawn a validation error(dawn doesn't allow
40     // a pipeline with a color attachment but without a fragment shader).
41     wgpu::ShaderModule fNoopFragment;
42 };
43 
44 } // namespace skgpu::graphite
45 
46 #endif // skgpu_graphite_DawnSharedContext_DEFINED
47 
48