Report the actual GPU framerate rather than the main thread submit rate when using the filament renderer.
PiperOrigin-RevId: 838775463 Change-Id: If66644d284a4a9e0263cf31bfbd1785b18e0209b
This commit is contained in:
committed by
Copybara-Service
parent
4896e698f6
commit
448fc0e4d5
@@ -57,17 +57,6 @@ void Renderer::Render(const mjModel* model, mjData* data,
|
||||
|
||||
mjrRect main_viewport = {0, 0, width, height};
|
||||
mjr_render(main_viewport, data ? &scene_ : nullptr, &render_context_);
|
||||
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
auto delta_time = now - last_fps_update_;
|
||||
const double interval = std::chrono::duration<double>(delta_time).count();
|
||||
|
||||
++frames_;
|
||||
if (interval > 0.2) { // only update FPS stat at most 5 times per second
|
||||
last_fps_update_ = now;
|
||||
fps_ = frames_ / interval;
|
||||
frames_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::SaveScreenshot(const std::string& filename, int width,
|
||||
|
||||
@@ -54,15 +54,10 @@ class Renderer {
|
||||
// Rendering flags.
|
||||
mjtByte* GetRenderFlags() { return scene_.flags; }
|
||||
|
||||
// Returns the current, average frame rate.
|
||||
double GetFrameRate() const { return fps_; }
|
||||
|
||||
// Returns the render context.
|
||||
const mjrContext& GetContext() const { return render_context_; }
|
||||
|
||||
private:
|
||||
using TimePoint = std::chrono::time_point<std::chrono::steady_clock>;
|
||||
|
||||
// Resets the renderer; no rendering will occur until Init() is called again.
|
||||
void Deinit();
|
||||
|
||||
@@ -70,10 +65,6 @@ class Renderer {
|
||||
mjrContext render_context_;
|
||||
mjvScene scene_;
|
||||
bool initialized_ = false;
|
||||
|
||||
int frames_ = 0;
|
||||
TimePoint last_fps_update_;
|
||||
double fps_ = 0;
|
||||
};
|
||||
|
||||
} // namespace mujoco::platform
|
||||
|
||||
Reference in New Issue
Block a user