r/wgpu • u/GustavNilss • Sep 19 '22
Setting Scissor Rectangle before Clearing
Hello everyone!
I am currently converting some code from OpenGL to using WGPU, and I have hit a problem I can't seem to resolve. In my original code, I set the scissor rectangle before clearing the render area, as I want to keep most of my framebuffer intact and only re-render the area that has been modified.
However, in WGPU, the clearing operation seems to be only available as a loading operation, when creating the render pass. So when I set the scissor rectangle, which is done on the render pass, the clearing has already been performed, clearing the entire framebuffer.
Am I missing something or is this currently not possible on WGPU?
Regards,
Gustav
let mut render_pass = encoder.begin_render_pass(
&wgpu::RenderPassDescriptor {
label: Some("Render Pass"),
color_attachments: &[Some(
wgpu::RenderPassColorAttachment {
view: &view,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(
wgpu::Color {
r: 0.04,
g: 0.08,
b: 0.08,
a: 1.0,
}
),
store: true,
},
}
)],
depth_stencil_attachment: None,
}
);
//Here the render pass has already been generated, with the entire area cleared
render_pass.set_scissor_rect(
200,
200,
800,
800
);
2
Upvotes
1
u/GENTS83 Sep 19 '22
I never tried it with wgpu, but:
Could you do a second pass that doesn't clear, but load it, and write on it only where you need?
Or have you tried to play with the size (offset and extent) of the color attachment view?