Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
GrVkResourceProvider Class Reference

#include <GrVkResourceProvider.h>

Public Types

using SelfDependencyFlags = GrVkRenderPass::SelfDependencyFlags
 
using LoadFromResolve = GrVkRenderPass::LoadFromResolve
 

Public Member Functions

 GrVkResourceProvider (GrVkGpu *gpu)
 
 ~GrVkResourceProvider ()
 
GrThreadSafePipelineBuilderpipelineStateCache ()
 
sk_sp< GrThreadSafePipelineBuilderrefPipelineStateCache ()
 
void init ()
 
sk_sp< const GrVkPipelinemakePipeline (const GrProgramInfo &, VkPipelineShaderStageCreateInfo *shaderStageInfo, int shaderStageCount, VkRenderPass compatibleRenderPass, VkPipelineLayout layout, uint32_t subpass)
 
const GrVkRenderPassfindCompatibleRenderPass (GrVkRenderTarget *target, CompatibleRPHandle *compatibleHandle, bool withResolve, bool withStencil, SelfDependencyFlags selfDepFlags, LoadFromResolve)
 
const GrVkRenderPassfindCompatibleRenderPass (GrVkRenderPass::AttachmentsDescriptor *, GrVkRenderPass::AttachmentFlags, SelfDependencyFlags selfDepFlags, LoadFromResolve, CompatibleRPHandle *compatibleHandle=nullptr)
 
const GrVkRenderPassfindCompatibleExternalRenderPass (VkRenderPass, uint32_t colorAttachmentIndex)
 
const GrVkRenderPassfindRenderPass (GrVkRenderTarget *target, const GrVkRenderPass::LoadStoreOps &colorOps, const GrVkRenderPass::LoadStoreOps &resolveOps, const GrVkRenderPass::LoadStoreOps &stencilOps, CompatibleRPHandle *compatibleHandle, bool withResolve, bool withStencil, SelfDependencyFlags selfDepFlags, LoadFromResolve)
 
const GrVkRenderPassfindRenderPass (const CompatibleRPHandle &compatibleHandle, const GrVkRenderPass::LoadStoreOps &colorOps, const GrVkRenderPass::LoadStoreOps &resolveOps, const GrVkRenderPass::LoadStoreOps &stencilOps)
 
GrVkCommandPoolfindOrCreateCommandPool ()
 
void checkCommandBuffers ()
 
void forceSyncAllCommandBuffers ()
 
void addFinishedProcToActiveCommandBuffers (sk_sp< skgpu::RefCntedCallback > finishedCallback)
 
GrVkDescriptorPoolfindOrCreateCompatibleDescriptorPool (VkDescriptorType type, uint32_t count)
 
GrVkSamplerfindOrCreateCompatibleSampler (GrSamplerState, const GrVkYcbcrConversionInfo &ycbcrInfo)
 
GrVkSamplerYcbcrConversionfindOrCreateCompatibleSamplerYcbcrConversion (const GrVkYcbcrConversionInfo &ycbcrInfo)
 
GrVkPipelineStatefindOrCreateCompatiblePipelineState (GrRenderTarget *, const GrProgramInfo &, VkRenderPass compatibleRenderPass, bool overrideSubpassForResolveLoad)
 
GrVkPipelineStatefindOrCreateCompatiblePipelineState (const GrProgramDesc &, const GrProgramInfo &, VkRenderPass compatibleRenderPass, GrThreadSafePipelineBuilder::Stats::ProgramCacheResult *stat)
 
sk_sp< const GrVkPipelinefindOrCreateMSAALoadPipeline (const GrVkRenderPass &renderPass, int numSamples, VkPipelineShaderStageCreateInfo *, VkPipelineLayout)
 
void getSamplerDescriptorSetHandle (VkDescriptorType type, const GrVkUniformHandler &, GrVkDescriptorSetManager::Handle *handle)
 
void getZeroSamplerDescriptorSetHandle (GrVkDescriptorSetManager::Handle *handle)
 
VkDescriptorSetLayout getUniformDSLayout () const
 
VkDescriptorSetLayout getInputDSLayout () const
 
VkDescriptorSetLayout getSamplerDSLayout (const GrVkDescriptorSetManager::Handle &) const
 
const GrVkDescriptorSetgetUniformDescriptorSet ()
 
const GrVkDescriptorSetgetSamplerDescriptorSet (const GrVkDescriptorSetManager::Handle &)
 
const GrVkDescriptorSetgetInputDescriptorSet ()
 
void recycleDescriptorSet (const GrVkDescriptorSet *descSet, const GrVkDescriptorSetManager::Handle &)
 
void storePipelineCacheData ()
 
void destroyResources ()
 
void releaseUnlockedBackendObjects ()
 

Detailed Description

Definition at line 40 of file GrVkResourceProvider.h.

Member Typedef Documentation

◆ LoadFromResolve

Definition at line 66 of file GrVkResourceProvider.h.

◆ SelfDependencyFlags

Definition at line 65 of file GrVkResourceProvider.h.

Constructor & Destructor Documentation

◆ GrVkResourceProvider()

GrVkResourceProvider::GrVkResourceProvider ( GrVkGpu gpu)

Definition at line 23 of file GrVkResourceProvider.cpp.

24 : fGpu(gpu)
25 , fPipelineCache(VK_NULL_HANDLE) {
26 fPipelineStateCache = sk_make_sp<PipelineStateCache>(gpu);
27}
#define VK_NULL_HANDLE
Definition vulkan_core.h:46

◆ ~GrVkResourceProvider()

GrVkResourceProvider::~GrVkResourceProvider ( )

Definition at line 29 of file GrVkResourceProvider.cpp.

29 {
30 SkASSERT(fRenderPassArray.empty());
31 SkASSERT(fExternalRenderPasses.empty());
32 SkASSERT(fMSAALoadPipelines.empty());
33 SkASSERT(VK_NULL_HANDLE == fPipelineCache);
34}
#define SkASSERT(cond)
Definition SkAssert.h:116
bool empty() const
Definition SkTArray.h:194

Member Function Documentation

◆ addFinishedProcToActiveCommandBuffers()

void GrVkResourceProvider::addFinishedProcToActiveCommandBuffers ( sk_sp< skgpu::RefCntedCallback finishedCallback)

Definition at line 471 of file GrVkResourceProvider.cpp.

472 {
473 for (int i = 0; i < fActiveCommandPools.size(); ++i) {
474 GrVkCommandPool* pool = fActiveCommandPools[i];
475 GrVkPrimaryCommandBuffer* buffer = pool->getPrimaryCommandBuffer();
476 buffer->addFinishedProc(finishedCallback);
477 }
478}
AutoreleasePool pool
int size() const
Definition SkTArray.h:416
static const uint8_t buffer[]

◆ checkCommandBuffers()

void GrVkResourceProvider::checkCommandBuffers ( )

Definition at line 428 of file GrVkResourceProvider.cpp.

428 {
429 // When resetting a command buffer it can trigger client provided procs (e.g. release or
430 // finished) to be called. During these calls the client could trigger us to abandon the vk
431 // context, e.g. if we are in a DEVICE_LOST state. When we abandon the vk context we will
432 // unref all the fActiveCommandPools and reset the array. Since this can happen in the middle
433 // of the loop here, we need to additionally check that fActiveCommandPools still has pools on
434 // each iteration.
435 //
436 // TODO: We really need to have a more robust way to protect us from client proc calls that
437 // happen in the middle of us doing work. This may be just one of many potential pitfalls that
438 // could happen from the client triggering GrDirectContext changes during a proc call.
439 for (int i = fActiveCommandPools.size() - 1; !fActiveCommandPools.empty() && i >= 0; --i) {
440 GrVkCommandPool* pool = fActiveCommandPools[i];
441 if (!pool->isOpen()) {
442 GrVkPrimaryCommandBuffer* buffer = pool->getPrimaryCommandBuffer();
443 if (buffer->finished(fGpu)) {
444 fActiveCommandPools.removeShuffle(i);
445 SkASSERT(pool->unique());
446 pool->reset(fGpu);
447 // After resetting the pool (specifically releasing the pool's resources) we may
448 // have called a client callback proc which may have disconnected the GrVkGpu. In
449 // that case we do not want to push the pool back onto the cache, but instead just
450 // drop the pool.
451 if (fGpu->disconnected()) {
452 pool->unref();
453 return;
454 }
455 fAvailableCommandPools.push_back(pool);
456 }
457 }
458 }
459}
bool disconnected() const
Definition GrVkGpu.h:51
void removeShuffle(int n)
Definition SkTArray.h:183

◆ destroyResources()

void GrVkResourceProvider::destroyResources ( )

