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

Fix surfaces only compatible with first enabled backend #5535

Merged
merged 7 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ Bottom level categories:
- Failing to set the device lost closure will call the closure before returning. By @bradwerth in [#5358](https://github.com/gfx-rs/wgpu/pull/5358).
- Use memory pooling for UsageScopes to avoid frequent large allocations. by @robtfm in [#5414](https://github.com/gfx-rs/wgpu/pull/5414)
- Fix deadlocks caused by recursive read-write lock acquisitions [#5426](https://github.com/gfx-rs/wgpu/pull/5426).
- Fix surfaces being only compatible with first backend enabled on an instance, causing failures when manually specifying an adapter. By @Wumpf in [#5535](https://github.com/gfx-rs/wgpu/pull/5535).

#### Naga
- In spv-in, remove unnecessary "gl_PerVertex" name check so unused builtins will always be skipped. By @Imberflur in [#5227](https://github.com/gfx-rs/wgpu/pull/5227).
Expand Down
95 changes: 0 additions & 95 deletions wgpu-core/src/any_surface.rs

This file was deleted.

4 changes: 2 additions & 2 deletions wgpu-core/src/device/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@ impl Global {
};

let caps = unsafe {
let suf = A::get_surface(surface);
let suf = A::surface_as_hal(surface);
let adapter = &device.adapter;
match adapter.raw.adapter.surface_capabilities(suf.unwrap()) {
Some(caps) => caps,
Expand Down Expand Up @@ -2058,7 +2058,7 @@ impl Global {
// https://github.com/gfx-rs/wgpu/issues/4105

match unsafe {
A::get_surface(surface)
A::surface_as_hal(surface)
.unwrap()
.configure(device.raw(), &hal_config)
} {
Expand Down
20 changes: 10 additions & 10 deletions wgpu-core/src/hal_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub trait HalApi: hal::Api + 'static + WasmNotSendSync {
fn create_instance_from_hal(name: &str, hal_instance: Self::Instance) -> Instance;
fn instance_as_hal(instance: &Instance) -> Option<&Self::Instance>;
fn hub(global: &Global) -> &Hub<Self>;
fn get_surface(surface: &Surface) -> Option<&Self::Surface>;
fn surface_as_hal(surface: &Surface) -> Option<&Self::Surface>;
}

impl HalApi for hal::api::Empty {
Expand All @@ -25,7 +25,7 @@ impl HalApi for hal::api::Empty {
fn hub(_: &Global) -> &Hub<Self> {
unimplemented!("called empty api")
}
fn get_surface(_: &Surface) -> Option<&Self::Surface> {
fn surface_as_hal(_: &Surface) -> Option<&Self::Surface> {
unimplemented!("called empty api")
}
}
Expand All @@ -46,8 +46,8 @@ impl HalApi for hal::api::Vulkan {
fn hub(global: &Global) -> &Hub<Self> {
&global.hubs.vulkan
}
fn get_surface(surface: &Surface) -> Option<&Self::Surface> {
surface.raw.downcast_ref::<Self>()
fn surface_as_hal(surface: &Surface) -> Option<&Self::Surface> {
surface.vulkan.as_ref()
}
}

Expand All @@ -67,8 +67,8 @@ impl HalApi for hal::api::Metal {
fn hub(global: &Global) -> &Hub<Self> {
&global.hubs.metal
}
fn get_surface(surface: &Surface) -> Option<&Self::Surface> {
surface.raw.downcast_ref::<Self>()
fn surface_as_hal(surface: &Surface) -> Option<&Self::Surface> {
surface.metal.as_ref()
}
}

Expand All @@ -88,8 +88,8 @@ impl HalApi for hal::api::Dx12 {
fn hub(global: &Global) -> &Hub<Self> {
&global.hubs.dx12
}
fn get_surface(surface: &Surface) -> Option<&Self::Surface> {
surface.raw.downcast_ref::<Self>()
fn surface_as_hal(surface: &Surface) -> Option<&Self::Surface> {
surface.dx12.as_ref()
}
}

Expand All @@ -110,7 +110,7 @@ impl HalApi for hal::api::Gles {
fn hub(global: &Global) -> &Hub<Self> {
&global.hubs.gl
}
fn get_surface(surface: &Surface) -> Option<&Self::Surface> {
surface.raw.downcast_ref::<Self>()
fn surface_as_hal(surface: &Surface) -> Option<&Self::Surface> {
surface.gl.as_ref()
}
}
2 changes: 1 addition & 1 deletion wgpu-core/src/hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl<A: HalApi> Hub<A> {
if let Element::Occupied(ref surface, _epoch) = *element {
if let Some(ref mut present) = surface.presentation.lock().take() {
if let Some(device) = present.device.downcast_ref::<A>() {
let suf = A::get_surface(surface);
let suf = A::surface_as_hal(surface);
unsafe {
suf.unwrap().unconfigure(device.raw());
//TODO: we could destroy the surface here
Expand Down
Loading
Loading