Skip to content

Conversation

@MarijnS95
Copy link
Contributor

@MarijnS95 MarijnS95 commented Dec 23, 2025

Connections
Followup to #8012 (comment) and rust-windowing/softbuffer#298 (comment) (CC @cwfitzgerald @dhardy)

Description
While true for some window objects like winit's Window object, not everyone is or should be required to return their display handle in the same place as the window handle, by means of implementing both RawDisplayHandle and RawWindowHandle on the same object.

Additionally some APIs, specifically most/all GL(ES) context creation APIs require the RawDisplayHandle up-front to create a context that is compatible with that "compositor connection".

For this reason callers should no longer be required to pass a single object that implements both HasDisplayHandle and HasWindowHandle, allowing the former to become Optional in favour of taking the one stored (and kept alive!) in the Instance.

HasDisplayHandle can still be passed in this position however, because APIs like Vulkan have completely pushed out compositor integration via surfaces to the edge of the API and can technically let one instance or device render into multiple different RawDisplayHandle "compositor connections" concurrently.

Testing

$ WGPU_BACKEND=gl cargo r -p wgpu-example-02-hello-window
$ WGPU_BACKEND=gl cargo r -p wgpu-examples -- hello_triangle
$ WGPU_BACKEND=gl RUST_LOG=wgpu_hal=debug cargo r -p player # Changed code but don't have a file to play and test it yet

Squash or Rebase?

Doesn't matter.

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

While true for some window objects like `winit`'s `Window` object,
not everyone is or should be required to return their display handle
in the same place as the window handle, by means of implementing both
`RawDisplayHandle` and `RawWindowHandle` on the same object.

Additionally some APIs, specifically most/all GL(ES) context creation
APIs require the `RawDisplayHandle` up-front to create a context that is
compatible with that "compositor connection".

For this reason callers should no longer be required to pass a single
object that implements both `HasDisplayHandle` and `HasWindowHandle`,
allowing the former to become `Option`al in favour of taking the one
stored (and kept alive!) in the `Instance`.

`HasDisplayHandle` can still be passed in this position however, because
APIs like Vulkan have completely pushed out compositor integration via
surfaces to the edge of the API and can technically let one instance
or device render into multiple different `RawDisplayHandle` "compositor
connections" concurrently.
@MarijnS95 MarijnS95 force-pushed the window-handle-without-display branch from 9c484dd to 14caa8a Compare December 23, 2025 23:17
@cwfitzgerald cwfitzgerald self-assigned this Dec 24, 2025
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