Debian Codegraph @

include/gpu/graphite/Recording.h

raw
1 /*
2 * Copyright 2021 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_Recording_DEFINED
9 #define skgpu_graphite_Recording_DEFINED
10
11 #include "include/core/SkRefCnt.h"
12 #include "include/private/base/SkAPI.h"
13 #include "include/private/base/SkTArray.h"
14 #include <cstddef>
15 #include <cstdint>
16 #include <memory>
17 #include <unordered_set>
18 #include <vector>
19
20 struct SkISize;
21
22 namespace skgpu {
23 class RefCntedCallback;
24 }
25
26 namespace skgpu::graphite {
27
28 class Caps;
29 class CommandBuffer;
30 class RecordingPriv;
31 class Resource;
32 class ResourceProvider;
33 class TaskList;
34 class Texture;
35 class TextureInfo;
36 class TextureProxy;
37
38 class SK_API Recording final {
39 public:
40 ~Recording();
41
42 RecordingPriv priv();
43
44 private:
45 friend class Recorder; // for ctor and LazyProxyData
46 friend class RecordingPriv;
47
48 // LazyProxyData is used if this recording should be replayed to a target that is provided on
49 // replay, and it handles the target proxy's instantiation with the provided target.
50 class LazyProxyData {
51 public:
52 LazyProxyData(const Caps*, SkISize dimensions, const TextureInfo&);
53 ~LazyProxyData();
54
55 TextureProxy* lazyProxy();
56 sk_sp<TextureProxy> refLazyProxy();
57
58 bool lazyInstantiate(ResourceProvider*, sk_sp<Texture>);
59
60 private:
61 sk_sp<Texture> fTarget;
62 sk_sp<TextureProxy> fTargetProxy;
63 };
64
65 struct ProxyHash {
66 std::size_t operator()(const sk_sp<TextureProxy>& proxy) const;
67 };
68
69 Recording(uint32_t uniqueID,
70 uint32_t recorderID,
71 std::unique_ptr<LazyProxyData> targetProxyData,
72 skia_private::TArray<sk_sp<RefCntedCallback>>&& finishedProcs);
73
74 void addResourceRef(sk_sp<Resource>);
75
76 // Used to verify ordering if recorder ID is not SK_InvalidGenID
77 uint32_t fUniqueID;
78 uint32_t fRecorderID;
79
80 // This is held by a pointer instead of being inline to allow TaskList to be forward declared.
81 std::unique_ptr<TaskList> fRootTaskList;
82 // We don't always take refs to all resources used by specific Tasks (e.g. a common buffer used
83 // for uploads). Instead we'll just hold onto one ref for those Resources outside the Tasks.
84 // Those refs are stored in the array here and will eventually be passed onto a CommandBuffer
85 // when the Recording adds its commands.
86 std::vector<sk_sp<Resource>> fExtraResourceRefs;
87
88 std::unordered_set<sk_sp<TextureProxy>, ProxyHash> fNonVolatileLazyProxies;
89 std::unordered_set<sk_sp<TextureProxy>, ProxyHash> fVolatileLazyProxies;
90
91 std::unique_ptr<LazyProxyData> fTargetProxyData;
92
93 skia_private::TArray<sk_sp<RefCntedCallback>> fFinishedProcs;
94 };
95
96 } // namespace skgpu::graphite
97
98 #endif // skgpu_graphite_Recording_DEFINED