1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 14:20:04 -04:00

egui-wgpu: attach stencil buffer (#7702)

This commit is contained in:
switch
2025-12-07 23:34:26 +01:00
committed by GitHub
parent 6277a310b9
commit 2115ca941b
2 changed files with 42 additions and 14 deletions

View File

@@ -243,13 +243,26 @@ impl WebPainter for WebPainterWgpu {
depth_stencil_attachment: self.depth_texture_view.as_ref().map(|view| { depth_stencil_attachment: self.depth_texture_view.as_ref().map(|view| {
wgpu::RenderPassDepthStencilAttachment { wgpu::RenderPassDepthStencilAttachment {
view, view,
depth_ops: Some(wgpu::Operations { depth_ops: self
load: wgpu::LoadOp::Clear(1.0), .depth_stencil_format
// It is very unlikely that the depth buffer is needed after egui finished rendering .is_some_and(|depth_stencil_format| {
// so no need to store it. (this can improve performance on tiling GPUs like mobile chips or Apple Silicon) depth_stencil_format.has_depth_aspect()
store: wgpu::StoreOp::Discard, })
}), .then_some(wgpu::Operations {
stencil_ops: None, load: wgpu::LoadOp::Clear(1.0),
// It is very unlikely that the depth buffer is needed after egui finished rendering
// so no need to store it. (this can improve performance on tiling GPUs like mobile chips or Apple Silicon)
store: wgpu::StoreOp::Discard,
}),
stencil_ops: self
.depth_stencil_format
.is_some_and(|depth_stencil_format| {
depth_stencil_format.has_stencil_aspect()
})
.then_some(wgpu::Operations {
load: wgpu::LoadOp::Clear(0),
store: wgpu::StoreOp::Discard,
}),
} }
}), }),
label: Some("egui_render"), label: Some("egui_render"),

View File

@@ -526,13 +526,28 @@ impl Painter {
depth_stencil_attachment: self.depth_texture_view.get(&viewport_id).map(|view| { depth_stencil_attachment: self.depth_texture_view.get(&viewport_id).map(|view| {
wgpu::RenderPassDepthStencilAttachment { wgpu::RenderPassDepthStencilAttachment {
view, view,
depth_ops: Some(wgpu::Operations { depth_ops: self
load: wgpu::LoadOp::Clear(1.0), .options
// It is very unlikely that the depth buffer is needed after egui finished rendering .depth_stencil_format
// so no need to store it. (this can improve performance on tiling GPUs like mobile chips or Apple Silicon) .is_some_and(|depth_stencil_format| {
store: wgpu::StoreOp::Discard, depth_stencil_format.has_depth_aspect()
}), })
stencil_ops: None, .then_some(wgpu::Operations {
load: wgpu::LoadOp::Clear(1.0),
// It is very unlikely that the depth buffer is needed after egui finished rendering
// so no need to store it. (this can improve performance on tiling GPUs like mobile chips or Apple Silicon)
store: wgpu::StoreOp::Discard,
}),
stencil_ops: self
.options
.depth_stencil_format
.is_some_and(|depth_stencil_format| {
depth_stencil_format.has_stencil_aspect()
})
.then_some(wgpu::Operations {
load: wgpu::LoadOp::Clear(0),
store: wgpu::StoreOp::Discard,
}),
} }
}), }),
timestamp_writes: None, timestamp_writes: None,