felixdoerre / primus_vk

Vulkan GPU-offloading layer
BSD 2-Clause "Simplified" License
230 stars 18 forks source link

Failed to Initialized Vulkan with pvkrun % command% on set launch option in dota 2 #73

Closed goldcoders closed 4 years ago

goldcoders commented 4 years ago

Hi im using bumblebee and bbswitch I tried enabling vulkan in dota,

Actually I can run it without the set launch options im getting 60 fps

im using mx150

i thought nvidia is kicking in but no i tried running nvidia-smi i see in output no running process found

I should be getting around 120-150 fps if im running on nvidia vulkan

I have installed all nvidia driver

my problem is when i run xrander --listproviders

before im seeing 2 card one intel and nvidia now its only 1

I tried enabling nvidia persitence to start with nvidia but still no avail

I also try to run again with no options and run nvidia-smi

still no process,

but if i run with set-options pvkrun %command% i see its loading processname /usr/lib/xorg and ../bin/iinuxsteamrt64/dota2

bit GPU process 0

Dont know why this is but if i run optirun glxinfo | grep NVIDIA Nvidia is running...

Then i try to set luanch option optirun %command%

it wont even launch, when you click play it just stop

Any help would be appreciated thanks

felixdoerre commented 4 years ago

Alone the copying of the images with memcopy takes its time so I doubt that you will get more than 60 fps in any case with primus-vk. You should be able to turn up your graphics settings and still stay at 60 fps with primus-vk. I could adjust primus-vk to just drop (and don't copy) frames if the application is faster than the copying, but I don't see any use in that. You say that you don't observe any load on your graphics card. That could be an indication that it does not work, however I am not sure if nvidia-smi just fails to detect the graphics card on the secondary X-server spawned by bumblebee.

That you only see one provider when running xrandr --listproviders is perfectly normal with bbswitch, as the nvidia graphics card has no power when your primary display server comes up, so it is not detected at that point in time. This should not be a problem. The same holds for nvidia persistence. Generally, nvidia persistence and bumblebee/bbswitch have two opposite objectives. bbswitch tries to get rid of the nvidia driver/device when it is not used, and nvidia persistence tries to keep it up all the time in order to make games start faster.

When you want to test if pvkrun works, you should try pvkrun vulkaninfo and check for the nvidia device there. optirun glxinfo only checks the same thing for the OpenGL api, which does not help you.

I assume that primus_vk is running, as you say:

before im seeing 2 card one intel and nvidia now its only 1

And this is the expected behavior when running an application under primus_vk. If you want to, you can verify that the game has opened the nvidia card, by checking that /dev/nvidia0 is linked in ls -als /proc/<pid of the running dota process>/fd. That nvidia-smi does not show any process is strange, as should work normally with primus_vk.

felixdoerre commented 4 years ago

Did you get primus_vk running as you wanted? Did the reply answer your questions?

goldcoders commented 4 years ago

Based on my experience trying both 1.) primus_vk + bbswitch + bumblebee + vulkan intel + vulkan-nvidia 2.) optimus-prime + bbswitch + vulkan-nvidia + vulkan-intel

Heres my take...

Ive tried both set up, Even in the second method fps is capped around 60 fps.... when using on demand graphics card... both have command pvkrun and prime-run.

I believe on demand graphics card in dota 2 is automatically capped around that fps...

based on playing...

the only difference is with bumblebee i dont have option to boot with nvidia... unlike optimus-prime-qt , i can set startup video card...

so when i reboot using nvidia , vulkan is still working and the fps reached the max potential 180fps and average 160 fps throughout the gameplay.

felixdoerre commented 4 years ago

I don't really understand what your "option 2)" is. Is "optimus-prime" the implementation from nvidia? Why is "bbswitch" included in there? What exactly do you mean with "bumblebee"? The "bumblebeed"-daemon? So by not-including bumblebee in the 2nd list, you indicated that you uninstalled bumblebeed or deactivated it?

Generally: when you want your X-Server/wayland to recognize the nvidia card during bootup, you can not have bumblebeed active, as it cuts power to the nvidia card, when it is not explicitly invoked (with primusrun, optirun or pvkrun... all having slight differences)

Also you describe a third option "when i reboot using nvidia". What exactly does that mean?

The 60 fps limit, that I described is not really by dota or any game, but it is imposed by the necessity to copy the images from the dedicated graphics card to main memory for displaying. Additionally I do not really understand, what your goal is? Do you want to be able to run dota with higher graphics settings and still have around 60 fps? Do you want an "fps" counter to be high? Because getting that counter higher is (as I wrote) possible (by just dropping frames, when there are more images, than the display can show). So just dropping frames, that in won't make it to the display in any case can help you see a higher fps counter with no real improvement, right?

So summing it up, I don't really understand what your problem is/what you are trying to achieve, could you please explain that?

goldcoders commented 4 years ago

option 2 uses nvidia proprietary drivers nvidia and nvidia-utils

why bbswitch is included? well im using optimus-manager-qt, and it uses bbswitch to switch cards

ive wrote my implementation with it using dwm https://github.com/goldcoders/dwm

reason i went that way is , even if i manage to make pvkrun its capped at 60fps when playing dota2

it happens also with optimus-manager when using on demand graphics card.. but you can reboot with nvidia and that solves the problem...

you go beyond 60fps...

felixdoerre commented 4 years ago

You go beyond 60fps in calculating them, but not in displaying them (probably your display does not have more than 60Hz, right?). Those frames need to get discarded at some place before they reach your display. As I wrote before, primus_vk doesn't have a mechanism to discard frames, when they are produced faster than needed, and I am not really sure where/how one would implement this in primus_vk. Currently the images are completely in sync, so primus_vk can't easily skip an image.

Do you have a concrete reason why you need far more than 60fps?

felixdoerre commented 4 years ago

If you want to try, you can increase the number of swapchain images: https://github.com/felixdoerre/primus_vk/blob/master/primus_vk.cpp#L854 to 4 or 6. That way you get more Threads copying around images. But I think, if we really want to have >60fps efficiently, we need to discard the images before copying them.