bugfix for redundant bufferReleass

Signed-off-by: Klaus_q <wangqi175@huawei.com>
Change-Id: Ide809dc072868c0530c24fd18eea2c1e551f4c43
This commit is contained in:
Klaus_q 2023-02-24 17:57:00 +08:00
parent 6bd45ef66d
commit 975f1e869f
5 changed files with 36 additions and 5 deletions

View File

@ -81,8 +81,6 @@ void RSHardwareThread::ReleaseBuffer(sptr<SurfaceBuffer> buffer, sptr<SyncFence>
RS_TRACE_NAME("RSHardwareThread::ReleaseBuffer");
auto ret = cSurface->ReleaseBuffer(buffer, releaseFence);
if (ret != OHOS::SURFACE_ERROR_OK) {
RS_LOGE("RsDebug RSHardwareThread::ReleaseBuffer failed(ret: %d)!",
buffer->GetSeqNum(), ret);
return;
}
// reset prevBuffer if we release it successfully,

View File

@ -81,6 +81,18 @@ void RSUniRenderComposerAdapter::CommitLayers(const std::vector<LayerInfoPtr>& l
RSHardwareThread::Instance().CommitAndReleaseLayers(output_, layers);
}
void RSUniRenderComposerAdapter::SetPreBufferInfo(RSSurfaceHandler& surfaceHandler, ComposeInfo& info) const
{
if (surfaceHandler.IsPreBufferReleased()) {
// reset prevBuffer if same layer has been committed successfully,
// to avoid releasing the same buffer next frame in some situations.
info.preBuffer = nullptr;
} else {
info.preBuffer = surfaceHandler.GetPreBuffer().buffer;
surfaceHandler.SetPreBufferReleased(true);
}
}
// private func, for RSDisplayRenderNode
ComposeInfo RSUniRenderComposerAdapter::BuildComposeInfo(RSDisplayRenderNode& node) const
{
@ -98,7 +110,7 @@ ComposeInfo RSUniRenderComposerAdapter::BuildComposeInfo(RSDisplayRenderNode& no
info.zOrder = static_cast<int32_t>(node.GetGlobalZOrder());
info.alpha.enGlobalAlpha = true;
info.alpha.gAlpha = 255;
info.preBuffer = node.GetPreBuffer().buffer;
SetPreBufferInfo(node, info);
info.buffer = buffer;
info.fence = node.GetAcquireFence();
info.blendType = GRAPHIC_BLEND_SRCOVER;
@ -121,7 +133,7 @@ ComposeInfo RSUniRenderComposerAdapter::BuildComposeInfo(RSDrivenSurfaceRenderNo
info.zOrder = static_cast<int32_t>(node.GetGlobalZOrder());
info.alpha.enGlobalAlpha = true;
info.alpha.gAlpha = 255;
info.preBuffer = node.GetPreBuffer().buffer;
SetPreBufferInfo(node, info);
info.buffer = buffer;
info.fence = node.GetAcquireFence();
info.blendType = GRAPHIC_BLEND_SRCOVER;
@ -299,7 +311,7 @@ ComposeInfo RSUniRenderComposerAdapter::BuildComposeInfo(RSSurfaceRenderNode& no
info.blendType = node.GetBlendType();
const auto& buffer = node.GetBuffer();
info.buffer = buffer;
info.preBuffer = node.GetPreBuffer().buffer;
SetPreBufferInfo(node, info);
GetComposerInfoSrcRect(info, node);
info.needClient = GetComposerInfoNeedClient(info, node);
DealWithNodeGravity(node, info);

View File

@ -63,6 +63,7 @@ private:
static void GetComposerInfoSrcRect(ComposeInfo &info, const RSSurfaceRenderNode& node);
bool GetComposerInfoNeedClient(const ComposeInfo &info, RSRenderNode& node) const;
bool CheckStatusBeforeCreateLayer(RSSurfaceRenderNode& node) const;
void SetPreBufferInfo(RSSurfaceHandler& surfaceHandler, ComposeInfo& info) const;
std::shared_ptr<HdiOutput> output_;
ScreenInfo screenInfo_;

View File

@ -915,6 +915,14 @@ void RSUniRenderVisitor::ProcessDisplayRenderNode(RSDisplayRenderNode& node)
if (isOpDropped_ && dirtySurfaceNodeMap_.empty() && !curDisplayDirtyManager_->IsDirty()) {
RS_LOGD("DisplayNode skip");
RS_TRACE_NAME("DisplayNode skip");
if (!IsHardwareComposerEnabled()) {
return;
}
for (auto& node: hardwareEnabledNodes_) {
if (!node->IsHardwareForcedDisabled()) {
node->MarkCurrentFrameHardwareEnabled();
}
}
return;
}
#endif

View File

@ -89,6 +89,7 @@ public:
buffer_.acquireFence = acquireFence;
buffer_.damageRect = damage;
buffer_.timestamp = timestamp;
isPreBufferReleased_ = false;
}
const sptr<SurfaceBuffer>& GetBuffer() const
@ -128,6 +129,16 @@ public:
return buffer_.timestamp;
}
bool IsPreBufferReleased() const
{
return isPreBufferReleased_;
}
void SetPreBufferReleased(bool isPreBufferReleased)
{
isPreBufferReleased_ = isPreBufferReleased;
}
void CleanCache()
{
buffer_.Reset();
@ -175,6 +186,7 @@ private:
SurfaceBufferEntry preBuffer_;
float globalZOrder_ = 0.0f;
std::atomic<int> bufferAvailableCount_ = 0;
bool isPreBufferReleased_ = false;
};
}
}