mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
Alpha to coverage support for GLES (#3187)
This commit is contained in:
parent
b838b0871c
commit
a377ae2b7f
@ -68,6 +68,7 @@ Bottom level categories:
|
|||||||
#### GLES
|
#### GLES
|
||||||
|
|
||||||
- Surfaces support now `TextureFormat::Rgba8Unorm` and (non-web only) `TextureFormat::Bgra8Unorm`. By @Wumpf in [#3070](https://github.com/gfx-rs/wgpu/pull/3070)
|
- Surfaces support now `TextureFormat::Rgba8Unorm` and (non-web only) `TextureFormat::Bgra8Unorm`. By @Wumpf in [#3070](https://github.com/gfx-rs/wgpu/pull/3070)
|
||||||
|
- Support alpha to coverage. By @Wumpf in [#3156](https://github.com/gfx-rs/wgpu/pull/3156)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ pub(super) struct State {
|
|||||||
color_targets: ArrayVec<super::ColorTargetDesc, { crate::MAX_COLOR_ATTACHMENTS }>,
|
color_targets: ArrayVec<super::ColorTargetDesc, { crate::MAX_COLOR_ATTACHMENTS }>,
|
||||||
stencil: super::StencilState,
|
stencil: super::StencilState,
|
||||||
depth_bias: wgt::DepthBiasState,
|
depth_bias: wgt::DepthBiasState,
|
||||||
|
alpha_to_coverage_enabled: bool,
|
||||||
samplers: [Option<glow::Sampler>; super::MAX_SAMPLERS],
|
samplers: [Option<glow::Sampler>; super::MAX_SAMPLERS],
|
||||||
texture_slots: [TextureSlotDesc; super::MAX_TEXTURE_SLOTS],
|
texture_slots: [TextureSlotDesc; super::MAX_TEXTURE_SLOTS],
|
||||||
render_size: wgt::Extent3d,
|
render_size: wgt::Extent3d,
|
||||||
@ -795,6 +796,14 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
|
|||||||
.commands
|
.commands
|
||||||
.push(C::ConfigureDepthStencil(aspects));
|
.push(C::ConfigureDepthStencil(aspects));
|
||||||
|
|
||||||
|
// set multisampling state
|
||||||
|
if pipeline.alpha_to_coverage_enabled != self.state.alpha_to_coverage_enabled {
|
||||||
|
self.state.alpha_to_coverage_enabled = pipeline.alpha_to_coverage_enabled;
|
||||||
|
self.cmd_buffer
|
||||||
|
.commands
|
||||||
|
.push(C::SetAlphaToCoverage(pipeline.alpha_to_coverage_enabled));
|
||||||
|
}
|
||||||
|
|
||||||
// set blend states
|
// set blend states
|
||||||
if self.state.color_targets[..] != pipeline.color_targets[..] {
|
if self.state.color_targets[..] != pipeline.color_targets[..] {
|
||||||
if pipeline
|
if pipeline
|
||||||
|
@ -1090,6 +1090,7 @@ impl crate::Device<super::Api> for super::Device {
|
|||||||
.depth_stencil
|
.depth_stencil
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|ds| conv::map_stencil(&ds.stencil)),
|
.map(|ds| conv::map_stencil(&ds.stencil)),
|
||||||
|
alpha_to_coverage_enabled: desc.multisample.alpha_to_coverage_enabled,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
unsafe fn destroy_render_pipeline(&self, pipeline: super::RenderPipeline) {
|
unsafe fn destroy_render_pipeline(&self, pipeline: super::RenderPipeline) {
|
||||||
|
@ -502,6 +502,7 @@ pub struct RenderPipeline {
|
|||||||
depth: Option<DepthState>,
|
depth: Option<DepthState>,
|
||||||
depth_bias: wgt::DepthBiasState,
|
depth_bias: wgt::DepthBiasState,
|
||||||
stencil: Option<StencilState>,
|
stencil: Option<StencilState>,
|
||||||
|
alpha_to_coverage_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
// SAFE: WASM doesn't have threads
|
// SAFE: WASM doesn't have threads
|
||||||
@ -742,6 +743,7 @@ enum Command {
|
|||||||
SetDepth(DepthState),
|
SetDepth(DepthState),
|
||||||
SetDepthBias(wgt::DepthBiasState),
|
SetDepthBias(wgt::DepthBiasState),
|
||||||
ConfigureDepthStencil(crate::FormatAspects),
|
ConfigureDepthStencil(crate::FormatAspects),
|
||||||
|
SetAlphaToCoverage(bool),
|
||||||
SetVertexAttribute {
|
SetVertexAttribute {
|
||||||
buffer: Option<glow::Buffer>,
|
buffer: Option<glow::Buffer>,
|
||||||
buffer_desc: VertexBufferDesc,
|
buffer_desc: VertexBufferDesc,
|
||||||
|
@ -992,6 +992,13 @@ impl super::Queue {
|
|||||||
gl.disable(glow::STENCIL_TEST);
|
gl.disable(glow::STENCIL_TEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
C::SetAlphaToCoverage(enabled) => {
|
||||||
|
if enabled {
|
||||||
|
gl.enable(glow::SAMPLE_ALPHA_TO_COVERAGE);
|
||||||
|
} else {
|
||||||
|
gl.disable(glow::SAMPLE_ALPHA_TO_COVERAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
C::SetProgram(program) => {
|
C::SetProgram(program) => {
|
||||||
gl.use_program(Some(program));
|
gl.use_program(Some(program));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user