Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low Frame Rate in OpenGL When Opening Multiple Windows, Works Fine in DX11 #8307

Open
imkcy9 opened this issue Jan 11, 2025 · 2 comments
Open

Comments

@imkcy9
Copy link

imkcy9 commented Jan 11, 2025

Version/Branch of Dear ImGui:

Version 1.91.X, Branch: master

Back-ends:

imgui_impl_glfw.h.cpp + imgui_impl_XXX.cpp

Compiler, OS:

Win11 + MSVC2022

Full config/build information:

No response

Details:

Hi everyone,

I encountered a performance issue when using ImGui with OpenGL on Windows. Specifically, when rendering multiple windows, the frame rate drops significantly in OpenGL mode. However, the same setup works perfectly fine with DirectX 11, and the frame rate remains stable.

Here’s a summary of the problem:

Frame rate drops noticeably when multiple ImGui windows are rendered in OpenGL.
Switching to DirectX 11 solves the issue, even with the same number of windows and content.
I am using the latest version of ImGui and my GPU drivers are up to date.
Could this be a bug in ImGui’s OpenGL implementation, or might it be related to OpenGL context handling or resource management? Is there any recommended way to optimize OpenGL performance in this scenario?

Any advice or insights would be greatly appreciated.

Thank you!

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

#include "imguiwidget.h"

ImGuiWidget::ImGuiWidget(QWidget *parent) : QOpenGLWidget(parent)
{

}

ImGuiWidget::~ImGuiWidget()
{

}

void ImGuiWidget::initializeGL() {
initializeOpenGLFunctions();
ref = QtImGui::initialize(this, false);

// Set ImGui style to light theme
ImGui::StyleColorsLight();

// Update at 60 fps
auto* timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(16);

}

void ImGuiWidget::paintGL() {
QtImGui::newFrame(ref);
auto& io = ImGui::GetIO();
static bool use_work_area = false;

const ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(use_work_area ? viewport->WorkPos : viewport->Pos);
ImGui::SetNextWindowSize(use_work_area ? viewport->WorkSize : viewport->Size);

onFrame(io.DeltaTime);

// Do render before ImGui UI is rendered
glViewport(0, 0, width(), height());
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
glClear(GL_COLOR_BUFFER_BIT);

ImGui::Render();
QtImGui::render(ref);

}

ImGuiWindowFlags ImGuiWidget::defaultWindowFlags() {
return ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings;
}

@imkcy9
Copy link
Author

imkcy9 commented Jan 11, 2025

1.Framerate is 120/fps when only one window open,
1736612625226(1)
2.Framerate drops to 67/fps when opening over 40 windows.
1736612567486

@imkcy9
Copy link
Author

imkcy9 commented Jan 11, 2025

Frame rate remains stable in 120/fps even over 100 windows opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant