Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
DawnSharedContext.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_DawnSharedContext_DEFINED
9#define skgpu_graphite_DawnSharedContext_DEFINED
10
11#include "webgpu/webgpu_cpp.h" // NO_G3_REWRITE
12
16
17namespace skgpu::graphite {
18
19struct DawnBackendContext;
20struct ContextOptions;
21
22class DawnSharedContext final : public SharedContext {
23public:
25 ~DawnSharedContext() override;
26
27 std::unique_ptr<ResourceProvider> makeResourceProvider(SingleOwner*,
28 uint32_t recorderID,
29 size_t resourceBudget) override;
30
31 const DawnCaps* dawnCaps() const { return static_cast<const DawnCaps*>(this->caps()); }
32 const wgpu::Device& device() const { return fDevice; }
33 const wgpu::Queue& queue() const { return fQueue; }
34 const wgpu::ShaderModule& noopFragment() const { return fNoopFragment; }
35
36 bool hasTick() const { return fTick; }
37
38 void tick() const {
39 SkASSERT(this->hasTick());
40 fTick(fInstance);
41 }
42
43private:
45 std::unique_ptr<const DawnCaps> caps,
46 wgpu::ShaderModule noopFragment);
47
48 wgpu::Instance fInstance;
49 wgpu::Device fDevice;
50 wgpu::Queue fQueue;
51 DawnTickFunction* fTick;
52 // A noop fragment shader, it is used to workaround dawn a validation error(dawn doesn't allow
53 // a pipeline with a color attachment but without a fragment shader).
54 wgpu::ShaderModule fNoopFragment;
55};
56
57} // namespace skgpu::graphite
58
59#endif // skgpu_graphite_DawnSharedContext_DEFINED
#define SkASSERT(cond)
Definition SkAssert.h:116
const DawnCaps * dawnCaps() const
const wgpu::ShaderModule & noopFragment() const
const wgpu::Device & device() const
std::unique_ptr< ResourceProvider > makeResourceProvider(SingleOwner *, uint32_t recorderID, size_t resourceBudget) override
static sk_sp< SharedContext > Make(const DawnBackendContext &, const ContextOptions &)
const wgpu::Queue & queue() const
const Caps * caps() const
void(const wgpu::Instance &device) DawnTickFunction