-
Notifications
You must be signed in to change notification settings - Fork 987
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
Is OpenGL Supported now? #450
Comments
GL was removed some time after we added it. Currently, it's not supported. |
Cool, thanks for the clarification. 👍 I'm good with closing this then, unless you think it should be left open. 🙂 |
Well, we don't have an issue open for GL, so I'm thinking of leaving this one open. |
At this point, would all that is necessary to get this working be to add the GL gfx backend code just like the Vulkan backend code? I was just messing around with it ( I really hardly any idea what I'm doing ) and I think I got everything except I pretty much just went through and whenever there were feature gates for Linux I added a section that would use the Gl backend instead of the Vulkan backend if the GL feature was enabled. It was a little haphazard and needs to be organized, but as far as I can tell the last step was window creation. Am I in the right direction or is there more that is going to need to be done? |
@zicklag the problem here is to minimize any deviation from the existing paths. Ideally, the code should support GL fully transparently, but this requires gfx-backend-gl to be smarter about its surfaces, i.e. gfx-rs/gfx#3133 You can post your code as a draft PR, and we'll be happy to see if you are moving in the right direction :) |
OK, cool. After looking around more I see how the surface creation is |
So, as far as I understand, as shown in the gfx quad example, you can create an OpenGL surface from a context, split from a windowed context, that was built with Glutin, but in It looks like, if I can get a Context from the raw window handle, I will be able to create the Surface and there shouldn't really be any more code branching for GL at that point, similar to the Quad example. Where should I look to find out how to go from RawWindowHandle to glutin Context? |
The quad example also shows that we don't initialize the surface the same way on GL. It looks like we need something like This is just the start of our problems though. In a typical GL the window is your context. So we wouldn't be able to enumerate adapters and create devices the way we do now, unless we either:
|
So I just found Then is As far as I can find that leaves all of the platform specific code in the gl backend and we wouldn't need a separate |
The raw wayland context is what you'd want to create (on wayland only) to back the Instance. |
I went in that direction and I think I've got the context creation working. I don't fully understand what it would mean to have the two contexts share resources like you are saying, but currently it is compiling and getting past the context creation successfully. Hopefully the rest of that will make more sense later, or I've already happened to get it right. 😉 It currently isn't successfully picking up the GL adapter so that is the next thing I have to look at, but I think I've found where I need to start looking. |
OK I've gotten to the point now where it is getting the adapter and failing an assertion.
If I comment those assertions out ( just to see where it gets next ) I get:
I'll try to look into these, but any help understanding the path forward is welcome. Edit: Also a note, I don't actually have wayland on my machine so I'm creating the context with Xlib, but I've got the code in there for both Xlib and wayland so far. Edit2: After commenting out that second failing assertion I got the Cube demo to work!! Over RDP of all things LOL. We'll have to do something about those assertions, but that is really promising. 😄 Most of the other examples don't run yet. |
Thanks, @zicklag , great to see progress here! The first assertion is just due to GL backend not providing a meaningful value for one of the limits here https://github.com/gfx-rs/gfx/blob/77c3e28331f8ab593e57425b47db344f0e9e8112/src/backend/gl/src/info.rs#L361 If you want to help fixing it, you can check out gfx locally ("hal-0.4 branch") and add a Also, please make a PR here on wgpu so that we can provide you with feedback early. |
Sounds good! I've already got all of those libraries setup locally with patches on I'll get at PRs up when I get the chance, probably later today. |
OK, I've got the following PRs:
I still have to fix the failing assertions and probably some other stuff ( oh, like the rebase ), so they are just drafts, but now you can see the code. 🙂 |
@kvark Technically its possible to support both the On a side note, I'm really not liking having the I think to maintain the featureless backend selection we just need to get |
We can't support glutin under the same API, so I don't think we really have an option here. Let's only care about surfman in wgpu.
… On Mar 28, 2020, at 20:49, Zicklag ***@***.***> wrote:
@kvark Technically its possible to support both the glutin and surfman GL backends for wgpu, but do you think that it would be better just to support surfman? It would reduce the amount of features a user would have to pick from when building it. Instead of having to specify either gl-glutin or gl-surfman possibly with gl-surfman-x11 ( on Linux only ), they would just have the x11 option.
On a side note, I'm really not liking having the x11 feature, actually, but surfman won't build on MacOS with the feature enabled, and you can't run it on X11 on Linux without the feature enabled.
I think to maintain the featureless backend selection we just need to get surfman to compile on MacOS even if the x11 feature is enabled. I'll look into that, but we still need to decide on whether or not to support glutin.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
I just pushed updates to my PR's for I will probably need some help with it but none of the other examples are working: I'm not sure if |
Now with seamless wgpu integration, we can start chopping through the issues of the GL backend and fill those gaps. Amazing work, @zicklag ! |
Um, that's kind of strange. Can you see if there is in fact a
Yes that branch is necessarily using the unreleased version of WGPU which has some minor breaking changes. That one should be very simple to fix as I just ran into the same thing while building Bevy with the changes.
The Diff for Bevy was, go from this: wgpu::BindingResource::Buffer(wgpu_buffer.slice(range.clone())) to this: wgpu::BindingResource::Buffer {
buffer: wgpu_buffer,
offset: range.start,
size: NonZeroU64::new(range.end - range.start)
} In your case I'm guessing you change it to: wgpu::BindingResource::Buffer {
buffer: transform,
offset: 0,
size: None
} Also, for other projects using WGPU, to make sure WGPU properly selects OpenGL as the backend that will be used at runtime, you need to change the line somewhere in the project that says something like this: wgpu::Instance::new(wgpu::BackendBit::PRIMARY); To this: wgpu::Instance::new(wgpu::BackendBit::PRIMARY | wgpu::BackendBit::SECONDARY); That will make it search for support for all available graphics backends. If you hardware supports Vulkan, though it will use Vulkan because it works better. If you are on a system that has vulkan and you want to force using the GL backend to test it, you can change that line to this instead: wgpu::Instance::new(wgpu::BackendBit::GL); |
Hope I do not derail this issue but regarding this
I've tried the cube example but I'm only getting a black window. That's the output I get after closing the window:
I get some warnings too:
Here's probably some important info:
I can do some more tests as needed. Excited for opengl support! |
Hmm, I don't know what the issue is there. Maybe you could try the triangle example: Edit: Actually the black screen you get could be related to the synchronization errors that are creating rendering artifacts for my driver. If the current design is undefined behaviour because of shared FBO's then it could result in a black screen on one driver and glitches on another driver. I'll post here when I get an attempted fix at the synchronization issues and you can try again. |
Oh, good, thanks @jmwright. So I think that helps to confirm that we definitely need to fix some stuff around synchronization as it doesn't work for @Songtronix, works half-way for me and works completely fine for @jmwright. I'll be trying out the suggestions here to see if I can fix the issues I'm getting on my system and move towards a more sound setup. After that @Songtronix and @jmwright, you guys can try it on your systems and see if it's any better/worse. |
After some hacking of Unfortunately it crashed with the following message:
Detailed backtrace:
|
Looks like it fails on |
@0x7CFE I ran the following on Arbian Bionic to get past that error.
I didn't test whether you needed both or just one of those packages. |
@jmwright, awesome! Thanks for the hint. Indeed, it helped to move forward a bit. Still no luck whatsoever:
|
Yeah @0x7CFE, I don't know how many real projects are going to work with GL support at the moment. As far as I understand, Hopefully by adding it as a backend to WGPU, though, we can finally start testing it out in real projects that already use WGPU and we can start fixing the bugs. Once we get the WGPU changes released, we can start creating bug reports for GFX to address the issues that are encountered while trying to run WGPU projects using the GL backend. |
This may be something that is a build tool issue or that needs to be filed against a different repo, but I thought I'd post here just to check. I created a fresh project with only 3 dependencies, and tried to build it on my RockPro64 64-bit ARM (Bionic Desktop) device. The app builds fine with
I get a segmentation fault somewhere along the line when compiling
|
Whoa, I've never seen a compiler segfault. 😉 Anyway I think that's unrelated to the direct changes made by the While I'm here, an update on progress: I'm still working towards fixing the rendering artifacts but I've taken a quick detour over to learnopengl.com to actually learn OpenGL, because until this point I didn't actually know what a framebuffer or a renderbuffer was. 😲 Anyway, OpenGL actually seems really easy so far. I'm going to skim through the tutorials and such just to get a better picture of how things work and then hopefully come back better armed to fix the issue. It shouldn't take long to get what I feel is a decent enough exposure to how OpenGL works before I should be able to start debugging the rendering issue here again. |
I switched to the following line in Cargo.toml and I do not get the segfault.
At this point I don't think it's worth bogging down the GL development on your fork with this segfault @zicklag . We can wait and see if anyone else has this issue, or if it's specific to my hardware/OS. |
@kvark Any news on the changes on surfman needed to avoid context sharing? Given the current situation with Mozilla I'm not sure if this is something we can expect. Context sharing seems to be the source of many problems/artifacts in the examples, and I imagine many more in real applications. And avoiding it sounded like a promising solution. |
Now that @pcwalton has departed from Mozilla, and there is no issue describing what they had in mind, and there is no news about any progress, I'd say we are on our own. Surfman itself will likely keep being maintained as Servo uses it, but we'd likely need to reconstruct the ideas Patrick had, and possibly try to implement it ourselves... Help is much needed! |
Is there anywhere that we have any rough explanation about what the original non-sharing idea was? Maybe we should dump that in a surfman tracking issue. |
Yes, we totally do that as the last step. We should dig up the matrix logs... |
Filed servo/surfman#202 |
907: Implement OpenGL Backend For Unix Platforms r=kvark a=zicklag **Connections** Requires: gfx-rs/gfx#3340 ( merged ) Should be merged first: #910 Works towards: #450 **Description** Integrates the GFX GL backend for Unix platforms **Testing** Runs the basic cube and triangle examples for wgpu-rs, but not without rendering artifacts on the cube. <!-- Non-trivial functional changes would need to be tested through: - [wgpu-rs](https://github.com/gfx-rs/wgpu-rs) - test the examples. - [wgpu-native](https://github.com/gfx-rs/wgpu-native/) - check the generated C header for sanity. Ideally, a PR needs to link to the draft PRs in these projects with relevant modifications. See #666 for an example. If you can add a unit/integration test here in `wgpu`, that would be best. --> Co-authored-by: Zicklag <[email protected]>
907: Implement OpenGL Backend For Unix Platforms r=kvark a=zicklag **Connections** Requires: gfx-rs/gfx#3340 ( merged ) Should be merged first: #910 Works towards: #450 **Description** Integrates the GFX GL backend for Unix platforms **Testing** Runs the basic cube and triangle examples for wgpu-rs, but not without rendering artifacts on the cube. <!-- Non-trivial functional changes would need to be tested through: - [wgpu-rs](https://github.com/gfx-rs/wgpu-rs) - test the examples. - [wgpu-native](https://github.com/gfx-rs/wgpu-native/) - check the generated C header for sanity. Ideally, a PR needs to link to the draft PRs in these projects with relevant modifications. See #666 for an example. If you can add a unit/integration test here in `wgpu`, that would be best. --> Co-authored-by: Zicklag <[email protected]>
There's still some outstanding issues, but OpenGL support has been merged into WGPU! |
* Implement more derives for `Operations` * Use `trace` / `replay` features for serialization * Set `store` to default
With #183 getting closed in wgpu-rs does that mean that OpenGL is now supported here and we can update the checkmark on the README?
The text was updated successfully, but these errors were encountered: