GithubHelp home page GithubHelp logo

vkdevicechooser's Introduction

Vulkan Device Chooser Layer

This is a quick and dirty implementation of a Vulkan layer to force a specific physical device to be used. This is useful for Vulkan games which do not provide an option to choose the device themselves.

Compiling requires vulkan/vulkan.h, vulkan/vk_layer.h and vulkan/vk_layer_dispatch_table.h. On Debian based systems, you can install these with:

sudo apt-get install libvulkan-dev vulkan-validationlayers-dev

On Fedora, you can install these with:

sudo dnf install vulkan-headers vulkan-validation-layers-devel

Build and install with:

meson builddir --prefix=/usr
meson compile -C builddir
sudo meson install -C builddir

This will install to the system's Vulkan layer directory, /usr/share/vulkan/implicit_layer.d/.

To run a Vulkan application forcing a specific device to be used, launch it with these environment variables:

ENABLE_DEVICE_CHOOSER_LAYER=1 VULKAN_DEVICE_INDEX=<device index>

Replace <device index> with the "GPU id" for the desired device as reported by vulkaninfo (without the layer enabled).

For example:

$ ENABLE_DEVICE_CHOOSER_LAYER=1 VULKAN_DEVICE_INDEX=1 vulkaninfo

should give info for the device which had GPU id 1 when running vulkaninfo without the environment variable set.

The layer can be used with Steam games by setting their launch options to:

ENABLE_DEVICE_CHOOSER_LAYER=1 VULKAN_DEVICE_INDEX=<device index> %command%

vkdevicechooser's People

Contributors

aejsmith avatar stephanlachnit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vkdevicechooser's Issues

Not Working with Refres2025 --force-vulkan

Used commands:
./Refresh2025.x86_64 --force-vulkan ENABLE_DEVICE_CHOOSER_LAYER=1 VULKAN_DEVICE_INDEX=1 vulkaninfo
./Refresh2025.x86_64 --force-vulkan ENABLE_DEVICE_CHOOSER_LAYER=1 VULKAN_DEVICE_INDEX=0 vulkaninfo

I have two VEGA64 in my PC running Manjaro KDE, vulkaninfo pastebin.

Plus i just tried to run RUST linux native, same result. Both running on the second VEGA what isnt connected to any display.
Same with Subnautica and Subnautica Below Zero.

Vulkan development files not present (vulkan/vk_layer_dispatch_table.h) ? VK Loader 1.2.145

Hey there I was about to build an RPM for openSUSE out of your source.

However meson complains about vk_layer_dispatch_table.h been missing.

I validated several things and still I am unsure if the openSUSE vulkan developemnt and header packages are just missing this file or if the meson script is wrong here maybe because that header file got removed by the Vulkan devs themselves in the most recent version?

I found a package on the build service which has a packed source archive of Vulkan Loader 1.2.145 which contains this file but it seems not to be present in the final RPM which is build out of this and therefore not "installed" in the include directory.

According to the spec file it builds vulkan-devel and libvulkan1 but no trace of the header file anywhere in those rpms but in the archive.

So my question is if this package was build upon an older/newer version (at this point I found Vulkan Loader 1.2.148 in the Khronos GitHub repo) of Vulkan and recent/older versions do/did not have this header or if I need to contact the package maintainer of the vulkan-loader packages and point him to the missing file.

Keep in mind that my Vulkan knowledge is very minimal ^^"

Fedora 40 - vulkan/vk_layer_dispatch_table.h missing

Even after installing vulkan-headers and vulkan-validation-layers-devel the vulkan/vk_layer_dispatch_table.h still cannot be found by meson and the build fails. Doing some digging, it seems this file simply is not included in the packages anymore. Maybe it's deprecated? Or is there another package I need to install? The closest header I could find is vk_dispatch_table.h in vulkan/utility.

Compile error

Hi, I download this tool and i have error when I try "make install"

g++ -gdwarf-2 -shared -O2 -fPIC -std=gnu++11 layer.cpp -o libVkLayer_device_chooser.so layer.cpp: In function ‘VkResult ChooseDevice(VkInstance, const VkLayerInstanceDispatchTable&, const char*, VkPhysicalDevice_T*&)’: layer.cpp:65:23: error: ‘atoi’ was not declared in this scope 65 | int deviceIndex = atoi(env); | ^~~~ layer.cpp: In function ‘VkResult DeviceChooserLayer_EnumeratePhysicalDevices(VkInstance, uint32_t*, VkPhysicalDevice_T**)’: layer.cpp:88:29: error: ‘getenv’ was not declared in this scope 88 | const char* const env = getenv(kEnvVariable); | ^~~~~~ layer.cpp: In function ‘VkResult DeviceChooserLayer_EnumeratePhysicalDeviceGroupsKHR(VkInstance, uint32_t*, VkPhysicalDeviceGroupPropertiesKHR*)’: layer.cpp:125:29: error: ‘getenv’ was not declared in this scope 125 | const char* const env = getenv(kEnvVariable); | ^~~~~~ make: *** [Makefile:4: libVkLayer_device_chooser.so] Error 1

AUR - ERROR: One or more files did not pass the validity check!

yay -S vkdevicechooser
:: Checking for conflicts...
:: Checking for inner conflicts...
[Aur: 1] vkdevicechooser-1-1

:: Downloaded PKGBUILD (1/1): vkdevicechooser
1 vkdevicechooser (Build Files Exist)
==> Diffs to show?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==> n
:: Parsing SRCINFO (1/1): vkdevicechooser
==> Making package: vkdevicechooser 1-1 (Сб 18 июл 2020 22:22:32)
==> Retrieving sources...
-> Downloading master.zip...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 129 100 129 0 0 383 0 --:--:-- --:--:-- --:--:-- 382
100 5226 0 5226 0 0 6311 0 --:--:-- --:--:-- --:--:-- 6311
==> Validating source files with md5sums...
master.zip ... FAILED
==> ERROR: One or more files did not pass the validity check!
Error downloading sources: vkdevicechooser
Some more specific information I need to tell you about that?

Not an issue, just TYVM!

I added a GTX1080 to run some video rendering, it has no monitors attached to it.
I still game Dota and Warframe via my GTX950.

For the longest time I could not figure out why Warframe stopped working and Dota wouldn't launch using Vulkan, only OpenGL, till someone on the Glorious Eggroll discord suggested I try specifying the GPU using vkdevicechooser and everything is working now.

Thanks a ton for this project, I owe you some beers, please add a Paypal button or something. ❤️

Which License is this code under?

I use vkdevicechooser daily for gaming on my laptop, and I'm looking at packaging your project up for the Archlinux AUR since I find it really useful and think others might too. However, I do not want to do so if the license for the code does permit doing such. What open-source license (if any) applies to this software? Do you mind if it is packaged for the Arch AUR?

New tag

@aejsmith can you create a git tag? This way a source tarball gets created by github which I can use for packaging.

Device index 1 does not exist, returning device 0

I ran War Thunder using $ ENABLE_DEVICE_CHOOSER_LAYER=1 VULKAN_DEVICE_INDEX=1 ./launcher and everything were nice. I also created .asoundrc file with content from this manual but entered my audio device name.

But, after I closed War Thunder app, vulkaninfo and other utils including War Thunder lost my discrete GPU at all. After reboot I can use it again but if I close WT window the same happens.

My configuration -

What I got in terminal:
152452.txt
Screenshot_20211021_012108

You helped me so much with your software! I want to improve experience of using your application sharing this problem and helping to solve it. Thank you so much!

Aur buildtime error

When installing from aur:

g++ -gdwarf-2 -shared -O2 -fPIC -std=gnu++11 layer.cpp -o libVkLayer_device_chooser.so
layer.cpp: In function ‘VkResult ChooseDevice(VkInstance, const VkLayerInstanceDispatchTable&, const char*, VkPhysicalDevice_T*&)’:
layer.cpp:65:23: error: ‘atoi’ was not declared in this scope
   65 |     int deviceIndex = atoi(env);
      |                       ^~~~
layer.cpp: In function ‘VkResult DeviceChooserLayer_EnumeratePhysicalDevices(VkInstance, uint32_t*, VkPhysicalDevice_T**)’:
layer.cpp:88:29: error: ‘getenv’ was not declared in this scope
   88 |     const char* const env = getenv(kEnvVariable);
      |                             ^~~~~~
layer.cpp: In function ‘VkResult DeviceChooserLayer_EnumeratePhysicalDeviceGroupsKHR(VkInstance, uint32_t*, VkPhysicalDeviceGroupPropertiesKHR*)’:
layer.cpp:125:29: error: ‘getenv’ was not declared in this scope
  125 |     const char* const env = getenv(kEnvVariable);
      |                             ^~~~~~
make: *** [Makefile:4: libVkLayer_device_chooser.so] Error 1
==> ERROR: A failure occurred in build().
    Aborting...
Error making: vkdevicechooser

Arch Linux
Kernel 5.7
Mesa-20.1.0

Option to hide non-DEDICATED devices

It would be nice to be able to change the order of devices, or even hide non-DEDICATED devices.

Something like DEVICE_CHOOSER_DEDICATED_ONLY=1.

This way it might be possible to get rid of device index in a lot of use cases, making it easier to users, as well making it more deterministic (i.e. in case devices are reordered due to some other reason, like directory entries being scanned by the loader in different order, or similar).

Vulkan vk_layer_dispatch_table header located in a different spot than the meson build expects on Fedora 34

