进入Adaptive Sync提前送显模式需要关闭vsync校准

Signed-off-by: 陶春龙 <taochunlong@huawei.com>
This commit is contained in:
陶春龙 2024-09-23 17:16:54 +08:00
parent 5791bc5068
commit 68a064891e
6 changed files with 22 additions and 9 deletions

View File

@ -63,6 +63,7 @@ public:
/* set a temporary period used only for VSyncSampler::GetHardwarePeriod interface */
void SetPendingMode(const OutputPtr &output, int64_t period, int64_t timestamp);
void SetVsyncSamplerEnabled(const OutputPtr &output, bool enabled);
bool GetVsyncSamplerEnabled(const OutputPtr &output);
private:
HdiBackend() = default;
virtual ~HdiBackend() = default;

View File

@ -97,6 +97,7 @@ public:
void ReleaseLayers(sptr<SyncFence>& releaseFence);
int32_t GetBufferCacheSize();
void SetVsyncSamplerEnabled(bool enabled);
bool GetVsyncSamplerEnabled();
private:
HdiDevice *device_ = nullptr;
@ -150,7 +151,7 @@ private:
void ClearBufferCache();
std::map<LayerInfoPtr, sptr<SyncFence>> GetLayersReleaseFenceLocked();
bool disableVsyncSample_ = false;
bool enableVsyncSample_ = true;
};
} // namespace Rosen
} // namespace OHOS

View File

@ -257,6 +257,15 @@ void HdiBackend::SetVsyncSamplerEnabled(const OutputPtr &output, bool enabled)
output->SetVsyncSamplerEnabled(enabled);
}
bool HdiBackend::GetVsyncSamplerEnabled(const OutputPtr &output)
{
if (output == nullptr) {
HLOGE("output is nullptr.");
return false;
}
output->GetVsyncSamplerEnabled();
}
void HdiBackend::ResetDevice()
{
if (device_) {

View File

@ -545,7 +545,7 @@ int32_t HdiOutput::UpdateInfosAfterCommit(sptr<SyncFence> fbFence)
int64_t timestamp = thirdFrameAheadPresentFence_->SyncFileReadTimestamp();
bool startSample = false;
if (timestamp != SyncFence::FENCE_PENDING_TIMESTAMP) {
startSample = !disableVsyncSample_ && sampler_->AddPresentFenceTime(timestamp);
startSample = enableVsyncSample_ && sampler_->AddPresentFenceTime(timestamp);
RecordCompositionTime(timestamp);
bool presentTimeUpdated = false;
LayerPtr uniRenderLayer = nullptr;
@ -580,7 +580,12 @@ int32_t HdiOutput::UpdateInfosAfterCommit(sptr<SyncFence> fbFence)
void HdiOutput::SetVsyncSamplerEnabled(bool enabled)
{
std::unique_lock<std::mutex> lock(mutex_);
disableVsyncSample_ = !enabled;
enableVsyncSample_ = enabled;
}
bool HdiOutput::GetVsyncSamplerEnabled()
{
return enableVsyncSample_;
}
@ -714,7 +719,7 @@ int32_t HdiOutput::StartVSyncSampler(bool forceReSample)
{
std::unique_lock<std::mutex> lock(mutex_);
ScopedBytrace func("HdiOutput::StartVSyncSampler, forceReSample:" + std::to_string(forceReSample));
if (disableVsyncSample_) {
if (!enableVsyncSample_) {
ScopedBytrace func("disabled vsyncSample");
return GRAPHIC_DISPLAY_FAILURE;
}

View File

@ -231,19 +231,17 @@ void RSHardwareThread::CommitAndReleaseLayers(OutputPtr output, const std::vecto
RS_LOGD("RSHardwareThread::CommitAndReleaseLayers send layer isAdaptive: %{public}u", isAdaptive);
if (isAdaptive) {
RS_TRACE_NAME("RSHardwareThread::CommitAndReleaseLayers PostTask in Adaptive Mode");
if (!isLastAdaptive_) {
if (hdiBackend_->GetVsyncSamplerEnabled(output)) {
// enter adaptive sync mode must disable vsync sampler
isLastAdaptive_ = true;
hdiBackend_->SetVsyncSamplerEnabled(output, false);
}
PostTask(task);
return;
}
}
if (isLastAdaptive_) {
if (!hdiBackend_->GetVsyncSamplerEnabled(output)) {
// exit adaptive sync mode must restore vsync sampler
hdiBackend_->SetVsyncSamplerEnabled(output, true);
isLastAdaptive_ = false;
}
auto period = CreateVSyncSampler()->GetHardwarePeriod();
int64_t pipelineOffset = hgmCore.GetPipelineOffset();

View File

@ -104,7 +104,6 @@ private:
std::map<uint32_t, uint64_t> refreshRateCounts_;
sptr<SyncFence> releaseFence_ = SyncFence::InvalidFence();
int64_t delayTime_ = 0;
bool isLastAdaptive_ = false;
friend class RSUniRenderThread;
friend class RSUifirstManager;