28 fPipelines.reserve(fPipelines.size() + fPipelineDescs.size());
32 SKGPU_LOG_W(
"Failed to create ComputePipeline for dispatch group. Dropping group!");
35 fPipelines.push_back(std::move(pipeline));
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!");
44 SKGPU_LOG_W(
"Failed to instantiate bound texture. Dropping dispatch group!");
52 SKGPU_LOG_W(
"Failed to create sampler. Dropping dispatch group!");
55 fSamplers.push_back(std::move(sampler));
60 fPipelineDescs.clear();
61 fSamplerDescs.clear();
67 for (
int i = 0;
i < fPipelines.size(); ++
i) {
70 for (
int i = 0;
i < fTextures.size(); ++
i) {
76 if (fClearList.empty()) {
86 return fTextures[index]->texture();
92 return fSamplers[index].get();
102 return this->appendStepInternal(
step,
103 globalSize ? *globalSize :
step->calculateGlobalDispatchSize());
107 return this->appendStepInternal(
step, indirectBuffer);
110bool Builder::appendStepInternal(
112 const std::variant<WorkgroupSize, BufferView>& globalSizeOrIndirect) {
119 auto resources =
step->resources();
120 dispatch.
fBindings.reserve(resources.size());
131 bool separateSampler = bindingReqs.fSeparateTextureAndSamplerBinding;
132 int bufferOrGlobalIndex = 0;
139 const int index = nextIndex++;
146 case DataFlow::kPrivate:
150 SkASSERT(r.fType != Type::kReadOnlyTexture);
151 SkASSERT(r.fType != Type::kSampledTexture);
152 maybeResource = this->allocateResource(
step, r, index);
154 case DataFlow::kShared: {
159 if (std::holds_alternative<std::monostate>(*slot)) {
160 SkASSERT(r.fType != Type::kReadOnlyTexture);
161 SkASSERT(r.fType != Type::kSampledTexture);
162 maybeResource = this->allocateResource(
step, r, index);
163 *slot = maybeResource;
165 SkASSERT(((r.fType == Type::kUniformBuffer ||
166 r.fType == Type::kStorageBuffer ||
167 r.fType == Type::kReadOnlyStorageBuffer ||
168 r.fType == Type::kIndirectBuffer) &&
169 std::holds_alternative<BufferView>(*slot)) ||
170 ((r.fType == Type::kReadOnlyTexture ||
171 r.fType == Type::kSampledTexture ||
172 r.fType == Type::kWriteOnlyStorageTexture) &&
173 std::holds_alternative<TextureIndex>(*slot)));
177 const TextureIndex* texIdx = std::get_if<TextureIndex>(slot);
178 if (texIdx && r.fType == Type::kWriteOnlyStorageTexture) {
181 auto [_,
colorType] =
step->calculateTextureParameters(index, r);
187 maybeResource = *slot;
189 if (r.fType == Type::kSampledTexture) {
192 SkASSERT(std::holds_alternative<TextureIndex>(*slot));
193 auto samplerResource = this->allocateResource(
step, r, index);
194 const SamplerIndex* samplerIdx =
195 std::get_if<SamplerIndex>(&samplerResource);
197 int bindingIndex = distinctRanges ? texIndex
198 : separateSampler ? bufferOrGlobalIndex++
199 : bufferOrGlobalIndex;
201 {
static_cast<BindingIndex>(bindingIndex), *samplerIdx});
208 int bindingIndex = 0;
210 if (
const BufferView*
buffer = std::get_if<BufferView>(&maybeResource)) {
211 dispatchResource = *
buffer;
212 bindingIndex = bufferOrGlobalIndex++;
213 }
else if (
const TextureIndex* texIdx = std::get_if<TextureIndex>(&maybeResource)) {
214 dispatchResource = *texIdx;
215 bindingIndex = distinctRanges ? texIndex++ : bufferOrGlobalIndex++;
217 SKGPU_LOG_W(
"Failed to allocate resource for compute dispatch");
223 auto wgBufferDescs =
step->workgroupBuffers();
224 if (!wgBufferDescs.empty()) {
225 dispatch.
fWorkgroupBuffers.push_back_n(wgBufferDescs.size(), wgBufferDescs.data());
229 if (fObj->fPipelineDescs.empty() ||
230 fObj->fPipelineDescs.back().uniqueID() !=
step->uniqueID()) {
231 fObj->fPipelineDescs.push_back(ComputePipelineDesc(
step));
238 fObj->fDispatchList.push_back(std::move(dispatch));
250 fObj->fClearList.push_back({
buffer.fInfo.fBuffer,
buffer.fInfo.fOffset,
buffer.fSize});
258 fObj->fTextures.push_back(std::move(
texture));
263 auto obj = std::move(fObj);
264 fOutputTable.
reset();
268#if defined(GRAPHITE_TEST_UTILS)
270 fOutputTable.
reset();
280 info = slotValue->fInfo;
294 return fObj->fTextures[idx->
fValue];
308 case Type::kReadOnlyStorageBuffer:
309 case Type::kStorageBuffer: {
310 size_t bufferSize =
step->calculateBufferSize(resourceIdx,
resource);
312 if (
resource.fPolicy == ResourcePolicy::kMapped) {
315 step->prepareStorageBuffer(resourceIdx,
resource, ptr, bufferSize);
319 auto bufInfo = bufferMgr->
getStorage(bufferSize,
320 resource.fPolicy == ResourcePolicy::kClear
324 result = BufferView{bufInfo, bufferSize};
329 case Type::kIndirectBuffer: {
332 size_t bufferSize =
step->calculateBufferSize(resourceIdx,
resource);
335 resource.fPolicy == ResourcePolicy::kClear
339 result = BufferView{bufInfo, bufferSize};
343 case Type::kUniformBuffer: {
347 UniformManager uboMgr(resourceReqs.fUniformBufferLayout);
348 step->prepareUniformBuffer(resourceIdx,
resource, &uboMgr);
350 auto dataBlock = uboMgr.finishUniformDataBlock();
355 writer.write(dataBlock.data(), dataBlock.size());
356 result = BufferView{bufInfo, dataBlock.size()};
360 case Type::kWriteOnlyStorageTexture: {
370 fObj->fTextures.push_back(std::move(
texture));
371 result = TextureIndex{fObj->fTextures.size() - 1u};
375 case Type::kReadOnlyTexture:
385 SK_ABORT(
"a readonly texture must be externally assigned to a ComputeStep");
387 case Type::kSampledTexture: {
388 fObj->fSamplerDescs.push_back(
step->calculateSamplerParameters(resourceIdx,
resource));
389 result = SamplerIndex{fObj->fSamplerDescs.size() - 1u};
static int step(int x, SkScalar min, SkScalar max)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
#define SKGPU_LOG_W(fmt,...)
#define SK_ABORT(message,...)
@ kUnknown_SkColorType
uninitialized
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static SkString resource(SkPDFResourceType type, int index)
constexpr size_t SkToSizeT(S x)
const ResourceBindingRequirements & resourceBindingRequirements() const
virtual TextureInfo getDefaultStorageTextureInfo(SkColorType) const =0
static sk_sp< ClearBuffersTask > Make(skia_private::TArray< ClearBufferInfo >)
void trackResource(sk_sp< Resource > resource)
void trackCommandBufferResource(sk_sp< Resource > resource)
bool appendStepIndirect(const ComputeStep *, BufferView indirectBuffer)
void assignSharedBuffer(BufferView buffer, unsigned int slot, ClearBuffer cleared=ClearBuffer::kNo)
sk_sp< TextureProxy > getSharedTextureResource(unsigned int slot) const
std::unique_ptr< DispatchGroup > finalize()
bool appendStep(const ComputeStep *, std::optional< WorkgroupSize > globalSize=std::nullopt)
void assignSharedTexture(sk_sp< TextureProxy > texture, unsigned int slot)
BindBufferInfo getSharedBufferResource(unsigned int slot) const
void addResourceRefs(CommandBuffer *) const
const Texture * getTexture(size_t index) const
sk_sp< Task > snapChildTask()
bool prepareResources(ResourceProvider *)
const Sampler * getSampler(size_t index) const
std::pair< void *, BindBufferInfo > getStoragePointer(size_t requiredBytes)
std::pair< UniformWriter, BindBufferInfo > getUniformWriter(size_t requiredBytes)
BindBufferInfo getStorage(size_t requiredBytes, ClearBuffer cleared=ClearBuffer::kNo)
BindBufferInfo getIndirectStorage(size_t requiredBytes, ClearBuffer cleared=ClearBuffer::kNo)
const Caps * caps() const
ResourceProvider * resourceProvider()
DrawBufferManager * drawBufferManager()
sk_sp< ComputePipeline > findOrCreateComputePipeline(const ComputePipelineDesc &)
sk_sp< Sampler > findOrCreateCompatibleSampler(const SamplerDesc &)
bool isCompatible(const TextureInfo &that) const
static bool InstantiateIfNotLazy(ResourceProvider *, TextureProxy *)
static sk_sp< TextureProxy > Make(const Caps *, ResourceProvider *, SkISize dimensions, const TextureInfo &, std::string_view label, skgpu::Budgeted)
const TextureInfo & textureInfo() const
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
const myers::Point & get(const myers::Segment &)
std::variant< BufferView, TextureIndex, SamplerIndex > DispatchResource
constexpr int kMaxComputeDataFlowSlots
DispatchGroup::Builder Builder
std::variant< std::monostate, BufferView, TextureIndex, SamplerIndex > DispatchResourceOptional
DispatchResourceOptional fSharedSlots[kMaxComputeDataFlowSlots]
skia_private::TArray< ComputeStep::WorkgroupBufferDesc > fWorkgroupBuffers
std::variant< WorkgroupSize, BufferView > fGlobalSizeOrIndirect
skia_private::TArray< ResourceBinding > fBindings
bool fDistinctIndexRanges