godotengine / godot

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

Wayland: `DRI_PRIME` warnings raised by DetectPrimeEGL #88364

Open akien-mga opened 8 months ago

akien-mga commented 8 months ago

Tested versions

System information

Fedora Linux 39 (KDE Plasma) - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX 7600M XT (RADV NAVI33) () - AMD Ryzen 7 7840HS w/ Radeon 780M Graphics (16 Threads)

Issue description

When running the Godot project manager with the Wayland driver and the GL compatibility backend, the following warnings are printed:

Invalid value (0) for DRI_PRIME. Should be > 0
Inconsistent value (2) for DRI_PRIME. Should be < 2 (GPU devices count). Using: 1
Inconsistent value (3) for DRI_PRIME. Should be < 2 (GPU devices count). Using: 1

See https://github.com/godotengine/godot/pull/86180#issuecomment-1916479457 and following comments for context.

The current DetectPrimeEGL logic tries all integer values from DRI_PRIME=0 to DRI_PRIME=3 to see whether more than 2 GPUs may be available, and attempt to pick the best one.

Mesa doesn't seem to like running DRI_PRIME=2 or DRI_PRIME=3 when the GPU devices count is only 2. Maybe it provides a way to query what that GPU devices count is so we don't attempt the ids that aren't supported? It's pretty much Mesa's own ERR_FAIL_INDEX we need to work around on the calling side ;)

Likewise, it seems to complain about DRI_PRIME=0. It's a bit weird as we even have a message recommending using it to force using the default device, but apparently that's not correct usage? So with 2 GPUs it's only DRI_PRIME=1 to pick the second one, and no env variable to pick the first? Seems pretty weird.

All in all a pretty low priority issue, but silencing those warnings would be nice.

@hpvb has done some work on a better GPU detection for EGL which may solve this issue.

The GLX detect_prime doesn't raise warnings as currently it only tests no env var and DRI_PRIME=1. But if we decide to sync it with the current EGL one to support more than 2 GPUs, we'd have a similar issue.

Steps to reproduce

godot --display-driver wayland --rendering-driver opengl3

Minimal reproduction project (MRP)

n/a

Riteo commented 8 months ago

FTR, I have a WIP branch which aims to use the proper EGL extension for device enumeration (thanks to the work of @hpvb). It's potentially riskier as we can't fork like we used to with the DRI_PRIME stuff, but a mesa folk guaranteed us that it shouldn't be an issue.

Edit: For some mystical reason I completely missed that you already reported hpvb's work in the OP, I'm really sorry for repeating what you said :sweat_smile:. That said, I'm carrying the rest of the work by integrating it in the engine based on the probing code built by them.