-
Notifications
You must be signed in to change notification settings - Fork 60
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
Investigate rendering backends, such as gfx-rs or wgpu-rs or glow #34
Comments
|
Games From Scratch: Cross Platform OpenGL Alternatives has a good list, several options. Use an existing rendering engine (no go, would like to stay lower level as Steven already is, but could be viable in some situations). Use Vulkan + MoltenVK (but then, another layer of abstraction, and does everything have Vulkan yet? Not quite ready to let go of OpenGL yet). Or what I'm interested in: use an abstraction layer. bgfx gets high marks but there is also:
Neither of these are too appealing. The other options are to implement our own rendering backends separately, or, stay on OpenGL (do nothing). But bgfx continues to tempt. An informative presentation: From the Dark Side of the Moon: GPU Programming with BGFX and Eclipse, a good introduction to bgfx (although for a different platform, general concepts apply). BGFX has its own shader compiler, shaderc, which accepts its own shading language language .sc, similar to glsl, but is preprocessed, so it is compiled to other rendering backend languages, examples:
and:
The only potential problem with bgfx is the Rust wrapper, https://github.com/rhoot/bgfx-rs was last modified 2 years ago, and isn't published on crates.io. There is an open pull request rhoot/bgfx-rs#3 to update to the latest bgfx and dependencies, but the CI failed. Last commit adds this disclaimer to the readme:
There are 7 forks, which one is the newest? fuzzybinary is 7 commits ahead, and jazzay in turn has a fork of it, even. TheJare is 18 commits ahead, 2 behind. Either way, using bgfx will likely mean I'll need to do some of my own maintenance on bgfx-rs. And having bindings to a library written in another language is another downside, why not go all Rust? This is the mission of gfx-rs. Their goals are outlined in the 2017 blog post We need to go lower:
The momentum and community seems to be more behind gfx-rs than bgfx-rs, how much effort would it be to port Steven to it? |
This is cool too: https://github.com/tomaka/glutin - bills itself as a "Pure Rust alternative to GLFW". Steven doesn't use GLFW, but it uses the tried and true SDL, which is in some ways a predecessor to GLFW. SDL2 is the only 3rd party dependency that has to be manually installed (e.g., besides Rust crates through cargo) since OpenSSL was removed https://github.com/iceiix/steven/issues/2, would be nice to get rid of it, simplifying installation. SDL2 can be replaced with glutin independently of changing out the OpenGL rendering code with gfx-rs or whatever, and should be easier, Steven doesn't use it very much:
|
Merged in the switch to glutin, but still using Steven's homegrown OpenGL 3.2 wrapper. glium is another wrapper, intended to be higher-level and safer to use; very popular and it aims to detect undefined behaviors and manage state. But "Glium is no longer actively developed by its original author. That said, PRs are still welcome and maintenance is continued by the surrounding community." It may be nice to catch more bugs at compile-time or with glium library checks, especially since rendering can be so platform-specific, but it is no silver bullet. The author has moved onto vulkano, a Vulkan wrapper. Another newer lighter wrapper is grr but it is only for OpenGL 4.5+ (Difference between OpenGL 3.x and 4.x?). Would like to stick to OpenGL 3 to maximize compatibility for now (what about OpenGL 2? History of OpenGL, differences between OpenGL 2.1 and 3.0?, probably not worth going back to 2 now that 3 is widely supported). gfx-rs certainly worth keeping an eye on, if going to put in the effort to switch out the whole rendering system, would like to get some more benefits. |
Update: gfx-hal is out: https://www.reddit.com/r/rust_gamedev/comments/a9vs20/gfxhal_is_finally_published/ but it has a regression from gfx in terms of supporting WebGL, because it is based on Vulkan instead of OpenGL. However, it may support WebGPU well:
How promising is WebGPU? https://en.wikipedia.org/wiki/WebGPU
as of yet unreleased, but once it is more supported, could consider using it. |
gfx-rs is coming up again in #92 WebAssembly support, once it supports wasm32-unknown-unknown/WebGL target, it will be quite appealing for this project. grovesNL is working on adding that, using his "GL on Whatever" set of bindings: https://github.com/grovesNL/glow to target OpenGL + OpenGL ES + WebGL avoiding target-specific code. As an intermediate step, may want to see if can replace the homegrown steven_gl wrapper with glow? Though ultimately, gfx-rs may be the way to go. Start porting to it now? (for native at first). Another complication, from https://gfx-rs.github.io/2018/12/27/this-year.html:
wgpu: https://github.com/gfx-rs/wgpu, still incomplete pre-"draw the first triangle" stage, but under active development, last modified within days. A pleasure to use for native or web, sounds promising. But is this too many abstractions, WebGPU to gfx-rs to Vulkan-like API/SPIR-V to WebGL? |
https://wiki.alopex.li/AGuideToRustGraphicsLibraries2019 No clear winner still, but there are some important recent developments: 2019-04-26 https://phaazon.net/blog/pre-luminance-n-random-thoughts - for 1.0.0 the author is planning "At least one WebGL implementation and it must be WASM compatible." 2019-04-18 https://amethyst.rs/blog/moss-grant-announce/ - Amethyst was awarded a $10,000 grant for making it run in the browser with WebAssembly, and they plan to help where possible with: https://github.com/rust-windowing/winit/pull//797 stdweb support for eventloop 2.0 WebGPU working group https://www.w3.org/community/gpu/ https://github.com/gpuweb/ (not to be confused with https://github.com/webgpu and https://webgpu.com) is still active, as is https://github.com/gfx-rs/wgpu/, but isn't shipping in browsers yet. Targeting wgpu may very well be a good option, and the wgpu developers agree: https://old.reddit.com/r/rust/comments/bjnxd3/a_guide_to_rust_graphics_libraries_as_of_2019/emeznnf/
|
Posted more thoughts at https://www.reddit.com/r/rust/comments/bjnxd3/a_guide_to_rust_graphics_libraries_as_of_2019/emfekoe/ (in https://www.reddit.com/r/rust/comments/bjnxd3/a_guide_to_rust_graphics_libraries_as_of_2019/), but looking at https://github.com/gfx-rs/wgpu/ more closely, it already supports Vulkan (Windows/Linux), D3D12/11 (Windows), and Metal (macOS/iOS) platforms. Could I port to |
#171 wasm broken: not yet implemented: Glutin-Blank: Platform unsupported |
https://old.reddit.com/r/rust_gamedev/comments/brehgw/rendy_02_released/ has some more insights:
warming up to the idea of targeting wgpu-rs...it would require WebGPU support in browsers, but fine with targeting only the latest, presuming it would be supported eventually. The other dichotomy is gfx-hal/rendy, from https://www.reddit.com/r/rust_gamedev/comments/bn71it/gfxhal02_is_released/:
Is this project a demanding engine or a simpler engine/framework? |
https://github.com/Gordon-F/crossplatform_gfx_hal_example https://www.reddit.com/r/rust_gamedev/comments/bv7w2f/wgpurs_now_uses_rendy_to_manage_memory_and/ Looks like wgpu-rs is again a good choice, as for "4. wgpu-rs for the lowest safe level", |
https://github.com/rust-windowing/glutin now recommends glow:
https://github.com/grovesNL/glow
Looks great. The example shows targeting native through glutin, native through sdl2, and the web. Is this the cross-compatible crate I have been searching for? How hard would it be to adapt to use glow instead of glutin? |
Another new project, looks promising, bills itself as "Keep it simple, stupid 3d graphics engine for Rust " https://github.com/sebcrozet/kiss3d http://kiss3d.org |
Update: gfx-hal 0.3.0 is released, continues to march forward: https://www.reddit.com/r/rust/comments/cnvfrm/gfxhal03_release_notes/ Most notably, they added wasm32-unknown-unknown support to the GL backend so it runs on the web, and switched from gl-rs to glow. Looking more and more that glow is the way to go. Not to rule out gfx-rs but would be a larger change. Ought to replace gl-generator/khronos_api (from steven_gl) with glow then see where we're at with #171 wasm support. |
icefoxen (no relation) has posted an excellent (as usual) "State of GGEZ 2020" report with many points also relevant to this project: https://wiki.alopex.li/TheStateOfGGEZ2020 A few takeaways: gfx-hal and rendy are promising cross-API compatible abstraction layers, a Vulkan-like API, but
What about WebGPU? Not standardized yet, probably will happen some day with wgpu using gfx-hal and rendy so "its ability to run on Web is still tied to theirs". The author speaks positively of newer versions of OpenGL:
This project currently targets OpenGL 3.2 and OpenGL ES 2.0, src/main.rs: .with_gl(glutin::GlRequest::GlThenGles{opengl_version: (3, 2), opengles_version: (2, 0)}) should update to OpenGL 4.3 and OpenGL ES 3.0, to target WebGL 2? The author of ggez came to the same conclusion I was leaning towards:
glow it is! (At least until gfx or wgpu are more ready) |
Update from glutin 0.21.x fork to glutin 0.22.0-alpha5 and corresponding compatible version of winit. This removes our custom temporary wasm_stub branches, back to mainline glutin and winit, and is a step towards WebAssembly compatibility, most importantly merging the game loop and event loops as required by winit _which now supports wasm_. Not yet functional on the web because other web dependencies have to be added, see #171 and #34, but native functionality is preserved. * Update for 0.22 glutin API changes: * Move game logic into event loop, run() replacing poll_events() * Specify fullscreen Borderless mode * Pass generic parameter of Event through handle_window_event * hidpi_factor() replaces get_hidpi_factor() * with_inner_size() replaces with_dimensions() * No longer need to unwrap() LogicalSize * set_cursor_grab/visible() replaces grab/hide_cursor() * Fix modifiers deprecated warnings by destructuring only event fields we use, ignoring the rest with '..' * Remove unnecessary mutability from events_loop * Listen for ModifiersChanged event, fixing deprecated modifiers field * Change to stdweb for web backend, replacing web-sys * Pin to glutin =0.22.0-alpha5 and winit =0.20.0-alpha6
More progress on wgpu-rs: https://gfx-rs.github.io/2020/04/21/wgpu-web.html wgpu-rs on the web
|
Decided for now to go with glow, GL on Whatever. A lightweight wrapper, supporting up to OpenGL 4.6 on native; we currently target OpenGL 3.2 on native so this works. For web, we could target WebGL 2 through glow (and also possibly OpenGL ES 3.0 for native). Merged glow support in #262, only working with OpenGL at the moment but see #446 and #451 for progress on getting WebGL working. |
Currently, steven uses OpenGL 3.2 core profile, through
SDL2 (#35)and gl_generator + khronos_api with a custom but lightweight wrapper, steven_gl: https://github.com/iceiix/steven/tree/updates/gl + https://github.com/iceiix/steven/blob/updates/src/gl/mod.rs. Is there a better way to do this? (3D graphics)May help with graphical glitches such as https://github.com/iceiix/steven/issues/25, and/or cross-platform compatibility
The text was updated successfully, but these errors were encountered: