Expand description
Blend mode pipeline variants and runtime blend-state selection.
OxiUI’s oxiui_core::paint::DrawCommand::SetBlendMode allows UI elements to be composited
with custom blend operations (Multiply, Screen, Overlay, etc.). This module
provides:
blend_state_for_mode— map aBlendModeto awgpu::BlendState.BlendPipelineSet— a set of pre-compiled solid-pass pipelines, one per supported blend mode. Switching blend modes within a frame is achieved by callingset_pipelinewith the appropriate variant rather than recreating a pipeline at runtime.
§wgpu blend-state mapping
BlendMode | wgpu colour blend equation |
|---|---|
Normal | Src + Dst × (1 − SrcAlpha) (standard source-over) |
Multiply | Src × Dst + Dst × 0 |
Screen | Src + Dst − Src × Dst (approx: Src + Dst × (1-Src)) |
Overlay | Not directly expressible in fixed-function blend; |
falls back to Normal in hardware blend mode. | |
Darken | min(Src, Dst) — not expressible; falls back. |
Lighten | max(Src, Dst) — not expressible; falls back. |
Copy | Src × 1 + Dst × 0 (replace). |
Destination | Src × 0 + Dst × 1 (no change). |
Modes that require per-pixel arithmetic beyond what fixed-function hardware
supports (Overlay, Darken, Lighten) fall back to Normal. A future
improvement could implement them via custom fragment shader variants.
Structs§
- Blend
Pipeline Set - A set of pre-compiled solid-pass pipeline variants, one per blend mode.
Functions§
- blend_
state_ for_ mode - Return the
wgpu::BlendStatethat best approximatesmode.