godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.16k stars 19.96k forks source link

Floating windows jitter on resize #84565

Open synalice opened 9 months ago

synalice commented 9 months ago

Godot version

v4.2.beta1.official [b1371806a]

System information

Godot v4.2.beta1 - Windows 10.0.19045 - GLES3 (Compatibility) - AMD Radeon(TM) Vega 8 Graphics (Advanced Micro Devices, Inc.; 31.0.21029.1006) - AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx (8 Threads)

Issue description

Why you try to resize floating windows (any Godot's windows, it seems) they "jitter", there is no smoothness. This happens with any renderer.

https://github.com/godotengine/godot/assets/61655860/266691cf-5c1f-4b7f-9e04-de5097edca4d

Steps to reproduce

Open "Project Settings" or press "Make Floating" on any tab. Then try to resize this new window.

Minimal reproduction project

Appears on any new project.

Calinou commented 9 months ago

This is expected as resizing the window requires reallocating OpenGL render buffers, so it can't be 100% instant like it can be with a "native" UI application. This is made worse at higher window sizes as allocating a larger buffer takes more time.

See those videos recorded at 120 FPS on an i9-13900K + RTX 4090 on Linux (KDE with compositing disabled). Notice how the GTK-based apps (which don't use hardware acceleration of any kind) are much smoother to resize:

Godot 4.2.beta4 (OpenGL)

https://github.com/godotengine/godot/assets/180032/8bd8098c-de40-449a-b5fc-00f986b8b078

Blender 3.6.0 (OpenGL)

https://github.com/godotengine/godot/assets/180032/c0578efa-c14e-4274-85c6-224d93b2f7ea

Inkscape 1.3 (GTK)

https://github.com/godotengine/godot/assets/180032/f7968230-8401-4376-91a1-248f9ed511a6

GIMP 2.10.34 (GTK)

https://github.com/godotengine/godot/assets/180032/a1887831-ac61-43d5-bb8d-4c1b24bcb262

synalice commented 9 months ago

(I assume it would be okay to ask these questions here since the issue is marked as a discussion)

GTK

But how does GTK solve this issue? Aren't absolutely all computer graphics done through some kind of graphics API like OpenGL, Vulcan or DirectX?

I tried reading a Wikipedia page about the GTK and there is nothing about any of those APIs.

About OpenGL

So, is it impossible to (elegantly, of course) find a solution to this render buffer reallocation issue?

How come the allocation of this buffer is so inefficient compared to how much processing can happen smoothly in each frame of the game?

(as you can probably see, I don't have any experience with using the raw graphics APIs)

Calinou commented 9 months ago

But how does GTK solve this issue? Aren't absolutely all computer graphics done through some kind of graphics API like OpenGL, Vulcan or DirectX?

No, it's possible to draw in a window purely in software without the use of any 3D graphics API (not even for presenting the software-generated image). All operating systems make this possible.

So, is it impossible to (elegantly, of course) find a solution to this render buffer reallocation issue?

Most applications seem to not care about this issue (or have given up). It's possible that resizing the window may be made to look less jittery (by moving the canvas depending on the direction of the resize), but it will not actually reallocate the buffers at a higher rate.

How come the allocation of this buffer is so inefficient compared to how much processing can happen smoothly in each frame of the game?

Graphics APIs aren't optimized towards reallocating buffers all the time, as this is never needed during gameplay.

Kiisu-Master commented 6 months ago

Godot 4.3 dev 3 with opengl3_angle has completely glitched window resizing. This also happens in 4.2.2 rc1 because the gpu blacklist got merged into that too. (Radeon R7)

No glitches in blender, just to prove it's possible to have.

https://github.com/godotengine/godot/assets/142301391/6b463a50-65c1-41f6-b386-400bb6746237