Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue SetDrawColorBuffers before clearing buffers in GLES, use clear_buffer_f32_slice instead of clear #5666

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ By @stefnotch in [#5410](https://github.com/gfx-rs/wgpu/pull/5410)
#### GLES / OpenGL

- Fix regression on OpenGL (EGL) where non-sRGB still used sRGB [#5642](https://github.com/gfx-rs/wgpu/pull/5642)
- Fix `ClearColorF`, `ClearColorU` and `ClearColorI` commands being issued before `SetDrawColorBuffers` [#5666](https://github.com/gfx-rs/wgpu/pull/5666)
- Replace `glClear` with `glClearBufferF` because `glDrawBuffers` requires that the ith buffer must be `COLOR_ATTACHMENTi` or `NONE` [#5666](https://github.com/gfx-rs/wgpu/pull/5666)

## v0.20.0 (2024-04-28)

Expand Down
14 changes: 7 additions & 7 deletions wgpu-hal/src/gles/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,13 @@ impl crate::CommandEncoder for super::CommandEncoder {
depth: 0.0..1.0,
});

if !rendering_to_external_framebuffer {
// set the draw buffers and states
self.cmd_buffer
.commands
.push(C::SetDrawColorBuffers(desc.color_attachments.len() as u8));
}

// issue the clears
for (i, cat) in desc
.color_attachments
Expand Down Expand Up @@ -634,13 +641,6 @@ impl crate::CommandEncoder for super::CommandEncoder {
}
}

if !rendering_to_external_framebuffer {
// set the draw buffers and states
self.cmd_buffer
.commands
.push(C::SetDrawColorBuffers(desc.color_attachments.len() as u8));
}

if let Some(ref dsat) = desc.depth_stencil_attachment {
let clear_depth = !dsat.depth_ops.contains(crate::AttachmentOps::LOAD);
let clear_stencil = !dsat.stencil_ops.contains(crate::AttachmentOps::LOAD);
Expand Down
8 changes: 1 addition & 7 deletions wgpu-hal/src/gles/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,13 +1075,7 @@ impl super::Queue {
{
unsafe { self.perform_shader_clear(gl, draw_buffer, *color) };
} else {
// Prefer `clear` as `clear_buffer` functions have issues on Sandy Bridge
// on Windows.
unsafe {
gl.draw_buffers(&[glow::COLOR_ATTACHMENT0 + draw_buffer]);
gl.clear_color(color[0], color[1], color[2], color[3]);
gl.clear(glow::COLOR_BUFFER_BIT);
}
unsafe { gl.clear_buffer_f32_slice(glow::COLOR, draw_buffer, color) };
}
}
C::ClearColorU(draw_buffer, ref color) => {
Expand Down