mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-26 08:44:08 +00:00
[Gles] Fix clearing depth and stencil at the same time (#2675)
This commit is contained in:
parent
b53a8bcb17
commit
1ec26784c4
@ -520,12 +520,19 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
|
||||
}
|
||||
}
|
||||
if let Some(ref dsat) = desc.depth_stencil_attachment {
|
||||
if !dsat.depth_ops.contains(crate::AttachmentOps::LOAD) {
|
||||
let clear_depth = !dsat.depth_ops.contains(crate::AttachmentOps::LOAD);
|
||||
let clear_stencil = !dsat.stencil_ops.contains(crate::AttachmentOps::LOAD);
|
||||
|
||||
if clear_depth && clear_stencil {
|
||||
self.cmd_buffer.commands.push(C::ClearDepthAndStencil(
|
||||
dsat.clear_value.0,
|
||||
dsat.clear_value.1,
|
||||
));
|
||||
} else if clear_depth {
|
||||
self.cmd_buffer
|
||||
.commands
|
||||
.push(C::ClearDepth(dsat.clear_value.0));
|
||||
}
|
||||
if !dsat.stencil_ops.contains(crate::AttachmentOps::LOAD) {
|
||||
} else if clear_stencil {
|
||||
self.cmd_buffer
|
||||
.commands
|
||||
.push(C::ClearStencil(dsat.clear_value.1));
|
||||
|
@ -667,6 +667,11 @@ enum Command {
|
||||
ClearColorI(u32, [i32; 4]),
|
||||
ClearDepth(f32),
|
||||
ClearStencil(u32),
|
||||
// Clearing both the depth and stencil buffer individually appears to
|
||||
// result in the stencil buffer failing to clear, atleast in WebGL.
|
||||
// It is also more efficient to emit a single command instead of two for
|
||||
// this.
|
||||
ClearDepthAndStencil(f32, u32),
|
||||
BufferBarrier(glow::Buffer, crate::BufferUses),
|
||||
TextureBarrier(crate::TextureUses),
|
||||
SetViewport {
|
||||
|
@ -758,6 +758,9 @@ impl super::Queue {
|
||||
C::ClearStencil(value) => {
|
||||
gl.clear_buffer_i32_slice(glow::STENCIL, 0, &[value as i32]);
|
||||
}
|
||||
C::ClearDepthAndStencil(depth, stencil_value) => {
|
||||
gl.clear_buffer_depth_stencil(glow::DEPTH_STENCIL, 0, depth, stencil_value as i32);
|
||||
}
|
||||
C::BufferBarrier(raw, usage) => {
|
||||
let mut flags = 0;
|
||||
if usage.contains(crate::BufferUses::VERTEX) {
|
||||
|
Loading…
Reference in New Issue
Block a user