LukeSmithxyz / voidrice

My dotfiles (deployed by LARBS)
GNU General Public License v3.0
4.29k stars 1.21k forks source link

Guide: Enabling Vulkan with Intel/Hybrid/Nvidia on DWM with Optimus Manager, Tested With Dota 2 Vulkan Enabled #795

Closed goldcoders closed 4 years ago

goldcoders commented 4 years ago

Im using as my base repo is @LukeSmithxyz voidrice and larbs

If u have Hybrid graphics card like mine...

and dont want to have trouble playing games in linux...

and switching intel, nvidia , or hybrid... read more below

Ive tested it on Dota 2

i got around an average of 50+ fps prior

with vulkan enabled i got around 150+ fps

Ive noticed that 60fps capped when switching GPU

To use or maxout the capabilities of your GPU

Just set optimus-manager startup to NVIDIA

Here is my Set up:

OS: Arch Linux x86_64
Kernel: 5.8.1-arch1-1
GPU: NVIDIA GeForce MX150
GPU: Intel UHD Graphics 620
wm: dwm
terminal: st

Ive Installed xorg based packages for intel graphics card ( i think larbs already included this)

xf86-video-intel
xf86-video-vesa
extra/mesa
extra/opencl-mesa
lib32-glu
lib32-mesa
lib32-opencl-mesa

I remove nouveau package since im using nvidia ( and its better on performance)

Ive installed nvidia packages

nvidia
nvidia-prime
nvidia-utils
lib32-nvidia-utils
libxnvctrl
egl-wayland

Important to mention that nvidia-prime allows us to use prime-run command (ON DEMAND GPU) when on HYBRID GPU, so ive added it

also ive created

/etc/pacman.d/hooks/nvidia.hook as stated in archwiki for nvidia

[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=nvidia
Target=linux
# Change the linux part above and in the Exec line if a different kernel is used

[Action]
Description=Update Nvidia module in initcpio
Depends=mkinitcpio
When=PostTransaction
NeedsTargets
Exec=/bin/sh -c 'while read -r trg; do case $trg in linux) exit 0; esac; done; /usr/bin/mkinitcpio -P'

also ive loaded nvidia modules inside

/etc/mkinitcpio.conf

MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)

dont forget to run this command

sudo mkinitcpio -p linux

and Installed vulkan packages

vulkan-icd-loader
vulkan-intel
vulkan-tools
lib32-vulkan-icd-loader
gpu-viewer

and installed Optimus manager QT , it comes with optimus manager as dependency

optimus-manage-qt
bbswitch
lightdm
lightdm-webkit2-greeter
lightdm-webkit-theme-aether-git

bbswitch is needed so we can switch GPU with optimus manager

lightdm is needed also so we can have the script needed to switching when quitting dwm

any theme of lightdm will do, but ive installed aether.

this is my optimus.conf /etc/optimus-manager/optimus-manager.conf

surprisingly all configuration for vulkan works out of the box same config for intel in arch wiki

[intel]
DRI=3
accel=
driver=modesetting
modeset=yes
tearfree=

[nvidia]
DPI=96
PAT=yes
allow_external_gpus=no
ignore_abi=no
modeset=yes
options=overclocking

[optimus]
auto_logout=no
pci_power_control=no
pci_remove=no
pci_reset=no
startup_auto_battery_mode=intel
startup_auto_extpower_mode=nvidia
startup_mode=intel
switching=bbswitch

this is my ~/.xprofile Im running optimus-manager-qt (startup programs)

#!/usr/bin/env sh

remaps &        # run the remaps script, switching caps/esc and more; check it for more info
setbg &         # set the background with the `setbg` script
dwmblocks &     # script for updating the status bar
dunst &         # dunst for notifications
xset r rate 300 50 &    # Speed xrate up
unclutter &     # Remove mouse when idle
fusuma &                 # MAC Like Gestures Enabled
compton >/dev/null 2>&1 &
/usr/bin/optimus-manager-qt > /dev/null 2>&1 &

my ~/.xinitrc

#!/usr/bin/env sh
. ~/.xprofile
ssh-agent dwm

my config for lightdm

/etc/lightdm/lightdm conf

[LightDM]
run-directory=/run/lightdm

[Seat:*]
greeter-session=lightdm-webkit2-greeter
user-session=dwm
session-wrapper=/etc/lightdm/Xsession

config for lightdm-webkit2-greeter

[greeter]
debug_mode          = false
detect_theme_errors = true
screensaver_timeout = 300
secure_mode         = true
time_format         = LT
time_language       = auto
webkit_theme        = lightdm-webkit-theme-aether
[branding]
background_images = /usr/share/backgrounds
logo              = /usr/share/pixmaps/archlinux-logo.svg
user_image        = /usr/share/pixmaps/user.svg

ive only modified here is the user_image added image on that path. and added 644 permission on that image or it wont show at all.

When I manually patched DWM , it doesnt come with dwm.desktop file

This is needed so I can use it inside lightdm this line is telling to use dwm as session

user-session=dwm

so to fix it ive added manually by creating a file

/usr/share/xsessions/dwm.desktop

[Desktop Entry]
Encoding=UTF-8
Name=Dwm
Comment=Dynamic window manager
Exec=dwm
Icon=dwm
Type=XSession

i do have this lightdm config installed by optimus manager

/etc/lightdm/lightdm.conf.d/20-optimus-manager.conf

So this basically is the one responsible for switching the Cards during login and logout

[Seat:*]
# Force using X
type=local
display-setup-script=/sbin/prime-offload
display-stopped-script=/sbin/prime-switch

Another thing to Add either on your .zshrc or .bashrc This is needed for vulkan to reference proper GPU like intel and NVIDIA

export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/intel_icd.x86_64.json:/usr/share/vulkan/icd.d/nvidia_icd.json

to check vulkan is working run

vulkaninfo

you can try to play Dota 2 with Vulkan Enabled

Have Fun!

drake-newell commented 4 years ago

Why is this a repo issue

vladdoster commented 4 years ago

Can you close this? This isn't an issue?

Davoodeh commented 4 years ago

One more note before closing: All these can be a hassle really and it will give you a black X screen 90% of the time. Another simple workaround is to just install the packages (but optimus) and enable the Nvidia cards simply by adding the line below to the head of your .xinit:

xrandr --setprovideroutputsource modesetting NVIDIA-0 # for Nvidia only systems

and writing the lines below to /etc/X11/xorg.conf.d/10-nvidia-drm-outputclass.conf

Section "OutputClass"
    Identifier "intel"
    MatchDriver "i915"
    Driver "modesetting"
EndSection

Section "OutputClass"
    Identifier "nvidia"
    MatchDriver "nvidia-drm"
    Driver "nvidia"
    Option "AllowEmptyInitialConfiguration"
    Option "PrimaryGPU" "yes"
    ModulePath "/usr/lib/nvidia/xorg"
    ModulePath "/usr/lib/xorg/modules"
EndSection
goldcoders commented 4 years ago

@MYDavoodeh before i have that xrandr line but i remove it, since when switching optimus manager handles that...

likewise that same file 10-nvidia-drm-outputclass.conf i did have that before when following arch wiki,

ive remove it since its also manage by optimus manager,

U might need it if u have bumblebee but i remove it