Improved drape benchmark

This commit is contained in:
Roman Kuznetsov 2018-10-04 00:02:55 +03:00 committed by Daria Volvenkova
parent c169804815
commit 111ad7190e
3 changed files with 38 additions and 21 deletions

View file

@ -1262,12 +1262,7 @@ void FrontendRenderer::EndUpdateOverlayTree()
void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFrame)
{
#if defined(DRAPE_MEASURER) && (defined(RENDER_STATISTIC) || defined(TRACK_GPU_MEM))
DrapeMeasurer::Instance().BeforeRenderFrame();
#endif
CHECK(m_context != nullptr, ());
PreRender3dLayer(modelView);
if (m_postprocessRenderer->BeginFrame(m_context, activeFrame))
@ -1374,10 +1369,6 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFram
m_guiRenderer->Render(m_context, make_ref(m_gpuProgramManager), m_myPositionController->IsInRouting(),
modelView);
}
#if defined(DRAPE_MEASURER) && (defined(RENDER_STATISTIC) || defined(TRACK_GPU_MEM))
DrapeMeasurer::Instance().AfterRenderFrame();
#endif
}
void FrontendRenderer::Render2dLayer(ScreenBase const & modelView)
@ -1575,6 +1566,10 @@ void FrontendRenderer::RenderEmptyFrame()
void FrontendRenderer::RenderFrame()
{
#if defined(DRAPE_MEASURER) && (defined(RENDER_STATISTIC) || defined(TRACK_GPU_MEM))
DrapeMeasurer::Instance().BeforeRenderFrame();
#endif
CHECK(m_context != nullptr, ());
if (!m_context->Validate())
{
@ -1618,6 +1613,9 @@ void FrontendRenderer::RenderFrame()
auto const hasForceUpdate = m_forceUpdateScene || m_forceUpdateUserMarks;
isActiveFrame |= hasForceUpdate;
#if defined(SCENARIO_ENABLE)
isActiveFrame = true;
#endif
if (m_frameData.m_modelViewChanged || hasForceUpdate)
UpdateScene(modelView);
@ -1679,6 +1677,10 @@ void FrontendRenderer::RenderFrame()
m_frameData.m_frameTime = m_frameData.m_timer.ElapsedSeconds();
scaleFpsHelper.SetFrameTime(m_frameData.m_frameTime,
m_frameData.m_inactiveFramesCounter + 1 < FrameData::kMaxInactiveFrames);
#if defined(DRAPE_MEASURER) && (defined(RENDER_STATISTIC) || defined(TRACK_GPU_MEM))
DrapeMeasurer::Instance().AfterRenderFrame();
#endif
}
void FrontendRenderer::BuildOverlayTree(ScreenBase const & modelView)
@ -2165,7 +2167,7 @@ void FrontendRenderer::Routine::Do()
m_renderer.OnContextCreate();
#if defined(DEBUG) || defined(DEBUG_DRAPE_XCODE)
#if defined(DEBUG) || defined(DEBUG_DRAPE_XCODE) || defined(SCENARIO_ENABLE)
gui::DrapeGui::Instance().GetScaleFpsHelper().SetVisible(true);
#endif

View file

@ -377,7 +377,7 @@ m2::PointF LayerCacher::CacheScaleFpsLabel(ref_ptr<dp::GraphicsContext> context,
{
MutableLabelDrawer::Params params;
params.m_alphabet = "MGLFPSAUEDcale: 1234567890/()";
params.m_maxLength = 30;
params.m_maxLength = 50;
params.m_anchor = position.m_anchor;
params.m_font = DrapeGui::GetGuiTextFont();
params.m_pivot = position.m_pixelPivot;

View file

@ -9,6 +9,11 @@
#include "platform/http_client.hpp"
#include "platform/platform.hpp"
#include "coding/file_name_utils.hpp"
#include "coding/reader.hpp"
#include "geometry/mercator.hpp"
#include "3party/jansson/myjansson.hpp"
#include <algorithm>
@ -79,19 +84,29 @@ void RunGraphicsBenchmark(Framework * framework)
#ifdef SCENARIO_ENABLE
using namespace df;
// Request scenarios from the server.
platform::HttpClient request("http://osmz.ru/mwm/graphics_benchmark.json");
if (!request.RunHttpRequest())
// Load scenario from file.
auto const fn = base::JoinPath(GetPlatform().SettingsDir(), "graphics_benchmark.json");
if (!GetPlatform().IsFileExistsByFullPath(fn))
return;
std::string benchmarkData;
try
{
ReaderPtr<Reader>(GetPlatform().GetReader(fn)).ReadAsString(benchmarkData);
}
catch (RootException const & e)
{
LOG(LCRITICAL, ("Error reading benchmark file: ", e.what()));
return;
}
std::shared_ptr<BenchmarkHandle> handle = std::make_shared<BenchmarkHandle>();
// Parse scenarios.
std::vector<m2::PointD> points;
string const & result = request.ServerResponse();
try
{
base::Json root(result.c_str());
base::Json root(benchmarkData.c_str());
json_t * scenariosNode = json_object_get(root.get(), "scenarios");
if (scenariosNode == nullptr || !json_is_array(scenariosNode))
return;
@ -128,12 +143,12 @@ void RunGraphicsBenchmark(Framework * framework)
json_t * centerNode = json_object_get(stepElem, "center");
if (centerNode == nullptr)
return;
double x = 0.0, y = 0.0;
FromJSONObject(centerNode, "x", x);
FromJSONObject(centerNode, "y", y);
double lat = 0.0, lon = 0.0;
FromJSONObject(centerNode, "lat", lat);
FromJSONObject(centerNode, "lon", lon);
json_int_t zoomLevel = -1;
FromJSONObject(stepElem, "zoomLevel", zoomLevel);
m2::PointD const pt(x, y);
m2::PointD const pt = MercatorBounds::FromLatLon(lat, lon);
points.push_back(pt);
scenario.push_back(std::unique_ptr<ScenarioManager::Action>(
new ScenarioManager::CenterViewportAction(pt, static_cast<int>(zoomLevel))));