nix-community / flake-firefox-nightly

this provides an auto-updating flake for firefox-nightly-bin from nixpkgs-mozilla [maintainer=@colemickens, @Artturin]
53 stars 7 forks source link

webgpu support #36

Open herkhinah opened 9 months ago

herkhinah commented 9 months ago

Firefox nightly supposedly has webgpu support but I can't get it running. Firefox complains Validation error without device target: No suitable adapter found. In about:config WebGPU is enabled and the blocklist is disabled and about:support says it can also find my integrated graphics card. Do I have to configure some environment variables so firefox can find some missing libraries?

colemickens commented 9 months ago

we have historically had issues with firefox-bin variants and hardware acceleration, but it is working for me:

screenshot-1708101156

It doesn't seem like I have anything webgl overriden in my about:config either.

MatthewCroughan commented 6 months ago

Setting LD_LIBRARY_PATH=/run/opengl-driver/lib on NixOS fixed this for me.

colemickens commented 6 months ago

I will try to keep this tab open to look at it, but I'm getting swamped from multiple angles in my life right now and don't know when I'll really be able to give this attention.

For what it's worth, I am glad to be aware of this. I'm surprised that Firefox Nightly works as well as it does, seemingly without the same type of wrapper present in nixpkgs wrapped-firefox builds. I was sure that we have had to fix this same opengl/libglvnd wrap issue for this build in the past.

There's a Nix Mozilla Matrix room too, might be worth bringing this up there if someone else wants to investigate more.

colemickens commented 6 months ago

This works for me, by just running firefox-nightly: https://toji.github.io/webgpu-test/

When I look at firefox-nightly, it's a shell script that pulls libglvnd in LD_LIBRARY_PATH which should enable gpu driver loading via /run/opengl-driver.

MatthewCroughan commented 6 months ago

@colemickens yeah, for what it's worth I didn't notice any slowdowns, but also never performed any tests prior to wrapping with LD_LIBRARY_PATH. However, it did make the log lines go away. But maybe the log lines don't mean much in the first place. Who knows!

Niedzwiedzw commented 2 months ago

hello, I have that problem. I need to get wgpu on firefox running and I'm getting the same error. I'm on AMD gpu, could that be related? LD_LIBRARY_PATH=/run/opengl-driver/lib firefox-nightly doesn't solve it either sadly

Niedzwiedzw commented 1 month ago

from my about:support / Graphics:

WebGPU Default Adapter    {
  "navigator.gpu.requestAdapter({})": null
}
WebGPU Fallback Adapter    {
  "navigator.gpu.requestAdapter({\"forceFallbackAdapter\":true})": null
}
GPU #1
Active    Yes
Description    AMD Radeon RX 7900 XT (radeonsi, navi31, LLVM 18.1.8, DRM 3.54, 6.6.50)
Vendor ID    0x1002
Device ID    0x744c
Driver Vendor    mesa/radeonsi
Driver Version    24.3.0.0
RAM    0
colemickens commented 1 month ago

I'm afraid I still don't have enough to go on. I'm using AMD as well:

WebGPU Default Adapter:

{
  "navigator.gpu.requestAdapter({})": {
    "isFallbackAdapter": false,
    "requestAdapterInfo()": {
      "architecture": "",
      "description": "",
      "device": "",
      "vendor": "",
      "wgpuBackend": "Vulkan",
      "wgpuDevice": 5761,
      "wgpuDeviceType": "IntegratedGpu",
      "wgpuDriver": "radv",
      "wgpuDriverInfo": "Mesa 24.2.2",
      "wgpuName": "AMD Radeon 680M (RADV REMBRANDT)",
      "wgpuVendor": 4098
    },
    "features": [
      "bgra8unorm-storage",
      "depth-clip-control",
      "depth32float-stencil8",
      "float32-filterable",
      "indirect-first-instance",
      "rg11b10ufloat-renderable",
      "texture-compression-bc",
      "timestamp-query"
    ],
    "limits": {
      "maxBindGroups": 8,
      "maxBindGroupsPlusVertexBuffers": 24,
      "maxBindingsPerBindGroup": 1000,
      "maxBufferSize": 1073741824,
      "maxColorAttachmentBytesPerSample": 32,
      "maxColorAttachments": 8,
      "maxComputeInvocationsPerWorkgroup": 1024,
      "maxComputeWorkgroupSizeX": 1024,
      "maxComputeWorkgroupSizeY": 1024,
      "maxComputeWorkgroupSizeZ": 1024,
      "maxComputeWorkgroupStorageSize": 65536,
      "maxComputeWorkgroupsPerDimension": 65535,
      "maxDynamicStorageBuffersPerPipelineLayout": 8,
      "maxDynamicUniformBuffersPerPipelineLayout": 16,
      "maxInterStageShaderComponents": 128,
      "maxInterStageShaderVariables": 16,
      "maxSampledTexturesPerShaderStage": 64,
      "maxSamplersPerShaderStage": 64,
      "maxStorageBufferBindingSize": 1073741824,
      "maxStorageBuffersPerShaderStage": 64,
      "maxStorageTexturesPerShaderStage": 64,
      "maxTextureArrayLayers": 2048,
      "maxTextureDimension1D": 16384,
      "maxTextureDimension2D": 16384,
      "maxTextureDimension3D": 2048,
      "maxUniformBufferBindingSize": 1073741824,
      "maxUniformBuffersPerShaderStage": 64,
      "maxVertexAttributes": 32,
      "maxVertexBufferArrayStride": 2048,
      "maxVertexBuffers": 16,
      "minStorageBufferOffsetAlignment": 32,
      "minUniformBufferOffsetAlignment": 32
    }
  }
}

