render statistics - closes #255
This commit is contained in:
parent
1025a3407e
commit
bc151506dc
6 changed files with 40 additions and 5 deletions
|
@ -1353,11 +1353,6 @@ struct WorldEditorImpl : public WorldEditor
|
|||
|
||||
virtual void update() override
|
||||
{
|
||||
char fps[100];
|
||||
copyString(fps, sizeof(fps), "FPS: ");
|
||||
toCString(m_engine->getFPS(), fps + strlen(fps), sizeof(fps) - strlen(fps), 1);
|
||||
static_cast<RenderScene*>(m_engine->getScene(crc32("renderer")))->setDebugText(m_fps_text, fps);
|
||||
|
||||
updateGoTo();
|
||||
|
||||
for (int i = 0; i < m_plugins.size(); ++i)
|
||||
|
@ -2657,6 +2652,12 @@ struct WorldEditorImpl : public WorldEditor
|
|||
}
|
||||
|
||||
|
||||
virtual int getFPSText() const override
|
||||
{
|
||||
return m_fps_text;
|
||||
}
|
||||
|
||||
|
||||
virtual bool runTest(const Path& undo_stack_path, const Path& result_universe_path) override
|
||||
{
|
||||
newUniverse();
|
||||
|
|
|
@ -120,6 +120,7 @@ namespace Lumix
|
|||
virtual Vec3 getCameraRaycastHit() = 0;
|
||||
virtual void toggleMeasure() = 0;
|
||||
virtual class MeasureTool* getMeasureTool() const = 0;
|
||||
virtual int getFPSText() const = 0;
|
||||
|
||||
virtual void saveUndoStack(const Path& path) = 0;
|
||||
virtual bool executeUndoStack(const Path& path) = 0;
|
||||
|
|
|
@ -506,6 +506,18 @@ struct PipelineInstanceImpl : public PipelineInstance
|
|||
}
|
||||
|
||||
|
||||
virtual int getDrawCalls() const override
|
||||
{
|
||||
return m_draw_calls_count;
|
||||
}
|
||||
|
||||
|
||||
virtual int getRenderedVerticesCount() const override
|
||||
{
|
||||
return m_vertices_count;
|
||||
}
|
||||
|
||||
|
||||
void sourceLoaded(Resource::State old_state, Resource::State new_state)
|
||||
{
|
||||
if (old_state != Resource::State::READY && new_state == Resource::State::READY)
|
||||
|
@ -1002,6 +1014,8 @@ struct PipelineInstanceImpl : public PipelineInstance
|
|||
setUniform(morph_const_location, data->m_morph_const);
|
||||
setUniform(quad_size_location, data->m_size);
|
||||
setUniform(quad_min_location, data->m_min);
|
||||
++m_draw_calls_count;
|
||||
m_vertices_count += mesh_part_indices_count;
|
||||
renderGeometry(mesh_part_indices_count * data->m_index, mesh_part_indices_count);
|
||||
++info;
|
||||
}
|
||||
|
|
|
@ -79,6 +79,8 @@ class LUMIX_ENGINE_API PipelineInstance abstract
|
|||
virtual RenderScene* getScene() = 0;
|
||||
virtual int getWidth() = 0;
|
||||
virtual int getHeight() = 0;
|
||||
virtual int getDrawCalls() const = 0;
|
||||
virtual int getRenderedVerticesCount() const = 0;
|
||||
virtual CustomCommandHandler& addCustomCommandHandler(const char* name) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -334,6 +334,19 @@ class App
|
|||
}
|
||||
|
||||
|
||||
void showStats()
|
||||
{
|
||||
char stats[1000];
|
||||
Lumix::copyString(stats, sizeof(stats), "FPS: ");
|
||||
Lumix::toCString(m_world_editor->getEngine().getFPS(), stats + strlen(stats), sizeof(stats) - strlen(stats), 1);
|
||||
Lumix::catCString(stats, sizeof(stats), ", Draw calls: ");
|
||||
Lumix::toCString(m_main_window->getSceneView()->getPipeline()->getDrawCalls(), stats + strlen(stats), sizeof(stats) - strlen(stats));
|
||||
Lumix::catCString(stats, sizeof(stats), ", Vertices: ");
|
||||
Lumix::toCStringPretty(m_main_window->getSceneView()->getPipeline()->getRenderedVerticesCount(), stats + strlen(stats), sizeof(stats) - strlen(stats));
|
||||
static_cast<Lumix::RenderScene*>(m_world_editor->getEngine().getScene(crc32("renderer")))->setDebugText(m_world_editor->getFPSText(), stats);
|
||||
}
|
||||
|
||||
|
||||
void run()
|
||||
{
|
||||
FPSLimiter* fps_limiter = FPSLimiter::create(60, m_allocator);
|
||||
|
@ -350,6 +363,9 @@ class App
|
|||
{
|
||||
m_world_editor->getEngine().getRenderer().renderGame();
|
||||
}
|
||||
|
||||
showStats();
|
||||
|
||||
m_world_editor->update();
|
||||
if (m_main_window->getSceneView()->isFrameDebuggerActive())
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ public:
|
|||
explicit SceneView(QWidget* parent = NULL);
|
||||
void setWorldEditor(Lumix::WorldEditor* editor);
|
||||
void setPipeline(Lumix::PipelineInstance& pipeline) { m_pipeline = &pipeline; }
|
||||
Lumix::PipelineInstance* getPipeline() const { return m_pipeline; }
|
||||
QWidget* getViewWidget() { return m_view; }
|
||||
float getNavigationSpeed() const;
|
||||
void changeNavigationSpeed(float value);
|
||||
|
|
Loading…
Reference in a new issue