Skip to content

Add gfx-backend-gl support#183

Merged
bors[bot] merged 3 commits intogfx-rs:masterfrom
kyren:wgpu-gl
May 24, 2019
Merged

Add gfx-backend-gl support#183
bors[bot] merged 3 commits intogfx-rs:masterfrom
kyren:wgpu-gl

Conversation

@kyren
Copy link
Copy Markdown
Contributor

@kyren kyren commented May 19, 2019

Also adds glutin-specific support methods to wgpu-native

Also adds glutin-specific support methods to wgpu-native
Copy link
Copy Markdown
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: let's rename to choose_adapter

let instance_guard = HUB.instances.read();
let instance = &instance_guard[instance_id];
fn get_adapter(
adapters: Vec<hal::Adapter<back::Backend>>,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's turn this into a slice: &[hal::Adapter<B>]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>>?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it won't matter anymore since the methods will be combined again.


#[cfg(feature = "gfx-backend-gl")]
#[no_mangle]
pub extern "C" fn wgpu_gl_surface_get_adapter(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@kyren
Copy link
Copy Markdown
Contributor Author

kyren commented May 21, 2019

The gl API is now somewhat closer to the vanilla, at least Instance still exists now.

@kvark
Copy link
Copy Markdown
Member

kvark commented May 24, 2019

Thanks @kyren , let us know when it's ready to merge.
I really hope @msiglreith (or someone else's) work would eventually bring back the Instance on GL backend.

@kyren kyren changed the title [DRAFT] Add gfx-backend-gl support Add gfx-backend-gl support May 24, 2019
@kyren
Copy link
Copy Markdown
Contributor Author

kyren commented May 24, 2019

Thanks @kyren , let us know when it's ready to merge.
I really hope @msiglreith (or someone else's) work would eventually bring back the Instance on GL backend.

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).

@kvark
Copy link
Copy Markdown
Member

kvark commented May 24, 2019

bors r+

bors bot added a commit that referenced this pull request May 24, 2019
183: Add gfx-backend-gl support r=kvark a=kyren

Also adds glutin-specific support methods to wgpu-native

Co-authored-by: kyren <kerriganw@gmail.com>
@kyren
Copy link
Copy Markdown
Contributor Author

kyren commented May 24, 2019

For others following along, this won't be super useful until this pr is merged into gfx-hal and then this pr is merged into wgpu-rs to use the updated wgpu.

@kvark
Copy link
Copy Markdown
Member

kvark commented May 24, 2019

bors r-
Actually, can we get some CI coverage here?

@bors
Copy link
Copy Markdown
Contributor

bors bot commented May 24, 2019

Canceled

@kyren
Copy link
Copy Markdown
Contributor Author

kyren commented May 24, 2019

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.

@kvark
Copy link
Copy Markdown
Member

kvark commented May 24, 2019

@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.
At the very least, having CI to build the feature gfx-backend-gl would be useful.

@kyren
Copy link
Copy Markdown
Contributor Author

kyren commented May 24, 2019

But the gl API isn't usable from C because it requires glutin types to be passed in, so there can't really be a C API test for it.

I'll try and make CI at least build the gfx-backend-gl feature.

@kvark
Copy link
Copy Markdown
Member

kvark commented May 24, 2019

Thank you!
bors r+

bors bot added a commit that referenced this pull request May 24, 2019
183: Add gfx-backend-gl support r=kvark a=kyren

Also adds glutin-specific support methods to wgpu-native

Co-authored-by: kyren <kerriganw@gmail.com>
@bors
Copy link
Copy Markdown
Contributor

bors bot commented May 24, 2019

Build succeeded

@bors bors bot merged commit 0fe94fc into gfx-rs:master May 24, 2019
@kyren kyren deleted the wgpu-gl branch May 24, 2019 19:29
bors bot added a commit to gfx-rs/wgpu-rs that referenced this pull request Jun 8, 2019
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>
@zicklag zicklag mentioned this pull request Jan 14, 2020
mitchmindtree pushed a commit to mitchmindtree/wgpu that referenced this pull request Mar 15, 2020
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>
kvark pushed a commit to kvark/wgpu that referenced this pull request Jun 3, 2021
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>
kvark pushed a commit to kvark/wgpu that referenced this pull request Jun 3, 2021
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants