[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 {}
|
~GraphicsPipeline() override {}
|
||||||
|
|
||||||
id<MTLRenderPipelineState> mtlPipelineState() const { return fPipelineState.get(); }
|
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; }
|
uint32_t stencilReferenceValue() const { return fStencilReferenceValue; }
|
||||||
size_t vertexStride() const { return fVertexStride; }
|
size_t vertexStride() const { return fVertexStride; }
|
||||||
size_t instanceStride() const { return fInstanceStride; }
|
size_t instanceStride() const { return fInstanceStride; }
|
||||||
@ -50,7 +50,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
GraphicsPipeline(const skgpu::Gpu* gpu,
|
GraphicsPipeline(const skgpu::Gpu* gpu,
|
||||||
sk_cfp<id<MTLRenderPipelineState>> pso,
|
sk_cfp<id<MTLRenderPipelineState>> pso,
|
||||||
id<MTLDepthStencilState> dss,
|
sk_cfp<id<MTLDepthStencilState>> dss,
|
||||||
uint32_t refValue,
|
uint32_t refValue,
|
||||||
size_t vertexStride,
|
size_t vertexStride,
|
||||||
size_t instanceStride)
|
size_t instanceStride)
|
||||||
@ -64,7 +64,7 @@ private:
|
|||||||
void freeGpuData() override;
|
void freeGpuData() override;
|
||||||
|
|
||||||
sk_cfp<id<MTLRenderPipelineState>> fPipelineState;
|
sk_cfp<id<MTLRenderPipelineState>> fPipelineState;
|
||||||
id<MTLDepthStencilState> fDepthStencilState;
|
sk_cfp<id<MTLDepthStencilState>> fDepthStencilState;
|
||||||
uint32_t fStencilReferenceValue;
|
uint32_t fStencilReferenceValue;
|
||||||
size_t fVertexStride = 0;
|
size_t fVertexStride = 0;
|
||||||
size_t fInstanceStride = 0;
|
size_t fInstanceStride = 0;
|
||||||
|
@ -560,13 +560,13 @@ sk_sp<GraphicsPipeline> GraphicsPipeline::Make(ResourceProvider* resourceProvide
|
|||||||
|
|
||||||
const DepthStencilSettings& depthStencilSettings =
|
const DepthStencilSettings& depthStencilSettings =
|
||||||
pipelineDesc.renderStep()->depthStencilSettings();
|
pipelineDesc.renderStep()->depthStencilSettings();
|
||||||
id<MTLDepthStencilState> dss = resourceProvider->findOrCreateCompatibleDepthStencilState(
|
sk_cfp<id<MTLDepthStencilState>> dss =
|
||||||
depthStencilSettings);
|
resourceProvider->findOrCreateCompatibleDepthStencilState(depthStencilSettings);
|
||||||
|
|
||||||
return sk_sp<GraphicsPipeline>(
|
return sk_sp<GraphicsPipeline>(
|
||||||
new GraphicsPipeline(gpu,
|
new GraphicsPipeline(gpu,
|
||||||
std::move(pso),
|
std::move(pso),
|
||||||
dss,
|
std::move(dss),
|
||||||
depthStencilSettings.fStencilReferenceValue,
|
depthStencilSettings.fStencilReferenceValue,
|
||||||
pipelineDesc.renderStep()->vertexStride(),
|
pipelineDesc.renderStep()->vertexStride(),
|
||||||
pipelineDesc.renderStep()->instanceStride()));
|
pipelineDesc.renderStep()->instanceStride()));
|
||||||
|
@ -30,7 +30,8 @@ public:
|
|||||||
sk_sp<skgpu::Texture> createWrappedTexture(const BackendTexture&) override;
|
sk_sp<skgpu::Texture> createWrappedTexture(const BackendTexture&) override;
|
||||||
|
|
||||||
// Finds or creates a compatible DepthStencilState based on the enum
|
// Finds or creates a compatible DepthStencilState based on the enum
|
||||||
id<MTLDepthStencilState> findOrCreateCompatibleDepthStencilState(const DepthStencilSettings&);
|
sk_cfp<id<MTLDepthStencilState>> findOrCreateCompatibleDepthStencilState(
|
||||||
|
const DepthStencilSettings&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Gpu* mtlGpu();
|
const Gpu* mtlGpu();
|
||||||
|
@ -127,7 +127,7 @@ MTLStencilDescriptor* stencil_face_to_mtl(DepthStencilSettings::Face face) {
|
|||||||
}
|
}
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
id<MTLDepthStencilState> ResourceProvider::findOrCreateCompatibleDepthStencilState(
|
sk_cfp<id<MTLDepthStencilState>> ResourceProvider::findOrCreateCompatibleDepthStencilState(
|
||||||
const DepthStencilSettings& depthStencilSettings) {
|
const DepthStencilSettings& depthStencilSettings) {
|
||||||
sk_cfp<id<MTLDepthStencilState>>* depthStencilState;
|
sk_cfp<id<MTLDepthStencilState>>* depthStencilState;
|
||||||
depthStencilState = fDepthStencilStates.find(depthStencilSettings);
|
depthStencilState = fDepthStencilStates.find(depthStencilSettings);
|
||||||
@ -150,7 +150,7 @@ id<MTLDepthStencilState> ResourceProvider::findOrCreateCompatibleDepthStencilSta
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkASSERT(depthStencilState);
|
SkASSERT(depthStencilState);
|
||||||
return depthStencilState->get();
|
return *depthStencilState;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace skgpu::mtl
|
} // namespace skgpu::mtl
|
||||||
|
Loading…
Reference in New Issue
Block a user