Definition at line 480 of file GrVkResourceProvider.cpp.

480 {
481 SkTaskGroup* taskGroup = fGpu->getContext()->priv().getTaskGroup();
482 if (taskGroup) {
483 taskGroup->wait();
484 }
485
486 // Release all msaa load pipelines
487 fMSAALoadPipelines.clear();
488
489 // loop over all render pass sets to make sure we destroy all the internal VkRenderPasses
490 for (int i = 0; i < fRenderPassArray.size(); ++i) {
491 fRenderPassArray[i].releaseResources();
492 }
493 fRenderPassArray.clear();
494
495 for (int i = 0; i < fExternalRenderPasses.size(); ++i) {
496 fExternalRenderPasses[i]->unref();
497 }
498 fExternalRenderPasses.clear();
499
500 // Iterate through all store GrVkSamplers and unref them before resetting the hash table.
501 fSamplers.foreach([&](auto* elt) { elt->unref(); });
502 fSamplers.reset();
503
504 fYcbcrConversions.foreach([&](auto* elt) { elt->unref(); });
505 fYcbcrConversions.reset();
506
507 fPipelineStateCache->release();
508
509 GR_VK_CALL(fGpu->vkInterface(), DestroyPipelineCache(fGpu->device(), fPipelineCache, nullptr));
510 fPipelineCache = VK_NULL_HANDLE;
511
512 for (GrVkCommandPool* pool : fActiveCommandPools) {
513 SkASSERT(pool->unique());
514 pool->unref();
515 }
516 fActiveCommandPools.clear();
517
518 for (GrVkCommandPool* pool : fAvailableCommandPools) {
519 SkASSERT(pool->unique());
520 pool->unref();
521 }
522 fAvailableCommandPools.clear();
523
524 // We must release/destroy all command buffers and pipeline states before releasing the
525 // GrVkDescriptorSetManagers. Additionally, we must release all uniform buffers since they hold
526 // refs to GrVkDescriptorSets.
527 for (int i = 0; i < fDescriptorSetManagers.size(); ++i) {
528 fDescriptorSetManagers[i]->release(fGpu);
529 }
530 fDescriptorSetManagers.clear();
531
532}
#define GR_VK_CALL(IFACE, X)
Definition GrVkUtil.h:24
SkTaskGroup * getTaskGroup()
GrDirectContextPriv priv()
GrDirectContext * getContext()
Definition GrGpu.h:67
const skgpu::VulkanInterface * vkInterface() const
Definition GrVkGpu.h:60
VkDevice device() const
Definition GrVkGpu.h:71
void foreach(Fn &&fn)
T * release()
Definition SkRefCnt.h:324

◆ findCompatibleExternalRenderPass()

const GrVkRenderPass * GrVkResourceProvider::findCompatibleExternalRenderPass ( VkRenderPass  renderPass,
uint32_t  colorAttachmentIndex 
)

Definition at line 161 of file GrVkResourceProvider.cpp.

162 {
163 for (int i = 0; i < fExternalRenderPasses.size(); ++i) {
164 if (fExternalRenderPasses[i]->isCompatibleExternalRP(renderPass)) {
165 fExternalRenderPasses[i]->ref();
166#ifdef SK_DEBUG
167 uint32_t cachedColorIndex;
168 SkASSERT(fExternalRenderPasses[i]->colorAttachmentIndex(&cachedColorIndex));
169 SkASSERT(cachedColorIndex == colorAttachmentIndex);
170#endif
171 return fExternalRenderPasses[i];
172 }
173 }
174
175 const GrVkRenderPass* newRenderPass = new GrVkRenderPass(fGpu, renderPass,
176 colorAttachmentIndex);
177 fExternalRenderPasses.push_back(newRenderPass);
178 newRenderPass->ref();
179 return newRenderPass;
180}

◆ findCompatibleRenderPass() [1/2]

const GrVkRenderPass * GrVkResourceProvider::findCompatibleRenderPass ( GrVkRenderPass::AttachmentsDescriptor desc,
GrVkRenderPass::AttachmentFlags  attachmentFlags,
SelfDependencyFlags  selfDepFlags,
LoadFromResolve  loadFromResolve,
CompatibleRPHandle *  compatibleHandle = nullptr 
)

Definition at line 131 of file GrVkResourceProvider.cpp.

135 {
136 for (int i = 0; i < fRenderPassArray.size(); ++i) {
137 if (fRenderPassArray[i].isCompatible(*desc, attachmentFlags, selfDepFlags,
138 loadFromResolve)) {
139 const GrVkRenderPass* renderPass = fRenderPassArray[i].getCompatibleRenderPass();
140 renderPass->ref();
141 if (compatibleHandle) {
142 *compatibleHandle = CompatibleRPHandle(i);
143 }
144 return renderPass;
145 }
146 }
147
148 GrVkRenderPass* renderPass = GrVkRenderPass::CreateSimple(fGpu, desc, attachmentFlags,
149 selfDepFlags, loadFromResolve);
150 if (!renderPass) {
151 return nullptr;
152 }
153 fRenderPassArray.emplace_back(renderPass);
154
155 if (compatibleHandle) {
156 *compatibleHandle = CompatibleRPHandle(fRenderPassArray.size() - 1);
157 }
158 return renderPass;
159}
static GrVkRenderPass * CreateSimple(GrVkGpu *, AttachmentsDescriptor *, AttachmentFlags, SelfDependencyFlags selfDepFlags, LoadFromResolve)
T & emplace_back(Args &&... args)
Definition SkTArray.h:243

◆ findCompatibleRenderPass() [2/2]

const GrVkRenderPass * GrVkResourceProvider::findCompatibleRenderPass ( GrVkRenderTarget target,
CompatibleRPHandle *  compatibleHandle,
bool  withResolve,
bool  withStencil,
SelfDependencyFlags  selfDepFlags,
LoadFromResolve  loadFromResolve 
)

Definition at line 111 of file GrVkResourceProvider.cpp.

116 {
117 // Get attachment information from render target. This includes which attachments the render
118 // target has (color, stencil) and the attachments format and sample count.
119 GrVkRenderPass::AttachmentFlags attachmentFlags;
121 if (!target->getAttachmentsDescriptor(&attachmentsDesc, &attachmentFlags,
122 withResolve, withStencil)) {
123 return nullptr;
124 }
125
126 return this->findCompatibleRenderPass(&attachmentsDesc, attachmentFlags, selfDepFlags,
127 loadFromResolve, compatibleHandle);
128}
const GrVkRenderPass * findCompatibleRenderPass(GrVkRenderTarget *target, CompatibleRPHandle *compatibleHandle, bool withResolve, bool withStencil, SelfDependencyFlags selfDepFlags, LoadFromResolve)
uint32_t * target

◆ findOrCreateCommandPool()

GrVkCommandPool * GrVkResourceProvider::findOrCreateCommandPool ( )

Definition at line 403 of file GrVkResourceProvider.cpp.

403 {
405 if (!fAvailableCommandPools.empty()) {
406 result = fAvailableCommandPools.back();
407 fAvailableCommandPools.pop_back();
408 } else {
410 if (!result) {
411 return nullptr;
412 }
413 }
414 SkASSERT(result->unique());
416 for (const GrVkCommandPool* pool : fActiveCommandPools) {
417 SkASSERT(pool != result);
418 }
419 for (const GrVkCommandPool* pool : fAvailableCommandPools) {
420 SkASSERT(pool != result);
421 }
422 )
423 fActiveCommandPools.push_back(result);
424 result->ref();
425 return result;
426}
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
static GrVkCommandPool * Create(GrVkGpu *gpu)
GAsyncResult * result

◆ findOrCreateCompatibleDescriptorPool()

GrVkDescriptorPool * GrVkResourceProvider::findOrCreateCompatibleDescriptorPool ( VkDescriptorType  type,
uint32_t  count 
)

Definition at line 222 of file GrVkResourceProvider.cpp.

223 {
225}
int count
static GrVkDescriptorPool * Create(GrVkGpu *gpu, VkDescriptorType type, uint32_t count)

◆ findOrCreateCompatiblePipelineState() [1/2]

GrVkPipelineState * GrVkResourceProvider::findOrCreateCompatiblePipelineState ( const GrProgramDesc desc,
const GrProgramInfo programInfo,
VkRenderPass  compatibleRenderPass,
GrThreadSafePipelineBuilder::Stats::ProgramCacheResult stat 
)

Definition at line 268 of file GrVkResourceProvider.cpp.

