Debian Codegraph @

src/gpu/graphite/PipelineCreationTask.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_PipelineCreationTask_DEFINED
9 #define skgpu_graphite_PipelineCreationTask_DEFINED
10
11 #include "include/core/SkRefCnt.h"
12 #include "src/gpu/graphite/GraphicsPipeline.h"
13 #include "src/gpu/graphite/GraphicsPipelineDesc.h"
14 #include "src/gpu/graphite/RenderPassDesc.h"
15
16 namespace skgpu::graphite {
17
18 // Once completed, the PipelineTask will lock the created Pipeline in the cache (via 'fPipeline')
19 // until the PipelineTask is deleted.
20 // Note that this is not a task in the sense of the Task class. It is a task in the sense that
21 // it is a unit of work possibly delegated to a thread. PipelineCreationTasks are also only
22 // known and handled by the PipelineManager vs being added to TaskLists (as Task-derived classes
23 // are).
24 class PipelineCreationTask : public SkRefCnt {
25 private:
26 friend class PipelineManager; // for entire API and fPipeline
27
28 PipelineCreationTask(const UniqueKey& pipelineKey,
29 const GraphicsPipelineDesc& graphicsPipelineDesc,
30 const RenderPassDesc& renderPassDesc,
31 SkEnumBitMask<PipelineCreationFlags> pipelineCreationFlags)
32 : fPipelineKey(pipelineKey)
33 , fGraphicsPipelineDesc(graphicsPipelineDesc)
34 , fRenderPassDesc(renderPassDesc)
35 , fPipelineCreationFlags(pipelineCreationFlags) {}
36
37 const UniqueKey fPipelineKey; // used to track this task in the PipelineManager
38 const GraphicsPipelineDesc fGraphicsPipelineDesc;
39 const RenderPassDesc fRenderPassDesc;
40 const SkEnumBitMask<PipelineCreationFlags> fPipelineCreationFlags;
41
42 // Once completed, this task will have filled in 'fPipeline' (if compilation succeeded).
43 // This also serves to lock the pipeline in the cache.
44 sk_sp<GraphicsPipeline> fPipeline;
45
46 std::atomic<bool> fCompleted = false;
47 };
48
49 } // namespace skgpu::graphite
50
51 #endif // skgpu_graphite_PipelineCreationTask_DEFINED