commit 6ffe3132e3727389eb023e6f2ea19164d6065fe3
parent d3d9f07d022f8e818e10321b382d283f8faa8b05
Author: Guillaume Bouchard <guillaum.bouchard@gmail.com>
Date: Sun, 8 Apr 2018 17:53:16 +0200
Merge pull request #7 from expipiplus1/vulkan
Add Vulkan support
Diffstat:
| M | README.md | | | 47 | +++++++++++++++++++++++++++++++++++++++++++---- |
| M | default.nix | | | 37 | ++++++++++++++++++++++++++++++++++--- |
2 files changed, 77 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
@@ -1,4 +1,4 @@
-This tool tries to solve the "OpenGL" problem on nix. Works with Nvidia cards (with bumblebee) and intel cards.
+This tool tries to solve the "OpenGL" problem on nix. Works with Nvidia cards (with bumblebee) and Intel cards. It works for Vulkan programs too.
# Quick start
@@ -33,10 +33,11 @@ libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
```
-This library contains a wrapper which is able to launch GL application:
+This library contains a wrapper which is able to launch GL or Vulkan applications:
```
nixGLXXX program
+nixVulkanXXX program
```
# Installation / Usage
@@ -61,18 +62,32 @@ OpenGL core profile version string: 4.5.0 NVIDIA 390.25
## Build
-For intel:
+For Intel GL:
```
nix-build -A nixGLIntel
```
-For NVIDIA alone:
+For Intel Vulkan:
+
+```
+nix-build -A nixVulkanIntel
+```
+
+For NVIDIA GL alone:
```
nix-build -A nixGLNvidia --argstr nvidiaVersion 390.25
```
+For NVIDIA Vulkan alone:
+
+Note that the NVIDIA GL and Vulkan wrappers are identical aside from the name
+
+```
+nix-build -A nixVulkanNvidia --argstr nvidiaVersion 390.25
+```
+
(replace `390.25` with the host driver version gathered earlier.)
For Nvidia with bumblebee:
@@ -94,10 +109,18 @@ nix-env -i ./result
# Usage
+For GL programs
+
```
nixGLXXX program args
```
+For Vulkan programs
+
+```
+nixVulkanXXX program args
+```
+
For example (on my dual GPU laptop):
```bash
@@ -107,6 +130,22 @@ $ nixGLNvidiaBumblebee glxinfo | grep -i 'OpenGL version string'
OpenGL version string: 4.6.0 NVIDIA 390.25
```
+Another example (on an XPS 9560 with the Intel GPU selected):
+
+```bash
+$ sudo apt install mesa-vulkan-drivers
+...
+$ nixVulkanIntel $(nix-build '<nixpkgs>' --no-out-link -A vulkan-loader)/bin/vulkaninfo | grep VkPhysicalDeviceProperties -A 7
+VkPhysicalDeviceProperties:
+===========================
+ apiVersion = 0x400036 (1.0.54)
+ driverVersion = 71311368 (0x4402008)
+ vendorID = 0x8086
+ deviceID = 0x591b
+ deviceType = INTEGRATED_GPU
+ deviceName = Intel(R) HD Graphics 630 (Kaby Lake GT2)
+```
+
# Limitations
Does not work now for AMD drivers because I dont' have the hardware.
diff --git a/default.nix b/default.nix
@@ -39,16 +39,16 @@ rec {
chmod u+x $out/bin/nixGLNvidiaBumblebee
'';
- nixGLNvidia = runCommand "nixGLNvidia-${version}" {
+ nixNvidiaWrapper = api: runCommand "nix${api}Nvidia-${version}" {
buildInputs = [ nvidiaLibsOnly ];
meta = with pkgs.stdenv.lib; {
- description = "A tool to launch OpenGL application on system other than NixOS - Nvidia version";
+ description = "A tool to launch ${api} application on system other than NixOS - Nvidia version";
homepage = "https://github.com/guibou/nixGL";
};
} ''
mkdir -p $out/bin
- cat > $out/bin/nixGLNvidia << FOO
+ cat > $out/bin/nix${api}Nvidia << FOO
#!/usr/bin/env sh
export LD_LIBRARY_PATH=${nvidiaLibsOnly}/lib
"\$@"
@@ -57,6 +57,10 @@ rec {
chmod u+x $out/bin/nixGLNvidia
'';
+ nixGLNvidia = nixNvidiaWrapper "GL";
+
+ nixVulkanNvidia = nixNvidiaWrapper "Vulkan";
+
nixGLIntel = runCommand "nixGLIntel-${version}" {
buildInputs = [ mesa_drivers ];
@@ -74,4 +78,31 @@ rec {
chmod u+x $out/bin/nixGLIntel
'';
+
+ nixVulkanIntel = runCommand "nixVulkanIntel-${version}" {
+ meta = with pkgs.stdenv.lib; {
+ description = "A tool to launch Vulkan application on system other than NixOS - Intel version";
+ homepage = "https://github.com/guibou/nixGL";
+ };
+ } ''
+ mkdir -p "$out/bin"
+ cat > "$out/bin/nixVulkanIntel" << EOF
+ #!/usr/bin/env bash
+ if [ ! -z "$LD_LIBRARY_PATH" ]; then
+ echo "Warning, nixVulkanIntel overwriting existing LD_LIBRARY_PATH" 1>&2
+ fi
+ export LD_LIBRARY_PATH=${lib.makeLibraryPath [
+ zlib
+ libdrm
+ xorg.libX11
+ xorg.libxcb
+ xorg.libxshmfence
+ wayland
+ gcc.cc
+ ]}
+ exec "\$@"
+ EOF
+ chmod u+x "$out/bin/nixVulkanIntel"
+ ${shellcheck}/bin/shellcheck "$out/bin/nixVulkanIntel"
+ '';
}