Conversation
Also adds glutin-specific support methods to wgpu-native
kvark
left a comment
There was a problem hiding this comment.
Thank you for the PR!
Our goal for GL integration should be - minimal disruption on the API, we need to reduce the divergence of code paths as much as possible, and in the long term remove it entirely (i.e. have the code path to work equally well for all backends).
Please let me know what you think of my notes
wgpu-native/src/instance.rs
Outdated
| pub fn instance_get_adapter(instance_id: InstanceId, desc: &AdapterDescriptor) -> AdapterHandle { | ||
| let instance_guard = HUB.instances.read(); | ||
| let instance = &instance_guard[instance_id]; | ||
| fn get_adapter( |
There was a problem hiding this comment.
nit: let's rename to choose_adapter
wgpu-native/src/instance.rs
Outdated
| let instance_guard = HUB.instances.read(); | ||
| let instance = &instance_guard[instance_id]; | ||
| fn get_adapter( | ||
| adapters: Vec<hal::Adapter<back::Backend>>, |
There was a problem hiding this comment.
let's turn this into a slice: &[hal::Adapter<B>]
There was a problem hiding this comment.
It returns an adapter by value not by reference, so it can't take the possible set of adapters by reference. I can change this to I: IntoIterator<Item = hal::Adapter<B>>?
There was a problem hiding this comment.
Actually it won't matter anymore since the methods will be combined again.
wgpu-native/src/instance.rs
Outdated
|
|
||
| #[cfg(feature = "gfx-backend-gl")] | ||
| #[no_mangle] | ||
| pub extern "C" fn wgpu_gl_surface_get_adapter( |
There was a problem hiding this comment.
I wonder if we can still have Instance types and (some) entry points on GL but merged with surfaces, i.e. like today we do type CommandEncoderId = CommandBufferId, we should consider type SurfaceId = InstanceId for GL only. Of course, this should be removed once GL gets proper support for headless instances...
There was a problem hiding this comment.
I actually tried to do this the first time, but I think I tried incorrectly to keep SurfaceId and InstanceId separate and was stymied by Surface not being clone-able. I'll see if there is more of the API surface that can be kept common with type SurfaceId = InstanceId.
by making InstanceId a type alias to SurfaceId
|
The gl API is now somewhat closer to the vanilla, at least |
|
Thanks @kyren , let us know when it's ready to merge. |
If you're okay with this as it is, I think this is fine for the time being?. Once the gl backend is in line with the others all of this can go away, but in the meantime something like this has to exist (especially when you include webgl support). |
|
bors r+ |
|
bors r- |
Canceled |
|
I'm not entirely sure whether that was the sort of thing you were thinking, or whether I did that correctly. Edit: Oh, I seee, the makefile is ONLY used on nightly anyway... and there's a GLFW error that I don't understand yet AND this can't work from C anyway because the gl backend is unusable from C. Hmm, how exactly would you like the gl backend added to CI... I'm not sure if I understand what the best way to do that is. |
|
@kyren current CI uses glfw, which also supports GL, so we should be testing GL backend the same way we are currently testing Metal/Vulkan from C API. |
|
But the gl API isn't usable from C because it requires I'll try and make CI at least build the gfx-backend-gl feature. |
|
Thank you! |
Build succeeded |
10: Update API for new wgpu gl backend support r=kvark a=kyren This won't work until [this pr](gfx-rs/wgpu#183) is merged in wgpu, but at least this way we can discuss it. Co-authored-by: kyren <kerriganw@gmail.com>
183: Expose `enumerate_adapters`. r=kvark a=daxpedda Depends on gfx-rs#505. Use case was to give end user the ability to choose which GPU to use for an application. Co-authored-by: daxpedda <daxpedda@gmail.com>
10: Update API for new wgpu gl backend support r=kvark a=kyren This won't work until [this pr](gfx-rs#183) is merged in wgpu, but at least this way we can discuss it. Co-authored-by: kyren <kerriganw@gmail.com>
183: Expose `enumerate_adapters`. r=kvark a=daxpedda Depends on gfx-rs#505. Use case was to give end user the ability to choose which GPU to use for an application. Co-authored-by: daxpedda <daxpedda@gmail.com>
Also adds glutin-specific support methods to wgpu-native