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

Glitches in OpenGL/DX renderers on Intel GPU #3033

Open
smok95 opened this issue Feb 20, 2020 · 18 comments
Open

Glitches in OpenGL/DX renderers on Intel GPU #3033

smok95 opened this issue Feb 20, 2020 · 18 comments

Comments

@smok95
Copy link

smok95 commented Feb 20, 2020

(you may also go to Demo>About Window, and click "Config/Build Information" to obtain a bunch of detailed information that you can paste here)

Version/Branch of Dear ImGui:

Dear ImGui 1.76 WIP (17502)
--------------------------------
sizeof(size_t): 4, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _MSC_VER=1924
--------------------------------
io.BackendPlatformName: imgui_impl_win32
io.BackendRendererName: imgui_impl_dx10
io.ConfigFlags: 0x00000021
 NavEnableKeyboard
 NoMouseCursorChange
io.ConfigWindowsMemoryCompactTimer = 60.0f
io.BackendFlags: 0x0000000E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1167.00,728.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Dear ImGui 1.76 WIP (17502)
--------------------------------
sizeof(size_t): 4, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _MSC_VER=1924
--------------------------------
io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000000
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigWindowsMemoryCompactTimer = 60.0f
io.BackendFlags: 0x00000006
 HasMouseCursors
 HasSetMousePos
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1268.00,357.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Compiler: msvc1924(vs2019) / msvc1600(vs2010)
Operating System: windows 7 64bit / windows 10 Pro 64bit (1909, OS Build:18363.657)

My Issue/Question:
what an awesome project. Thank you for your hard work!

I did download source code and build examples using vs2019( and vs2010)
(I had never change source code.)

and ran an example program.
(I did a test on windows 7 64bit and Windows 10 64bit with vs2010 and vs2019)

Please watch the below screenshots and gif animation carefully.
Irregularly something(small line?) blink slightly

I wonder why does this happen.

Screenshots/Video
imgui_blink_something

imgui_blink_something1
imgui_blink_something2

@ocornut ocornut changed the title unknown something blink Glitches in OpenGL renderer Feb 20, 2020
@ocornut
Copy link
Owner

ocornut commented Feb 20, 2020

My feeling is that it may be an issue with OpenGL drivers.

@smok95
Copy link
Author

smok95 commented Feb 20, 2020

Thanks very much for quick reply
It also has same issue with directx.
If it was a opengl drivers issue, is it also directx drivers issue?
Thanks

@ocornut
Copy link
Owner

ocornut commented Feb 20, 2020

Maybe it is a hardware issue?
I find it surprising that this kind of effect would happen with the example app accross multiple backends.

@ocornut
Copy link
Owner

ocornut commented Feb 20, 2020

You can open Tools>Metrics and look at the polygon count, try to record a video and see if the polygon count changed when the glitch happen.

@smok95
Copy link
Author

smok95 commented Feb 20, 2020

Thank you very much
I will check just as you said.

@djdeath
Copy link
Contributor

djdeath commented Mar 14, 2020

Are you using an Intel GPU? I've noticed the same on my laptop.

@smok95
Copy link
Author

smok95 commented Mar 15, 2020

Yes, I'm using an Intel GPU(UHD Graphics 630)

@jon-dez
Copy link

jon-dez commented Apr 13, 2020

If it helps narrow down this issue I'd also like to mention that the same thing happens on my laptop with Intel UHD Graphics 620 when using OpenGl 3.

Seems consistent with both of you guys.

@ocornut ocornut changed the title Glitches in OpenGL renderer Glitches in OpenGL/DX renderers on Intel GPU Apr 13, 2020
@ocornut
Copy link
Owner

ocornut commented Apr 13, 2020

OK so this looks very real, and even more surprising if it happens with multiple graphics API. I don’t think I myself have the knowledge to begin to guess what we might be doing wrong.

If you have issue on your machine, could you try running variety of examples and see where the bug happens for you (do you have it with dx9/dx11/dx12/vulkan as well?).

@Myszkoj
Copy link

Myszkoj commented Nov 30, 2021

I noticed that those glitches tend to be at least partially dependant on the mouse cursor. When I move it fast over many controls glitches start to statistically mimic movement of the cursor. Do you use some custom cursor rendering, or do you change it through OS events?

@Myszkoj
Copy link

Myszkoj commented Nov 30, 2021

