PRIME Render Offload on NVidia

Good news I suppose, we recently discovered that PRIME Render Offload is (sort of) working, at least for NVidia driver 495.29.05. I was a little sad when I switched over to FreeBSD that I would have to go back to the Bumblebee days (at least, that's what the ports solution is very similar to right now).

However, this technology is very likely the reason I ditched Linux after many years in the first place... For some reason my laptop on any Linux distribution would hard lock up ever since (or thereabouts) I started using it. I never really figured out the real cause, since I had no way to catch logs or debug the problem, so I had to move on. [More controversial stuff removed by me.]

I've been using FreeBSD since sometime in July and I've never experienced a freeze, which is great, and I can have an uptime of a week or more without any sluggishness. Of course I've had to sacrifice most of the gaming toys available... until now? Well, from my recent testing, almost nothing of interest works for me on wine-proton due to what seems to be address space issues. However, vkcube works for NVidia now, and I at least have seen that DXVK *can* work. I got a Unity 4-based demo to start on both GPUs using Vulkan, but it crashed on NVidia.

Seems a little buggy on a simple native application too, for example glxinfo:
tod@mata:~$ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep -i renderer
OpenGL renderer string: NVIDIA GeForce GTX 1050/PCIe/SSE2
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 78 (X_CreateColormap)
Serial number of failed request: 129
Current serial number in output stream: 136


As far as I know, that error isn't fatal, and glxgears certainly works.

For some reason the linux-compat stuff (Linuxulator?) can't detect my Intel card at all, so it sort of sees the NVidia driver without any extra work:
tod@mata:~$ /compat/linux/bin/glxinfo | grep -i renderer
libGL error: failed to create dri screen
libGL error: failed to load driver: nouveau
libGL error: failed to create dri screen
libGL error: failed to load driver: nouveau
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer,
GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer, GLX_MESA_query_renderer,
Extended renderer info (GLX_MESA_query_renderer):
OpenGL renderer string: llvmpipe (LLVM 7.0, 256 bits)
Failed to establish dbus connection GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer,
OpenGL renderer string: NVIDIA GeForce GTX 1050/PCIe/SSE2


Not sure why it's still showing llvmpipe...

I need more stuff to test, but I'm having trouble finding somewhat graphically demanding programs that aren't huge downloads.

Pardon the rant and introduction. Anybody else's experiences, introductions, suggestions, etc. are welcome. I suppose there was no real point to this post, no real problem to solve at this point, as all this stuff will fall into place eventually. It's certainly fun technology though if you're one of the (un)fortunate.

For reference:

Thanks,
Tod
 
FYI, I'm not sure why this place insists on spelling Nvidia as NVidia, but it's grossly inaccurate. This matches neither the normal capitalization rules nor the company policy. And this certainly doesn't match the old nᴠɪᴅɪᴀ logo.

As far as I know, that error isn't fatal, and glxgears certainly works.
There shouldn't be any errors.

For some reason the linux-compat stuff (Linuxulator?) can't detect my Intel card at all, so it sort of sees the NVidia driver without any extra work:
Mesa doesn't detect the proprietary Nvidia driver (they are incompatible), only the video card's presense. Set MESA_LOADER_DRIVER_OVERRIDE env var to i915 or i965 to force the proper driver for Intel (assuming you don't need Iris in which case you are out of luck). Of course, if you need offloading, you still need to set __NV_PRIME_RENDER_OFFLOAD and __GLX_VENDOR_LIBRARY_NAME.

I need more stuff to test, but I'm having trouble finding somewhat graphically demanding programs that aren't huge downloads.
games/linux-unigine-valley is the one I usually recommend. env LD_LIBRARY_PATH=/usr/local/steam-utils/lib64/fakepulse linux-unigine-valley will start it under Linuxulator. cd /usr/local/share/unigine-valley/bin && with-glibc-shim /libexec/ld-elf.so.1 valley_x64 -project_name Valley -data_path ../usr/local/share/unigine-valley/ -engine_config ../share/unigine-valley/data/valley_1.0.cfg will run it through emulators/libc6-shim, which allows us to test the native FreeBSD userspace drivers.
 
Depending on what is a huge download, you can test some 3D games.
What I know that is working:
* Half Life 2
* Firewatch (beware if you are not on current you will not get some linux futex bits that could prevent the game from crashing during some quest)
* Dota2 (in single mode player, but this is a huge download)
* OpenMorrowind (in ports)
* 0AD (in port)

I added in my shell an optirun function that setup the environment suggested in the previous post
 
Thanks for the tip. Got a little further with the Intel card. It hangs without LIBGL_DRI3_DISABLE=1. Maybe I should test an Ubuntu /compat again for that. From what I remember on Linux, Iris is optional but default.

tod@mata:~$ LIBGL_DRI3_DISABLE=1 MESA_LOADER_DRIVER_OVERRIDE=i965 /compat/linux/bin/glxinfo | grep -i renderer
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer,
GLX_MESA_query_renderer, GLX_MESA_swap_control, GLX_OML_swap_method,
Extended renderer info (GLX_MESA_query_renderer):
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 630 (Kaby Lake GT2)
Failed to establish dbus connection GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer,
OpenGL renderer string: NVIDIA GeForce GTX 1050/PCIe/SSE2


I'll try Ungine Valley, sounds good.

I did get OpenMW working without issue the other day, but that was with the ports solutions. I need to test Steam again with MESA_LOADER_DRIVER_OVERRIDE=i965 now too. I'm on FreeBSD 13 at the moment.
 
Happy to report that Steam's browser works with LIBGL_DRI3_DISABLE=1 MESA_LOADER_DRIVER_OVERRIDE=i965 and System Information looks correct, but emulators/wine-proton still dies right after it creates the device, and before a window is drawn.

Natively, everything looks good with Unigine Valley, but with-glibc-shim seems to select the wrong card:
tod@mata:/usr/local/share/unigine-valley/bin$ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia cd /usr/local/share/unigine-valley/bin && with-glibc-shim /libexec/ld-elf.so.1 valley_x64 -project_name Va
lley -data_path ../usr/local/share/unigine-valley/ -engine_config ../share/unigine-valley/data/valley_1.0.cfg
shim init
get_system_info(): can't open "/proc/meminfo" file
Loading "/home/tod/.Valley/valley_1.0.cfg"...
Loading "libGPUMonitor_x64.so"...
EnginePlugins::addPlugin(): can't load "libGPUMonitor_x64.so" library
Shared object "libGPUMonitor_x64.so" not found, required by "valley_x64"
Loading "libGL.so.1"...
Xlib: extension "XINERAMA" missing on display ":0.0".
Set 1920x1080 fullscreen video mode
Set 1.00 gamma value
Unigine engine http://unigine.com/
Binary: Linux 64bit GCC 4.4.5 Release Feb 14 2013 r11294
Features: OpenGL OpenAL XPad360 Joystick Flash Editor
App path: /libexec/
Data path: /usr/local/share/unigine-valley/data/
Save path: /home/tod/.Valley/

---- System ----
System: FreeBSD 13.0-RELEASE-p4 amd64
CPU: Intel(R) Core(TM) i5-7300HQ CPU @ 2.50GHz 2495MHz MMX SSE SSE2 SSE3 SSSE3 SSE41 SSE42 AVX HTT x1
GPU: NVIDIA GeForce GTX 1050 PCI Express 495.29.05 x1
System memory: 256 MB
Video memory: 4096 MB
Sync threads: 0
Async threads: 1

---- MathLib ----
Set SSE2 simd processor

---- Sound ----
NULL

---- Render ----
Renderer: INTEL HD 4096MB
OpenGL vendor: Intel
OpenGL renderer: Mesa Intel(R) HD Graphics 630 (KBL GT2)
OpenGL version: 4.6 (Core Profile) Mesa 21.1.8


Also, a little off-topic maybe, but I can set export PATH=/usr/local/wine-proton/bin:/usr/home/tod/.i386-wine-pkg/usr/local/wine-proton/bin:$PATH to use it like a normal WOW64 Wine. Some simple stuff like RPG Maker games work there, and https://github.com/skeeto/vulkan-test
It doesn't seem to require all the LD_32_* environment variables set manually that wine-devel does.

Anyway, thanks.
 
User error before. It has about the same FPS like this:
tod@mata:/usr/local/share/unigine-valley/bin$ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia with-glibc-shim /libexec/ld-elf.so.1 valley_x64 -project_name Valley -data_path ../usr/local/share/unigine-valley/ -engine_config ../share/unigine-valley/data/valley_1.0.cfg
---- Render ----
GLRender::GLRender(): Unknown NVidia GPU
OpenGL vendor: NVIDIA Corporation
OpenGL renderer: NVIDIA GeForce GTX 1050/PCIe/SSE2
OpenGL version: 3.2.0 NVIDIA 495.29.05
OpenGL flags: Core Profile
 
Happy to report that Steam's browser works with LIBGL_DRI3_DISABLE=1 MESA_LOADER_DRIVER_OVERRIDE=i965 and System Information looks correct, but emulators/wine-proton still dies right after it creates the device, and before a window is drawn.
You should at least get rid of LIBGL_DRI3_DISABLE=1 before passing control to Wine.

Natively, everything looks good with Unigine Valley, but with-glibc-shim seems to select the wrong card:
The shim doesn't select the card, benchmark does. It might also display a wrong card in HUD. I'd suggest running nvidia-settings: there is a utilization counter in a GPU section. That makes it very clear what is being actually used.

Also, a little off-topic maybe, but I can set export PATH=/usr/local/wine-proton/bin:/usr/home/tod/.i386-wine-pkg/usr/local/wine-proton/bin:$PATH to use it like a normal WOW64 Wine.
The /usr/local/wine-proton/bin/wine script already has all the necessary environment variable setup. You don't need to mess with it.
 
Not using nv-sglrun might've made a difference. I got a Steam game to start with Proton , no launch options required.
 

Attachments

  • 2021-10-24-153051_1920x1080_scrot.png
    2021-10-24-153051_1920x1080_scrot.png
    70 KB · Views: 85
Back
Top