272 {
273
274 auto tmp = fPipelineStateCache->findOrCreatePipelineState(desc, programInfo,
275 compatibleRenderPass, stat);
276 if (!tmp) {
277 fPipelineStateCache->stats()->incNumPreCompilationFailures();
278 } else {
279 fPipelineStateCache->stats()->incNumPreProgramCacheResult(*stat);
280 }
281
282 return tmp;
283}

◆ findOrCreateCompatiblePipelineState() [2/2]

GrVkPipelineState * GrVkResourceProvider::findOrCreateCompatiblePipelineState ( GrRenderTarget renderTarget,
const GrProgramInfo programInfo,
VkRenderPass  compatibleRenderPass,
bool  overrideSubpassForResolveLoad 
)

Definition at line 258 of file GrVkResourceProvider.cpp.

262 {
263 return fPipelineStateCache->findOrCreatePipelineState(renderTarget, programInfo,
264 compatibleRenderPass,
265 overrideSubpassForResolveLoad);
266}

◆ findOrCreateCompatibleSampler()

GrVkSampler * GrVkResourceProvider::findOrCreateCompatibleSampler ( GrSamplerState  params,
const GrVkYcbcrConversionInfo ycbcrInfo 
)

Definition at line 227 of file GrVkResourceProvider.cpp.

228 {
229 GrVkSampler* sampler = fSamplers.find(GrVkSampler::GenerateKey(params, ycbcrInfo));
230 if (!sampler) {
231 sampler = GrVkSampler::Create(fGpu, params, ycbcrInfo);
232 if (!sampler) {
233 return nullptr;
234 }
235 fSamplers.add(sampler);
236 }
237 SkASSERT(sampler);
238 sampler->ref();
239 return sampler;
240}
static SK_END_REQUIRE_DENSE Key GenerateKey(GrSamplerState, const GrVkYcbcrConversionInfo &)
static GrVkSampler * Create(GrVkGpu *gpu, GrSamplerState, const GrVkYcbcrConversionInfo &)
T * find(const Key &key) const
void add(T *entry)
const EmbeddedViewParams * params

◆ findOrCreateCompatibleSamplerYcbcrConversion()

GrVkSamplerYcbcrConversion * GrVkResourceProvider::findOrCreateCompatibleSamplerYcbcrConversion ( const GrVkYcbcrConversionInfo ycbcrInfo)

Definition at line 242 of file GrVkResourceProvider.cpp.

243 {
244 GrVkSamplerYcbcrConversion* ycbcrConversion =
245 fYcbcrConversions.find(GrVkSamplerYcbcrConversion::GenerateKey(ycbcrInfo));
246 if (!ycbcrConversion) {
247 ycbcrConversion = GrVkSamplerYcbcrConversion::Create(fGpu, ycbcrInfo);
248 if (!ycbcrConversion) {
249 return nullptr;
250 }
251 fYcbcrConversions.add(ycbcrConversion);
252 }
253 SkASSERT(ycbcrConversion);
254 ycbcrConversion->ref();
255 return ycbcrConversion;
256}
static GrVkSamplerYcbcrConversion * Create(GrVkGpu *gpu, const GrVkYcbcrConversionInfo &)
static SK_END_REQUIRE_DENSE Key GenerateKey(const GrVkYcbcrConversionInfo &ycbcrInfo)

◆ findOrCreateMSAALoadPipeline()

sk_sp< const GrVkPipeline > GrVkResourceProvider::findOrCreateMSAALoadPipeline ( const GrVkRenderPass renderPass,
int  numSamples,
VkPipelineShaderStageCreateInfo shaderStageInfo,
VkPipelineLayout  pipelineLayout 
)

Definition at line 285 of file GrVkResourceProvider.cpp.

289 {
290 // Find or Create a compatible pipeline
292 for (int i = 0; i < fMSAALoadPipelines.size() && !pipeline; ++i) {
293 if (fMSAALoadPipelines[i].fRenderPass->isCompatible(renderPass)) {
294 pipeline = fMSAALoadPipelines[i].fPipeline;
295 }
296 }
297 if (!pipeline) {
298 pipeline = GrVkPipeline::Make(
299 fGpu,
300 /*vertexAttribs=*/GrGeometryProcessor::AttributeSet(),
301 /*instanceAttribs=*/GrGeometryProcessor::AttributeSet(),
305 numSamples,
306 /*isHWantialiasState=*/false,
308 /*isWireframe=*/false,
309 /*useConservativeRaster=*/false,
310 /*subpass=*/0,
311 shaderStageInfo,
312 /*shaderStageCount=*/2,
313 renderPass.vkRenderPass(),
314 pipelineLayout,
315 /*ownsLayout=*/false,
316 this->pipelineCache());
317 if (!pipeline) {
318 return nullptr;
319 }
320 fMSAALoadPipelines.push_back({pipeline, &renderPass});
321 }
322 SkASSERT(pipeline);
323 return pipeline;
324}
@ kTopLeft_GrSurfaceOrigin
Definition GrTypes.h:148
static sk_sp< GrVkPipeline > Make(GrVkGpu *, const GrGeometryProcessor::AttributeSet &vertexAttribs, const GrGeometryProcessor::AttributeSet &instanceAttribs, GrPrimitiveType, GrSurfaceOrigin, const GrStencilSettings &, int numSamples, bool isHWAntialiasState, const skgpu::BlendInfo &, bool isWireframe, bool useConservativeRaster, uint32_t subpass, VkPipelineShaderStageCreateInfo *shaderStageInfo, int shaderStageCount, VkRenderPass compatibleRenderPass, VkPipelineLayout layout, bool ownsLayout, VkPipelineCache cache)
VkRenderPass vkRenderPass() const

◆ findRenderPass() [1/2]

const GrVkRenderPass * GrVkResourceProvider::findRenderPass ( const CompatibleRPHandle &  compatibleHandle,
const GrVkRenderPass::LoadStoreOps colorOps,
const GrVkRenderPass::LoadStoreOps resolveOps,
const GrVkRenderPass::LoadStoreOps stencilOps 
)

Definition at line 205 of file GrVkResourceProvider.cpp.

208 {
209 SkASSERT(compatibleHandle.isValid() && compatibleHandle.toIndex() < fRenderPassArray.size());
210 CompatibleRenderPassSet& compatibleSet = fRenderPassArray[compatibleHandle.toIndex()];
211 const GrVkRenderPass* renderPass = compatibleSet.getRenderPass(fGpu,
212 colorOps,
213 resolveOps,
214 stencilOps);
215 if (!renderPass) {
216 return nullptr;
217 }
218 renderPass->ref();
219 return renderPass;
220}

◆ findRenderPass() [2/2]

const GrVkRenderPass * GrVkResourceProvider::findRenderPass ( GrVkRenderTarget target,
const GrVkRenderPass::LoadStoreOps colorOps,
const GrVkRenderPass::LoadStoreOps resolveOps,
const GrVkRenderPass::LoadStoreOps stencilOps,
CompatibleRPHandle *  compatibleHandle,
bool  withResolve,
bool  withStencil,
SelfDependencyFlags  selfDepFlags,
LoadFromResolve  loadFromResolve 
)

Definition at line 182 of file GrVkResourceProvider.cpp.

191 {
192 GrVkResourceProvider::CompatibleRPHandle tempRPHandle;
193 GrVkResourceProvider::CompatibleRPHandle* pRPHandle = compatibleHandle ? compatibleHandle
194 : &tempRPHandle;
195 *pRPHandle = target->compatibleRenderPassHandle(withResolve, withStencil, selfDepFlags,
196 loadFromResolve);
197 if (!pRPHandle->isValid()) {
198 return nullptr;
199 }
200
201 return this->findRenderPass(*pRPHandle, colorOps, resolveOps, stencilOps);
202}
const GrVkRenderPass * findRenderPass(GrVkRenderTarget *target, const GrVkRenderPass::LoadStoreOps &colorOps, const GrVkRenderPass::LoadStoreOps &resolveOps, const GrVkRenderPass::LoadStoreOps &stencilOps, CompatibleRPHandle *compatibleHandle, bool withResolve, bool withStencil, SelfDependencyFlags selfDepFlags, LoadFromResolve)

◆ forceSyncAllCommandBuffers()

void GrVkResourceProvider::forceSyncAllCommandBuffers ( )

Definition at line 461 of file GrVkResourceProvider.cpp.

461 {
462 for (int i = fActiveCommandPools.size() - 1; !fActiveCommandPools.empty() && i >= 0; --i) {
463 GrVkCommandPool* pool = fActiveCommandPools[i];
464 if (!pool->isOpen()) {
465 GrVkPrimaryCommandBuffer* buffer = pool->getPrimaryCommandBuffer();
466 buffer->forceSync(fGpu);
467 }
468 }
469}

◆ getInputDescriptorSet()

const GrVkDescriptorSet * GrVkResourceProvider::getInputDescriptorSet ( )

Definition at line 383 of file GrVkResourceProvider.cpp.

383 {
384 SkASSERT(fInputDSHandle.isValid());
385 return fDescriptorSetManagers[fInputDSHandle.toIndex()]->getDescriptorSet(fGpu, fInputDSHandle);
386}

◆ getInputDSLayout()

VkDescriptorSetLayout GrVkResourceProvider::getInputDSLayout ( ) const

Definition at line 366 of file GrVkResourceProvider.cpp.

366 {
367 SkASSERT(fInputDSHandle.isValid());
368 return fDescriptorSetManagers[fInputDSHandle.toIndex()]->layout();
369}

◆ getSamplerDescriptorSet()

const GrVkDescriptorSet * GrVkResourceProvider::getSamplerDescriptorSet ( const GrVkDescriptorSetManager::Handle &  handle)

Definition at line 388 of file GrVkResourceProvider.cpp.

389 {
390 SkASSERT(handle.isValid());
391 return fDescriptorSetManagers[handle.toIndex()]->getDescriptorSet(fGpu, handle);
392}

◆ getSamplerDescriptorSetHandle()

void GrVkResourceProvider::getSamplerDescriptorSetHandle ( VkDescriptorType  type,
const GrVkUniformHandler uniformHandler,
GrVkDescriptorSetManager::Handle *  handle 
)

Definition at line 342 of file GrVkResourceProvider.cpp.

344 {
345 SkASSERT(handle);
348 for (int i = 0; i < fDescriptorSetManagers.size(); ++i) {
349 if (fDescriptorSetManagers[i]->isCompatible(type, &uniformHandler)) {
350 *handle = GrVkDescriptorSetManager::Handle(i);
351 return;
352 }
353 }
354
356 uniformHandler);
357 fDescriptorSetManagers.emplace_back(dsm);
358 *handle = GrVkDescriptorSetManager::Handle(fDescriptorSetManagers.size() - 1);
359}
static GrVkDescriptorSetManager * CreateSamplerManager(GrVkGpu *gpu, VkDescriptorType type, const GrVkUniformHandler &)
@ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
@ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER

◆ getSamplerDSLayout()

VkDescriptorSetLayout GrVkResourceProvider::getSamplerDSLayout ( const GrVkDescriptorSetManager::Handle &  handle) const

Definition at line 371 of file GrVkResourceProvider.cpp.

372 {
373 SkASSERT(handle.isValid());
374 return fDescriptorSetManagers[handle.toIndex()]->layout();
375}

◆ getUniformDescriptorSet()

const GrVkDescriptorSet * GrVkResourceProvider::getUniformDescriptorSet ( )

Definition at line 377 of file GrVkResourceProvider.cpp.

377 {
378 SkASSERT(fUniformDSHandle.isValid());
379 return fDescriptorSetManagers[fUniformDSHandle.toIndex()]->getDescriptorSet(fGpu,
380 fUniformDSHandle);
381}

◆ getUniformDSLayout()

VkDescriptorSetLayout GrVkResourceProvider::getUniformDSLayout ( ) const

Definition at line 361 of file GrVkResourceProvider.cpp.

361 {
362 SkASSERT(fUniformDSHandle.isValid());
363 return fDescriptorSetManagers[fUniformDSHandle.toIndex()]->layout();
364}

◆ getZeroSamplerDescriptorSetHandle()

void GrVkResourceProvider::getZeroSamplerDescriptorSetHandle ( GrVkDescriptorSetManager::Handle *  handle)

Definition at line 326 of file GrVkResourceProvider.cpp.

327 {
328 SkASSERT(handle);
329 for (int i = 0; i < fDescriptorSetManagers.size(); ++i) {
330 if (fDescriptorSetManagers[i]->isZeroSampler()) {
331 *handle = GrVkDescriptorSetManager::Handle(i);
332 return;
333 }
334 }
335
338 fDescriptorSetManagers.emplace_back(dsm);
339 *handle = GrVkDescriptorSetManager::Handle(fDescriptorSetManagers.size() - 1);
340}
static GrVkDescriptorSetManager * CreateZeroSamplerManager(GrVkGpu *gpu)

◆ init()

void GrVkResourceProvider::init ( )

Definition at line 84 of file GrVkResourceProvider.cpp.

