1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 13:50:04 -04:00

Add depth buffer support for egui-wgpu's render pass (#2002)

* add a depth texture for wgpu callbacks

* egui-wgpu: use depth from native_options

* add wgpu caveat to depth_buffer docstring
This commit is contained in:
Romet Tagobert
2022-09-06 15:37:07 +03:00
committed by GitHub
parent 162210f90e
commit 64aac30f36
4 changed files with 70 additions and 5 deletions

View File

@@ -683,6 +683,12 @@ mod wgpu_integration {
storage: Option<Box<dyn epi::Storage>>,
window: winit::window::Window,
) {
let mut limits = wgpu::Limits::downlevel_webgl2_defaults();
if self.native_options.depth_buffer > 0 {
// When using a depth buffer, we have to be able to create a texture large enough for the entire surface.
limits.max_texture_dimension_2d = 8192;
}
#[allow(unsafe_code, unused_mut, unused_unsafe)]
let painter = unsafe {
let mut painter = egui_wgpu::winit::Painter::new(
@@ -691,10 +697,11 @@ mod wgpu_integration {
wgpu::DeviceDescriptor {
label: None,
features: wgpu::Features::default(),
limits: wgpu::Limits::downlevel_webgl2_defaults(),
limits,
},
wgpu::PresentMode::Fifo,
self.native_options.multisampling.max(1) as _,
self.native_options.depth_buffer,
);
painter.set_window(Some(&window));
painter