54d09d9e45043f5432ca210369c977f6185dff9a
[mesa.git] / src / gallium / drivers / i965 / brw_pipe_blend.c
1
2
3 /* _NEW_COLOR */
4 if (key->logic_op != GL_COPY) {
5 cc.cc2.logicop_enable = 1;
6 cc.cc5.logicop_func = intel_translate_logic_op(key->logic_op);
7 } else if (key->color_blend) {
8 GLenum eqRGB = key->blend_eq_rgb;
9 GLenum eqA = key->blend_eq_a;
10 GLenum srcRGB = key->blend_src_rgb;
11 GLenum dstRGB = key->blend_dst_rgb;
12 GLenum srcA = key->blend_src_a;
13 GLenum dstA = key->blend_dst_a;
14
15 if (eqRGB == GL_MIN || eqRGB == GL_MAX) {
16 srcRGB = dstRGB = GL_ONE;
17 }
18
19 if (eqA == GL_MIN || eqA == GL_MAX) {
20 srcA = dstA = GL_ONE;
21 }
22
23 cc.cc6.dest_blend_factor = brw_translate_blend_factor(dstRGB);
24 cc.cc6.src_blend_factor = brw_translate_blend_factor(srcRGB);
25 cc.cc6.blend_function = brw_translate_blend_equation(eqRGB);
26
27 cc.cc5.ia_dest_blend_factor = brw_translate_blend_factor(dstA);
28 cc.cc5.ia_src_blend_factor = brw_translate_blend_factor(srcA);
29 cc.cc5.ia_blend_function = brw_translate_blend_equation(eqA);
30
31 cc.cc3.blend_enable = 1;
32 cc.cc3.ia_blend_enable = (srcA != srcRGB ||
33 dstA != dstRGB ||
34 eqA != eqRGB);
35 }
36
37 if (key->dither) {
38 cc.cc5.dither_enable = 1;
39 cc.cc6.y_dither_offset = 0;
40 cc.cc6.x_dither_offset = 0;
41 }
42
43 if (INTEL_DEBUG & DEBUG_STATS)
44 cc.cc5.statistics_enable = 1;
45 }
46
47
48
49 static void brw_set_blend_color(struct pipe_context *pipe,
50 const float *blend_color)
51 {
52 struct brw_context *brw = brw_context(pipe);
53 struct brw_blend_constant_color *bcc = &brw->curr.blend_color.bcc;
54
55 memset(bcc, 0, sizeof(*bcc));
56 bcc->header.opcode = CMD_BLEND_CONSTANT_COLOR;
57 bcc->header.length = sizeof(*bcc)/4-2;
58 bcc->blend_constant_color[0] = blend_color[0];
59 bcc->blend_constant_color[1] = blend_color[1];
60 bcc->blend_constant_color[2] = blend_color[2];
61 bcc->blend_constant_color[3] = blend_color[3];
62
63 brw->state.dirty.pipe |= PIPE_NEW_BLEND_COLOR;
64 }