After installing the pre-requisites on Fedora 34 I ran into an issue with the build not finding vk_layer_dispatch_table.h. Upon exploring the installed packages header files I found the file is located at "vulkan/vulkan/vk_layer_dispatch_table.h" instead of "vulkan/vk_layer_dispatch_table.h". I'm attempting to solve the issue on my own for myself, but thought I'd leave an issue to make you aware, or maybe my system is very special and decided to nest it this way.

Meson fails to find vk_layer_dispatch_table.h

Trying to build on Void Linux, installed packages vulkan-loader, Vulkan-Headers, Vulkan-ValidationLayers, file /usr/include/vk_layer_dispatch_table.h is present, yet Meson is unable to find it for some reason. Vulkan version 1.2.141

vkdevicechooser crashing pc

vkdevicechooser won't close vkcube again after it has run, and after a few moments it will freeze the entire desktop..

I build vkdevicechooser from source..

OS: Manjaro 21.2.0 Qonos
CPU: AMD Ryzen 7 5700G with Radeon Graphics @ 16x 3.8GHz
GPU: AMD Radeon RX 6800 XT (SIENNA_CICHLID, DRM 3.42.0, 5.15.7-1-MANJARO, LLVM 13.0.0)

Same GPU index refers to different GPUs between vkdevicechooser & vulkaninfo?

I'm seeing the same GPU index refer to different GPUs in vkdevicechooser & vulkaninfo.

vulkaninfo's view (from Debian's vulkan-tools package, version: 1.2.162.0+dfsg1-1):

$ vulkaninfo --summary | grep -E "GPU.:|deviceName|driverInfo"
(output trimmed)
GPU0:
        deviceName         = AMD RADV NAVY_FLOUNDER (ACO)
        driverInfo         = Mesa 20.3.5 (ACO)
GPU1:
        deviceName         = llvmpipe (LLVM 11.0.1, 256 bits)
        driverInfo         = Mesa 20.3.5 (LLVM 11.0.1)
GPU2:
        deviceName         = NVIDIA GeForce GTX 1650
        driverInfo         = 470.103.01
GPU3:
        deviceName         = llvmpipe (LLVM 11.0.1, 256 bits)
        driverInfo         = Mesa 22.0.2 (git-f1d9e66a84) (LLVM 11.0.1)
GPU4:
        deviceName         = AMD RADV NAVY_FLOUNDER
        driverInfo         = Mesa 22.0.2 (git-f1d9e66a84)

vkdevicechooser's view (current master, df15b9d33a):

$ ENABLE_DEVICE_CHOOSER_LAYER=1 VULKAN_DEVICE_INDEX=list vulkaninfo --summary
(output trimmed)
GPU0:
        deviceName = llvmpipe (LLVM 11.0.1, 256 bits)
        driverInfo = Mesa 20.3.5 (LLVM 11.0.1)
GPU1:
        deviceName = NVIDIA GeForce GTX 1650
        driverInfo = 470.103.01
GPU2:
        deviceName = AMD RADV NAVY_FLOUNDER (ACO)
        driverInfo = Mesa 20.3.5 (ACO)
GPU3:
        deviceName = llvmpipe (LLVM 11.0.1, 256 bits)
        driverInfo = Mesa 22.0.2 (git-f1d9e66a84) (LLVM 11.0.1)
GPU4:
        deviceName = AMD RADV NAVY_FLOUNDER
        driverInfo = Mesa 22.0.2 (git-f1d9e66a84)

It's almost like vkdevicechooser's list got shifted up an item, but then the AMD RADV NAVY_FLOUNDER (ACO) / Mesa 20.3.5 device gets put in after the NVidia card. I wonder if the vulkaninfo enumeration logic changed between when the README was written and now, resulting in different orders?

OS: Debian 11/Bullseye

Layer disabled with Vulkan-Loader v1.3.212

I'm trying to use vkdevicechooser with Vulkan-Loader v1.3.212 on Debian 11 but the ENABLE_DEVICE_CHOOSER_LAYER=1 environment variable seems to have no effect.

Getting log lines like this with VK_LOADER_DEBUG=all & vulkaninfo:

INFO:             loader_add_implicit_layer: Disabling implicit layer VK_LAYER_MESA_device_select for using an old API version 1.2 versus application requested 1.3

Suspect it's related to KhronosGroup/Vulkan-Loader#870.

Not working with Strange Brigade

So, this thing is awesome, I noticed Arlie's PR for mesa and came across this in the comments. However I noticed that while this works for DOOM, for some reason it does not work with Strange Brigade. If you want to skip having to guess where to press on the Strange Brigade launcher for testing, I have a custom proton build that runs the vulkan version of the game directly:

http://github.com/gloriouseggroll/proton-ge-custom

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.