Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
nvidia xorg without mesa
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
stefan11111
l33t
l33t


Joined: 29 Jan 2023
Posts: 954
Location: Romania

PostPosted: Fri Feb 16, 2024 8:36 pm    Post subject: nvidia xorg without mesa Reply with quote

UPDATE:
As of april 2025, what is presented here isn't completely true and hasn't been for at least a few months.
The proprietary nvidia drivers nowadays have drm support even for X11, and is it necessary for things like vaapi.
I have a full build of mesa on my system for things unrelated to the nvidia drivers, but one should at least
have libgbm from mesa when using the nvidia drivers on X11.
For anyone interested in reading more about this, you can look at this bug report and all the links in see also:
https://bugs.gentoo.org/940168

To build just libgbm from mesa, create the file /etc/portage/env/media-libs/mesa, if it doesn't already exist
and add this line to is:
Code:

MYMESONARGS="-Dgbm=enabled -Dexpat=disabled -Dgallium-drivers= -Dvideo-codecs="

And disable all USE flags except USE="X" on media-libs/mesa

Here's an updated guide to get a minimal system with an nvidia gpu on X11,
without losing any of the newer features of the nvidia gpu driver:

1. Build mesa with just libgbm, using the setup mentioned above.

2. Install this header: https://github.com/stefan11111/dri_interface.h
I have an ebuild for this header in my overlay, that might be useful:
https://github.com/stefan11111/stefan_overlay/blob/main/x11-base/xorg-dri-interface/xorg-dri-interface-1.0.ebuild

3. emerge x11-base/xorg-server
Do *NOT* enable USE=minimal on it, like in the old guide

If you didn't enable drm support, and you want it, you will have to enable it.
It isn't enabled by default and it is needed for vaapi.

As a side note, the drm support is needed for the nvidia framebuffer, but it is experimental
and I found that is has worse performance that the regular efi framebuffer.

I will keep the old guide here, as it may be useful to those who are using older
drivers that do not have drm support and to those who do not need/want the drm support.

OLD GUIDE HERE:

There are multiple ways of using a nvidia gpu on linux.
There are the nouveau drivers and the proprietary drivers.
This guide is for users of the proprietary drivers.

I have tried using the open source drivers too, but I've had problems with hw accel, which is a deal-breaker for me.

The proprietary nvidia drivers already have their own implementations of everything in mesa.
You can see for yourself by running:
Code:

$ equery f nvidia-drivers | grep lib | grep so

If you don't use steam and such, the process of using xorg without mesa is quite simple:
Enable USE="minimal" on xorg-server.
Disable USE="dri" on mpv, if you use it.
Rebuild and emerge -cav.
And that should be it.

I use steam, which requires xorg built with glx, and for which the process is a bit more involved.
Enable USE="minimal" on xorg-server.
Disable USE="dri" on mpv, if you use it.
Create the text file /etc/portage/env/x11-base/xorg-server, if it doesn't exist.
Add:
Code:

MYMESONARGS="-Dglx=true"

to the file /etc/portage/env/x11-base/xorg-server.

After doing this, you will have to install this header:
https://github.com/stefan11111/dri_interface.h

I have an ebuild for it here, but you can install it any other way you like:
https://github.com/stefan11111/stefan_overlay/blob/main/x11-base/xorg-dri-interface/xorg-dri-interface-1.0.ebuild

UPDATE: this patch is no longer needed.
After doing this, you will have to put this patch in /etc/portage/patches/x11-base/xorg-server/<whatever you want>.patch :
Code:

diff --git a/glx/meson.build b/glx/meson.build
index 2ec00ce..18d3f41 100644
--- a/glx/meson.build
+++ b/glx/meson.build
@@ -38,7 +38,6 @@ if build_glx
         dependencies: [
             common_dep,
             dl_dep,
-            dri_dep,
             dependency('glproto', version: '>= 1.4.17'),
             dependency('gl', version: '>= 1.2'),
         ],
diff --git a/hw/xfree86/dixmods/meson.build b/hw/xfree86/dixmods/meson.build
index a1afbe8..e4ac022 100644
--- a/hw/xfree86/dixmods/meson.build
+++ b/hw/xfree86/dixmods/meson.build
@@ -33,7 +33,7 @@ if build_glx

         include_directories: [ inc, xorg_inc, glx_inc ],
         c_args: [ xorg_c_args, glx_align64 ],
-        dependencies: [ common_dep, dl_dep, dri_dep ],
+        dependencies: [ common_dep, dl_dep ],
         link_whole: libxserver_glx,
         link_with: e,

diff --git a/include/meson.build b/include/meson.build
index 591bc25..eef9478 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -6,8 +6,6 @@ patch = version_split[2].to_int()
 # convert to the old-style 1.x.y version scheme used up to 1.20.x for backwards compatibility
 release = 1 * 10000000 + major * 100000 + minor * 1000 + patch

-dri_dep = dependency('dri', required: build_glx)
-
 conf_data = configuration_data()
 conf_data.set('_DIX_CONFIG_H_', '1')

@@ -209,9 +207,6 @@ conf_data.set('DGA', build_dga ? '1' : false)
 conf_data.set('DPMSExtension', build_dpms ? '1' : false)
 conf_data.set('DRI2', build_dri2 ? '1' : false)
 conf_data.set('DRI3', build_dri3 ? '1' : false)
-if build_glx
-    conf_data.set_quoted('DRI_DRIVER_PATH', dri_dep.get_pkgconfig_variable('dridriverdir'))
-endif
 conf_data.set('HAS_SHM', build_mitshm ? '1' : false)
 conf_data.set('MITSHM', build_mitshm ? '1' : false)
 conf_data.set('PANORAMIX', build_xinerama ? '1' : false)


Rebuild xorg-server and mpv(if you use it).

Steam depends on virtual/opengl-7.0-r2.

That virtual depends on mesa, but is not actually needed by steam.
To get rid of it, create the text file /etc/portage/profile/package.provided if it doesn't exist, and add:
Code:

virtual/opengl-7.0-r2

To it.

After doing this, emerge -cav should prompt you to uninstall mesa.
_________________
My overlay: https://github.com/stefan11111/stefan_overlay
INSTALL_MASK="/etc/systemd /lib/systemd /usr/lib/systemd /usr/lib/modules-load.d *udev* /usr/lib/tmpfiles.d *tmpfiles* /var/lib/dbus /usr/bin/gdbus /lib/udev"


Last edited by stefan11111 on Sat Apr 26, 2025 1:46 pm; edited 1 time in total
Back to top
View user's profile Send private message
slaterson
Guru
Guru


Joined: 26 Feb 2003
Posts: 313

PostPosted: Wed Feb 28, 2024 9:01 pm    Post subject: Reply with quote

what advantage is gained by doing this?
Back to top
View user's profile Send private message
stefan11111
l33t
l33t


Joined: 29 Jan 2023
Posts: 954
Location: Romania

PostPosted: Sat Mar 09, 2024 1:04 pm    Post subject: Reply with quote

slaterson wrote:
what advantage is gained by doing this?

Not having to build mesa.
_________________
My overlay: https://github.com/stefan11111/stefan_overlay
INSTALL_MASK="/etc/systemd /lib/systemd /usr/lib/systemd /usr/lib/modules-load.d *udev* /usr/lib/tmpfiles.d *tmpfiles* /var/lib/dbus /usr/bin/gdbus /lib/udev"
Back to top
View user's profile Send private message
stefan11111
l33t
l33t


Joined: 29 Jan 2023
Posts: 954
Location: Romania

PostPosted: Tue Sep 03, 2024 11:40 pm    Post subject: Reply with quote

I updated the repository with the header, so that patching xorg is no longer required.

https://github.com/stefan11111/dri_interface.h/commit/b0bc2692ebd5b92fc67eb80cca5f6e6f9ca0196b
_________________
My overlay: https://github.com/stefan11111/stefan_overlay
INSTALL_MASK="/etc/systemd /lib/systemd /usr/lib/systemd /usr/lib/modules-load.d *udev* /usr/lib/tmpfiles.d *tmpfiles* /var/lib/dbus /usr/bin/gdbus /lib/udev"
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum