Debian Codegraph @

src/gpu/graphite/GraphicsPipelineHandle.h

raw
1 /*
2 * Copyright 2025 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_GraphicsPipelineHandle_DEFINED
9 #define skgpu_graphite_GraphicsPipelineHandle_DEFINED
10
11 #include "include/core/SkRefCnt.h"
12
13 #include <variant>
14
15 namespace skgpu::graphite {
16
17 class GraphicsPipeline;
18 class PipelineCreationTask;
19
20 /*
21 * The PipelineHandle holds a ref to either a Pipeline or the Task that will create the Pipeline.
22 * In the latter case, ResourceProvider::resolveHandle can be used to wait for the Task to
23 * complete. How this works is:
24 * At Recorder::snap time, the DrawPass will create GraphicsPipelineHandles and will
25 * kick off all the tasks (using ResourceProvider::kickOffTask)
26 * Upon Context::insertRecording, all the Handles will be exchanged for GraphicsPipelines in
27 * the DrawPass::addResourceRefs. This will also release any Tasks being held by the Handles.
28 *
29 * Note that the Tasks lock the generated Pipelines in the cache until they are deleted. This avoids
30 * any race conditions where a Pipeline could be purged between when it was created on a thread
31 * and when it was actually requested by a DrawPass.
32 */
33 class GraphicsPipelineHandle {
34 private:
35 friend class PipelineManager; // for ctors
36
37 GraphicsPipelineHandle(sk_sp<PipelineCreationTask> task);
38
39 GraphicsPipelineHandle(sk_sp<GraphicsPipeline> pipeline);
40
41 std::variant<sk_sp<PipelineCreationTask>, sk_sp<GraphicsPipeline>> fTaskOrPipeline;
42 };
43
44 } // namespace skgpu::graphite
45
46 #endif // skgpu_graphite_GraphicsPipelineHandle_DEFINED