flyinghead / flycast

Flycast is a multiplatform Sega Dreamcast, Naomi, Naomi 2 and Atomiswave emulator
GNU General Public License v2.0
1.36k stars 167 forks source link

The workaround for nouveau in gl4PixelPipelineShader does not get applied because nouveau is not detected properly #1373

Closed sircodalotkob closed 7 months ago

sircodalotkob commented 7 months ago

Platform / OS: Linux 6.6, nouveau driver Hardware: Nvidia GTX 780M

Description of the Issue

flycast has a workaround for nouveau in gl4PixelPipelineShader to prevent the driver's over-aggressive optimization.

That workaround is applied when the constant NOUVEAU is set to true in the shader which in turn happens when gl.mesa_nouveau is true.

gl.mesa_nouveau is currently initialized like this:

gl.mesa_nouveau = strstr((const char *)glGetString(GL_VERSION), "Mesa") != nullptr && !strcmp((const char *)glGetString(GL_VENDOR), "nouveau");

On my system, however, nouveau yields the following values:

GL_VENDOR: Mesa
GL_RENDERER: NVE4
GL_VERSION: 4.3 (Core Profile) Mesa 23.3.3-manjaro1.1

With GL_VENDOR not equal to nouveau, the detection fails and the workaround does not get applied. Unfortunately, the workaround is still needed for nouveau or else it discards quite some fragments.

flyinghead commented 7 months ago

Should be fixed in the latest master build

sircodalotkob commented 7 months ago

Thanks for your fast reply.

The proposed fix scans the GL_RENDERER string for NVE4 which would certainly solve the issue for me.

However, NVE4 is the codename of the driver that nouveau picks for my Nvidia GeForce GTX 780M graphics card. Nouveau provides several drivers for several chipsets, and GL_RENDERER would yield different values for different GPUs.

Unfortunately, I cannot suggest a good solution to reliably detect nouveau as the string nouveau doesn't seem to be present in any GL variable anymore.

flyinghead commented 7 months ago

Yes, I just realized that. I guess I'll have to come up with a better way to do this.

sircodalotkob commented 7 months ago

How about reading the virtual file /proc/modules and checking for nouveau in it? Users of other GPU drivers would have the nouveau module blacklisted.

flyinghead commented 7 months ago

Test fixed. Now using GL_VENDOR: Mesa and GL_RENDERER: NV*

sircodalotkob commented 7 months ago

Looks good to me, thanks!