Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Friends | List of all members
skgpu::graphite::DispatchGroup Class Referencefinal

#include <DispatchGroup.h>

Classes

class  Builder
 
struct  Dispatch
 

Public Member Functions

 ~DispatchGroup ()
 
const skia_private::TArray< Dispatch > & dispatches () const
 
const ComputePipelinegetPipeline (size_t index) const
 
const TexturegetTexture (size_t index) const
 
const SamplergetSampler (size_t index) const
 
bool prepareResources (ResourceProvider *)
 
void addResourceRefs (CommandBuffer *) const
 
sk_sp< TasksnapChildTask ()
 

Friends

class DispatchGroupBuilder
 

Detailed Description

DispatchGroup groups a series of compute pipeline dispatches that need to execute sequentially (i.e. with a barrier). Dispatches are stored in the order that they will be encoded in the eventual command buffer.

A DispatchGroup can be constructed from a series of ComputeSteps using a Builder. The Builder verifies that the data flow specification between successive ComputeSteps are compatible. The resources required by a ComputeStep (such as Buffers and TextureProxies) are created by the Builder as they get added.

Once a DispatchGroup is finalized, it is immutable. It contains the complete ResourceBinding list for each dispatch. A list of finalized DispatchGroups can be submitted to the command buffer in a ComputeTask.

Definition at line 61 of file DispatchGroup.h.

Constructor & Destructor Documentation

◆ ~DispatchGroup()

skgpu::graphite::DispatchGroup::~DispatchGroup ( )
default

Member Function Documentation

◆ addResourceRefs()

void skgpu::graphite::DispatchGroup::addResourceRefs ( CommandBuffer commandBuffer) const

Definition at line 66 of file DispatchGroup.cpp.

66 {
67 for (int i = 0; i < fPipelines.size(); ++i) {
68 commandBuffer->trackResource(fPipelines[i]);
69 }
70 for (int i = 0; i < fTextures.size(); ++i) {
71 commandBuffer->trackCommandBufferResource(fTextures[i]->refTexture());
72 }
73}

◆ dispatches()

const skia_private::TArray< Dispatch > & skgpu::graphite::DispatchGroup::dispatches ( ) const
inline

Definition at line 77 of file DispatchGroup.h.

77{ return fDispatchList; }

◆ getPipeline()

const ComputePipeline * skgpu::graphite::DispatchGroup::getPipeline ( size_t  index) const
inline

Definition at line 79 of file DispatchGroup.h.

79{ return fPipelines[index].get(); }

◆ getSampler()

const Sampler * skgpu::graphite::DispatchGroup::getSampler ( size_t  index) const

Definition at line 89 of file DispatchGroup.cpp.

89 {
90 SkASSERT(index < SkToSizeT(fSamplers.size()));
91 SkASSERT(fSamplers[index]);
92 return fSamplers[index].get();
93}
#define SkASSERT(cond)
Definition SkAssert.h:116
constexpr size_t SkToSizeT(S x)
Definition SkTo.h:31

◆ getTexture()

const Texture * skgpu::graphite::DispatchGroup::getTexture ( size_t  index) const

Definition at line 82 of file DispatchGroup.cpp.

82 {
83 SkASSERT(index < SkToSizeT(fTextures.size()));
84 SkASSERT(fTextures[index]);
85 SkASSERT(fTextures[index]->texture());
86 return fTextures[index]->texture();
87}
FlTexture * texture

◆ prepareResources()

bool skgpu::graphite::DispatchGroup::prepareResources ( ResourceProvider resourceProvider)

Definition at line 27 of file DispatchGroup.cpp.

27 {
28 fPipelines.reserve(fPipelines.size() + fPipelineDescs.size());
29 for (const ComputePipelineDesc& desc : fPipelineDescs) {
30 auto pipeline = resourceProvider->findOrCreateComputePipeline(desc);
31 if (!pipeline) {
32 SKGPU_LOG_W("Failed to create ComputePipeline for dispatch group. Dropping group!");
33 return false;
34 }
35 fPipelines.push_back(std::move(pipeline));
36 }
37
38 for (int i = 0; i < fTextures.size(); ++i) {
39 if (!fTextures[i]->textureInfo().isValid()) {
40 SKGPU_LOG_W("Failed to validate bound texture. Dropping dispatch group!");
41 return false;
42 }
43 if (!TextureProxy::InstantiateIfNotLazy(resourceProvider, fTextures[i].get())) {
44 SKGPU_LOG_W("Failed to instantiate bound texture. Dropping dispatch group!");
45 return false;
46 }
47 }
48
49 for (const SamplerDesc& desc : fSamplerDescs) {
50 sk_sp<Sampler> sampler = resourceProvider->findOrCreateCompatibleSampler(desc);
51 if (!sampler) {
52 SKGPU_LOG_W("Failed to create sampler. Dropping dispatch group!");
53 return false;
54 }
55 fSamplers.push_back(std::move(sampler));
56 }
57
58 // The DispatchGroup may be long lived on a Recording and we no longer need the descriptors
59 // once we've created pipelines.
60 fPipelineDescs.clear();
61 fSamplerDescs.clear();
62
63 return true;
64}
#define SKGPU_LOG_W(fmt,...)
Definition Log.h:40
static bool InstantiateIfNotLazy(ResourceProvider *, TextureProxy *)
const myers::Point & get(const myers::Segment &)

◆ snapChildTask()

sk_sp< Task > skgpu::graphite::DispatchGroup::snapChildTask ( )

Definition at line 75 of file DispatchGroup.cpp.

75 {
76 if (fClearList.empty()) {
77 return nullptr;
78 }
79 return ClearBuffersTask::Make(std::move(fClearList));
80}
static sk_sp< ClearBuffersTask > Make(skia_private::TArray< ClearBufferInfo >)

Friends And Related Symbol Documentation

◆ DispatchGroupBuilder

friend class DispatchGroupBuilder
friend

Definition at line 91 of file DispatchGroup.h.


The documentation for this class was generated from the following files: