Merge remote branch 'origin/master' into glsl2
[mesa.git] / src / gallium / docs / source / cso / blend.rst
1 .. _blend:
2
3 Blend
4 =====
5
6 This state controls blending of the final fragments into the target rendering
7 buffers.
8
9 Blend Factors
10 -------------
11
12 The blend factors largely follow the same pattern as their counterparts
13 in other modern and legacy drawing APIs.
14
15 XXX blurb about dual-source blends
16
17 Logical Operations
18 ------------------
19
20 Logical operations, also known as logicops, lops, or rops, are supported.
21 Only two-operand logicops are available. When logicops are enabled, all other
22 blend state is ignored, including per-render-target state, so logicops are
23 performed on all render targets.
24
25 .. warning::
26 The blend_enable flag is ignored for all render targets when logical
27 operations are enabled.
28
29 For a source component `s` and destination component `d`, the logical
30 operations are defined as taking the bits of each channel of each component,
31 and performing one of the following operations per-channel:
32
33 * ``CLEAR``: 0
34 * ``NOR``: :math:`\lnot(s \lor d)`
35 * ``AND_INVERTED``: :math:`\lnot s \land d`
36 * ``COPY_INVERTED``: :math:`\lnot s`
37 * ``AND_REVERSE``: :math:`s \land \lnot d`
38 * ``INVERT``: :math:`\lnot d`
39 * ``XOR``: :math:`s \oplus d`
40 * ``NAND``: :math:`\lnot(s \land d)`
41 * ``AND``: :math:`s \land d`
42 * ``EQUIV``: :math:`\lnot(s \oplus d)`
43 * ``NOOP``: :math:`d`
44 * ``OR_INVERTED``: :math:`\lnot s \lor d`
45 * ``COPY``: :math:`s`
46 * ``OR_REVERSE``: :math:`s \lor \lnot d`
47 * ``OR``: :math:`s \lor d`
48 * ``SET``: 1
49
50 .. note::
51 The logical operation names and definitions match those of the OpenGL API,
52 and are similar to the ROP2 and ROP3 definitions of GDI. This is
53 intentional, to ease transitions to Gallium.
54
55 Members
56 -------
57
58 These members affect all render targets.
59
60 dither
61 %%%%%%
62
63 Whether dithering is enabled.
64
65 .. note::
66 Dithering is completely implementation-dependent. It may be ignored by
67 drivers for any reason, and some render targets may always or never be
68 dithered depending on their format or usage flags.
69
70 logicop_enable
71 %%%%%%%%%%%%%%
72
73 Whether the blender should perform a logicop instead of blending.
74
75 logicop_func
76 %%%%%%%%%%%%
77
78 The logicop to use. One of ``PIPE_LOGICOP``.
79
80 independent_blend_enable
81 If enabled, blend state is different for each render target, and
82 for each render target set in the respective member of the rt array.
83 If disabled, blend state is the same for all render targets, and only
84 the first member of the rt array contains valid data.
85 rt
86 Contains the per-rendertarget blend state.
87
88 Per-rendertarget Members
89 ------------------------
90
91 blend_enable
92 If blending is enabled, perform a blend calculation according to blend
93 functions and source/destination factors. Otherwise, the incoming fragment
94 color gets passed unmodified (but colormask still applies).
95 rgb_func
96 The blend function to use for rgb channels. One of PIPE_BLEND.
97 rgb_src_factor
98 The blend source factor to use for rgb channels. One of PIPE_BLENDFACTOR.
99 rgb_dst_factor
100 The blend destination factor to use for rgb channels. One of PIPE_BLENDFACTOR.
101 alpha_func
102 The blend function to use for the alpha channel. One of PIPE_BLEND.
103 alpha_src_factor
104 The blend source factor to use for the alpha channel. One of PIPE_BLENDFACTOR.
105 alpha_dst_factor
106 The blend destination factor to use for alpha channel. One of PIPE_BLENDFACTOR.
107 colormask
108 Bitmask of which channels to write. Combination of PIPE_MASK bits.