-
-
Notifications
You must be signed in to change notification settings - Fork 102
WebGPU surface creation / basic app lifecycle #1302
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
base: the-wgpu-moment
Are you sure you want to change the base?
WebGPU surface creation / basic app lifecycle #1302
Conversation
| if (Platform.get() == Platform.MACOSX) { | ||
| return GLFWNativeCocoa.glfwGetCocoaWindow(window); | ||
| } else { | ||
| throw new UnsupportedOperationException("Window handle retrieval not implemented for this platform"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@catilac We'll need to add wayland/x11 detection here for linux. Window I think should be pretty easy I just can't test right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll get it going on wayland!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing! Merge when ready. I'll get started on wayland support since I'm running it.
Also I'm seeing how this lib can be consumed by other languages like C or python
| F: FnOnce() -> Result<T, ProcessingError> + panic::UnwindSafe, | ||
| { | ||
| // we'll catch panics here to prevent unwinding across the FFI boundary | ||
| panic::catch_unwind(|| match f() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooh good catch. i'll be sure to pay attention to this
| tracing = "0.1" | ||
| tracing-subscriber = "0.3" | ||
| bevy = { version = "0.16", no-default-features = true, features = [ | ||
| bevy = { version = "0.17", no-default-features = true, features = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YAY
| ] } | ||
| thiserror = "2" | ||
| thiserror = "2" | ||
| raw-window-handle = "0.6" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a library to help us manage a raw window handle to pass into JVM world?
Implements the basic rendering lifecycle needed to drive bevy forward from the processing event loop.
When a
PSurfaceGLFWis created, we pass the window handle over ffi and import it into bevy. Bevy then will create the underlyingwgpusurface via its ordinary operations for windows. TheWindowhere we insert is a non-functional facade -- we'll make sure to synchronize it from the Java side but have no need atm to allow bi-directional communication (i.e. bevy resizes Glfw).There's some additional work we'll need to do to think about multi-window support. Right now we're driving the wgpu renderer forward in
endDrawonPGraphicsWebGPUbut this may not be correct in the presence of multiple graphics contexts.Basically, for implementing the main processing api, what we'll want to do is run all the user's functions to build up a frame's worth of abstract draw data on the Rust side (i.e. insert stuff into the ECS world as needed) and then run
updateonce at the end of frame which will drive the world forward one tick and present to the surface.GLFW + AWT = :(
GLFW does not play nice with AWT, especially on macOS where we have the requirement to run on the main thread. This is well documented including in this repo and will be an issue long term. Right now, I've chosen to just hard code disabling AWT when launching a sketch, but we'll need a more comprehensive solution here eventually.
How to test
Right now, I've only added support for macOS because I don't have my other machines to test on. But if you have a mac it should be pretty easy, just add a basic bevy scene to the app init. The next PR should implement our first basic actual rendering to test from Java.