UnityGaussianSplatting icon indicating copy to clipboard operation
UnityGaussianSplatting copied to clipboard

Platforms: WebGPU support

Open ca1773130n opened this issue 1 year ago • 10 comments

Thanks for sharing your great work. I've been investigating about how to make this run on web browsers.

WebGL doesn't work as there is no compute shaders, so we need WebGPU backend. Fortunately, Unity 2023 beta supports experimental WebGPU though some scripting for editor is needed to enable it.

For now I'm struggling with radix sort codes from FidelityFX, to make it work on WebGPU. Here's some issues:

It seems like WGSL does not have a counterpart of GroupMemoryBarrierWithGroupSync().

  • It's being converted to just workgroupBarrier() which will slow down the sorting algorithm.
  • Also the shader compilation fails due to calling the function on a non-uniform control bound.
  • I couldn't succeeded to modify the original HLSL code to make it work.

wavebasic does not work. it produces an error like: invalid kernel index passed.

  • Metal backend works without it, so I can just comment it out but it could be much slower

There are working WebGPU implementations for 3D GS, so hopefully we could modify the current code to make it run without errors.

ca1773130n avatar Nov 06 '23 22:11 ca1773130n

Yeah all the shaders there right now are very much geared towards "let's assume we have a full modern shader capability", which WebGPU is still lacking in some aspects. I've spent zero effort to get this working on mobile or the web. Doable, but was not my focus.

aras-p avatar Nov 07 '23 08:11 aras-p

In my view there are going to by multiple, performant, web-native implementations (there already are). The interesting thing about this project is the Unity integration. Unity doesn't have any way to make use of WebGL or WebGPU and this projects remains the only way to use gsplats in conjunction with other Unity features.

andybak avatar Nov 07 '23 08:11 andybak

@ca1773130n Please don't hesitate to open/upvote an issue on https://github.com/gpuweb/gpuweb advocating for GroupMemoryBarrierWithGroupSync Webgpu was a severe mistake reinventing the wheel from vulkan and giving the world a subpar api but it can still be improved in the future

LifeIsStrange avatar Dec 03 '23 16:12 LifeIsStrange

Are you sure that you need GroupMemoryBarrierWithGroupSync()? Seems DX doesn’t support it and all executed in lock-step.

munrocket avatar May 09 '24 08:05 munrocket

Hi, ca1773130n Did you later successfully complete the support work for WebGPU? Can this project correctly open and view PLY files in Chrome? Thanks ~

lucylucy27 avatar Jun 28 '24 03:06 lucylucy27

Hello, I want to try to use webgl package to generate in chrome now, but after chrome runs, there is a black screen. Through my check of browser developer tools, I find that there is no compute shader. Secondly, I find that the lack of compute shader is due to the lack of browser. I look forward to your reply, which is very important to me

crazyzyz avatar Oct 31 '24 03:10 crazyzyz

@crazyzyz WebGPU is not supported right now. This very issue is open for a reason!

aras-p avatar Oct 31 '24 04:10 aras-p

目前不支持 WebGPU。这个问题是有原因的!

Do you know why

crazyzyz avatar Nov 07 '24 07:11 crazyzyz

Do you know why

Because I have not implemented the right things needed for WebGPU support. The largest issue currently is probably lack of GPU sorting, since WebGPU (right now) does not have "wave/subgroup" shader operations.

aras-p avatar Nov 07 '24 19:11 aras-p

WebGPU subgroup operations will be enabled by default in Chrome 134 : https://chromestatus.com/feature/5126409856221184

Zarbuz avatar Feb 01 '25 14:02 Zarbuz