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

[gles] enable/disable blending per attachment only when available (on ES 3.2 or higher) #4234

Merged
merged 2 commits into from
Oct 13, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ By @teoxoy in [#4185](https://github.com/gfx-rs/wgpu/pull/4185)
- Ensure that limit requests and reporting is done correctly. By @OptimisticPeach in [#4107](https://github.com/gfx-rs/wgpu/pull/4107)
- Validate usage of polygon mode. By @teoxoy in [#4196](https://github.com/gfx-rs/wgpu/pull/4196)

#### GLES

- enable/disable blending per attachment only when available (on ES 3.2 or higher). By @teoxoy in [#4234](https://github.com/gfx-rs/wgpu/pull/4234)

#### Testing

- Skip `test_multithreaded_compute` on MoltenVK. By @jimblandy in [#4096](https://github.com/gfx-rs/wgpu/pull/4096).
Expand Down
4 changes: 0 additions & 4 deletions wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,6 @@ impl super::Adapter {
super::PrivateCapabilities::INDEX_BUFFER_ROLE_CHANGE,
!cfg!(target_arch = "wasm32"),
);
private_caps.set(
super::PrivateCapabilities::CAN_DISABLE_DRAW_BUFFER,
!cfg!(target_arch = "wasm32"),
);
private_caps.set(
super::PrivateCapabilities::GET_BUFFER_SUB_DATA,
cfg!(target_arch = "wasm32"),
Expand Down
2 changes: 0 additions & 2 deletions wgpu-hal/src/gles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ bitflags::bitflags! {
/// Indicates that buffers used as `GL_ELEMENT_ARRAY_BUFFER` may be created / initialized / used
/// as other targets, if not present they must not be mixed with other targets.
const INDEX_BUFFER_ROLE_CHANGE = 1 << 5;
/// Indicates that the device supports disabling draw buffers
const CAN_DISABLE_DRAW_BUFFER = 1 << 6;
/// Supports `glGetBufferSubData`
const GET_BUFFER_SUB_DATA = 1 << 7;
/// Supports `f16` color buffers
Expand Down
24 changes: 3 additions & 21 deletions wgpu-hal/src/gles/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ impl super::Queue {
.collect::<ArrayVec<_, { crate::MAX_COLOR_ATTACHMENTS }>>();
unsafe { gl.draw_buffers(&indices) };
}
#[cfg(not(target_arch = "wasm32"))]
for draw_buffer in 0..self.draw_buffer_count as u32 {
unsafe { gl.disable_draw_buffer(glow::BLEND, draw_buffer) };
}
}

unsafe fn reset_state(&mut self, gl: &glow::Context) {
Expand Down Expand Up @@ -970,16 +966,6 @@ impl super::Queue {
.map(|i| glow::COLOR_ATTACHMENT0 + i)
.collect::<ArrayVec<_, { crate::MAX_COLOR_ATTACHMENTS }>>();
unsafe { gl.draw_buffers(&indices) };

if self
.shared
.private_caps
.contains(super::PrivateCapabilities::CAN_DISABLE_DRAW_BUFFER)
{
for draw_buffer in 0..count as u32 {
unsafe { gl.disable_draw_buffer(glow::BLEND, draw_buffer) };
}
}
}
C::ClearColorF {
draw_buffer,
Expand Down Expand Up @@ -1249,7 +1235,7 @@ impl super::Queue {
)
};
if let Some(ref blend) = *blend {
unsafe { gl.enable_draw_buffer(index, glow::BLEND) };
unsafe { gl.enable_draw_buffer(glow::BLEND, index) };
cwfitzgerald marked this conversation as resolved.
Show resolved Hide resolved
if blend.color != blend.alpha {
unsafe {
gl.blend_equation_separate_draw_buffer(
Expand All @@ -1273,12 +1259,8 @@ impl super::Queue {
gl.blend_func_draw_buffer(index, blend.color.src, blend.color.dst)
};
}
} else if self
.shared
.private_caps
.contains(super::PrivateCapabilities::CAN_DISABLE_DRAW_BUFFER)
{
unsafe { gl.disable_draw_buffer(index, glow::BLEND) };
} else {
unsafe { gl.disable_draw_buffer(glow::BLEND, index) };
}
} else {
unsafe {
Expand Down