nix-community / nixGL

A wrapper tool for nix OpenGL application [maintainer=@guibou]
677 stars 78 forks source link

GL and Vulkan at the same time #91

Open leiserfg opened 2 years ago

leiserfg commented 2 years ago

Is there a way of exposing both APIs at the same time? There are apps that are able to change from one backend to the other (games manly but also some other 3d dev apps). Also, I'm thinking of wrapping my app launcher (or maybe even my Xsession so all the apps get GL and Vulkan if they need it but as far as I understand, with the current approach one has to pick one or the other.

Nidrop commented 2 years ago

Same question. Chromium can use both. Chromium from flatpak works ok, but chromium from Nix fails to run Vulkan. For testing: Enable chrome://flags/#enable-vulkan, optionally chrome://flags/#ignore-gpu-blacklist, restart and check chrome://gpu/. If it crashes, edit ~/.config/chromium/Local State, change enable-vulkan@1 to enable-vulkan@2 to disable Vulkan.

seitenca commented 1 year ago

For me using nixGL nixVulkanIntel program solve the issue

Nidrop commented 1 year ago

@seitenca Does OpenGL also work in you case?

seitenca commented 1 year ago

@Nidrop yes, at least works on Yuzu, I can change from OpenGL and Vulkan with no issue

seitenca commented 1 year ago

@Nidrop just tested it on Brave

with nixGL and nixVulkanIntel

Graphics Feature Status
Canvas: Hardware accelerated
Canvas out-of-process rasterization: Disabled
Direct Rendering Display Compositor: Disabled
Compositing: Hardware accelerated
Multiple Raster Threads: Enabled
OpenGL: Enabled
Rasterization: Hardware accelerated
Raw Draw: Disabled
Video Decode: Hardware accelerated
Video Encode: Hardware accelerated
Vulkan: Enabled
WebGL: Hardware accelerated
WebGL2: Hardware accelerated
WebGPU: Disabled

only nixGL

Graphics Feature Status
Canvas: Hardware accelerated
Canvas out-of-process rasterization: Disabled
Direct Rendering Display Compositor: Disabled
Compositing: Hardware accelerated
Multiple Raster Threads: Enabled
OpenGL: Enabled
Rasterization: Hardware accelerated
Raw Draw: Disabled
Video Decode: Hardware accelerated
Video Encode: Hardware accelerated
Vulkan: Disabled
WebGL: Hardware accelerated
WebGL2: Hardware accelerated
WebGPU: Disabled

without nixGL and nixVulkanIntel

Graphics Feature Status
Canvas: Software only, hardware acceleration unavailable
Canvas out-of-process rasterization: Disabled
Direct Rendering Display Compositor: Disabled
Compositing: Software only. Hardware acceleration disabled
Multiple Raster Threads: Enabled
OpenGL: Disabled
Rasterization: Software only. Hardware acceleration disabled
Raw Draw: Disabled
Video Decode: Software only. Hardware acceleration disabled
Video Encode: Software only. Hardware acceleration disabled
Vulkan: Disabled
WebGL: Software only, hardware acceleration unavailable
WebGL2: Software only, hardware acceleration unavailable
WebGPU: Disabled
Nidrop commented 1 year ago

@seitenca I confirm it. Brave works even without nixVulkanIntel in my case (idk why). nixGL brave:

Graphics Feature Status
Canvas: Hardware accelerated
Canvas out-of-process rasterization: Disabled
Direct Rendering Display Compositor: Disabled
Compositing: Software only. Hardware acceleration disabled
Multiple Raster Threads: Enabled
OpenGL: Enabled
Rasterization: Hardware accelerated
Raw Draw: Disabled
Video Decode: Hardware accelerated
Video Encode: Hardware accelerated
Vulkan: Enabled
WebGL: Hardware accelerated but at reduced performance
WebGL2: Hardware accelerated but at reduced performance
WebGPU: Disabled

My ungoogled-chromium issue seems to be related to https://github.com/NixOS/nixpkgs/issues/150398

@leiserfg I think we can close the issue.

leiserfg commented 1 year ago

Fine for me, I'm not using nixGL any more so I can't reproduce it myself

rengare commented 1 year ago

@leiserfg Here is my wrapper example musing both GL and Vulkan drivers

  nixGLVulkanMesaWrap = pkg:
    pkgs.runCommand "${pkg.name}-nixgl-wrapper" { } ''
      mkdir $out
      ln -s ${pkg}/* $out
      rm $out/bin
      mkdir $out/bin
      for bin in ${pkg}/bin/*; do
       wrapped_bin=$out/bin/$(basename $bin)
       echo "${lib.getExe pkgs.nixgl.nixGLIntel} ${
         lib.getExe pkgs.nixgl.nixVulkanIntel
       } $bin \$@" > $wrapped_bin
       chmod +x $wrapped_bin
      done
    '';

here you can see what I have done so you can easly set it up rengare/dotfiles

leiserfg commented 1 year ago

Given that I only use it on my office laptop (where I can't use nixos) I just use a home-manager managed xsession and expose the gl and vulkan drivers in as environment variables , which works fine so far. Thanks any way @rengare