Remove uses of sk_sp when passing around GrVkPipelineState

There is no need to be passing ref's around when we get a GrVkPipelineState
from the cache. We don't track its use on the GPU and we never delete
them from the cache until we are destorying the GrVkGpu object.

Bug: skia:
Change-Id: If675ce9e0690b36663f6d227c48fd4874ba46770
Reviewed-on: https://skia-review.googlesource.com/59985
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2017-10-16 15:15:02 -04:00 committed by Skia Commit-Bot
parent 6a3dbeed00
commit 09eeefba6d
5 changed files with 31 additions and 33 deletions

View File

@ -498,15 +498,14 @@ void GrVkGpuRTCommandBuffer::bindGeometry(const GrPrimitiveProcessor& primProc,
}
}
sk_sp<GrVkPipelineState> GrVkGpuRTCommandBuffer::prepareDrawState(
const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
GrPrimitiveType primitiveType,
bool hasDynamicState) {
GrVkPipelineState* GrVkGpuRTCommandBuffer::prepareDrawState(const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
GrPrimitiveType primitiveType,
bool hasDynamicState) {
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
SkASSERT(cbInfo.fRenderPass);
sk_sp<GrVkPipelineState> pipelineState =
GrVkPipelineState* pipelineState =
fGpu->resourceProvider().findOrCreateCompatiblePipelineState(pipeline,
primProc,
primitiveType,
@ -516,11 +515,11 @@ sk_sp<GrVkPipelineState> GrVkGpuRTCommandBuffer::prepareDrawState(
}
if (!cbInfo.fIsEmpty &&
fLastPipelineState && fLastPipelineState != pipelineState.get() &&
fLastPipelineState && fLastPipelineState != pipelineState &&
fGpu->vkCaps().newCBOnPipelineChange()) {
this->addAdditionalCommandBuffer();
}
fLastPipelineState = pipelineState.get();
fLastPipelineState = pipelineState;
pipelineState->setData(fGpu, primProc, pipeline);
@ -598,10 +597,10 @@ void GrVkGpuRTCommandBuffer::onDraw(const GrPipeline& pipeline,
}
GrPrimitiveType primitiveType = meshes[0].primitiveType();
sk_sp<GrVkPipelineState> pipelineState = this->prepareDrawState(pipeline,
primProc,
primitiveType,
SkToBool(dynamicStates));
GrVkPipelineState* pipelineState = this->prepareDrawState(pipeline,
primProc,
primitiveType,
SkToBool(dynamicStates));
if (!pipelineState) {
return;
}

View File

@ -87,10 +87,10 @@ private:
const GrBuffer* vertexBuffer,
const GrBuffer* instanceBuffer);
sk_sp<GrVkPipelineState> prepareDrawState(const GrPipeline&,
const GrPrimitiveProcessor&,
GrPrimitiveType,
bool hasDynamicState);
GrVkPipelineState* prepareDrawState(const GrPipeline&,
const GrPrimitiveProcessor&,
GrPrimitiveType,
bool hasDynamicState);
void onDraw(const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,

View File

@ -22,7 +22,7 @@ static const bool c_DisplayVkPipelineCache{false};
#endif
struct GrVkResourceProvider::PipelineStateCache::Entry {
Entry(GrVkGpu* gpu, sk_sp<GrVkPipelineState> pipelineState)
Entry(GrVkGpu* gpu, GrVkPipelineState* pipelineState)
: fGpu(gpu)
, fPipelineState(pipelineState) {}
@ -33,7 +33,7 @@ struct GrVkResourceProvider::PipelineStateCache::Entry {
}
GrVkGpu* fGpu;
sk_sp<GrVkPipelineState> fPipelineState;
std::unique_ptr<GrVkPipelineState> fPipelineState;
};
GrVkResourceProvider::PipelineStateCache::PipelineStateCache(GrVkGpu* gpu)
@ -73,7 +73,7 @@ void GrVkResourceProvider::PipelineStateCache::release() {
fMap.reset();
}
sk_sp<GrVkPipelineState> GrVkResourceProvider::PipelineStateCache::refPipelineState(
GrVkPipelineState* GrVkResourceProvider::PipelineStateCache::refPipelineState(
const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
GrPrimitiveType primitiveType,
@ -111,7 +111,7 @@ sk_sp<GrVkPipelineState> GrVkResourceProvider::PipelineStateCache::refPipelineSt
#ifdef GR_PIPELINE_STATE_CACHE_STATS
++fCacheMisses;
#endif
sk_sp<GrVkPipelineState> pipelineState(
GrVkPipelineState* pipelineState(
GrVkPipelineStateBuilder::CreatePipelineState(fGpu,
pipeline,
stencil,
@ -122,9 +122,8 @@ sk_sp<GrVkPipelineState> GrVkResourceProvider::PipelineStateCache::refPipelineSt
if (nullptr == pipelineState) {
return nullptr;
}
entry = fMap.insert(desc, std::unique_ptr<Entry>(new Entry(fGpu,
std::move(pipelineState))));
return (*entry)->fPipelineState;
entry = fMap.insert(desc, std::unique_ptr<Entry>(new Entry(fGpu, pipelineState)));
return (*entry)->fPipelineState.get();
}
return (*entry)->fPipelineState;
return (*entry)->fPipelineState.get();
}

View File

@ -177,7 +177,7 @@ GrVkSampler* GrVkResourceProvider::findOrCreateCompatibleSampler(const GrSampler
return sampler;
}
sk_sp<GrVkPipelineState> GrVkResourceProvider::findOrCreateCompatiblePipelineState(
GrVkPipelineState* GrVkResourceProvider::findOrCreateCompatiblePipelineState(
const GrPipeline& pipeline,
const GrPrimitiveProcessor& proc,
GrPrimitiveType primitiveType,

View File

@ -100,10 +100,10 @@ public:
// The refcount is incremented and a pointer returned.
GrVkSampler* findOrCreateCompatibleSampler(const GrSamplerState&, uint32_t maxMipLevel);
sk_sp<GrVkPipelineState> findOrCreateCompatiblePipelineState(const GrPipeline&,
const GrPrimitiveProcessor&,
GrPrimitiveType,
const GrVkRenderPass& renderPass);
GrVkPipelineState* findOrCreateCompatiblePipelineState(const GrPipeline&,
const GrPrimitiveProcessor&,
GrPrimitiveType,
const GrVkRenderPass& renderPass);
void getSamplerDescriptorSetHandle(VkDescriptorType type,
const GrVkUniformHandler&,
@ -170,10 +170,10 @@ private:
void abandon();
void release();
sk_sp<GrVkPipelineState> refPipelineState(const GrPipeline&,
const GrPrimitiveProcessor&,
GrPrimitiveType,
const GrVkRenderPass& renderPass);
GrVkPipelineState* refPipelineState(const GrPipeline&,
const GrPrimitiveProcessor&,
GrPrimitiveType,
const GrVkRenderPass& renderPass);
private:
enum {