[graphite] Don't delete MTLDepthStencilState until CommandBuffer is done
The MTLDepthStencilState objects are only refed in MtlResourceProvider. When we shut down, we tear down all the Recorders. That tears down their resource providers, which in the Metal case deletes these DepthStencil objects. But we can have a command buffer still in flight, so we need to add a ref to keep those objects alive. Bug: skia:13068 Change-Id: Ic2fb8fdd83c5323505fa4ccda509e28a8c7e3bfc Reviewed-on: https://skia-review.googlesource.com/c/skia/+/521521 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
parent
96f09dc005
commit
6916d3e90e
@ -42,7 +42,7 @@ public:
|
||||
~GraphicsPipeline() override {}
|
||||
|
||||
id<MTLRenderPipelineState> mtlPipelineState() const { return fPipelineState.get(); }
|
||||
id<MTLDepthStencilState> mtlDepthStencilState() const { return fDepthStencilState; }
|
||||
id<MTLDepthStencilState> mtlDepthStencilState() const { return fDepthStencilState.get(); }
|
||||
uint32_t stencilReferenceValue() const { return fStencilReferenceValue; }
|
||||
size_t vertexStride() const { return fVertexStride; }
|
||||
size_t instanceStride() const { return fInstanceStride; }
|
||||
@ -50,7 +50,7 @@ public:
|
||||
private:
|
||||
GraphicsPipeline(const skgpu::Gpu* gpu,
|
||||
sk_cfp<id<MTLRenderPipelineState>> pso,
|
||||
id<MTLDepthStencilState> dss,
|
||||
sk_cfp<id<MTLDepthStencilState>> dss,
|
||||
uint32_t refValue,
|
||||
size_t vertexStride,
|
||||
size_t instanceStride)
|
||||
@ -64,7 +64,7 @@ private:
|
||||
void freeGpuData() override;
|
||||
|
||||
sk_cfp<id<MTLRenderPipelineState>> fPipelineState;
|
||||
id<MTLDepthStencilState> fDepthStencilState;
|
||||
sk_cfp<id<MTLDepthStencilState>> fDepthStencilState;
|
||||
uint32_t fStencilReferenceValue;
|
||||
size_t fVertexStride = 0;
|
||||
size_t fInstanceStride = 0;
|
||||
|
@ -560,13 +560,13 @@ sk_sp<GraphicsPipeline> GraphicsPipeline::Make(ResourceProvider* resourceProvide
|
||||
|
||||
const DepthStencilSettings& depthStencilSettings =
|
||||
pipelineDesc.renderStep()->depthStencilSettings();
|
||||
id<MTLDepthStencilState> dss = resourceProvider->findOrCreateCompatibleDepthStencilState(
|
||||
depthStencilSettings);
|
||||
sk_cfp<id<MTLDepthStencilState>> dss =
|
||||
resourceProvider->findOrCreateCompatibleDepthStencilState(depthStencilSettings);
|
||||
|
||||
return sk_sp<GraphicsPipeline>(
|
||||
new GraphicsPipeline(gpu,
|
||||
std::move(pso),
|
||||
dss,
|
||||
std::move(dss),
|
||||
depthStencilSettings.fStencilReferenceValue,
|
||||
pipelineDesc.renderStep()->vertexStride(),
|
||||
pipelineDesc.renderStep()->instanceStride()));
|
||||
|
@ -30,7 +30,8 @@ public:
|
||||
sk_sp<skgpu::Texture> createWrappedTexture(const BackendTexture&) override;
|
||||
|
||||
// Finds or creates a compatible DepthStencilState based on the enum
|
||||
id<MTLDepthStencilState> findOrCreateCompatibleDepthStencilState(const DepthStencilSettings&);
|
||||
sk_cfp<id<MTLDepthStencilState>> findOrCreateCompatibleDepthStencilState(
|
||||
const DepthStencilSettings&);
|
||||
|
||||
private:
|
||||
const Gpu* mtlGpu();
|
||||
|
@ -127,7 +127,7 @@ MTLStencilDescriptor* stencil_face_to_mtl(DepthStencilSettings::Face face) {
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
id<MTLDepthStencilState> ResourceProvider::findOrCreateCompatibleDepthStencilState(
|
||||
sk_cfp<id<MTLDepthStencilState>> ResourceProvider::findOrCreateCompatibleDepthStencilState(
|
||||
const DepthStencilSettings& depthStencilSettings) {
|
||||
sk_cfp<id<MTLDepthStencilState>>* depthStencilState;
|
||||
depthStencilState = fDepthStencilStates.find(depthStencilSettings);
|
||||
@ -150,7 +150,7 @@ id<MTLDepthStencilState> ResourceProvider::findOrCreateCompatibleDepthStencilSta
|
||||
}
|
||||
|
||||
SkASSERT(depthStencilState);
|
||||
return depthStencilState->get();
|
||||
return *depthStencilState;
|
||||
}
|
||||
|
||||
} // namespace skgpu::mtl
|
||||
|
Loading…
Reference in New Issue
Block a user