From 9a16a4d01830297987db40b45f03382ed3acad62 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 17 Dec 2021 22:26:59 +0000 Subject: [PATCH] Added set_scissor_rect to tracked render pass. (#3320) # Objective And Solution Add `set_scissor_rect` from wgpu-rs to the `TrackedRenderPass`. wgpu documentation can be found here: https://docs.rs/wgpu/latest/wgpu/struct.RenderPass.html#method.set_scissor_rect The reason for adding this is to cull fragments that are outside of the given rect. For my purposes this is extremely useful for UI. --- crates/bevy_render/src/render_phase/draw_state.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/bevy_render/src/render_phase/draw_state.rs b/crates/bevy_render/src/render_phase/draw_state.rs index 62c19706d1..b2f13312a4 100644 --- a/crates/bevy_render/src/render_phase/draw_state.rs +++ b/crates/bevy_render/src/render_phase/draw_state.rs @@ -228,4 +228,11 @@ impl<'a> TrackedRenderPass<'a> { self.pass.set_stencil_reference(reference); } + + /// Sets the scissor region. + /// Subsequent draw calls will discard any fragments that fall outside this region. + pub fn set_scissor_rect(&mut self, x: u32, y: u32, width: u32, height: u32) { + debug!("set_scissor_rect: {} {} {} {}", x, y, width, height); + self.pass.set_scissor_rect(x, y, width, height); + } }