wgpu
wgpu copied to clipboard
Implement texture clear on store = false
This code should be portable (from #2254)
let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("Render Pass"),
color_attachments: &[
wgpu::RenderPassColorAttachment {
view: &view,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(
if self.config.wgpu.transparent {
wgpu::Color::TRANSPARENT
} else {
wgpu::Color::BLACK
}
),
store: false, /* issue */
}
}
],
depth_stencil_attachment: None,
});
There is an upstream spec. issue for clarifying that we need to be zeroing when store
is false
(viz., is "discard"
in JS): https://github.com/gpuweb/gpuweb/issues/4398
We should have implemented this a while ago - the zero init code should handle this.
I think I'm running into this "issue" on my project. I have one render pass that writes to a depth buffer (store: true), and then the several following passes with store: false. I need that depth buffer to /not/ be zeroed after these passes. How can I disable?
Cheers
EDIT:
Well, immediately after posting this I had an idea to try out a different approach. I use "store: true" on all my render passes but change the pipeline state instead. By using a pipeline descriptor with the DepthStencilState::depth_write_enable set to false, the depth texture is no longer cleared.
I'm new to this but "store" is confusing for a beginner. The store always happens, as it seems, but the value is either discarded or kept.