-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
WGPU Backend #221
Comments
Thanks for the kind words 🙏 It would be cool with other backends and I have considered it, I even planned for it. However, I'm not sure how much benefit it will do right now compared to the amount of work (but please prove me wrong). Also, I'm not sure about WGPU as opposed to directly using WebGPU, Metal, Vulkan etc. but I will definitely consider it if it becomes relevant. However, first, I need to be convinced that another backend is worth the trouble 🙂 So to explain my opinion, please keep in mind the purpose of
This is definitely a good argument for making a Metal backend, but OpenGL is still working, so not super urgent.
OpenGL is, as you said, still relevant and still the most cross platform graphics API and on some platforms the standard graphics API. For me, that it's old, is not an argument that would make me do a lot of work.
I specified 3.3 since that corresponds to webgl2 and I can therefore write the same code (almost). I'm curious to know what you want to use compute shaders for? Also, please keep in mind the purpose of
GLOW will definitely not support WebGPU. Again I'm curious as to what features you are missing? And again, think of the purpose of
It's true that you can get a performance gain if using a modern graphics API, but I would always look at the code and hardware first. How much you gain will depend on the platform, some might give a significant speed-up (I'm guessing apple products). However, modern graphics APIs tend to be more complex and that complexity will either be reflected in |
I think there are some good points in support of wgpu.
one obvious issue is that its still not final and breaking changes every few months. opengl is
I definitely think opengl backend should be the priority for now as wgpu is still unstable. but having wgpu backend is cool because
EDIT: |
Thanks for the input @coderedart 👍 First of all, I hope that I got the right message across with the first reply; I definitely think it is a good idea with other backends. My sole concern is that it is a lot of work (all shaders has to be reimplemented for example) and that it will limit other development efforts, but it is difficult to know exactly how bad it is. Could be interesting to make a quick proof of concept though. I didn't (and I still haven’t) looked much into WGPU, I just follow it at a distance, so nice with some insights. Could be really nice to have one API instead of implementing a lot of different backends, so it is quite attractive, but it sounds like it needs to be a bit more stable. Compute shaders are definitely nice to have, but unfortunately they are not available everywhere yet, so I’m unsure how I can support them without dropping support on some platforms or having specific behaviour for different platforms which wouldn't be nice from a user perspective. Also, I think you can draw millions of billboards with |
At least for me the appeal of compute shaders and my use case for them is to be able to simulate large numbers of particles in real-time. I didn't realize glow actually supports compute shaders, if you were going to implement them I would just make it so they all have the same interface, that way the user doesn't need to figure out what function to call on what platform. If the user is on a platform / OpenGL version that doesn't support compute shaders then just panic like std does. You could also have a toggle of some kind somewhere like Portable and Desktop then its up to the user to figure out which is better for their use case given a list of features each one supports. Also as far as wgpu stability goes the bevy engine uses it and I haven't seen them having any major issues with it. Also wgpu does support GLSL shaders so you might not need to completely rewrite them. |
btw, I'm not asking three-d to support compute shaders. three-d can stay simple (as it is right now), and only expose the current high/mid API abstracting over wgpu / openGL. but i would like to take that low level context rendering api to use compute shaders or other features based on my target hardware. One reason I'm afraid of openGL is the driver issues and unsafety.
one really really convincing argument for three-d itself, regardless of my niche use case, is that wgpu is getting angle backend which allows it to run even on gles 2 or dx11 platforms (source: wgpu README). if i use three-d (with wgpu) and find that some of my users using windows 11 have issues with vulkan drivers, i could just change a single line in my app and release a dx12 version until the drivers are fixed as a workaround or even gles with less performance workarounds. I can even just change the backend i use at program startup based on user configuration (MYAPP_DRIVER_BACKEND) and ask them to test if some bug is happening with other backends too. its way too convenient :) I cannot use sprites for now. |
I think both of you have valid points 👍 This is of course not just a discussion about compute shaders, but I think it is a good example of a feature that could be added at some point in the future to That leads os to the points about OpenGL unsafety and so on, which are very valid indeed. One of the points of using a library like Driver bugs is also a valid point, I'm don't have a windows computer, so I don't know how bad it is. And yeah apple support is also a valid point as I also said earlier. However, these things tend to move very slowly (I predict that WebGPU is not supported on all major browsers before at least 5 years, and probably 10 😆 ).
And @coderedart, your use case sounds super nice, please share screenshots or something, if you'd like. And it might be super niche, but I think it is a quite typical that you want to use |
@asny I will also add to discussion. WebGPU is new, it removed a lot of mistakes from previous graphics api interfaces. It provide easier interface and scalability than OpeGL, my boss which is senior OpenGL engineer is saying he never want to go back to OpenGL :D :D, But in future WebGPU will provide access to Vulkan/Metal/DirectX core via browser, so for us who develop Web3D content for industry it will be gamechanger and we can create bigger and better looking applications :) And basically, when WebGPU will be supported across browsers, you can remove all your opengl code, there will be no backend, there will be only webgpu , which will cover opengl,vulkan,metal for your :) |
@asny wgpu is rust crate which implements webgpu standard :) so I think thats the same,... |
if i wanted to add wgpu backend to three-d, where would i start? start porting the shaders and mid-level api? I just realized that |
That's a good question. This may be obvious but it should just be to change the context in the This was the very naive description of the task, in practice it is probably not that easy to switch since
Well, I'm pretty sure |
understood, i will start by first porting to winit, which is useful regardless of the wgpu stuff. not urgent, but one thing that will need consideration for high level APIs is that wgpu can be multi-threaded, so for example, you could setup a rendergraph first and execute it later in a background thread like pipelined rendering. |
Sounds great 👍 Good point. For the record, I think we should avoid multi threading right now to not complicate things further, but I guess that is also what you are saying. However, I guess the solution is also relevant with respect to the immediate mode of OpenGL and command queue of |
porting to winit was pretty easy. but I give up on adding wgpu to three-d. It is very much possible to do so, but first, rewriting it from scratch seems to be much simpler and easier than patching the existing code. and second, i also don't have enough rendering knowledge to pull it off.
Ofcourse, if someone else feels different, then they are welcome to try. that's why i mentioned naga and shader reflection so that the next person knows where to start. |
I totally understand, I tried to warn you that this was no small endeavour 😆 I'm not sure I agree about rewriting from scratch now that I know how much effort that takes, but you are right that About the shaders, if it is not easy to do automatic conversion using Naga (I would just do it offline and have both copies of the shader in the source) they could be written again. Shouldn't be a big problem to do, it again just requires effort, and of course multiple shaders needs to be kept in sync.
I'll dare you to do it 😆 |
Based on the above conversation I wonder if their would be a reason to keep Glow and not just have wgpu as the only backend. Wgpu supports opengl es, webgl2 and angle which should cover older computers and web(until webgpu is prevalent). |
Yeah that might be a good approach but i would prefer that both live alongside each other in the beginning if it's at all possible. Again the overall structure of |
One reason is because wgpu currently has issues with hybrid graphics on Linux. Particularly if the dpgu is Nvidia based, and it seems related to wayland (xorg is unmaintained tech now). If wgpu were to be used it would have to closely follow upstream. You can see some of what I've experienced here |
It would be cool to have a WGPU backed for a couple of reasons
There is another framework https://github.com/BVE-Reborn/rend3 that is similar to this one that uses WGPU as its back-end but it is a lot more verbose compared to this library.
Thanks for offering a really cool and simple to get started 3D Library in rust :)
The text was updated successfully, but these errors were encountered: