Skip to content

Commit

Permalink
Revert "deps: update to wgpu 0.19"
Browse files Browse the repository at this point in the history
This reverts commit b4c5dc7.
This reverts commit 3214610.
This reverts commit 3ec1cfb.
This reverts commit 47590bb.
This reverts commit ea88dca.
This reverts commit c269230.
This reverts commit 1484e2a.
This reverts commit 6fd45c1.
This reverts commit 9acc2ae.

refs: #4825
refs: #4826
  • Loading branch information
wez committed Jan 21, 2024
1 parent 7c452d3 commit bf07f6d
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 196 deletions.
115 changes: 47 additions & 68 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wezterm-gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ wezterm-open-url = { path = "../wezterm-open-url" }
wezterm-ssh = { path = "../wezterm-ssh" }
wezterm-term = { path = "../term", features=["use_serde"] }
wezterm-toast-notification = { path = "../wezterm-toast-notification" }
wgpu = "0.19"
wgpu = "0.18"
window = { path = "../window" }
window-funcs = { path = "../lua-api-crates/window-funcs" }

Expand Down
1 change: 0 additions & 1 deletion wezterm-gui/src/scripting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ pub fn register(lua: &Lua) -> anyhow::Result<()> {
});
let gpus: Vec<GpuInfo> = instance
.enumerate_adapters(backends)
.into_iter()
.map(|adapter| {
let info = adapter.get_info();
crate::termwindow::webgpu::adapter_info_to_gpu_info(info)
Expand Down
33 changes: 14 additions & 19 deletions wezterm-gui/src/termwindow/webgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use std::sync::Arc;
use wgpu::util::DeviceExt;
use window::bitmaps::Texture2d;
use window::raw_window_handle::{
DisplayHandle, HandleError, HasDisplayHandle, HasWindowHandle, RawDisplayHandle,
RawWindowHandle, WindowHandle,
HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle, RawWindowHandle,
};
use window::{BitmapImage, Dimensions, Rect, Window};

Expand All @@ -24,7 +23,7 @@ pub struct ShaderUniform {
pub struct WebGpuState {
pub adapter_info: wgpu::AdapterInfo,
pub downlevel_caps: wgpu::DownlevelCapabilities,
pub surface: wgpu::Surface<'static>,
pub surface: wgpu::Surface,
pub device: wgpu::Device,
pub queue: Arc<wgpu::Queue>,
pub config: RefCell<wgpu::SurfaceConfiguration>,
Expand All @@ -45,21 +44,21 @@ pub struct RawHandlePair {
impl RawHandlePair {
fn new(window: &Window) -> Self {
Self {
window: window.window_handle().expect("window handle").as_raw(),
display: window.display_handle().expect("display handle").as_raw(),
window: window.raw_window_handle(),
display: window.raw_display_handle(),
}
}
}

impl HasWindowHandle for RawHandlePair {
fn window_handle(&self) -> Result<WindowHandle, HandleError> {
unsafe { Ok(WindowHandle::borrow_raw(self.window)) }
unsafe impl HasRawWindowHandle for RawHandlePair {
fn raw_window_handle(&self) -> RawWindowHandle {
self.window
}
}

impl HasDisplayHandle for RawHandlePair {
fn display_handle(&self) -> Result<DisplayHandle, HandleError> {
unsafe { Ok(DisplayHandle::borrow_raw(self.display)) }
unsafe impl HasRawDisplayHandle for RawHandlePair {
fn raw_display_handle(&self) -> RawDisplayHandle {
self.display
}
}

Expand Down Expand Up @@ -195,7 +194,6 @@ fn compute_compatibility_list(
) -> Vec<String> {
instance
.enumerate_adapters(backends)
.into_iter()
.map(|a| {
let info = adapter_info_to_gpu_info(a.get_info());
let compatible = a.is_surface_supported(&surface);
Expand Down Expand Up @@ -228,9 +226,7 @@ impl WebGpuState {
backends,
..Default::default()
});
let surface = unsafe {
instance.create_surface_unsafe(wgpu::SurfaceTargetUnsafe::from_window(&handle)?)?
};
let surface = unsafe { instance.create_surface(&handle)? };

let mut adapter: Option<wgpu::Adapter> = None;

Expand Down Expand Up @@ -320,10 +316,10 @@ impl WebGpuState {
let (device, queue) = adapter
.request_device(
&wgpu::DeviceDescriptor {
required_features: wgpu::Features::empty(),
features: wgpu::Features::empty(),
// WebGL doesn't support all of wgpu's features, so if
// we're building for the web we'll have to disable some.
required_limits: if cfg!(target_arch = "wasm32") {
limits: if cfg!(target_arch = "wasm32") {
wgpu::Limits::downlevel_webgl2_defaults()
} else {
wgpu::Limits::downlevel_defaults()
Expand Down Expand Up @@ -378,7 +374,6 @@ impl WebGpuState {
wgpu::CompositeAlphaMode::Auto
},
view_formats,
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);

Expand Down Expand Up @@ -533,7 +528,7 @@ impl WebGpuState {
#[cfg(windows)]
RawWindowHandle::Win32(h) => {
let mut rect = unsafe { std::mem::zeroed() };
unsafe { winapi::um::winuser::GetClientRect(h.hwnd.get() as _, &mut rect) };
unsafe { winapi::um::winuser::GetClientRect(h.hwnd as _, &mut rect) };
dims.pixel_width = (rect.right - rect.left) as usize;
dims.pixel_height = (rect.bottom - rect.top) as usize;
}
Expand Down
2 changes: 1 addition & 1 deletion window/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ line_drawing = "0.8"
log = "0.4"
metrics = { version="0.17", features=["std"]}
promise = { path = "../promise" }
raw-window-handle = "0.6"
raw-window-handle = "0.5"
resize = "0.5"
serde = {version="1.0", features = ["rc", "derive"]}
tiny-skia = "0.11"
Expand Down
Loading

0 comments on commit bf07f6d

Please sign in to comment.