From e7dd36dfe0410ec77c0d7568c58697e3d110dcaa Mon Sep 17 00:00:00 2001 From: yangchunlin Date: Mon, 17 Jul 2023 15:17:37 +0800 Subject: [PATCH 1/2] Fix OpsTask crash in multi-thread rendering Signed-off-by: yangchunlin --- src/gpu/ops/OpsTask.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gpu/ops/OpsTask.cpp b/src/gpu/ops/OpsTask.cpp index bd7ee8bd43..e56def2774 100644 --- a/src/gpu/ops/OpsTask.cpp +++ b/src/gpu/ops/OpsTask.cpp @@ -276,6 +276,12 @@ bool OpsTask::OpChain::tryConcat( SkASSERT(fProcessorAnalysis.requiresDstTexture() == SkToBool(fDstProxyView.proxy())); SkASSERT(processorAnalysis.requiresDstTexture() == SkToBool(dstProxyView.proxy())); // All returns use explicit tuple constructor rather than {a, b} to work around old GCC bug. + if (fList.empty() || list->empty() || + fProcessorAnalysis.requiresDstTexture() != SkToBool(fDstProxyView.proxy()) || + processorAnalysis.requiresDstTexture() != SkToBool(dstProxyView.proxy())) { + SkDebugf("OHOS OpsTask::OpChain::tryConcat failed, return!!!"); + return; + } if (fList.head()->classID() != list->head()->classID() || SkToBool(fAppliedClip) != SkToBool(appliedClip) || (fAppliedClip && *fAppliedClip != *appliedClip) || @@ -999,6 +1005,10 @@ void OpsTask::recordOp( // 1) check every op // 2) intersect with something // 3) find a 'blocker' + if (!fAuditTrail) { + SkDebugf("OHOS fAuditTrail is nullptr, return!!!"); + return; + } GR_AUDIT_TRAIL_ADD_OP(fAuditTrail, op.get(), proxy->uniqueID()); GrOP_INFO("opsTask: %d Recording (%s, opID: %u)\n" "\tBounds [L: %.2f, T: %.2f R: %.2f B: %.2f]\n", @@ -1042,6 +1052,10 @@ void OpsTask::recordOp( void OpsTask::forwardCombine(const GrCaps& caps) { SkASSERT(!this->isClosed()); + if (this->isClosed()) { + SkDebugf("OHOS OpsTask::forwardCombine return!!!"); + return; + } GrOP_INFO("opsTask: %d ForwardCombine %d ops:\n", this->uniqueID(), fOpChains.count()); for (int i = 0; i < fOpChains.count() - 1; ++i) { -- Gitee From 506b237b784198befe88de2af0346fe7b14a62e6 Mon Sep 17 00:00:00 2001 From: yangchunlin4 Date: Tue, 5 Dec 2023 01:05:29 +0800 Subject: [PATCH 2/2] dump vk resource Signed-off-by: yangchunlin4 --- src/gpu/ops/OpsTask.cpp | 14 -------------- src/gpu/vk/GrVkTexture.cpp | 8 ++++++++ src/gpu/vk/GrVkTexture.h | 2 ++ src/gpu/vk/GrVkTextureRenderTarget.cpp | 7 +++++++ src/gpu/vk/GrVkTextureRenderTarget.h | 2 ++ 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/gpu/ops/OpsTask.cpp b/src/gpu/ops/OpsTask.cpp index e56def2774..bd7ee8bd43 100644 --- a/src/gpu/ops/OpsTask.cpp +++ b/src/gpu/ops/OpsTask.cpp @@ -276,12 +276,6 @@ bool OpsTask::OpChain::tryConcat( SkASSERT(fProcessorAnalysis.requiresDstTexture() == SkToBool(fDstProxyView.proxy())); SkASSERT(processorAnalysis.requiresDstTexture() == SkToBool(dstProxyView.proxy())); // All returns use explicit tuple constructor rather than {a, b} to work around old GCC bug. - if (fList.empty() || list->empty() || - fProcessorAnalysis.requiresDstTexture() != SkToBool(fDstProxyView.proxy()) || - processorAnalysis.requiresDstTexture() != SkToBool(dstProxyView.proxy())) { - SkDebugf("OHOS OpsTask::OpChain::tryConcat failed, return!!!"); - return; - } if (fList.head()->classID() != list->head()->classID() || SkToBool(fAppliedClip) != SkToBool(appliedClip) || (fAppliedClip && *fAppliedClip != *appliedClip) || @@ -1005,10 +999,6 @@ void OpsTask::recordOp( // 1) check every op // 2) intersect with something // 3) find a 'blocker' - if (!fAuditTrail) { - SkDebugf("OHOS fAuditTrail is nullptr, return!!!"); - return; - } GR_AUDIT_TRAIL_ADD_OP(fAuditTrail, op.get(), proxy->uniqueID()); GrOP_INFO("opsTask: %d Recording (%s, opID: %u)\n" "\tBounds [L: %.2f, T: %.2f R: %.2f B: %.2f]\n", @@ -1052,10 +1042,6 @@ void OpsTask::recordOp( void OpsTask::forwardCombine(const GrCaps& caps) { SkASSERT(!this->isClosed()); - if (this->isClosed()) { - SkDebugf("OHOS OpsTask::forwardCombine return!!!"); - return; - } GrOP_INFO("opsTask: %d ForwardCombine %d ops:\n", this->uniqueID(), fOpChains.count()); for (int i = 0; i < fOpChains.count() - 1; ++i) { diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp index ed1c52abb9..ac55fda89a 100644 --- a/src/gpu/vk/GrVkTexture.cpp +++ b/src/gpu/vk/GrVkTexture.cpp @@ -179,3 +179,11 @@ void GrVkTexture::addDescriptorSetToCache(const GrVkDescriptorSet* descSet, GrSa descSet->ref(); fDescSetCache.insert(state, std::make_unique(descSet, this->getVkGpu())); } + +void GrVkTexture::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { + size_t size = GrSurface::ComputeSize(this->backendFormat(), this->dimensions(), 1, + this->mipmapped()); + SkString resourceName = this->getResourceName(); + resourceName.append("/texture"); + this->dumpMemoryStatisticsPriv(traceMemoryDump, resourceName, "Texture", size); +} diff --git a/src/gpu/vk/GrVkTexture.h b/src/gpu/vk/GrVkTexture.h index cbae00e4cf..bfb0b09d6d 100644 --- a/src/gpu/vk/GrVkTexture.h +++ b/src/gpu/vk/GrVkTexture.h @@ -57,6 +57,8 @@ public: void addDescriptorSetToCache(const GrVkDescriptorSet*, GrSamplerState); + void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override; + protected: GrVkTexture(GrVkGpu*, SkISize dimensions, diff --git a/src/gpu/vk/GrVkTextureRenderTarget.cpp b/src/gpu/vk/GrVkTextureRenderTarget.cpp index b05af936ad..b1e12f6102 100644 --- a/src/gpu/vk/GrVkTextureRenderTarget.cpp +++ b/src/gpu/vk/GrVkTextureRenderTarget.cpp @@ -174,3 +174,10 @@ size_t GrVkTextureRenderTarget::onGpuMemorySize() const { return GrSurface::ComputeSize(this->backendFormat(), this->dimensions(), 1 /*colorSamplesPerPixel*/, this->mipmapped()); } + +void GrVkTextureRenderTarget::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { + SkString resourceName = this->getResourceName(); + resourceName.append("/texture_renderbuffer"); + this->dumpMemoryStatisticsPriv(traceMemoryDump, resourceName, "RenderTarget", + this->gpuMemorySize()); +} \ No newline at end of file diff --git a/src/gpu/vk/GrVkTextureRenderTarget.h b/src/gpu/vk/GrVkTextureRenderTarget.h index d089d44184..90b36588e4 100644 --- a/src/gpu/vk/GrVkTextureRenderTarget.h +++ b/src/gpu/vk/GrVkTextureRenderTarget.h @@ -47,6 +47,8 @@ public: GrBackendFormat backendFormat() const override { return GrVkTexture::backendFormat(); } + void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override; + protected: void onAbandon() override { // In order to correctly handle calling texture idle procs, GrVkTexture must go first. -- Gitee