Ok, I don't know if this is coincidance, but in my case they have color of the text.
I changed my theme so that text color was always different than other GUI elements.
What is more interesting is that sometimes glitches had color of the text from a previous test, so if I changed it to red, they show up red, but if I changed it to green they show up red few times, and then green.
I assume that ImGui treats font rendering the same as any other element(it renders one or two triangles with UV on the texture/glyph atlas), so there is probably an array with vertex/color data per quad. There is usually a lot of characters compared to other GUI elements so text color is more common in that buffer. My guess is that those glitches are remnants of the previous iteration in that buffer. At some point when I was designing my own control I looked at polyline rendering(or something similar) and you basically append the buffer with the assumption that you will use N amount of triangles/quads, but if you use less than that you have to shift back the remaining, unused triangles/quads. Does that sound familiar, or I remember something incorrectly? Maybe there is a bug in one of those functions and you return wrong amount of space in the buffer? That's the only explenation that I can think of why those glitches would have those colors.

@ocornut
Copy link
Owner

ocornut commented Nov 30, 2021

There's no bug of that sort in the ImDrawList functions, it's entirely a bug between the backend code and the driver.
Perhaps double-buffering those buffer would help but normally as I understand it shouldn't be necessary.

@Myszkoj
Copy link

Myszkoj commented Nov 30, 2021

Then how do you explain the color behaviors? They are definitely not random.

@Myszkoj
Copy link

Myszkoj commented Nov 30, 2021

Are those draw lists cleared to zeros every frame, or you simply set current buffer size to 0?

@ocornut
Copy link
Owner

ocornut commented Nov 30, 2021

Then how do you explain the color behaviors? They are definitely not random.

It's probably using data from Frame N+1 on Frame N or vice-versa, it makes sense.
I suppose if backends has N in-flight buffers (where N can be configured by user to be 2 or 3).
But it only happens with Intel GPU drivers afaik, what is your GPU and driver version? Can you try updating drivers?

Are those draw lists cleared to zeros every frame, or you simply set current buffer size to 0?

The later, we don't superfluously clear data we don't need to clear. It wouldn't be a correct solution to clear them either way.

PS: This is not an IRC channel, please avoid spamming either threads with oneliner questions. This needs thoughtful research. Each of your message here are e-mailed to ~1000 people.

@Myszkoj
Copy link

Myszkoj commented Nov 30, 2021

Keeping buffer from the previous frame and setting its size to 0 at the beginning of the new frame is of course a good idea.
It was just a guess and at that time, it looked for me like a random quad with undefined state caused by some pointer shifting logic, but I was wrong.
I can confirm that problem disappears when I switch to NVIDIA gpu.
My intel card: Intel UHD Graphics 630
Drivers at the time glitch occurs: 27.20.100.9664 (newest according to windows).
I looked inside ImGui::ImGui_ImplOpenGL3_RenderDrawData function and noticed that you create and destroy vertex array object every frame. Maybe there is something wrong with vbo-vao binding in the intel drivers(new vao binds storage of the vbo from the previous frame). I tried to make this vao global and generate it in ImGui_ImplOpenGL3_CreateDeviceObjects and destroy in ImGui_ImplOpenGL3_DestroyDeviceObjects, but it doesn't work and I don't have a knowlage of your code to make it work and test.
Anyway, sorry for the spam and that I couldn't help.

@Voxtric
Copy link

Voxtric commented Jan 4, 2022

I've been having this exact issue as well. I've gone down quite a rabbit hole in trying to figure it out, and I have managed to impact this but never eliminate it. What I've tried and the results below:

  • Updating from ImGUI 1.84 WIP to 1.86 Release: Was unable to tell as docking windows kept freezing when interacted with, so reverted change
  • Changing renderer from GLFW OpenGL3 to DX11 Win32: No change in issue
  • Commenting out the vertices and indices appending in drawRectFilled: Eliminated the issue, but obviously also ruined the look of the GUI
  • Setting all styles related to anti-aliasing to false: Drastically reduced how often the issue occurred, but still not eliminated

One thing I've definitely noticed is that it occurs more frequently when there are large amounts of filled rectangles on the screen. For example, I have a window with a lot of drop downs and it was barely happening. I changed those drop downs to use the collapsible header style, and the issue became much more frequent.

@Jack-Ji
Copy link

Jack-Ji commented Feb 9, 2022

I'm experiencing simillar problems with windows11/Opengl3/Intel graphics card, here's what I did:

  • Draw some simple stuff (a triangle) with PolygonMode being set to GL_LINE
  • Draw some imgui widgets

The imgui window will flicker from time to time, even disappear completely some time. BTW, I'm using version 1.86.

cfillion added a commit to cfillion/reaimgui that referenced this issue Apr 4, 2024
Windows users with Intel GPUs are experiencing random rendering artifacts (ocornut/imgui#3033).

Option is only available for Direct3D on Windows and OpenGL on macOS.

On Linux the only way to force a software renderer is by setting the
LIBGL_ALWAYS_SOFTWARE environment variable, which Mesa reads from
glxInitialize/eglInitialize which are per-display not per-window,
so dynamically overriding that per context is not possible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants