This state controls blending of the final fragments into the target rendering buffers.
The blend factors largely follow the same pattern as their counterparts in other modern and legacy drawing APIs.
Dual source blend factors are supported for up to 1 MRT, although you can advertise > 1 MRT, the stack cannot handle them for a few reasons. There is no definition on how the 1D array of shader outputs should be mapped to something that would be a 2D array (location, index). No current hardware exposes > 1 MRT, and we should revisit this issue if anyone ever does.
Logical operations, also known as logicops, LOPs, or ROPs, are supported. Only two-operand logicops are available. When logicops are enabled, all other blend state is ignored, including per-render-target state, so logicops are performed on all render targets.
The blend_enable flag is ignored for all render targets when logical operations are enabled.
For a source component s and destination component d, the logical operations are defined as taking the bits of each channel of each component, and performing one of the following operations per-channel:
NOR: \(\lnot(s \lor d)\)
AND_INVERTED: \(\lnot s \land d\)
COPY_INVERTED: \(\lnot s\)
AND_REVERSE: \(s \land \lnot d\)
INVERT: \(\lnot d\)
XOR: \(s \oplus d\)
NAND: \(\lnot(s \land d)\)
AND: \(s \land d\)
EQUIV: \(\lnot(s \oplus d)\)
OR_INVERTED: \(\lnot s \lor d\)
OR_REVERSE: \(s \lor \lnot d\)
OR: \(s \lor d\)
The logical operation names and definitions match those of the OpenGL API, and are similar to the ROP2 and ROP3 definitions of GDI. This is intentional, to ease transitions to Gallium.
These members affect all render targets.
Whether dithering is enabled.
Dithering is completely implementation-dependent. It may be ignored by drivers for any reason, and some render targets may always or never be dithered depending on their format or usage flags.
Whether the blender should perform a logicop instead of blending.
The logicop to use. One of
If enabled, blend state is different for each render target, and for each render target set in the respective member of the rt array. If disabled, blend state is the same for all render targets, and only the first member of the rt array contains valid data.
Contains the per-rendertarget blend state.
If enabled, the fragment’s alpha value is used to override the fragment’s coverage mask. The coverage mask will be all zeros if the alpha value is zero. The coverage mask will be all ones if the alpha value is one. Otherwise, the number of bits set in the coverage mask will be proportional to the alpha value. Note that this step happens regardless of whether multisample is enabled or the destination buffer is multisampled.
If enabled, the fragment’s alpha value will be set to one. As with alpha_to_coverage, this step happens regardless of whether multisample is enabled or the destination buffer is multisampled.
The index of the max render target (irrespecitive of whether independent blend is enabled), i.e. the number of MRTs minus one. This is provided so that the driver can avoid the overhead of programming unused MRTs.
If blending is enabled, perform a blend calculation according to blend functions and source/destination factors. Otherwise, the incoming fragment color gets passed unmodified (but colormask still applies).
The blend function to use for rgb channels. One of PIPE_BLEND.
The blend source factor to use for rgb channels. One of PIPE_BLENDFACTOR.
The blend destination factor to use for rgb channels. One of PIPE_BLENDFACTOR.
The blend function to use for the alpha channel. One of PIPE_BLEND.
The blend source factor to use for the alpha channel. One of PIPE_BLENDFACTOR.
The blend destination factor to use for alpha channel. One of PIPE_BLENDFACTOR.
Bitmask of which channels to write. Combination of PIPE_MASK bits.