NVidia Optimus - I can no longer use my graphics card with Wine for some applications

After some recent updates I can no longer use my NVidia Optimus graphics card with Wine for some applications, especially Counter Strike 1.6.

ERROR (part):

[...]
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  152 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  25
  Current serial number in output stream:  26
[...]

COMMAND:

cd "/home/eduardolac/Data1/Games/Counter Strike 1.6 RE-MOD v1.5.0b/Counter Strike 1.6 RE-MOD/" && WINEPREFIX=/home/eduardolac/.PlayOnLinux/wineprefix/csremod prime-run wine cstrike.exe -console -game cstrike -gl -32bpp -dxlevel 100 -full -w 1920 -h 1080 -forceres -freq 75 -noipx -toconsole +connect

[Refs.: https://www.reddit.com/r/linux_gaming/comments/itx2bw/help_i_think_i_messed_up_my_nvidia_drivers/ , NVidia Optimus - Graphics card no longer can be activated by the primusrun command (bumblebee) , How to Use Manjaro Hardware Detection Tool – Linux Hint ]

The solution was to remove some old components/drivers and (re)install updated versions. The answer below is an adaptation of my answer to a problem related also to NVidia Optimus graphics ( NVidia Optimus - Graphics card no longer can be activated by the primusrun command (bumblebee) ).

IMPORTANT:

Handling video card drivers is always a critical process and YOU RISK RUNNING OUT OF ACCESS TO THE MANJARO’S GRAPHICAL USER INTERFACE. So, first of all WE STRONGLY RECOMMEND burning a DVD or preparing a USB stick with the Manjaro’s installer ISO ( Manjaro - Downloads ). If something goes wrong you can access your Manjaro’s installation by booting your computer with the Manjaro’s installer and then run the manjaro-chroot -a command on the terminal.

To writing a Manjaro installer ISO to a USB stick you could use the dd bs=4M if=<PATH_TO_MANJARO_ISO> of=/dev/sd<DRIVE_LETTER> status=progress oflag=sync command. Use the fdisk -l command to find out the <DRIVE_LETTER>. To burn to a DVD you could use the K3b application ( K3b ).

[Refs.: Burn an ISO File - Manjaro , Manjaro Brasil • Exibir tópico - Atualização no Mabox quebra o x ]

INSTALL NVIDIA PRIME:

Find out the exact driver name you use now with the command…

mhwd -li

… and, if applicable, remove with this example command…

mhwd -f -i pci <DRIVER_NAME>

If applicable, remove these other components…

yay -Rc optimus-manager
yay -Rc linux54-nvidia-440xx
yay -Rc nvidia-440xx-utils

(Re)Install new Nvidia prime driver…

mhwd -f -i pci video-modesetting
mhwd -f -i pci video-hybrid-intel-nvidia-prime

Create the 10-prime-offload.conf Xorg configuration file with this command…

read -r -d '' FILE_CONTENT << 'HEREDOC'
BEGIN
Section "ServerLayout"
    Identifier "layout"
    Screen 0 "intel"
    Inactive "nvidia"
    Option "AllowNVIDIAGPUScreens"
EndSection

Section "Device"
    Identifier "intel"
    Driver "modesetting"
    BusID "PCI:0:2:0"
EndSection

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:1:0:0"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
EndSection

END
HEREDOC
echo -n "${FILE_CONTENT:6:-3}" > '/etc/X11/xorg.conf.d/10-prime-offload.conf'

TIP: Use the lspci | grep -E "VGA|3D" command to confirm the BusID of each device.

Run the command…

systemctl set-default multi-user.target

… and reboot your computer.

IMPORTANT: The systemctl set-default multi-user.target command will cause your graphical user interface to be temporarily unusable. Therefore, access this thread via another device (a smart phone, for example) as the next commands must be executed manually after reboot and login.

modprobe nvidia
modprobe nvidia_modeset
modprobe nvidia_drm
systemctl set-default graphical.target
reboot

Done! =D

[Refs.: https://www.reddit.com/r/linux_gaming/comments/itx2bw/help_i_think_i_messed_up_my_nvidia_drivers/ , NVidia Optimus - Graphics card no longer can be activated by the primusrun command (bumblebee) , How to Use Manjaro Hardware Detection Tool – Linux Hint ]

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.