Added imgui debug dialog for render statistics
This commit is contained in:
parent
d2d06c9f73
commit
d2597482e0
3 changed files with 39 additions and 2 deletions
|
@ -11,6 +11,8 @@
|
||||||
#define ENABLE_SELECTION_DEBUG_OUTPUT 0
|
#define ENABLE_SELECTION_DEBUG_OUTPUT 0
|
||||||
// Renders a small sphere in the center of the bounding box of the current selection when no gizmo is active
|
// Renders a small sphere in the center of the bounding box of the current selection when no gizmo is active
|
||||||
#define ENABLE_RENDER_SELECTION_CENTER 0
|
#define ENABLE_RENDER_SELECTION_CENTER 0
|
||||||
|
// Shows an imgui dialog with render related data
|
||||||
|
#define ENABLE_RENDER_STATISTICS 1
|
||||||
|
|
||||||
|
|
||||||
//====================
|
//====================
|
||||||
|
|
|
@ -52,6 +52,9 @@
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#if ENABLE_RENDER_STATISTICS
|
||||||
|
#include <chrono>
|
||||||
|
#endif // ENABLE_RENDER_STATISTICS
|
||||||
|
|
||||||
static const float TRACKBALLSIZE = 0.8f;
|
static const float TRACKBALLSIZE = 0.8f;
|
||||||
static const float GROUND_Z = -0.02f;
|
static const float GROUND_Z = -0.02f;
|
||||||
|
@ -1581,6 +1584,10 @@ void GLCanvas3D::render()
|
||||||
if (!_set_current() || !_3DScene::init(m_canvas))
|
if (!_set_current() || !_3DScene::init(m_canvas))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if ENABLE_RENDER_STATISTICS
|
||||||
|
auto start_time = std::chrono::high_resolution_clock::now();
|
||||||
|
#endif // ENABLE_RENDER_STATISTICS
|
||||||
|
|
||||||
if (m_bed.get_shape().empty())
|
if (m_bed.get_shape().empty())
|
||||||
{
|
{
|
||||||
// this happens at startup when no data is still saved under <>\AppData\Roaming\Slic3rPE
|
// this happens at startup when no data is still saved under <>\AppData\Roaming\Slic3rPE
|
||||||
|
@ -1666,9 +1673,26 @@ void GLCanvas3D::render()
|
||||||
if ((m_layers_editing.last_object_id >= 0) && (m_layers_editing.object_max_z() > 0.0f))
|
if ((m_layers_editing.last_object_id >= 0) && (m_layers_editing.object_max_z() > 0.0f))
|
||||||
m_layers_editing.render_overlay(*this);
|
m_layers_editing.render_overlay(*this);
|
||||||
|
|
||||||
|
#if ENABLE_RENDER_STATISTICS
|
||||||
|
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||||
|
imgui.set_next_window_bg_alpha(0.5f);
|
||||||
|
imgui.begin(std::string("Render statistics"), ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||||
|
imgui.text("Last frame: ");
|
||||||
|
ImGui::SameLine();
|
||||||
|
imgui.text(std::to_string(m_render_stats.last_frame));
|
||||||
|
ImGui::SameLine();
|
||||||
|
imgui.text(" ms");
|
||||||
|
imgui.end();
|
||||||
|
#endif // ENABLE_RENDER_STATISTICS
|
||||||
|
|
||||||
wxGetApp().imgui()->render();
|
wxGetApp().imgui()->render();
|
||||||
|
|
||||||
m_canvas->SwapBuffers();
|
m_canvas->SwapBuffers();
|
||||||
|
|
||||||
|
#if ENABLE_RENDER_STATISTICS
|
||||||
|
auto end_time = std::chrono::high_resolution_clock::now();
|
||||||
|
m_render_stats.last_frame = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count();
|
||||||
|
#endif // ENABLE_RENDER_STATISTICS
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::select_all()
|
void GLCanvas3D::select_all()
|
||||||
|
@ -2751,7 +2775,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
m_regenerate_volumes = false;
|
m_regenerate_volumes = false;
|
||||||
m_selection.translate(cur_pos - m_mouse.drag.start_position_3D);
|
m_selection.translate(cur_pos - m_mouse.drag.start_position_3D);
|
||||||
wxGetApp().obj_manipul()->update_settings_value(m_selection);
|
wxGetApp().obj_manipul()->update_settings_value(m_selection);
|
||||||
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,7 +319,6 @@ class GLCanvas3D
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
|
||||||
struct SlaCap
|
struct SlaCap
|
||||||
{
|
{
|
||||||
struct Triangles
|
struct Triangles
|
||||||
|
@ -399,6 +398,15 @@ private:
|
||||||
void render(const GLCanvas3D& canvas) const;
|
void render(const GLCanvas3D& canvas) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if ENABLE_RENDER_STATISTICS
|
||||||
|
struct RenderStats
|
||||||
|
{
|
||||||
|
long long last_frame;
|
||||||
|
|
||||||
|
RenderStats() : last_frame(0) {}
|
||||||
|
};
|
||||||
|
#endif // ENABLE_RENDER_STATISTICS
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ECursorType : unsigned char
|
enum ECursorType : unsigned char
|
||||||
{
|
{
|
||||||
|
@ -464,6 +472,10 @@ private:
|
||||||
|
|
||||||
GCodePreviewVolumeIndex m_gcode_preview_volume_index;
|
GCodePreviewVolumeIndex m_gcode_preview_volume_index;
|
||||||
|
|
||||||
|
#if ENABLE_RENDER_STATISTICS
|
||||||
|
RenderStats m_render_stats;
|
||||||
|
#endif // ENABLE_RENDER_STATISTICS
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar);
|
GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar);
|
||||||
~GLCanvas3D();
|
~GLCanvas3D();
|
||||||
|
|
Loading…
Reference in a new issue