[rs] Blend state API update

This commit is contained in:
Dzmitry Malyshau
2021-02-19 12:57:06 -05:00
parent b75f6118bb
commit 5c680a1629
5 changed files with 36 additions and 30 deletions

View File

@@ -26,20 +26,20 @@ webgl = ["wgc"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "5afe832c3c8e3417e4ad4d95f92a3f65379467ff"
rev = "53bab9d68f91d6802d6913ed2dde9cad8537ed2f"
features = ["raw-window-handle", "cross"]
[target.'cfg(target_arch = "wasm32")'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "5afe832c3c8e3417e4ad4d95f92a3f65379467ff"
rev = "53bab9d68f91d6802d6913ed2dde9cad8537ed2f"
features = ["raw-window-handle", "cross"]
optional = true
[dependencies.wgt]
package = "wgpu-types"
git = "https://github.com/gfx-rs/wgpu"
rev = "5afe832c3c8e3417e4ad4d95f92a3f65379467ff"
rev = "53bab9d68f91d6802d6913ed2dde9cad8537ed2f"
[dependencies]
arrayvec = "0.5"

View File

@@ -316,12 +316,14 @@ impl framework::Example for Example {
entry_point: "fs_wire",
targets: &[wgpu::ColorTargetState {
format: sc_desc.format,
color_blend: wgpu::BlendState {
operation: wgpu::BlendOperation::Add,
src_factor: wgpu::BlendFactor::SrcAlpha,
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
},
alpha_blend: wgpu::BlendState::REPLACE,
blend: Some(wgpu::BlendState {
color: wgpu::BlendComponent {
operation: wgpu::BlendOperation::Add,
src_factor: wgpu::BlendFactor::SrcAlpha,
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
},
alpha: wgpu::BlendComponent::REPLACE,
}),
write_mask: wgpu::ColorWrite::ALL,
}],
}),

View File

@@ -524,16 +524,18 @@ impl framework::Example for Example {
// and assigned to the output attachment.
targets: &[wgpu::ColorTargetState {
format: sc_desc.format,
color_blend: wgpu::BlendState {
src_factor: wgpu::BlendFactor::SrcAlpha,
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
operation: wgpu::BlendOperation::Add,
},
alpha_blend: wgpu::BlendState {
src_factor: wgpu::BlendFactor::One,
dst_factor: wgpu::BlendFactor::One,
operation: wgpu::BlendOperation::Max,
},
blend: Some(wgpu::BlendState {
color: wgpu::BlendComponent {
src_factor: wgpu::BlendFactor::SrcAlpha,
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
operation: wgpu::BlendOperation::Add,
},
alpha: wgpu::BlendComponent {
src_factor: wgpu::BlendFactor::One,
dst_factor: wgpu::BlendFactor::One,
operation: wgpu::BlendOperation::Max,
},
}),
write_mask: wgpu::ColorWrite::ALL,
}],
}),

View File

@@ -594,7 +594,7 @@ fn map_depth_stencil_state_descriptor(
mapped
}
fn map_blend_descriptor(desc: &wgt::BlendState) -> web_sys::GpuBlendDescriptor {
fn map_blend_descriptor(desc: &wgt::BlendComponent) -> web_sys::GpuBlendDescriptor {
let mut mapped = web_sys::GpuBlendDescriptor::new();
mapped.dst_factor(map_blend_factor(desc.dst_factor));
mapped.operation(map_blend_operation(desc.operation));
@@ -1226,8 +1226,10 @@ impl crate::Context for Context {
let mapped_format = map_texture_format(target.format);
let mut mapped_color_state_desc =
web_sys::GpuColorStateDescriptor::new(mapped_format);
mapped_color_state_desc.alpha_blend(&map_blend_descriptor(&target.alpha_blend));
mapped_color_state_desc.color_blend(&map_blend_descriptor(&target.color_blend));
if let Some(ref bs) = target.blend {
mapped_color_state_desc.alpha_blend(&map_blend_descriptor(&bs.alpha));
mapped_color_state_desc.color_blend(&map_blend_descriptor(&bs.color));
}
mapped_color_state_desc.write_mask(target.write_mask.bits());
mapped_color_state_desc
})

View File

@@ -25,14 +25,14 @@ use std::{
use parking_lot::Mutex;
pub use wgt::{
AdapterInfo, AddressMode, Backend, BackendBit, BindGroupLayoutEntry, BindingType, BlendFactor,
BlendOperation, BlendState, BufferAddress, BufferBindingType, BufferSize, BufferUsage, Color,
ColorTargetState, ColorWrite, CommandBufferDescriptor, CompareFunction, DepthBiasState,
DepthStencilState, DeviceType, DynamicOffset, Extent3d, Face, Features, FilterMode, FrontFace,
IndexFormat, InputStepMode, Limits, MultisampleState, Origin3d, PipelineStatisticsTypes,
PolygonMode, PowerPreference, PresentMode, PrimitiveState, PrimitiveTopology,
PushConstantRange, QuerySetDescriptor, QueryType, SamplerBorderColor, ShaderFlags,
ShaderLocation, ShaderStage, StencilFaceState, StencilOperation, StencilState,
AdapterInfo, AddressMode, Backend, BackendBit, BindGroupLayoutEntry, BindingType,
BlendComponent, BlendFactor, BlendOperation, BlendState, BufferAddress, BufferBindingType,
BufferSize, BufferUsage, Color, ColorTargetState, ColorWrite, CommandBufferDescriptor,
CompareFunction, DepthBiasState, DepthStencilState, DeviceType, DynamicOffset, Extent3d, Face,
Features, FilterMode, FrontFace, IndexFormat, InputStepMode, Limits, MultisampleState,
Origin3d, PipelineStatisticsTypes, PolygonMode, PowerPreference, PresentMode, PrimitiveState,
PrimitiveTopology, PushConstantRange, QuerySetDescriptor, QueryType, SamplerBorderColor,
ShaderFlags, ShaderLocation, ShaderStage, StencilFaceState, StencilOperation, StencilState,
StorageTextureAccess, SwapChainDescriptor, SwapChainStatus, TextureAspect, TextureDataLayout,
TextureDimension, TextureFormat, TextureSampleType, TextureUsage, TextureViewDimension,
VertexAttribute, VertexFormat, BIND_BUFFER_ALIGNMENT, COPY_BUFFER_ALIGNMENT,