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_task_RenderPassTask_DEFINED 9 #define skgpu_graphite_task_RenderPassTask_DEFINED 10 11 #include "src/gpu/graphite/CommandBuffer.h" 12 #include "src/gpu/graphite/RenderPassDesc.h" 13 #include "src/gpu/graphite/task/Task.h" 14 15 namespace skgpu::graphite { 16 17 class DrawPass; 18 19 /** 20 * RenderPassTask handles preparing and recording DrawLists into a single render pass within a 21 * command buffer. If the backend supports subpasses, and the DrawLists/surfaces are compatible, a 22 * RenderPassTask can execute multiple DrawLists across different surfaces as subpasses nested 23 * within a single render pass. If there is no such support, a RenderPassTask is one-to-one with a 24 * "render pass" to specific surface. 25 */ 26 class RenderPassTask final : public Task { 27 public: 28 using DrawPassList = skia_private::STArray<1, std::unique_ptr<DrawPass>>; 29 30 // dstCopy should only be provided if the draw passes require a texture copy 31 // for dst reads and must cover the union of all `DrawPass::dstCopyBounds()` values in the 32 // render pass. It is assumed that the copy's (0,0) texel matches the top-left corner of the 33 // pass's dst copy bounds. The copy can be larger than the required bounds. 34 static sk_sp<RenderPassTask> Make(DrawPassList, 35 const RenderPassDesc&, 36 sk_sp<TextureProxy> target, 37 sk_sp<TextureProxy> dstCopy, 38 SkIRect dstCopyBounds); 39 40 ~RenderPassTask() override; 41 42 Status prepareResources(ResourceProvider*, 43 ScratchResourceManager*, 44 const RuntimeEffectDictionary*) override; 45 46 Status addCommands(Context*, CommandBuffer*, ReplayTargetData) override; 47 48 private: 49 RenderPassTask(DrawPassList, 50 const RenderPassDesc&, 51 sk_sp<TextureProxy> target, 52 sk_sp<TextureProxy> dstCopy, 53 SkIRect dstCopyBounds); 54 55 DrawPassList fDrawPasses; 56 RenderPassDesc fRenderPassDesc; 57 sk_sp<TextureProxy> fTarget; 58 59 sk_sp<TextureProxy> fDstCopy; 60 SkIRect fDstCopyBounds; 61 }; 62 63 } // namespace skgpu::graphite 64 65 #endif // skgpu_graphite_task_RenderPassTask_DEFINED 66