Skip to content

Commit

Permalink
[gles] enable/disable blending per attachment only when available (on…
Browse files Browse the repository at this point in the history
… ES 3.2 or higher) (#4234)
  • Loading branch information
teoxoy authored Oct 13, 2023
1 parent 9df73c5 commit 6c8ccde
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 27 deletions.
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) };
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

0 comments on commit 6c8ccde

Please sign in to comment.