godotengine / godot

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

TileMap performance degradation on MacOS using ANGLE #84591

Closed Knight-XAura closed 11 months ago

Knight-XAura commented 1 year ago

Godot version

v4.2.beta5.official [4c96e9676]

System information

Godot v4.2.beta5 - macOS 14.0.0 - GLES3 (Compatibility) - ANGLE (Apple, ANGLE Metal Renderer: Apple M1, Version 14.0 (Build 23A344)) - Apple M1 (8 Threads)

Issue description

MacOS seems to have very bad TileMap performance on very small (8 tiles) tile sets. I opened same project on my lower end Windows 10 machine and it ran perfectly. Once running game seems to run fine, it's only in the editor this issue seems to occur and I've noticed it in all the Betas I worked on this project in which was Beta 2. If I use the Stable 4.1.3 that was just released the performance issue doesn't exist. This is only since Version 4.2. I know some changes came with the system and may have greatly affected performance on the MacOS systems, but not Windows. Linux is unknown.

Steps to reproduce

Create a project with a TileMap and then attach any size tile set. Select the TileMap tab at the bottom and watch the editor feel like it's gonna come to a halt.

Minimal reproduction project

N/A

Veradictus commented 1 year ago

Encountering this issue as well, 4.1 ran perfectly fine on MacOS, moved to Godot 4.2 beta 6 and it's absolutely atrocious. I cannot even run the game anymore and it ends up crashing. I need the 4.2 version because of per-tile flipping.

Calinou commented 1 year ago

@Knight-XAura @Veradictus Can you try following the same steps on 4.2 dev/beta releases? You can download them here.

Also, try reproducing the issue after disabling ANGLE in the Project Settings (rendering/gl_compatibility/driver.macos to opengl3 instead of opengl3_angle). Enabling this means that Apple's own OpenGL -> Metal translation layer is used, like in 4.1.3 and prior.

Knight-XAura commented 1 year ago

It's the Renderer. Disabled ANGLE in Beta 5 (sorry it's what I had already) and it works AMAZING

akien-mga commented 1 year ago

We won't have time to fix this for the 4.2-stable release which is imminent, but this stays a high priority issue for us to tackle in 4.3 and ideally in a 4.2.x maintenance release, as this seems to be a big issue for using TileMaps on macOS.

For 4.2, I suggest changing the rendering/gl_compatibility/driver.macos project setting to opengl3 instead of opengl3_angle for projects that need to edit TileMaps with a tight grid.

tudor07 commented 12 months ago

Can confirm opengl13 fixed the issue on macOS 14.1.1

gamenerds commented 10 months ago

While changing to opengl3 fixed the editor lag, it makes the game crash on launch for me (M1 MBP, doesn't matter if tilemap has few or no tiles). We need some real solution to this.

akien-mga commented 10 months ago

You both mentioned opengl13 which doesn't exist, make sure you're using opengl3.

gamenerds commented 10 months ago

You both mentioned opengl13 which doesn't exist, make sure you're using opengl3.

haha yes, that's the one. Edited my post.

clayjohn commented 6 months ago

I spent some time looking into this today as we would like to eventually enable the Metal ANGLE eventually. I tracked the issue down to this line: https://github.com/godotengine/godot/blob/a4f2ea91a1bd18f70a43ff4c1377db49b56bc3f0/scene/resources/2d/tile_set.cpp#L1561

This issues a draw call for each tile using a mesh with the PRIMITIVE_LINE_STRIP primitive. Line drawing is discouraged by Metal and meshes can't be batched together by Godot. This creates a perfect storm of performance problems resulting in the tilemap grid overwhelming the GPU.

The solution will be to rewrite that function to use the line drawing API instead of the mesh drawing API. It shouldn't be a lot of work, but it isn't worth doing unless we re-enable the Metal ANGLE backend (which is currently on ice due to unrelated driver bugs)

gamenerds commented 6 months ago

Thanks for the response, Clay!

On Thu, May 30, 2024 at 3:03 PM Clay John @.***> wrote:

I spent some time looking into this today as we would like to eventually enable the Metal ANGLE eventually. I tracked the issue down to this line:

https://github.com/godotengine/godot/blob/a4f2ea91a1bd18f70a43ff4c1377db49b56bc3f0/scene/resources/2d/tile_set.cpp#L1561

This issues a draw call for each tile using a mesh with the PRIMITIVE_LINE_STRIP primitive. Line drawing is discouraged by Metal and meshes can't be batched together by Godot. This creates a perfect storm of performance problems resulting in the tilemap grid overwhelming the GPU.

The solution will be to rewrite that function to use the line drawing API instead of the mesh drawing API. It shouldn't be a lot of work, but it isn't worth doing unless we re-enable the Metal ANGLE backend (which is currently on ice due to unrelated driver bugs)

— Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/84591#issuecomment-2141066095, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK5SLYFWFHYRECX4QDRB63ZE7D7JAVCNFSM6AAAAAA7BY6OVWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBRGA3DMMBZGU . You are receiving this because you commented.Message ID: @.***>