Solved How to NVIDIA in Hybrid Mode?

Hi, My laptop is an Optimus capable and there is no way to select Intel, NVIDIA, or Prime graphics from the BIOS. I am using Nvidia GTX 1660Ti Mobile and FreeBSD 13.2-RELEASE-p3 (64-bit) with X11.
Code:
# pciconf -lv | grep -B3 display
vgapci1@pci0:0:2:0:     class=0x030000 rev=0x05 hdr=0x00 vendor=0x8086 device=0x9bc4 subvendor=0x1458 subdevice=0x86b6
    vendor     = 'Intel Corporation'
    device     = 'CometLake-H GT2 [UHD Graphics]'
    class      = display
--
vgapci0@pci0:1:0:0:     class=0x030000 rev=0xa1 hdr=0x00 vendor=0x10de device=0x2191 subvendor=0x1458 subdevice=0x86b6
    vendor     = 'NVIDIA Corporation'
    device     = 'TU116M [GeForce GTX 1660 Ti Mobile]'
    class      = display
I have the following drivers installed,
Code:
# pkg info -x nvidia
nvidia-hybrid-graphics-0.5
nvidia-secondary-driver-525.116.03_1
nvidia-settings-470.86_1
nvidia-xconfig-525.116.04
I got only one file in /usr/local/etc/X11/xorg.conf.d/20-intel.conf,
Code:
Section "Device"
    Identifier "Card1"
    Driver "intel"
    Driver "modesetting" # Without it, I am unable to get any GUI login
    BusID  "PCI:0:2:0"
    VendorName "Intel Corporation"
EndSection
My /etc/rc.conf,
Code:
clear_tmp_enable="YES"
sendmail_enable="NONE"
hostname="freebsd.lan"
wlans_iwlwifi0="wlan0"
ifconfig_wlan0="WPA DHCP"
sshd_enable="YES"
ntpd_enable="YES"
powerd_enable="YES"
dumpdev="AUTO"
dbus_enable="YES"
sddm_enable="YES"
#Linux Binary Compatibility
linux_enable="YES"

#NVIDIA
nvidia_load="YES"
kld_list="${kld_list} nvidia-modeset"

#NVIDIA HYBRID Xorg in headless mode on Display 8
nvidia_xorg_enable="YES"

#Intel VIDEO CARD
kld_list="${kld_list} i915kms.ko acpi_video"
I followed these instructions and got the following results,
Code:
$ nvrun glxinfo -B
name of display: :8
display: :8  screen: 0
direct rendering: Yes
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 6144 MB
    Total available memory: 6144 MB
    Currently available dedicated video memory: 5926 MB
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: NVIDIA GeForce GTX 1660 Ti/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 525.116.03
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.6.0 NVIDIA 525.116.03
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)

OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 525.116.03
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
but when I run nvrun-vgl I get the game running with following errors and I got 0% GPU utilization,
Code:
$ nvrun-vgl bomber
[ALSOFT] (EE) Failed to set real-time priority for thread: Operation not permitted (1)
 

Attachments

  • Xorg.0.log.txt
    38.5 KB · Views: 59
  • Screenshot_20231004_011730.png
    Screenshot_20231004_011730.png
    149.4 KB · Views: 75
  • Xorg.8.log.txt
    10.5 KB · Views: 64
I'm guessing that you're using an attached external monitor (that might be useful info, when not having read your history from your previous thread).
What kld_list and what Xorg conf settings in /usr/local/etc/X11/xorg.conf.d/ do you have?

Your Xorg log shows no mention of an Xorg nvidia driver being used, instead only Xorg's modesetting driver.
 
Try $ nvrun-vgl vlc and watch some movie.

View attachment 17050
OMG! You are absolutely correct. Using VLC does utilize about 10%. But, I get following,
Code:
nvrun-vgl vlc
VLC media player 3.0.18 Vetinari (revision 3.0.13-8-g41878ff4f2)
[000000004125e060] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
[0000000041331860] main playlist: playlist is empty
uint DBusMenuExporterDBus::GetLayout(int, int, const QStringList &, DBusMenuLayoutItem &): Condition failed: menu
uint DBusMenuExporterDBus::GetLayout(int, int, const QStringList &, DBusMenuLayoutItem &): Condition failed: menu
uint DBusMenuExporterDBus::GetLayout(int, int, const QStringList &, DBusMenuLayoutItem &): Condition failed: menu
[000000005ce9c9e0] chain filter error: Too high level of recursion (3)
[000000005ce9c660] main filter error: Failed to create video converter
.
.
.
[000000005ce01560] main vout display error: Failed to create video converter
[000000005ce01560] main vout display error: Failed to adapt decoder format to display
[0000000057210060] main video output error: video output creation failed
[000000005926f760] main decoder error: failed to create video output
Failed to open VDPAU backend Shared object "libvdpau_va_gl.so" not found, required by "vlc"
Failed to open VDPAU backend Shared object "libvdpau_va_gl.so" not found, required by "vlc"
Do you also get similar to this? I have also been experiencing screen tearing when I move the window.
 
I'm guessing that you're using an attached external monitor (that might be useful info, when not having read your history from your previous thread).
What kld_list and what Xorg conf settings in /usr/local/etc/X11/xorg.conf.d/ do you have?

Your Xorg log shows no mention of an Xorg nvidia driver being used, instead only Xorg's modesetting driver.
Sorry, I am trying to work on built in display for the laptop. I have updated the parent post with configuration files.
 
I think your Optimus NVIDIA driver and Xorg in "headless" mode work correctly.
I don't know why, but some software don't work well with Xorg in headless mode.
This is not a "prime render offload whis NVIDIA", now we have Xorg in "headless" mode or call it "Hybrid Mode".
"Hybrid Mode" is a wrapper for VirtualGL.
In this mode, two X server processes (two Xorgs) are running in the operating system, one for each video adapter/accelerator.
Disadvantages:
- NVIDIA card always works and consumes energy.
- I haven’t figured out how to output an image through the display port yet in my Thinkpad T530.
Positive:
+ I use the driver for the Intel card as the main one. In my opinion and with my hardware, this driver works better than NVIDIA. Shows clearer images and fonts.
+ I can control the screen brightness using hotkeys and put the laptop into sleep mode. With the NVIDIA driver, sleep mode is not available to me and for everyone else I think.
 
[...]
- NVIDIA card always works and consumes energy.
That may be brand/type specific to the laptop under investigation. Nvidia powermanagement for FreeBSD seems to have been introduced as early as 2020 (FreeBSD Display Driver – x64 - 2020.6.24):
  • Extended the dynamic runtime power management support in the NVIDIA driver to shut off power to video memory under certain conditions. See the chapter titled "PCI-Express Runtime D3 (RTD3) Power Management" in the README for more information.
However, Chapter 15. Configuring a Notebook - Known Notebook Issues mentions possible issues:
There are a few known issues associated with notebooks:
  • In many cases, suspending and/or resuming will fail. As mentioned above, this functionality is very system-specific. There are still many cases that are problematic. Here are some tips that may help:
    • In some cases, hibernation can have bad interactions with the PCI Express bus clocks, which can lead to system hangs when entering hibernation. This issue is still being investigated, but a known workaround is to leave an OpenGL application running when hibernating.
  • On some notebooks, PowerMizer is not enabled by default. This issue is being investigated, and there is no known workaround.
  • ACPI is not currently supported on FreeBSD As a result, ACPI hotkey events are not supported.

So, there is no prime render offload or similar technology exist in FreeBSD, right?
NVIDIA Lands X.Org Server Support For PRIME Render Offload On FreeBSD - 24 February 2023 says otherwise. Scanning through your reference of prime render offload and comparing with your settings mentioned in your opening message, additional settings seem applicable. So, there is more to explore!
 
That may be brand/type specific to the laptop under investigation. Nvidia powermanagement for FreeBSD seems to have been introduced as early as 2020 (FreeBSD Display Driver – x64 - 2020.6.24):

However, Chapter 15. Configuring a Notebook - Known Notebook Issues mentions possible issues:



NVIDIA Lands X.Org Server Support For PRIME Render Offload On FreeBSD - 24 February 2023 says otherwise. Scanning through your reference of prime render offload and comparing with your settings mentioned in your opening message, additional settings seem applicable. So, there is more to explore!
I read that phoronix article but couldn't find a workable guide or documentation anywhere.
 
Back
Top