84 {
85 // Init uniform descriptor objects
87 fDescriptorSetManagers.emplace_back(dsm);
88 SkASSERT(1 == fDescriptorSetManagers.size());
89 fUniformDSHandle = GrVkDescriptorSetManager::Handle(0);
91 fDescriptorSetManagers.emplace_back(dsm);
92 SkASSERT(2 == fDescriptorSetManagers.size());
93 fInputDSHandle = GrVkDescriptorSetManager::Handle(1);
94}
static GrVkDescriptorSetManager * CreateInputManager(GrVkGpu *gpu)
static GrVkDescriptorSetManager * CreateUniformManager(GrVkGpu *gpu)

◆ makePipeline()

sk_sp< const GrVkPipeline > GrVkResourceProvider::makePipeline ( const GrProgramInfo programInfo,
VkPipelineShaderStageCreateInfo shaderStageInfo,
int  shaderStageCount,
VkRenderPass  compatibleRenderPass,
VkPipelineLayout  layout,
uint32_t  subpass 
)

Definition at line 96 of file GrVkResourceProvider.cpp.

102 {
103 return GrVkPipeline::Make(fGpu, programInfo, shaderStageInfo, shaderStageCount,
104 compatibleRenderPass, layout, this->pipelineCache(), subpass);
105}

◆ pipelineStateCache()

GrThreadSafePipelineBuilder * GrVkResourceProvider::pipelineStateCache ( )
inline

Definition at line 45 of file GrVkResourceProvider.h.

45 {
46 return fPipelineStateCache.get();
47 }
T * get() const
Definition SkRefCnt.h:303

◆ recycleDescriptorSet()

void GrVkResourceProvider::recycleDescriptorSet ( const GrVkDescriptorSet descSet,
const GrVkDescriptorSetManager::Handle &  handle 
)

Definition at line 394 of file GrVkResourceProvider.cpp.

395 {
396 SkASSERT(descSet);
397 SkASSERT(handle.isValid());
398 int managerIdx = handle.toIndex();
399 SkASSERT(managerIdx < fDescriptorSetManagers.size());
400 fDescriptorSetManagers[managerIdx]->recycleDescriptorSet(descSet);
401}

◆ refPipelineStateCache()

sk_sp< GrThreadSafePipelineBuilder > GrVkResourceProvider::refPipelineStateCache ( )
inline

Definition at line 49 of file GrVkResourceProvider.h.

49 {
50 return fPipelineStateCache;
51 }

◆ releaseUnlockedBackendObjects()

void GrVkResourceProvider::releaseUnlockedBackendObjects ( )

Definition at line 534 of file GrVkResourceProvider.cpp.

534 {
535 for (GrVkCommandPool* pool : fAvailableCommandPools) {
536 SkASSERT(pool->unique());
537 pool->unref();
538 }
539 fAvailableCommandPools.clear();
540}

◆ storePipelineCacheData()

void GrVkResourceProvider::storePipelineCacheData ( )

Definition at line 542 of file GrVkResourceProvider.cpp.

542 {
543 if (this->pipelineCache() == VK_NULL_HANDLE) {
544 return;
545 }
546 size_t dataSize = 0;
548 GR_VK_CALL_RESULT(fGpu, result, GetPipelineCacheData(fGpu->device(), this->pipelineCache(),
549 &dataSize, nullptr));
550 if (result != VK_SUCCESS) {
551 return;
552 }
553
554 std::unique_ptr<uint8_t[]> data(new uint8_t[dataSize]);
555
556 GR_VK_CALL_RESULT(fGpu, result, GetPipelineCacheData(fGpu->device(), this->pipelineCache(),
557 &dataSize, (void*)data.get()));
558 if (result != VK_SUCCESS) {
559 return;
560 }
561
563 sk_sp<SkData> keyData = SkData::MakeWithoutCopy(&key, sizeof(uint32_t));
564
566 *keyData, *SkData::MakeWithoutCopy(data.get(), dataSize), SkString("VkPipelineCache"));
567}
#define GR_VK_CALL_RESULT(GPU, RESULT, X)
Definition GrVkUtil.h:35
virtual void store(const SkData &, const SkData &)
GrContextOptions::PersistentCache * getPersistentCache()
@ kPipelineCache_PersistentCacheKeyType
Definition GrVkGpu.h:186
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
Definition SkData.h:116
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
VkResult
@ VK_SUCCESS

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