Files
DarkRoom/third_party/wgpu-hal-29.0.4/src/dynamic/instance.rs
T
dtourolle dc1add9dbb Vendor wgpu-hal 29.0.4 and i-slint-renderer-skia 1.17.1, unmodified
The Android develop view reads its frame back through memory (TD-1)
because wgpu's Vulkan swapchain never pre-rotates, and a portrait window
on this tablet's landscape panel then tears. The fix is a small patch to
each of these two crates, and this commit is only the ground it lands on:
both are byte-for-byte the crates.io sources the lockfile already
resolved, so the commits that follow are the patch and nothing else.

third_party/ is excluded from the workspace, or every path dependency
under the root would become a member and `--workspace` would test and
lint upstream code as ours. The README says how to carry the patches
across a Slint or wgpu bump, which matters because a stale version here
does not fail the build — cargo just warns and uses the unpatched crate.
2026-09-25 04:18:39 -04:00

71 lines
2.2 KiB
Rust

use alloc::{boxed::Box, vec::Vec};
use crate::{Api, Capabilities, ExposedAdapter, Instance, InstanceError};
use super::{DynAdapter, DynResource, DynResourceExt as _, DynSurface};
pub struct DynExposedAdapter {
pub adapter: Box<dyn DynAdapter>,
pub info: wgt::AdapterInfo,
pub features: wgt::Features,
pub capabilities: Capabilities,
}
impl DynExposedAdapter {
/// Returns the backend this adapter is using.
pub fn backend(&self) -> wgt::Backend {
self.info.backend
}
}
impl<A: Api> From<ExposedAdapter<A>> for DynExposedAdapter {
fn from(exposed_adapter: ExposedAdapter<A>) -> Self {
Self {
adapter: Box::new(exposed_adapter.adapter),
info: exposed_adapter.info,
features: exposed_adapter.features,
capabilities: exposed_adapter.capabilities,
}
}
}
pub trait DynInstance: DynResource {
unsafe fn create_surface(
&self,
display_handle: raw_window_handle::RawDisplayHandle,
window_handle: raw_window_handle::RawWindowHandle,
) -> Result<Box<dyn DynSurface>, InstanceError>;
unsafe fn enumerate_adapters(
&self,
surface_hint: Option<&dyn DynSurface>,
) -> Vec<DynExposedAdapter>;
}
impl<I: Instance + DynResource> DynInstance for I {
unsafe fn create_surface(
&self,
display_handle: raw_window_handle::RawDisplayHandle,
window_handle: raw_window_handle::RawWindowHandle,
) -> Result<Box<dyn DynSurface>, InstanceError> {
unsafe { I::create_surface(self, display_handle, window_handle) }
.map(|surface| -> Box<dyn DynSurface> { Box::new(surface) })
}
unsafe fn enumerate_adapters(
&self,
surface_hint: Option<&dyn DynSurface>,
) -> Vec<DynExposedAdapter> {
let surface_hint = surface_hint.map(|s| s.expect_downcast_ref());
unsafe { I::enumerate_adapters(self, surface_hint) }
.into_iter()
.map(|exposed| DynExposedAdapter {
adapter: Box::new(exposed.adapter),
info: exposed.info,
features: exposed.features,
capabilities: exposed.capabilities,
})
.collect()
}
}