mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-28 17:53:40 +00:00
extract set_scissor
from render_pass_end_impl
This commit is contained in:
parent
b295a4578c
commit
a79ac34b15
@ -1587,28 +1587,9 @@ impl Global {
|
|||||||
)
|
)
|
||||||
.map_pass_err(scope)?;
|
.map_pass_err(scope)?;
|
||||||
}
|
}
|
||||||
ArcRenderCommand::SetScissor(ref rect) => {
|
ArcRenderCommand::SetScissor(rect) => {
|
||||||
api_log!("RenderPass::set_scissor_rect {rect:?}");
|
|
||||||
|
|
||||||
let scope = PassErrorScope::SetScissorRect;
|
let scope = PassErrorScope::SetScissorRect;
|
||||||
if rect.x + rect.w > state.info.extent.width
|
set_scissor(&mut state, rect).map_pass_err(scope)?;
|
||||||
|| rect.y + rect.h > state.info.extent.height
|
|
||||||
{
|
|
||||||
return Err(RenderCommandError::InvalidScissorRect(
|
|
||||||
*rect,
|
|
||||||
state.info.extent,
|
|
||||||
))
|
|
||||||
.map_pass_err(scope);
|
|
||||||
}
|
|
||||||
let r = hal::Rect {
|
|
||||||
x: rect.x,
|
|
||||||
y: rect.y,
|
|
||||||
w: rect.w,
|
|
||||||
h: rect.h,
|
|
||||||
};
|
|
||||||
unsafe {
|
|
||||||
state.raw_encoder.set_scissor_rect(&r);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ArcRenderCommand::Draw {
|
ArcRenderCommand::Draw {
|
||||||
vertex_count,
|
vertex_count,
|
||||||
@ -2586,6 +2567,27 @@ fn set_push_constant<A: HalApi>(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_scissor<A: HalApi>(
|
||||||
|
state: &mut State<A>,
|
||||||
|
rect: Rect<u32>,
|
||||||
|
) -> Result<(), RenderPassErrorInner> {
|
||||||
|
api_log!("RenderPass::set_scissor_rect {rect:?}");
|
||||||
|
|
||||||
|
if rect.x + rect.w > state.info.extent.width || rect.y + rect.h > state.info.extent.height {
|
||||||
|
return Err(RenderCommandError::InvalidScissorRect(rect, state.info.extent).into());
|
||||||
|
}
|
||||||
|
let r = hal::Rect {
|
||||||
|
x: rect.x,
|
||||||
|
y: rect.y,
|
||||||
|
w: rect.w,
|
||||||
|
h: rect.h,
|
||||||
|
};
|
||||||
|
unsafe {
|
||||||
|
state.raw_encoder.set_scissor_rect(&r);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
impl Global {
|
impl Global {
|
||||||
pub fn render_pass_set_bind_group(
|
pub fn render_pass_set_bind_group(
|
||||||
&self,
|
&self,
|
||||||
|
Loading…
Reference in New Issue
Block a user