[wgpu] Add depth stencil initialization to Painter (#2316)

This commit is contained in:
Lukas Hermann 2022-11-21 01:08:24 -08:00 committed by GitHub
parent dfc1f2c470
commit f4d8ab9779
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 21 deletions

View file

@ -13,6 +13,7 @@ All notable changes to the `egui-wgpu` integration will be noted in this file.
* Only a single vertex & index buffer is now created and resized when necessary (previously, vertex/index buffers were allocated for every mesh) ([#2148](https://github.com/emilk/egui/pull/2148)).
* `Renderer::update_texture` no longer creates a new `wgpu::Sampler` with every new texture ([#2198](https://github.com/emilk/egui/pull/2198))
* `Painter`'s instance/device/adapter/surface creation is now configurable via `WgpuConfiguration` ([#2207](https://github.com/emilk/egui/pull/2207))
* Fix panic on using a depth buffer ([#2316](https://github.com/emilk/egui/pull/2316))
## 0.19.0 - 2022-08-20
* Enables deferred render + surface state initialization for Android ([#1634](https://github.com/emilk/egui/pull/1634)).

View file

@ -176,7 +176,7 @@ impl Painter {
width,
height,
});
self.configure_surface(width, height);
self.resize_and_generate_depth_texture_view(width, height);
}
None => {
self.surface_state = None;
@ -195,8 +195,11 @@ impl Painter {
.map(|rs| rs.device.limits().max_texture_dimension_2d as usize)
}
pub fn on_window_resized(&mut self, width_in_pixels: u32, height_in_pixels: u32) {
if self.surface_state.is_some() {
pub fn resize_and_generate_depth_texture_view(
&mut self,
width_in_pixels: u32,
height_in_pixels: u32,
) {
self.configure_surface(width_in_pixels, height_in_pixels);
let device = &self.render_state.as_ref().unwrap().device;
self.depth_texture_view = self.depth_format.map(|depth_format| {
@ -217,6 +220,11 @@ impl Painter {
})
.create_view(&wgpu::TextureViewDescriptor::default())
});
}
pub fn on_window_resized(&mut self, width_in_pixels: u32, height_in_pixels: u32) {
if self.surface_state.is_some() {
self.resize_and_generate_depth_texture_view(width_in_pixels, height_in_pixels);
} else {
error!("Ignoring window resize notification with no surface created via Painter::set_window()");
}