!455 提供dump fps的原始时间戳数据

Merge pull request !455 from hudi/master
This commit is contained in:
openharmony_ci 2022-02-18 07:08:58 +00:00 committed by Gitee
commit b60e7a3663
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
10 changed files with 89 additions and 1 deletions

View File

@ -34,6 +34,8 @@ public:
explicit HdiLayer(uint32_t screenId);
virtual ~HdiLayer();
static constexpr int FRAME_RECORDS_NUM = 128;
/* output create and set layer info */
static std::shared_ptr<HdiLayer> CreateHdiLayer(uint32_t screenId);
@ -49,6 +51,8 @@ public:
void UpdateLayerInfo(const LayerInfoPtr &layerInfo);
void SetHdiLayerInfo();
uint32_t GetLayerId() const;
void RecordPresentTime(const sptr<SyncFence> &fbFence);
void Dump(std::string &result);
int32_t SetLayerColorTransform(const float *matrix) const;
int32_t SetLayerColorDataSpace(ColorDataSpace colorSpace) const;
@ -67,6 +71,13 @@ private:
sptr<SyncFence> releaseFence_ = SyncFence::INVALID_FENCE;
};
struct PresentTimeRecord {
int64_t presentTime = 0;
sptr<SyncFence> presentFence = SyncFence::INVALID_FENCE;
};
PresentTimeRecord presentTimeRecords[FRAME_RECORDS_NUM];
uint32_t count = 0;
uint32_t screenId_ = INT_MAX;
uint32_t layerId_ = INT_MAX;
bool isInUsing_ = false;

View File

@ -52,6 +52,7 @@ public:
int32_t ReleaseFramebuffer(const sptr<SyncFence> &releaseFence);
void FramebufferSemWait();
void Dump(std::string &result) const;
void DumpFps(std::string &result, const std::string &arg) const;
private:
sptr<HdiFramebufferSurface> fbSurface_ = nullptr;

View File

@ -122,6 +122,11 @@ void HdiBackend::Repaint(std::vector<OutputPtr> &outputs)
// return
}
for (auto iter = layersMap.begin(); iter != layersMap.end(); ++iter) {
const LayerPtr &layer = iter->second;
layer->RecordPresentTime(fbFence);
}
ReleaseLayerBuffer(screenId, layersMap);
// wrong check

View File

@ -279,6 +279,14 @@ SurfaceError HdiLayer::ReleasePrevBuffer()
return ret;
}
void HdiLayer::RecordPresentTime(const sptr<SyncFence> &fbFence)
{
if (currSbuffer_->sbuffer_ != prevSbuffer_->sbuffer_) {
presentTimeRecords[count].presentFence = fbFence;
count = (count + 1) % FRAME_RECORDS_NUM;
}
}
void HdiLayer::MergeWithFramebufferFence(const sptr<SyncFence> &fbAcquireFence)
{
if (fbAcquireFence != nullptr) {
@ -315,5 +323,16 @@ void HdiLayer::CheckRet(int32_t ret, const char* func)
}
}
void HdiLayer::Dump(std::string &result)
{
for (int i = 0; i < FRAME_RECORDS_NUM; i++) {
if (presentTimeRecords[i].presentFence != SyncFence::INVALID_FENCE) {
presentTimeRecords[i].presentTime = presentTimeRecords[i].presentFence->SyncFileReadTimestamp();
presentTimeRecords[i].presentFence = SyncFence::INVALID_FENCE;
}
result += std::to_string(presentTimeRecords[i].presentTime) + "\n";
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -206,10 +206,27 @@ void HdiOutput::Dump(std::string &result) const
for (auto iter = surfaceIdMap_.begin(); iter != surfaceIdMap_.end(); ++iter) {
iter->second->SetLayerStatus(false);
const LayerPtr &layer = iter->second;
std::string name;
layer->GetLayerInfo()->GetSurface()->GetName(name);
const LayerInfoPtr &info = layer->GetLayerInfo();
result += " surfaceId[" + std::to_string(iter->first) + "]:\n";
result += " surface [" + name + "] Id[" + std::to_string(iter->first) + "]:\n";
info->Dump(result);
}
}
void HdiOutput::DumpFps(std::string &result, const std::string &arg) const
{
result.append("\n");
for (auto iter = surfaceIdMap_.begin(); iter != surfaceIdMap_.end(); ++iter) {
iter->second->SetLayerStatus(false);
const LayerPtr &layer = iter->second;
std::string name;
layer->GetLayerInfo()->GetSurface()->GetName(name);
if (name == arg) {
result += " surface [" + name + "] Id[" + std::to_string(iter->first) + "]:\n";
layer->Dump(result);
}
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -107,10 +107,12 @@ int RSRenderService::Dump(int fd, const std::vector<std::u16string>& args)
std::unordered_set<std::u16string> argSets;
std::u16string arg1(u"display");
std::u16string arg2(u"surface");
std::u16string arg3(u"fps");
for (decltype(args.size()) index = 0; index < args.size(); ++index) {
argSets.insert(args[index]);
}
std::string dumpString;
std::string layerArg;
if (screenManager_ == nullptr) {
return OHOS::INVALID_OPERATION;
}
@ -122,6 +124,16 @@ int RSRenderService::Dump(int fd, const std::vector<std::u16string>& args)
return screenManager_->SurfaceDump(dumpString);
}).wait();
}
auto iter = argSets.find(arg3);
if (iter != argSets.end()) {
argSets.erase(iter);
if (!argSets.empty()) {
layerArg = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> {}.to_bytes(*argSets.begin());
}
mainThread_->ScheduleTask([this, &dumpString, &layerArg]() {
return screenManager_->FpsDump(dumpString, layerArg);
}).wait();
}
if (dumpString.size() == 0) {
return OHOS::INVALID_OPERATION;
}