AMD Radeon 680M (radeonsi, rembrandt, LLVM 18.1.8, DRM 3.57, 6.10.9)

Niedzwiedzw commented 1 month ago

yeah so it seems to be the marker for whether it's gonna work or not. question is what's the logic behind it :D I've tried looking into firefox source code to figure out how is that adapter determined but couldn't find anything

Artturin commented 1 month ago

I repro

WebGPU Default Adapter  {
  "navigator.gpu.requestAdapter({})": null
}
WebGPU Fallback Adapter {
  "navigator.gpu.requestAdapter({\"forceFallbackAdapter\":true})": null
}
GPU #1
Active  Yes
Description AMD Radeon RX Vega (radeonsi, vega10, LLVM 18.1.8, DRM 3.57, 6.10.8)
Vendor ID   0x1002
Device ID   0x687f
Driver Vendor   mesa/radeonsi
Driver Version  24.2.1.0

vega64

Niedzwiedzw commented 1 month ago

I'm fighting hard for this, because while it works on chromium, it is very jaggy and randomly crashes - also it crashes after page refresh. I remember from my arch installation this was working flawlessly on firefox-nightly, I could resize the screen and refresh however many times I wanted. any ideas what details of our setup we could compare? I've only started using nixos less than 2 weeks ago

colemickens commented 1 month ago

Are y'all using nixos-unstable? I am pretty out of my depth here. I don't think I do anything remotely special to make this work on my system.

Just to sanity check: 132.0a1 20240914211959

If I show only modified preferences and search "gpu", I get no hits, so I can't think of any "config" differences worth mentioning.

Niedzwiedzw commented 1 month ago

ok so I just had a breakthrough. it works but idk why, maybe someone here can help

  1. i pull this repo https://github.com/gfx-rs/wgpu
  2. run nix-shell ./shell.nix
  3. from within that shell I run firefox-nightly

then everything magically works. maybe someone smarter with nix could help me port this to my main configuration somehow

https://github.com/gfx-rs/wgpu/blob/trunk/shell.nix

Artturin commented 1 month ago

ok so I just had a breakthrough. it works but idk why, maybe someone here can help

1. i pull this repo [gfx-rs/wgpu](https://github.com/gfx-rs/wgpu)

2. run `nix-shell ./shell.nix`

3. from within that shell I run `firefox-nightly`

then everything magically works. maybe someone smarter with nix could help me port this to my main configuration somehow

gfx-rs/wgpu@trunk/shell.nix

Do a process of elimination on the shell by removing parts of it until it doesn't work anymore. First remove half of it then half of half and so on

Artturin commented 1 month ago

vulkan-loader is the fix

https://github.com/NixOS/nixpkgs/pull/349116

image

colemickens commented 1 month ago

I assume this should be fixed in the wrapper in nixpkgs?

Artturin commented 1 month ago

I assume this should be fixed in the wrapper in nixpkgs?

I linked the pr

Niedzwiedzw commented 1 week ago

sorry but it didn't fix it, I still need to run nix-shell ~/Programming/wgpu/shell.nix --command firefox-nightly for it to work

❯ firefox-nightly --version
Mozilla Firefox 132.0a1
Artturin commented 1 week ago

sorry but it didn't fix it, I still need to run nix-shell ~/Programming/wgpu/shell.nix --command firefox-nightly for it to work

❯ firefox-nightly --version
Mozilla Firefox 132.0a1

Try the other vulkan packages, maybe I had an impurity.