Skip to content
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

Allow passing canvas to request_adapter #83

Merged
merged 1 commit into from
Apr 12, 2020
Merged

Conversation

almarklein
Copy link
Collaborator

@almarklein almarklein commented Apr 12, 2020

The request_adapter in wgpu-native now supports passing the surface id, so that we can make sure that the returned adapter is actually compatible with that (or such type of) surface.

I considered a few options to express this in the API, and this seems to be the most straightforward, even though it makes the API deviate from WebGPU somewhat (because in WebGPU the browser knows the surface id, so the user does not need pass it). Made it a required argument, so that it's obvious when it's set to None.

It's quite liberating that in an API that's low-level, we can afford to be a bit verbose at times :)

@almarklein almarklein merged commit f47fb71 into master Apr 12, 2020
@almarklein almarklein deleted the requestadapter branch April 12, 2020 18:58
@almarklein almarklein mentioned this pull request Apr 12, 2020
34 tasks
@Korijn
Copy link
Collaborator

Korijn commented Apr 12, 2020

Is it still possible for people to "roll their own" GUI layer? Meaning, without using one of the wgpu-py provided canvases?

@almarklein
Copy link
Collaborator Author

Yes, but they'd have to implement some abstract methods of WgpuCanvasBase, so that we can query the physical size, and obtain the surface id. As far as I can tell these are get_physical_size, get_window_id, and get_display_id (on Linux).

We could document and test this requirement. Now, or when needed :)

@Korijn
Copy link
Collaborator

Korijn commented Apr 13, 2020

I mean, without using WgpuCanvasBase (or anything else from wgpu.gui)?

In other words, can people use just the python wrappers for the webgpu API without being vendor locked into our other design choices?

@almarklein
Copy link
Collaborator Author

Well, there is some interplay between wgpu and the gui. This occurs on 2 points:

  • When requesting an adapter you can pass the surface id so that the adapter is compatible. We've changed that to passing the canvas. It can be any object as long as it implements get_window_id (and get_display_id on Linux).
  • At some point you need a swap chain. And you need to call into wgpu-native for this. So here it would be far easier to follow our "canvas interface". But it's duck-typed, so I don't think that's too big a deal.

Our current WgpuCanvasBase is a mix of that canvas interface required to interact with the wgpu-api, and some convenience functions so that all canvases work the same. We should probably split these, to make it easier for ppl to hook into the API with minimal conformance to our GUI stuff.

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.

None yet

2 participants