View File

@ -349,6 +349,14 @@ void RSScreen::SurfaceDump(int32_t screenIndex, std::string& dumpString)
hdiOutput_->Dump(dumpString);
}
void RSScreen::FpsDump(int32_t screenIndex, std::string& dumpString, std::string& arg)
{
if (hdiOutput_ == nullptr) {
return;
}
hdiOutput_->DumpFps(dumpString, arg);
}
void RSScreen::SetScreenBacklight(uint32_t level)
{
if (hdiScreen_->SetScreenBacklight(level) < 0) {

View File

@ -61,6 +61,7 @@ public:
virtual void SetProducerSurface(sptr<Surface> producerSurface) = 0;
virtual void DisplayDump(int32_t screenIndex, std::string& dumpString) = 0;
virtual void SurfaceDump(int32_t screenIndex, std::string& dumpString) = 0;
virtual void FpsDump(int32_t screenIndex, std::string& dumpString, std::string& arg) = 0;
virtual void SetScreenBacklight(uint32_t level) = 0;
virtual int32_t GetScreenBacklight() const = 0;
virtual int32_t GetScreenSupportedColorGamuts(std::vector<ScreenColorGamut> &mode) const = 0;
@ -105,6 +106,7 @@ public:
void SetProducerSurface(sptr<Surface> producerSurface) override;
void DisplayDump(int32_t screenIndex, std::string& dumpString) override;
void SurfaceDump(int32_t screenIndex, std::string& dumpString) override;
void FpsDump(int32_t screenIndex, std::string& dumpString, std::string& arg) override;
void SetScreenBacklight(uint32_t level) override;
int32_t GetScreenBacklight() const override;
int32_t GetScreenSupportedColorGamuts(std::vector<ScreenColorGamut> &mode) const override;

View File

@ -591,6 +591,15 @@ void RSScreenManager::SurfaceDump(std::string& dumpString)
}
}
void RSScreenManager::FpsDump(std::string& dumpString, std::string& arg)
{
int32_t index = 0;
for (const auto &[id, screen] : screens_) {
screen->FpsDump(index, dumpString, arg);
index++;
}
}
int32_t RSScreenManager::GetScreenSupportedColorGamutsLocked(ScreenId id, std::vector<ScreenColorGamut>& mode) const
{
if (screens_.count(id) == 0) {

View File

@ -109,6 +109,8 @@ public:
virtual void SurfaceDump(std::string& dumpString) = 0;
virtual void FpsDump(std::string& dumpString, std::string& arg) = 0;
virtual int32_t GetScreenBacklight(ScreenId id) = 0;
virtual void SetScreenBacklight(ScreenId id, uint32_t level) = 0;
@ -197,6 +199,8 @@ public:
void SurfaceDump(std::string& dumpString) override;
void FpsDump(std::string& dumpString, std::string& arg) override;
int32_t GetScreenBacklight(ScreenId id) override;
void SetScreenBacklight(ScreenId id, uint32_t level) override;