freedreno: Remove the Emacs mode lines
[mesa.git] / src / gallium / drivers / freedreno / a2xx / fd2_blend.c
index b3cb23977b12392a119f00b58c104a76fa9dd1e0..223eec9f592b421bc416d9249a1ccbffd0ece969 100644 (file)
@@ -1,5 +1,3 @@
-/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
-
 /*
  * Copyright (C) 2012-2013 Rob Clark <robclark@freedesktop.org>
  *
@@ -27,6 +25,7 @@
  */
 
 #include "pipe/p_state.h"
+#include "util/u_blend.h"
 #include "util/u_string.h"
 #include "util/u_memory.h"
 
@@ -40,15 +39,15 @@ blend_func(unsigned func)
 {
        switch (func) {
        case PIPE_BLEND_ADD:
-               return BLEND_DST_PLUS_SRC;
+               return BLEND2_DST_PLUS_SRC;
        case PIPE_BLEND_MIN:
-               return BLEND_MIN_DST_SRC;
+               return BLEND2_MIN_DST_SRC;
        case PIPE_BLEND_MAX:
-               return BLEND_MAX_DST_SRC;
+               return BLEND2_MAX_DST_SRC;
        case PIPE_BLEND_SUBTRACT:
-               return BLEND_SRC_MINUS_DST;
+               return BLEND2_SRC_MINUS_DST;
        case PIPE_BLEND_REVERSE_SUBTRACT:
-               return BLEND_DST_MINUS_SRC;
+               return BLEND2_DST_MINUS_SRC;
        default:
                DBG("invalid blend func: %x", func);
                return 0;
@@ -61,11 +60,10 @@ fd2_blend_state_create(struct pipe_context *pctx,
 {
        const struct pipe_rt_blend_state *rt = &cso->rt[0];
        struct fd2_blend_stateobj *so;
+       unsigned rop = PIPE_LOGICOP_COPY;
 
-       if (cso->logicop_enable) {
-               DBG("Unsupported! logicop");
-               return NULL;
-       }
+       if (cso->logicop_enable)
+               rop = cso->logicop_func; /* 1:1 mapping with hw */
 
        if (cso->independent_blend_enable) {
                DBG("Unsupported! independent blend state");
@@ -78,16 +76,23 @@ fd2_blend_state_create(struct pipe_context *pctx,
 
        so->base = *cso;
 
-       so->rb_colorcontrol = A2XX_RB_COLORCONTROL_ROP_CODE(12);
+       so->rb_colorcontrol = A2XX_RB_COLORCONTROL_ROP_CODE(rop);
 
-       so->rb_blendcontrol =
+       so->rb_blendcontrol_rgb =
                A2XX_RB_BLEND_CONTROL_COLOR_SRCBLEND(fd_blend_factor(rt->rgb_src_factor)) |
                A2XX_RB_BLEND_CONTROL_COLOR_COMB_FCN(blend_func(rt->rgb_func)) |
-               A2XX_RB_BLEND_CONTROL_COLOR_DESTBLEND(fd_blend_factor(rt->rgb_dst_factor)) |
+               A2XX_RB_BLEND_CONTROL_COLOR_DESTBLEND(fd_blend_factor(rt->rgb_dst_factor));
+
+       so->rb_blendcontrol_alpha =
                A2XX_RB_BLEND_CONTROL_ALPHA_SRCBLEND(fd_blend_factor(rt->alpha_src_factor)) |
                A2XX_RB_BLEND_CONTROL_ALPHA_COMB_FCN(blend_func(rt->alpha_func)) |
                A2XX_RB_BLEND_CONTROL_ALPHA_DESTBLEND(fd_blend_factor(rt->alpha_dst_factor));
 
+       so->rb_blendcontrol_no_alpha_rgb =
+               A2XX_RB_BLEND_CONTROL_COLOR_SRCBLEND(fd_blend_factor(util_blend_dst_alpha_to_one(rt->rgb_src_factor))) |
+               A2XX_RB_BLEND_CONTROL_COLOR_COMB_FCN(blend_func(rt->rgb_func)) |
+               A2XX_RB_BLEND_CONTROL_COLOR_DESTBLEND(fd_blend_factor(util_blend_dst_alpha_to_one(rt->rgb_dst_factor)));
+
        if (rt->colormask & PIPE_MASK_R)
                so->rb_colormask |= A2XX_RB_COLOR_MASK_WRITE_RED;
        if (rt->colormask & PIPE_MASK_G)