Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work on Firefox #4

Closed
levkk opened this issue Sep 6, 2024 · 5 comments
Closed

Doesn't work on Firefox #4

levkk opened this issue Sep 6, 2024 · 5 comments

Comments

@levkk
Copy link

levkk commented Sep 6, 2024

Uncaught ReferenceError: GPUBufferUsage is not defined
    <anonymous> webgpu.ts:46
    <anonymous> index.web.ts:290
@levkk
Copy link
Author

levkk commented Sep 6, 2024

Nevermind, should of consulted this: https://developer.mozilla.org/en-US/docs/Web/API/WebGPU_API#browser_compatibility

@levkk levkk closed this as completed Sep 6, 2024
@ErichDonGubler
Copy link

For anybody who's interested: Firefox is tracking this at bug 1917099. Looks like it's close to working! 😀

@Scthe
Copy link
Owner

Scthe commented Nov 12, 2024

I did not test either nanite-webgpu nor frostbitten-hair-webgpu in Firefox, as webgpu is not available on release builds. However, both apps can render the first frame in Deno, which uses wgpu under the hood (same as firefox). Deno version:

  • deno 1.43.5 (release, x86_64-pc-windows-msvc)
  • v8 12.4.254.13
  • typescript 5.4.5

"Render the first frame" is meant to be taken literary, there are a few hacks in the codebase to make it work. In both nanite-webgpu and frostbitten-hair-webgpu , there is a src/constants.ts file that defines IS_DENO, IS_BROWSER, and IS_WGPU. These flags are used to control certain things in the app. If you are interested, you can search for their usages.

For example, bugzilla#1917099 mentions e.createQuerySet, which is used in src/gpuProfiler.ts (link to frostbitten-hair-webgpu). createQuerySet() was never called in Deno cause: const FORCE_DISABLE_GPU_TIMINGS = IS_DENO;. IIRC nanite-webgpu just did not request device feature and it's respective GpuProfiler checked for it. So this has led to some problems in Firefox as the code assumed parity with Chrome.

I've decided to not test it against Firefox canary, as I was curious how certain issues will be solved first. For example, comment from src/passes/_shaderSnippets/nagaFixes.ts:

If you create a const array e.g. const COLORS = array<vec3f, COLOR_COUNT>(...);, Naga only allows consts indices. E.g. COLORS[0], but no COLORS[i]. Fix this by creating a giant switch(). Hope you did not execute this code in a render loop!

I admit I did not check WGSL specification if this is allowed. It worked on Chrome and I if (IS_WGPU)'ed it out to make it work on Deno.

Rendering only the first frame in Deno also means I removed occlusion culling. It's an optimization for subsequent frames based on the current frame's depth buffer. But as Deno only renders the first frame, I did not bother to port the code to firefox. Comment from depthPyramidPass::runtimeEnvSupportsDepthPyramid:

wgpu/naga throws errors if we bind depth texture as normal [Sic: I meant a color texture, nothing to do with normal maps] texture. This could be fixed with more code. But it's only needed for Deno rendering, where we always render only first frame, so why bother? First frame (even on web) never uses depth pyramid, cause no previous frame data..

So yeah, this pass' shader (src/passes/depthPyramid/depthPyramidPass.wgsl.ts) does some questionable stuff. This is what (I assume) the last comment in bugzilla#1917099 refers to. Firefox will crash here, which is why I decided to wait for webgpu support in ff release version before I fix it.

@ErichDonGubler
Copy link

@Scthe:

If you create a const array e.g. const COLORS = array<vec3f, COLOR_COUNT>(...);, Naga only allows consts indices. E.g. COLORS[0], but no COLORS[i]. Fix this by creating a giant switch(). Hope you did not execute this code in a render loop!

WGPU fixed the issue where runtime-known indices weren't usable with gfx-rs/wgpu#6188; that was also a WGSL spec. thing we were behind on. 😅

@ErichDonGubler
Copy link

@Scthe: RE:

So yeah, this pass' shader (src/passes/depthPyramid/depthPyramidPass.wgsl.ts) does some questionable stuff. This is what (I assume) the last comment in bugzilla#1917099 refers to. Firefox will crash here, which is why I decided to wait for webgpu support in ff release version before I fix it.

This is being fixed in gfx-rs/wgpu#6527! Once again, something we were behind on in the spec. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants