Merge commit 'origin/perrtblend'
authorRoland Scheidegger <sroland@vmware.com>
Thu, 28 Jan 2010 16:23:58 +0000 (17:23 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Thu, 28 Jan 2010 16:23:58 +0000 (17:23 +0100)
Conflicts:
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/include/pipe/p_defines.h

56 files changed:
src/gallium/auxiliary/cso_cache/cso_context.c
src/gallium/auxiliary/util/u_blit.c
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_gen_mipmap.c
src/gallium/docs/source/cso/blend.rst
src/gallium/docs/source/cso/sampler.rst
src/gallium/drivers/cell/ppu/cell_gen_fragment.c
src/gallium/drivers/cell/ppu/cell_state_per_fragment.c
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/i965/brw_pipe_blend.c
src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/gallium/drivers/llvmpipe/lp_test_blend.c
src/gallium/drivers/nv04/nv04_screen.c
src/gallium/drivers/nv04/nv04_state.c
src/gallium/drivers/nv10/nv10_screen.c
src/gallium/drivers/nv10/nv10_state.c
src/gallium/drivers/nv20/nv20_screen.c
src/gallium/drivers/nv20/nv20_state.c
src/gallium/drivers/nv30/nv30_screen.c
src/gallium/drivers/nv30/nv30_state.c
src/gallium/drivers/nv40/nv40_screen.c
src/gallium/drivers/nv40/nv40_state.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/softpipe/sp_quad_blend.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/softpipe/sp_video_context.c
src/gallium/drivers/svga/svga_pipe_blend.c
src/gallium/drivers/trace/tr_dump_state.c
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_state.h
src/gallium/state_trackers/dri/dri_extensions.c
src/gallium/state_trackers/python/samples/gs.py
src/gallium/state_trackers/python/samples/tri.py
src/gallium/state_trackers/python/st_device.c
src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py
src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py
src/gallium/state_trackers/python/tests/texture_render.py
src/gallium/state_trackers/python/tests/texture_sample.py
src/gallium/state_trackers/vega/api_filters.c
src/gallium/state_trackers/vega/api_masks.c
src/gallium/state_trackers/vega/mask.c
src/gallium/state_trackers/vega/polygon.c
src/gallium/state_trackers/vega/renderer.c
src/gallium/state_trackers/vega/vg_context.c
src/gallium/state_trackers/xorg/xorg_composite.c
src/gallium/state_trackers/xorg/xorg_renderer.c
src/gallium/state_trackers/xorg/xorg_xv.c
src/mesa/state_tracker/st_atom_blend.c
src/mesa/state_tracker/st_cb_clear.c
src/mesa/state_tracker/st_extensions.c

index fdfb5faa59e4037b6cd4e2745fb82c6ab4671e1c..c479c360643142b114d28405bfa2156551aa8370 100644 (file)
@@ -310,18 +310,21 @@ void cso_destroy_context( struct cso_context *ctx )
 enum pipe_error cso_set_blend(struct cso_context *ctx,
                               const struct pipe_blend_state *templ)
 {
-   unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_blend_state));
-   struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
-                                                       hash_key, CSO_BLEND,
-                                                       (void*)templ);
+   unsigned key_size, hash_key;
+   struct cso_hash_iter iter;
    void *handle;
 
+   key_size = templ->independent_blend_enable ? sizeof(struct pipe_blend_state) :
+              (char *)&(templ->rt[1]) - (char *)templ;
+   hash_key = cso_construct_key((void*)templ, key_size);
+   iter = cso_find_state_template(ctx->cache, hash_key, CSO_BLEND, (void*)templ);
+
    if (cso_hash_iter_is_null(iter)) {
       struct cso_blend *cso = MALLOC(sizeof(struct cso_blend));
       if (!cso)
          return PIPE_ERROR_OUT_OF_MEMORY;
 
-      memcpy(&cso->state, templ, sizeof(*templ));
+      memcpy(&cso->state, templ, key_size);
       cso->data = ctx->pipe->create_blend_state(ctx->pipe, &cso->state);
       cso->delete_state = (cso_state_callback)ctx->pipe->delete_blend_state;
       cso->context = ctx->pipe;
index 236f1e4feee0d7cd5563de3d373d4c0231e9ca05..eb63bec7b50f4c6d18e6cba72c8025b7d0527f69 100644 (file)
@@ -92,7 +92,7 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso)
 
    /* disabled blending/masking */
    memset(&ctx->blend, 0, sizeof(ctx->blend));
-   ctx->blend.colormask = PIPE_MASK_RGBA;
+   ctx->blend.rt[0].colormask = PIPE_MASK_RGBA;
 
    /* no-op depth/stencil/alpha */
    memset(&ctx->depthstencil, 0, sizeof(ctx->depthstencil));
index 249a0375fc54f76c8312a3b5306eef5d3fd1a9c0..935e11c5d85145a5a856d73568fc569acf0e32c8 100644 (file)
@@ -125,7 +125,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
    memset(&blend, 0, sizeof(blend));
    ctx->blend_keep_color = pipe->create_blend_state(pipe, &blend);
 
-   blend.colormask = PIPE_MASK_RGBA;
+   blend.rt[0].colormask = PIPE_MASK_RGBA;
    ctx->blend_write_color = pipe->create_blend_state(pipe, &blend);
 
    /* depth stencil alpha state objects */
index 5426c91152da3187de33d0c4ea05d5305178b323..8611231ed705041d7bbff6920d5fd127d6e9a0aa 100644 (file)
@@ -1287,7 +1287,7 @@ util_create_gen_mipmap(struct pipe_context *pipe,
 
    /* disabled blending/masking */
    memset(&ctx->blend, 0, sizeof(ctx->blend));
-   ctx->blend.colormask = PIPE_MASK_RGBA;
+   ctx->blend.rt[0].colormask = PIPE_MASK_RGBA;
 
    /* no-op depth/stencil/alpha */
    memset(&ctx->depthstencil, 0, sizeof(ctx->depthstencil));
index fd9e4a1e2d512dbf5ef8f98dc36bb963ddfd0286..3fc573054e666557256b509246e20dbc4296608b 100644 (file)
@@ -6,9 +6,42 @@ Blend
 This state controls blending of the final fragments into the target rendering
 buffers.
 
-XXX it is unresolved what behavior should result if blend_enable is off.
-
 Members
 -------
 
-XXX undocumented members
+independent_blend_enable
+   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.
+logicop_enable
+   Enables logic ops. Cannot be enabled at the same time as blending, and
+   is always the same for all render targets.
+logicop_func
+   The logic operation to use if logic ops are enabled. One of PIPE_LOGICOP.
+dither
+   Whether dithering is enabled.
+rt
+   Contains the per rendertarget blend state.
+
+per rendertarget members
+------------------------
+
+blend_enable
+   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).
+rgb_func
+   The blend function to use for rgb channels. One of PIPE_BLEND.
+rgb_src_factor
+   The blend source factor to use for rgb channels. One of PIPE_BLENDFACTOR.
+rgb_dst_factor
+   The blend destination factor to use for rgb channels. One of PIPE_BLENDFACTOR.
+alpha_func
+   The blend function to use for the alpha channel. One of PIPE_BLEND.
+alpha_src_factor
+   The blend source factor to use for the alpha channel. One of PIPE_BLENDFACTOR.
+alpha_dst_factor
+   The blend destination factor to use for alpha channel. One of PIPE_BLENDFACTOR.
+colormask
+   Bitmask of which channels to write. Combination of PIPE_MASK bits.
index e3f1757f57a42fdb69f0014728f061284b4683f3..8b67ca57f12994d2c155814d55b161588fac3ec2 100644 (file)
@@ -12,8 +12,6 @@ with the traditional (S, T, R, Q) notation.
 Members
 -------
 
-XXX undocumented compare_mode, compare_func
-
 wrap_s
     How to wrap the S coordinate. One of PIPE_TEX_WRAP.
 wrap_t
@@ -27,12 +25,18 @@ min_mip_filter
     PIPE_TEX_FILTER.
 mag_img_filter
     The filter to use when magnifying texels. One of PIPE_TEX_FILTER.
+compare_mode
+    If set to PIPE_TEX_COMPARE_R_TO_TEXTURE, texture output is computed
+    according to compare_func, using r coord and the texture value as operands.
+    If set to PIPE_TEX_COMPARE_NONE, no comparison calculation is performed.
+compare_func
+    How the comparison is computed. One of PIPE_FUNC.
 normalized_coords
     Whether the texture coordinates are normalized. If normalized, they will
     always be in [0, 1]. If not, they will be in the range of each dimension
     of the loaded texture.
 prefilter
-    XXX From the Doxy, "weird sampling state exposed by some APIs." Refine.
+    Cylindrical texcoord wrap enable per coord. Not exposed by most APIs.
 lod_bias
     The bias to apply to the level of detail.
 min_lod
index 66d4b3b6a31b348f9f0b28ebe92c199f2f17482a..0dab34075da525cec2697a5fec73de2c90492629 100644 (file)
@@ -408,7 +408,7 @@ gen_blend(const struct pipe_blend_state *blend,
    int one_reg = -1;
    int constR_reg = -1, constG_reg = -1, constB_reg = -1, constA_reg = -1;
 
-   ASSERT(blend->blend_enable);
+   ASSERT(blend->rt[0].blend_enable);
 
    /* packed RGBA -> float colors */
    unpack_colors(f, color_format, fbRGBA_reg,
@@ -420,7 +420,7 @@ gen_blend(const struct pipe_blend_state *blend,
     * because in some cases (like PIPE_BLENDFACTOR_ONE and 
     * PIPE_BLENDFACTOR_ZERO) we can avoid doing unnecessary math.
     */
-   switch (blend->rgb_src_factor) {
+   switch (blend->rt[0].rgb_src_factor) {
    case PIPE_BLENDFACTOR_ONE:
       /* factors = (1,1,1), so term = (R,G,B) */
       spe_move(f, term1R_reg, fragR_reg);
@@ -574,7 +574,7 @@ gen_blend(const struct pipe_blend_state *blend,
     * the full term A*factor, not just the factor itself, because
     * in many cases we can avoid doing unnecessary multiplies.
     */
-   switch (blend->alpha_src_factor) {
+   switch (blend->rt[0].alpha_src_factor) {
    case PIPE_BLENDFACTOR_ZERO:
       /* factor = 0, so term = 0 */
       spe_load_float(f, term1A_reg, 0.0f);
@@ -648,7 +648,7 @@ gen_blend(const struct pipe_blend_state *blend,
     * the full term (Rfb,Gfb,Bfb)*(factor), not just the factor itself, because
     * in many cases we can avoid doing unnecessary multiplies.
     */
-   switch (blend->rgb_dst_factor) {
+   switch (blend->rt[0].rgb_dst_factor) {
    case PIPE_BLENDFACTOR_ONE:
       /* factors = (1,1,1), so term = (Rfb,Gfb,Bfb) */
       spe_move(f, term2R_reg, fbR_reg);
@@ -786,7 +786,7 @@ gen_blend(const struct pipe_blend_state *blend,
     * the full term Afb*factor, not just the factor itself, because
     * in many cases we can avoid doing unnecessary multiplies.
     */
-   switch (blend->alpha_dst_factor) {
+   switch (blend->rt[0].alpha_dst_factor) {
    case PIPE_BLENDFACTOR_ONE:
       /* factor = 1, so term = Afb */
       spe_move(f, term2A_reg, fbA_reg);
@@ -858,7 +858,7 @@ gen_blend(const struct pipe_blend_state *blend,
    /*
     * Combine Src/Dest RGB terms as per the blend equation.
     */
-   switch (blend->rgb_func) {
+   switch (blend->rt[0].rgb_func) {
    case PIPE_BLEND_ADD:
       spe_fa(f, fragR_reg, term1R_reg, term2R_reg);
       spe_fa(f, fragG_reg, term1G_reg, term2G_reg);
@@ -891,7 +891,7 @@ gen_blend(const struct pipe_blend_state *blend,
    /*
     * Combine Src/Dest A term
     */
-   switch (blend->alpha_func) {
+   switch (blend->rt[0].alpha_func) {
    case PIPE_BLEND_ADD:
       spe_fa(f, fragA_reg, term1A_reg, term2A_reg);
       break;
@@ -2118,7 +2118,7 @@ cell_gen_fragment_function(struct cell_context *cell,
    spe_comment(f, 0, "Fetch quad colors from tile");
    spe_lqx(f, fbRGBA_reg, color_tile_reg, quad_offset_reg);
 
-   if (blend->blend_enable) {
+   if (blend->rt[0].blend_enable) {
       spe_comment(f, 0, "Perform blending");
       gen_blend(blend, blend_color, f, color_format,
                 fragR_reg, fragG_reg, fragB_reg, fragA_reg, fbRGBA_reg);
@@ -2143,9 +2143,9 @@ cell_gen_fragment_function(struct cell_context *cell,
          gen_logicop(blend, f, rgba_reg, fbRGBA_reg);
       }
 
-      if (blend->colormask != PIPE_MASK_RGBA) {
+      if (blend->rt[0].colormask != PIPE_MASK_RGBA) {
          spe_comment(f, 0, "Compute color mask");
-         gen_colormask(f, blend->colormask, color_format, rgba_reg, fbRGBA_reg);
+         gen_colormask(f, blend->rt[0].colormask, color_format, rgba_reg, fbRGBA_reg);
       }
 
       /* Mix fragment colors with framebuffer colors using the quad/pixel mask:
index d97c22b2efe82286ed26115eac3ac33e64661ffc..21af7ed1c3fbd066a8dc5b017e9afc310f9fdd7f 100644 (file)
@@ -999,23 +999,23 @@ cell_generate_alpha_blend(struct cell_blend_state *cb)
    /* Does the selected blend mode make use of the source / destination
     * color (RGB) blend factors?
     */
-   boolean need_color_factor = b->blend_enable
-       && (b->rgb_func != PIPE_BLEND_MIN)
-       && (b->rgb_func != PIPE_BLEND_MAX);
+   boolean need_color_factor = b->rt[0].blend_enable
+       && (b->rt[0].rgb_func != PIPE_BLEND_MIN)
+       && (b->rt[0].rgb_func != PIPE_BLEND_MAX);
 
    /* Does the selected blend mode make use of the source / destination
     * alpha blend factors?
     */
-   boolean need_alpha_factor = b->blend_enable
-       && (b->alpha_func != PIPE_BLEND_MIN)
-       && (b->alpha_func != PIPE_BLEND_MAX);
+   boolean need_alpha_factor = b->rt[0].blend_enable
+       && (b->rt[0].alpha_func != PIPE_BLEND_MIN)
+       && (b->rt[0].alpha_func != PIPE_BLEND_MAX);
 
 
-   if (b->blend_enable) {
-      sF[0] = b->rgb_src_factor;
+   if (b->rt[0].blend_enable) {
+      sF[0] = b->rt[0].rgb_src_factor;
       sF[1] = sF[0];
       sF[2] = sF[0];
-      switch (b->alpha_src_factor & 0x0f) {
+      switch (b->rt[0].alpha_src_factor & 0x0f) {
       case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
          sF[3] = PIPE_BLENDFACTOR_ONE;
          break;
@@ -1023,30 +1023,30 @@ cell_generate_alpha_blend(struct cell_blend_state *cb)
       case PIPE_BLENDFACTOR_DST_COLOR:
       case PIPE_BLENDFACTOR_CONST_COLOR:
       case PIPE_BLENDFACTOR_SRC1_COLOR:
-         sF[3] = b->alpha_src_factor + 1;
+         sF[3] = b->rt[0].alpha_src_factor + 1;
          break;
       default:
-         sF[3] = b->alpha_src_factor;
+         sF[3] = b->rt[0].alpha_src_factor;
       }
 
-      dF[0] = b->rgb_dst_factor;
+      dF[0] = b->rt[0].rgb_dst_factor;
       dF[1] = dF[0];
       dF[2] = dF[0];
-      switch (b->alpha_dst_factor & 0x0f) {
+      switch (b->rt[0].alpha_dst_factor & 0x0f) {
       case PIPE_BLENDFACTOR_SRC_COLOR:
       case PIPE_BLENDFACTOR_DST_COLOR:
       case PIPE_BLENDFACTOR_CONST_COLOR:
       case PIPE_BLENDFACTOR_SRC1_COLOR:
-         dF[3] = b->alpha_dst_factor + 1;
+         dF[3] = b->rt[0].alpha_dst_factor + 1;
          break;
       default:
-         dF[3] = b->alpha_dst_factor;
+         dF[3] = b->rt[0].alpha_dst_factor;
       }
 
-      func[0] = b->rgb_func;
+      func[0] = b->rt[0].rgb_func;
       func[1] = func[0];
       func[2] = func[0];
-      func[3] = b->alpha_func;
+      func[3] = b->rt[0].alpha_func;
    } else {
       sF[0] = PIPE_BLENDFACTOR_ONE;
       sF[1] = PIPE_BLENDFACTOR_ONE;
@@ -1067,7 +1067,7 @@ cell_generate_alpha_blend(struct cell_blend_state *cb)
    /* If alpha writing is enabled and the alpha blend mode requires use of
     * the alpha factor, calculate the alpha factor.
     */
-   if (((b->colormask & 8) != 0) && need_alpha_factor) {
+   if (((b->rt[0].colormask & 8) != 0) && need_alpha_factor) {
       src_factor[3] = emit_alpha_factor_calculation(f, sF[3], const_color[3],
                                                     frag[3], pixel[3]);
 
@@ -1091,8 +1091,8 @@ cell_generate_alpha_blend(struct cell_blend_state *cb)
       src_factor[2] = dst_factor[3];
    } else if (need_color_factor) {
       emit_color_factor_calculation(f,
-                                    b->rgb_src_factor,
-                                    b->colormask,
+                                    b->rt[0].rgb_src_factor,
+                                    b->rt[0].colormask,
                                     frag, pixel, const_color, src_factor);
    }
 
@@ -1111,15 +1111,15 @@ cell_generate_alpha_blend(struct cell_blend_state *cb)
       dst_factor[2] = src_factor[2];
    } else if (need_color_factor) {
       emit_color_factor_calculation(f,
-                                    b->rgb_dst_factor,
-                                    b->colormask,
+                                    b->rt[0].rgb_dst_factor,
+                                    b->rt[0].colormask,
                                     frag, pixel, const_color, dst_factor);
    }
 
 
 
    for (i = 0; i < 4; ++i) {
-      if ((b->colormask & (1U << i)) != 0) {
+      if ((b->rt[0].colormask & (1U << i)) != 0) {
          emit_blend_calculation(f,
                                 func[i], sF[i], dF[i],
                                 frag[i], src_factor[i],
@@ -1216,7 +1216,7 @@ cell_generate_logic_op(struct spe_function *f,
 
    /* Short-circuit the noop and invert cases.
     */
-   if ((logic_op == PIPE_LOGICOP_NOOP) || (blend->colormask == 0)) {
+   if ((logic_op == PIPE_LOGICOP_NOOP) || (blend->rt[0].colormask == 0)) {
       spe_bi(f, 0, 0, 0);
       return;
    } else if (logic_op == PIPE_LOGICOP_INVERT) {
index 06949c15f88178205567ccd99dfa18a928cbf74a..23e4d6b993889af9e2eb578a6dfb86c3611e77a2 100644 (file)
@@ -103,13 +103,13 @@ i915_create_blend_state(struct pipe_context *pipe,
    struct i915_blend_state *cso_data = CALLOC_STRUCT( i915_blend_state );
 
    {
-      unsigned eqRGB  = blend->rgb_func;
-      unsigned srcRGB = blend->rgb_src_factor;
-      unsigned dstRGB = blend->rgb_dst_factor;
+      unsigned eqRGB  = blend->rt[0].rgb_func;
+      unsigned srcRGB = blend->rt[0].rgb_src_factor;
+      unsigned dstRGB = blend->rt[0].rgb_dst_factor;
 
-      unsigned eqA    = blend->alpha_func;
-      unsigned srcA   = blend->alpha_src_factor;
-      unsigned dstA   = blend->alpha_dst_factor;
+      unsigned eqA    = blend->rt[0].alpha_func;
+      unsigned srcA   = blend->rt[0].alpha_src_factor;
+      unsigned dstA   = blend->rt[0].alpha_dst_factor;
 
       /* Special handling for MIN/MAX filter modes handled at
        * state_tracker level.
@@ -146,22 +146,22 @@ i915_create_blend_state(struct pipe_context *pipe,
    if (blend->dither)
       cso_data->LIS5 |= S5_COLOR_DITHER_ENABLE;
 
-   if ((blend->colormask & PIPE_MASK_R) == 0)
+   if ((blend->rt[0].colormask & PIPE_MASK_R) == 0)
       cso_data->LIS5 |= S5_WRITEDISABLE_RED;
 
-   if ((blend->colormask & PIPE_MASK_G) == 0)
+   if ((blend->rt[0].colormask & PIPE_MASK_G) == 0)
       cso_data->LIS5 |= S5_WRITEDISABLE_GREEN;
 
-   if ((blend->colormask & PIPE_MASK_B) == 0)
+   if ((blend->rt[0].colormask & PIPE_MASK_B) == 0)
       cso_data->LIS5 |= S5_WRITEDISABLE_BLUE;
 
-   if ((blend->colormask & PIPE_MASK_A) == 0)
+   if ((blend->rt[0].colormask & PIPE_MASK_A) == 0)
       cso_data->LIS5 |= S5_WRITEDISABLE_ALPHA;
 
-   if (blend->blend_enable) {
-      unsigned funcRGB = blend->rgb_func;
-      unsigned srcRGB  = blend->rgb_src_factor;
-      unsigned dstRGB  = blend->rgb_dst_factor;
+   if (blend->rt[0].blend_enable) {
+      unsigned funcRGB = blend->rt[0].rgb_func;
+      unsigned srcRGB  = blend->rt[0].rgb_src_factor;
+      unsigned dstRGB  = blend->rt[0].rgb_dst_factor;
 
       cso_data->LIS6 |= (S6_CBUF_BLEND_ENABLE |
                          SRC_BLND_FACT(i915_translate_blend_factor(srcRGB)) |
index b759a910b638bd08bebcc3103b1d1322ccd7e7b9..21f786f871529402604145ef1bb5be211b9d5c69 100644 (file)
@@ -118,14 +118,14 @@ static void *brw_create_blend_state( struct pipe_context *pipe,
       blend->cc2.logicop_enable = 1;
       blend->cc5.logicop_func = translate_logicop(templ->logicop_func);
    } 
-   else if (templ->blend_enable) {
-      blend->cc6.dest_blend_factor = translate_blend_factor(templ->rgb_dst_factor);
-      blend->cc6.src_blend_factor = translate_blend_factor(templ->rgb_src_factor);
-      blend->cc6.blend_function = translate_blend_equation(templ->rgb_func);
+   else if (templ->rt[0].blend_enable) {
+      blend->cc6.dest_blend_factor = translate_blend_factor(templ->rt[0].rgb_dst_factor);
+      blend->cc6.src_blend_factor = translate_blend_factor(templ->rt[0].rgb_src_factor);
+      blend->cc6.blend_function = translate_blend_equation(templ->rt[0].rgb_func);
 
-      blend->cc5.ia_dest_blend_factor = translate_blend_factor(templ->alpha_dst_factor);
-      blend->cc5.ia_src_blend_factor = translate_blend_factor(templ->alpha_src_factor);
-      blend->cc5.ia_blend_function = translate_blend_equation(templ->alpha_func);
+      blend->cc5.ia_dest_blend_factor = translate_blend_factor(templ->rt[0].alpha_dst_factor);
+      blend->cc5.ia_src_blend_factor = translate_blend_factor(templ->rt[0].alpha_src_factor);
+      blend->cc5.ia_blend_function = translate_blend_equation(templ->rt[0].alpha_func);
 
       blend->cc3.blend_enable = 1;
       blend->cc3.ia_blend_enable = 
@@ -146,10 +146,10 @@ static void *brw_create_blend_state( struct pipe_context *pipe,
 
    /* Per-surface color mask -- just follow global state:
     */
-   blend->ss0.writedisable_red   = (templ->colormask & PIPE_MASK_R) ? 0 : 1;
-   blend->ss0.writedisable_green = (templ->colormask & PIPE_MASK_G) ? 0 : 1;
-   blend->ss0.writedisable_blue  = (templ->colormask & PIPE_MASK_B) ? 0 : 1;
-   blend->ss0.writedisable_alpha = (templ->colormask & PIPE_MASK_A) ? 0 : 1;
+   blend->ss0.writedisable_red   = (templ->rt[0].colormask & PIPE_MASK_R) ? 0 : 1;
+   blend->ss0.writedisable_green = (templ->rt[0].colormask & PIPE_MASK_G) ? 0 : 1;
+   blend->ss0.writedisable_blue  = (templ->rt[0].colormask & PIPE_MASK_B) ? 0 : 1;
+   blend->ss0.writedisable_alpha = (templ->rt[0].colormask & PIPE_MASK_A) ? 0 : 1;
 
    return (void *)blend;
 }
index ced7b9c11d739e1821357c13d5778b823e0e760c..ad1dbbc9b19313aed0b0abf518911873aa2ebfa4 100644 (file)
@@ -314,9 +314,10 @@ lp_build_blend_aos(LLVMBuilderRef builder,
    LLVMValueRef dst_term;
 
    /* FIXME */
-   assert(blend->colormask == 0xf);
+   assert(blend->independent_blend_enable == 0);
+   assert(blend->rt[0].colormask == 0xf);
 
-   if(!blend->blend_enable)
+   if(!blend->rt[0].blend_enable)
       return src;
 
    /* It makes no sense to blend unless values are normalized */
@@ -333,14 +334,16 @@ lp_build_blend_aos(LLVMBuilderRef builder,
     * combinations it is possible to reorder the operations and therefore saving
     * some instructions. */
 
-   src_term = lp_build_blend_factor(&bld, src, blend->rgb_src_factor, blend->alpha_src_factor, alpha_swizzle);
-   dst_term = lp_build_blend_factor(&bld, dst, blend->rgb_dst_factor, blend->alpha_dst_factor, alpha_swizzle);
+   src_term = lp_build_blend_factor(&bld, src, blend->rt[0].rgb_src_factor,
+                                    blend->rt[0].alpha_src_factor, alpha_swizzle);
+   dst_term = lp_build_blend_factor(&bld, dst, blend->rt[0].rgb_dst_factor,
+                                    blend->rt[0].alpha_dst_factor, alpha_swizzle);
 
    lp_build_name(src_term, "src_term");
    lp_build_name(dst_term, "dst_term");
 
-   if(blend->rgb_func == blend->alpha_func) {
-      return lp_build_blend_func(&bld.base, blend->rgb_func, src_term, dst_term);
+   if(blend->rt[0].rgb_func == blend->rt[0].alpha_func) {
+      return lp_build_blend_func(&bld.base, blend->rt[0].rgb_func, src_term, dst_term);
    }
    else {
       /* Seperate RGB / A functions */
@@ -348,8 +351,8 @@ lp_build_blend_aos(LLVMBuilderRef builder,
       LLVMValueRef rgb;
       LLVMValueRef alpha;
 
-      rgb   = lp_build_blend_func(&bld.base, blend->rgb_func,   src_term, dst_term);
-      alpha = lp_build_blend_func(&bld.base, blend->alpha_func, src_term, dst_term);
+      rgb   = lp_build_blend_func(&bld.base, blend->rt[0].rgb_func,   src_term, dst_term);
+      alpha = lp_build_blend_func(&bld.base, blend->rt[0].alpha_func, src_term, dst_term);
 
       return lp_build_blend_swizzle(&bld, rgb, alpha, LP_BUILD_BLEND_SWIZZLE_RGBA, alpha_swizzle);
    }
index 5d5ca7a5d43015effa64f11cefd711459a83423a..a73d1158e79261c7144689f31251440222ad1115 100644 (file)
@@ -217,7 +217,7 @@ lp_build_blend_soa(LLVMBuilderRef builder,
    }
 
    for (i = 0; i < 4; ++i) {
-      if (blend->colormask & (1 << i)) {
+      if (blend->rt[0].colormask & (1 << i)) {
          if (blend->logicop_enable) {
             if(!type.floating) {
                res[i] = lp_build_logicop(builder, blend->logicop_func, src[i], dst[i]);
@@ -225,10 +225,10 @@ lp_build_blend_soa(LLVMBuilderRef builder,
             else
                res[i] = dst[i];
          }
-         else if (blend->blend_enable) {
-            unsigned src_factor = i < 3 ? blend->rgb_src_factor : blend->alpha_src_factor;
-            unsigned dst_factor = i < 3 ? blend->rgb_dst_factor : blend->alpha_dst_factor;
-            unsigned func = i < 3 ? blend->rgb_func : blend->alpha_func;
+         else if (blend->rt[0].blend_enable) {
+            unsigned src_factor = i < 3 ? blend->rt[0].rgb_src_factor : blend->rt[0].alpha_src_factor;
+            unsigned dst_factor = i < 3 ? blend->rt[0].rgb_dst_factor : blend->rt[0].alpha_dst_factor;
+            unsigned func = i < 3 ? blend->rt[0].rgb_func : blend->rt[0].alpha_func;
             boolean func_commutative = lp_build_blend_func_commutative(func);
 
             /* It makes no sense to blend unless values are normalized */
@@ -269,7 +269,7 @@ lp_build_blend_soa(LLVMBuilderRef builder,
 
             /* See if this function has been previously applied */
             for(j = 0; j < i; ++j) {
-               unsigned prev_func = j < 3 ? blend->rgb_func : blend->alpha_func;
+               unsigned prev_func = j < 3 ? blend->rt[0].rgb_func : blend->rt[0].alpha_func;
                unsigned func_reverse = lp_build_blend_func_reverse(func, prev_func);
 
                if((!func_reverse &&
index 9b47415f003350c7592894fb6338f50c7943e2b6..f04c0320ba06a80a76984d099801347490921e52 100644 (file)
@@ -110,6 +110,10 @@ llvmpipe_get_param(struct pipe_screen *screen, int param)
       return 1;
    case PIPE_CAP_BLEND_EQUATION_SEPARATE:
       return 1;
+   case PIPE_CAP_INDEP_BLEND_ENABLE:
+      return 0;
+   case PIPE_CAP_INDEP_BLEND_FUNC:
+      return 0;
    default:
       return 0;
    }
index 0cb335fe27a4c8b671945bf88b6ece9934c1d85f..ddd0740f1b4054ba6114cf787c5bc95172aaf92d 100644 (file)
@@ -352,7 +352,7 @@ generate_blend(const struct pipe_blend_state *blend,
    lp_build_blend_soa(builder, blend, type, src, dst, con, res);
 
    for(chan = 0; chan < 4; ++chan) {
-      if(blend->colormask & (1 << chan)) {
+      if(blend->rt[0].colormask & (1 << chan)) {
          LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), chan, 0);
          lp_build_name(res[chan], "res.%c", "rgba"[chan]);
          res[chan] = lp_build_select(&bld, mask, res[chan], dst[chan]);
@@ -421,15 +421,15 @@ generate_fragment(struct llvmpipe_context *lp,
       if(key->blend.logicop_enable) {
          debug_printf("blend.logicop_func = %u\n", key->blend.logicop_func);
       }
-      else if(key->blend.blend_enable) {
-         debug_printf("blend.rgb_func = %s\n",   debug_dump_blend_func  (key->blend.rgb_func, TRUE));
-         debug_printf("rgb_src_factor = %s\n",   debug_dump_blend_factor(key->blend.rgb_src_factor, TRUE));
-         debug_printf("rgb_dst_factor = %s\n",   debug_dump_blend_factor(key->blend.rgb_dst_factor, TRUE));
-         debug_printf("alpha_func = %s\n",       debug_dump_blend_func  (key->blend.alpha_func, TRUE));
-         debug_printf("alpha_src_factor = %s\n", debug_dump_blend_factor(key->blend.alpha_src_factor, TRUE));
-         debug_printf("alpha_dst_factor = %s\n", debug_dump_blend_factor(key->blend.alpha_dst_factor, TRUE));
+      else if(key->blend.rt[0].blend_enable) {
+         debug_printf("blend.rgb_func = %s\n",   debug_dump_blend_func  (key->blend.rt[0].rgb_func, TRUE));
+         debug_printf("rgb_src_factor = %s\n",   debug_dump_blend_factor(key->blend.rt[0].rgb_src_factor, TRUE));
+         debug_printf("rgb_dst_factor = %s\n",   debug_dump_blend_factor(key->blend.rt[0].rgb_dst_factor, TRUE));
+         debug_printf("alpha_func = %s\n",       debug_dump_blend_func  (key->blend.rt[0].alpha_func, TRUE));
+         debug_printf("alpha_src_factor = %s\n", debug_dump_blend_factor(key->blend.rt[0].alpha_src_factor, TRUE));
+         debug_printf("alpha_dst_factor = %s\n", debug_dump_blend_factor(key->blend.rt[0].alpha_dst_factor, TRUE));
       }
-      debug_printf("blend.colormask = 0x%x\n", key->blend.colormask);
+      debug_printf("blend.colormask = 0x%x\n", key->blend.rt[0].colormask);
       for(i = 0; i < PIPE_MAX_SAMPLERS; ++i) {
          if(key->sampler[i].format) {
             debug_printf("sampler[%u] = \n", i);
@@ -780,7 +780,7 @@ make_variant_key(struct llvmpipe_context *lp,
       for(chan = 0; chan < 4; ++chan) {
          enum util_format_swizzle swizzle = format_desc->swizzle[chan];
          if(swizzle > 4)
-            key->blend.colormask &= ~(1 << chan);
+            key->blend.rt[0].colormask &= ~(1 << chan);
       }
    }
 
index 7b65bab43a472de9e60113f2ec1afc4b0569bf5a..ee72f6ce4fcc4d315d3b267a2f9a37323cf0060f 100644 (file)
@@ -103,18 +103,18 @@ write_tsv_row(FILE *fp,
 
    fprintf(fp,
            "%s\t%s\t%s\t",
-           blend->rgb_func != blend->alpha_func ? "true" : "false",
-           blend->rgb_src_factor != blend->alpha_src_factor ? "true" : "false",
-           blend->rgb_dst_factor != blend->alpha_dst_factor ? "true" : "false");
+           blend->rt[0].rgb_func != blend->rt[0].alpha_func ? "true" : "false",
+           blend->rt[0].rgb_src_factor != blend->rt[0].alpha_src_factor ? "true" : "false",
+           blend->rt[0].rgb_dst_factor != blend->rt[0].alpha_dst_factor ? "true" : "false");
 
    fprintf(fp,
            "%s\t%s\t%s\t%s\t%s\t%s\n",
-           debug_dump_blend_func(blend->rgb_func, TRUE),
-           debug_dump_blend_factor(blend->rgb_src_factor, TRUE),
-           debug_dump_blend_factor(blend->rgb_dst_factor, TRUE),
-           debug_dump_blend_func(blend->alpha_func, TRUE),
-           debug_dump_blend_factor(blend->alpha_src_factor, TRUE),
-           debug_dump_blend_factor(blend->alpha_dst_factor, TRUE));
+           debug_dump_blend_func(blend->rt[0].rgb_func, TRUE),
+           debug_dump_blend_factor(blend->rt[0].rgb_src_factor, TRUE),
+           debug_dump_blend_factor(blend->rt[0].rgb_dst_factor, TRUE),
+           debug_dump_blend_func(blend->rt[0].alpha_func, TRUE),
+           debug_dump_blend_factor(blend->rt[0].alpha_src_factor, TRUE),
+           debug_dump_blend_factor(blend->rt[0].alpha_dst_factor, TRUE));
 
    fflush(fp);
 }
@@ -136,12 +136,12 @@ dump_blend_type(FILE *fp,
 
    fprintf(fp,
            " %s=%s %s=%s %s=%s %s=%s %s=%s %s=%s",
-           "rgb_func",         debug_dump_blend_func(blend->rgb_func, TRUE),
-           "rgb_src_factor",   debug_dump_blend_factor(blend->rgb_src_factor, TRUE),
-           "rgb_dst_factor",   debug_dump_blend_factor(blend->rgb_dst_factor, TRUE),
-           "alpha_func",       debug_dump_blend_func(blend->alpha_func, TRUE),
-           "alpha_src_factor", debug_dump_blend_factor(blend->alpha_src_factor, TRUE),
-           "alpha_dst_factor", debug_dump_blend_factor(blend->alpha_dst_factor, TRUE));
+           "rgb_func",         debug_dump_blend_func(blend->rt[0].rgb_func, TRUE),
+           "rgb_src_factor",   debug_dump_blend_factor(blend->rt[0].rgb_src_factor, TRUE),
+           "rgb_dst_factor",   debug_dump_blend_factor(blend->rt[0].rgb_dst_factor, TRUE),
+           "alpha_func",       debug_dump_blend_func(blend->rt[0].alpha_func, TRUE),
+           "alpha_src_factor", debug_dump_blend_factor(blend->rt[0].alpha_src_factor, TRUE),
+           "alpha_dst_factor", debug_dump_blend_factor(blend->rt[0].alpha_dst_factor, TRUE));
 
    fprintf(fp, " ...\n");
    fflush(fp);
@@ -400,13 +400,15 @@ compute_blend_ref(const struct pipe_blend_state *blend,
    double src_term[4];
    double dst_term[4];
 
-   compute_blend_ref_term(blend->rgb_src_factor, blend->alpha_src_factor, src, src, dst, con, src_term);
-   compute_blend_ref_term(blend->rgb_dst_factor, blend->alpha_dst_factor, dst, src, dst, con, dst_term);
+   compute_blend_ref_term(blend->rt[0].rgb_src_factor, blend->rt[0].alpha_src_factor,
+                          src, src, dst, con, src_term);
+   compute_blend_ref_term(blend->rt[0].rgb_dst_factor, blend->rt[0].alpha_dst_factor,
+                          dst, src, dst, con, dst_term);
 
    /*
     * Combine RGB terms
     */
-   switch (blend->rgb_func) {
+   switch (blend->rt[0].rgb_func) {
    case PIPE_BLEND_ADD:
       ADD_SAT(res[0], src_term[0], dst_term[0]); /* R */
       ADD_SAT(res[1], src_term[1], dst_term[1]); /* G */
@@ -439,7 +441,7 @@ compute_blend_ref(const struct pipe_blend_state *blend,
    /*
     * Combine A terms
     */
-   switch (blend->alpha_func) {
+   switch (blend->rt[0].alpha_func) {
    case PIPE_BLEND_ADD:
       ADD_SAT(res[3], src_term[3], dst_term[3]); /* A */
       break;
@@ -805,14 +807,14 @@ test_all(unsigned verbose, FILE *fp)
                               continue;
 
                            memset(&blend, 0, sizeof blend);
-                           blend.blend_enable      = 1;
-                           blend.rgb_func          = *rgb_func;
-                           blend.rgb_src_factor    = *rgb_src_factor;
-                           blend.rgb_dst_factor    = *rgb_dst_factor;
-                           blend.alpha_func        = *alpha_func;
-                           blend.alpha_src_factor  = *alpha_src_factor;
-                           blend.alpha_dst_factor  = *alpha_dst_factor;
-                           blend.colormask         = PIPE_MASK_RGBA;
+                           blend.rt[0].blend_enable      = 1;
+                           blend.rt[0].rgb_func          = *rgb_func;
+                           blend.rt[0].rgb_src_factor    = *rgb_src_factor;
+                           blend.rt[0].rgb_dst_factor    = *rgb_dst_factor;
+                           blend.rt[0].alpha_func        = *alpha_func;
+                           blend.rt[0].alpha_src_factor  = *alpha_src_factor;
+                           blend.rt[0].alpha_dst_factor  = *alpha_dst_factor;
+                           blend.rt[0].colormask         = PIPE_MASK_RGBA;
 
                            if(!test_one(verbose, fp, &blend, mode, *type))
                              success = FALSE;
@@ -864,14 +866,14 @@ test_some(unsigned verbose, FILE *fp, unsigned long n)
       type = &blend_types[rand() % num_types];
 
       memset(&blend, 0, sizeof blend);
-      blend.blend_enable      = 1;
-      blend.rgb_func          = *rgb_func;
-      blend.rgb_src_factor    = *rgb_src_factor;
-      blend.rgb_dst_factor    = *rgb_dst_factor;
-      blend.alpha_func        = *alpha_func;
-      blend.alpha_src_factor  = *alpha_src_factor;
-      blend.alpha_dst_factor  = *alpha_dst_factor;
-      blend.colormask         = PIPE_MASK_RGBA;
+      blend.rt[0].blend_enable      = 1;
+      blend.rt[0].rgb_func          = *rgb_func;
+      blend.rt[0].rgb_src_factor    = *rgb_src_factor;
+      blend.rt[0].rgb_dst_factor    = *rgb_dst_factor;
+      blend.rt[0].alpha_func        = *alpha_func;
+      blend.rt[0].alpha_src_factor  = *alpha_src_factor;
+      blend.rt[0].alpha_dst_factor  = *alpha_dst_factor;
+      blend.rt[0].colormask         = PIPE_MASK_RGBA;
 
       if(!test_one(verbose, fp, &blend, mode, *type))
         success = FALSE;
index 7c5b6e8229ae1d8f3ad4b5bf5cdf1f64acc47726..4eba7725753626eb0a7fffe3d8683fb7d41cd575 100644 (file)
@@ -45,6 +45,10 @@ nv04_screen_get_param(struct pipe_screen *screen, int param)
        case NOUVEAU_CAP_HW_VTXBUF:
        case NOUVEAU_CAP_HW_IDXBUF:
                return 0;
+       case PIPE_CAP_INDEP_BLEND_ENABLE:
+               return 0;
+       case PIPE_CAP_INDEP_BLEND_FUNC:
+               return 0;
        default:
                NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
                return 0;
index b67f1e16b1c3c4f1ddcd35f7795b94402017a885..1fdb764b5323a5a38033f9bbf4b428fa4a1014d3 100644 (file)
@@ -17,11 +17,11 @@ nv04_blend_state_create(struct pipe_context *pipe,
 
        cb = MALLOC(sizeof(struct nv04_blend_state));
 
-       cb->b_enable = cso->blend_enable ? 1 : 0;
-       cb->b_src = ((nvgl_blend_func(cso->alpha_src_factor)<<16) |
-                        (nvgl_blend_func(cso->rgb_src_factor)));
-       cb->b_dst = ((nvgl_blend_func(cso->alpha_dst_factor)<<16) |
-                        (nvgl_blend_func(cso->rgb_dst_factor)));
+       cb->b_enable = cso->rt[0].blend_enable ? 1 : 0;
+       cb->b_src = ((nvgl_blend_func(cso->rt[0].alpha_src_factor)<<16) |
+                        (nvgl_blend_func(cso->rt[0].rgb_src_factor)));
+       cb->b_dst = ((nvgl_blend_func(cso->rt[0].alpha_dst_factor)<<16) |
+                        (nvgl_blend_func(cso->rt[0].rgb_dst_factor)));
        
 
        return (void *)cb;
index 69a6dab866a6f3c2c6e0f74f0672f2fa6cd92b7e..2dabc4509fb4011debb5b56b68c3b93b9b6bdb8b 100644 (file)
@@ -40,6 +40,10 @@ nv10_screen_get_param(struct pipe_screen *screen, int param)
        case NOUVEAU_CAP_HW_VTXBUF:
        case NOUVEAU_CAP_HW_IDXBUF:
                return 0;
+       case PIPE_CAP_INDEP_BLEND_ENABLE:
+               return 0;
+       case PIPE_CAP_INDEP_BLEND_FUNC:
+               return 0;
        default:
                NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
                return 0;
index ad7def53b12c3b99421ce46406e5f58ce6f7bb08..9aafc604116b265a30a3149305e35b0fc46624f4 100644 (file)
@@ -17,16 +17,16 @@ nv10_blend_state_create(struct pipe_context *pipe,
 
        cb = MALLOC(sizeof(struct nv10_blend_state));
 
-       cb->b_enable = cso->blend_enable ? 1 : 0;
-       cb->b_srcfunc = ((nvgl_blend_func(cso->alpha_src_factor)<<16) |
-                        (nvgl_blend_func(cso->rgb_src_factor)));
-       cb->b_dstfunc = ((nvgl_blend_func(cso->alpha_dst_factor)<<16) |
-                        (nvgl_blend_func(cso->rgb_dst_factor)));
-
-       cb->c_mask = (((cso->colormask & PIPE_MASK_A) ? (0x01<<24) : 0) |
-                     ((cso->colormask & PIPE_MASK_R) ? (0x01<<16) : 0) |
-                     ((cso->colormask & PIPE_MASK_G) ? (0x01<< 8) : 0) |
-                     ((cso->colormask & PIPE_MASK_B) ? (0x01<< 0) : 0));
+       cb->b_enable = cso->rt[0].blend_enable ? 1 : 0;
+       cb->b_srcfunc = ((nvgl_blend_func(cso->rt[0].alpha_src_factor)<<16) |
+                        (nvgl_blend_func(cso->rt[0].rgb_src_factor)));
+       cb->b_dstfunc = ((nvgl_blend_func(cso->rt[0].alpha_dst_factor)<<16) |
+                        (nvgl_blend_func(cso->rt[0].rgb_dst_factor)));
+
+       cb->c_mask = (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01<<24) : 0) |
+                     ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01<<16) : 0) |
+                     ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01<< 8) : 0) |
+                     ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01<< 0) : 0));
 
        cb->d_enable = cso->dither ? 1 : 0;
 
index d091335063b9ba668b73a012966b5f95764fcd84..7782cbe3a8ecb9d2a05b7dc420a55b4d01a170fe 100644 (file)
@@ -40,6 +40,10 @@ nv20_screen_get_param(struct pipe_screen *screen, int param)
        case NOUVEAU_CAP_HW_VTXBUF:
        case NOUVEAU_CAP_HW_IDXBUF:
                return 0;
+       case PIPE_CAP_INDEP_BLEND_ENABLE:
+               return 0;
+       case PIPE_CAP_INDEP_BLEND_FUNC:
+               return 0;
        default:
                NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
                return 0;
index 45697a60efda018c111c4250016d411423e9a021..83335c790a039a7dbdf67b34b840ac2ddc4dce93 100644 (file)
@@ -17,16 +17,16 @@ nv20_blend_state_create(struct pipe_context *pipe,
 
        cb = MALLOC(sizeof(struct nv20_blend_state));
 
-       cb->b_enable = cso->blend_enable ? 1 : 0;
-       cb->b_srcfunc = ((nvgl_blend_func(cso->alpha_src_factor)<<16) |
-                        (nvgl_blend_func(cso->rgb_src_factor)));
-       cb->b_dstfunc = ((nvgl_blend_func(cso->alpha_dst_factor)<<16) |
-                        (nvgl_blend_func(cso->rgb_dst_factor)));
-
-       cb->c_mask = (((cso->colormask & PIPE_MASK_A) ? (0x01<<24) : 0) |
-                     ((cso->colormask & PIPE_MASK_R) ? (0x01<<16) : 0) |
-                     ((cso->colormask & PIPE_MASK_G) ? (0x01<< 8) : 0) |
-                     ((cso->colormask & PIPE_MASK_B) ? (0x01<< 0) : 0));
+       cb->b_enable = cso->rt[0].blend_enable ? 1 : 0;
+       cb->b_srcfunc = ((nvgl_blend_func(cso->rt[0].alpha_src_factor)<<16) |
+                        (nvgl_blend_func(cso->rt[0].rgb_src_factor)));
+       cb->b_dstfunc = ((nvgl_blend_func(cso->rt[0].alpha_dst_factor)<<16) |
+                        (nvgl_blend_func(cso->rt[0].rgb_dst_factor)));
+
+       cb->c_mask = (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01<<24) : 0) |
+                     ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01<<16) : 0) |
+                     ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01<< 8) : 0) |
+                     ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01<< 0) : 0));
 
        cb->d_enable = cso->dither ? 1 : 0;
 
index 9ed48178dc2b6d12bf26c8f41abcb6b64e1a4325..8f8f3ea1a9f8403abac3b7b128914f6ca0c20aed 100644 (file)
@@ -67,6 +67,10 @@ nv30_screen_get_param(struct pipe_screen *pscreen, int param)
        case NOUVEAU_CAP_HW_VTXBUF:
        case NOUVEAU_CAP_HW_IDXBUF:
                return 1;
+       case PIPE_CAP_INDEP_BLEND_ENABLE:
+               return 0;
+       case PIPE_CAP_INDEP_BLEND_FUNC:
+               return 0;
        default:
                NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
                return 0;
index 065c927a10dd4a3d5c750cdbbbd5741a8cd34a86..1f4c964270583470f124fd1acff826d8c508b32c 100644 (file)
@@ -16,27 +16,27 @@ nv30_blend_state_create(struct pipe_context *pipe,
        struct nv30_blend_state *bso = CALLOC(1, sizeof(*bso));
        struct nouveau_stateobj *so = so_new(5, 8, 0);
 
-       if (cso->blend_enable) {
+       if (cso->rt[0].blend_enable) {
                so_method(so, rankine, NV34TCL_BLEND_FUNC_ENABLE, 3);
                so_data  (so, 1);
-               so_data  (so, (nvgl_blend_func(cso->alpha_src_factor) << 16) |
-                              nvgl_blend_func(cso->rgb_src_factor));
-               so_data  (so, nvgl_blend_func(cso->alpha_dst_factor) << 16 |
-                             nvgl_blend_func(cso->rgb_dst_factor));
+               so_data  (so, (nvgl_blend_func(cso->rt[0].alpha_src_factor) << 16) |
+                              nvgl_blend_func(cso->rt[0].rgb_src_factor));
+               so_data  (so, nvgl_blend_func(cso->rt[0].alpha_dst_factor) << 16 |
+                             nvgl_blend_func(cso->rt[0].rgb_dst_factor));
                /* FIXME: Gallium assumes GL_EXT_blend_func_separate.
                   It is not the case for NV30 */
                so_method(so, rankine, NV34TCL_BLEND_EQUATION, 1);
-               so_data  (so, nvgl_blend_eqn(cso->rgb_func));
+               so_data  (so, nvgl_blend_eqn(cso->rt[0].rgb_func));
        } else {
                so_method(so, rankine, NV34TCL_BLEND_FUNC_ENABLE, 1);
                so_data  (so, 0);
        }
 
        so_method(so, rankine, NV34TCL_COLOR_MASK, 1);
-       so_data  (so, (((cso->colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) |
-                      ((cso->colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) |
-                      ((cso->colormask & PIPE_MASK_G) ? (0x01 <<  8) : 0) |
-                      ((cso->colormask & PIPE_MASK_B) ? (0x01 <<  0) : 0)));
+       so_data  (so, (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) |
+                      ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) |
+                      ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01 <<  8) : 0) |
+                      ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01 <<  0) : 0)));
 
        if (cso->logicop_enable) {
                so_method(so, rankine, NV34TCL_COLOR_LOGIC_OP_ENABLE, 2);
index 9e55e5a089c6eb46790c44b9e7902bc593fa1188..4eab5daa80c68143d0aeeeedeb30e2cc6f7ba70b 100644 (file)
@@ -52,6 +52,10 @@ nv40_screen_get_param(struct pipe_screen *pscreen, int param)
                if (screen->curie->grclass == NV40TCL)
                        return 1;
                return 0;
+       case PIPE_CAP_INDEP_BLEND_ENABLE:
+               return 0;
+       case PIPE_CAP_INDEP_BLEND_FUNC:
+               return 0;
        default:
                NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
                return 0;
index 7d990f7d567b154e08e93821d6c1eb576ad13e86..7a63fba18c5bfafaa138ea3f084cdd6ec3f9140e 100644 (file)
@@ -18,26 +18,26 @@ nv40_blend_state_create(struct pipe_context *pipe,
        struct nv40_blend_state *bso = CALLOC(1, sizeof(*bso));
        struct nouveau_stateobj *so = so_new(5, 8, 0);
 
-       if (cso->blend_enable) {
+       if (cso->rt[0].blend_enable) {
                so_method(so, curie, NV40TCL_BLEND_ENABLE, 3);
                so_data  (so, 1);
-               so_data  (so, (nvgl_blend_func(cso->alpha_src_factor) << 16) |
-                              nvgl_blend_func(cso->rgb_src_factor));
-               so_data  (so, nvgl_blend_func(cso->alpha_dst_factor) << 16 |
-                             nvgl_blend_func(cso->rgb_dst_factor));
+               so_data  (so, (nvgl_blend_func(cso->rt[0].alpha_src_factor) << 16) |
+                              nvgl_blend_func(cso->rt[0].rgb_src_factor));
+               so_data  (so, nvgl_blend_func(cso->rt[0].alpha_dst_factor) << 16 |
+                             nvgl_blend_func(cso->rt[0].rgb_dst_factor));
                so_method(so, curie, NV40TCL_BLEND_EQUATION, 1);
-               so_data  (so, nvgl_blend_eqn(cso->alpha_func) << 16 |
-                             nvgl_blend_eqn(cso->rgb_func));
+               so_data  (so, nvgl_blend_eqn(cso->rt[0].alpha_func) << 16 |
+                             nvgl_blend_eqn(cso->rt[0].rgb_func));
        } else {
                so_method(so, curie, NV40TCL_BLEND_ENABLE, 1);
                so_data  (so, 0);
        }
 
        so_method(so, curie, NV40TCL_COLOR_MASK, 1);
-       so_data  (so, (((cso->colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) |
-                      ((cso->colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) |
-                      ((cso->colormask & PIPE_MASK_G) ? (0x01 <<  8) : 0) |
-                      ((cso->colormask & PIPE_MASK_B) ? (0x01 <<  0) : 0)));
+       so_data  (so, (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) |
+                      ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) |
+                      ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01 <<  8) : 0) |
+                      ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01 <<  0) : 0)));
 
        if (cso->logicop_enable) {
                so_method(so, curie, NV40TCL_COLOR_LOGIC_OP_ENABLE, 2);
index 9d58f3c9651552a7cf5f7a8f335527a355a8f26e..6af9700c1afded245135c9b6929514a5f1541fbb 100644 (file)
@@ -135,6 +135,10 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param)
                return 1;
        case NOUVEAU_CAP_HW_IDXBUF:
                return 0;
+       case PIPE_CAP_INDEP_BLEND_ENABLE:
+               return 1;
+       case PIPE_CAP_INDEP_BLEND_FUNC:
+               return 0;
        default:
                NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
                return 0;
index 6ab33be663dc47b3a3717f4796619bbc1dedb5c4..da8dc933b030f03f30b07144744ae12cf9ba83ba 100644 (file)
 
 #include "nouveau/nouveau_stateobj.h"
 
+static INLINE uint32_t
+nv50_colormask(unsigned mask)
+{
+       uint32_t cmask = 0;
+
+       if (mask & PIPE_MASK_R)
+               cmask |= 0x0001;
+       if (mask & PIPE_MASK_G)
+               cmask |= 0x0010;
+       if (mask & PIPE_MASK_B)
+               cmask |= 0x0100;
+       if (mask & PIPE_MASK_A)
+               cmask |= 0x1000;
+
+       return cmask;
+}
+
 static void *
 nv50_blend_state_create(struct pipe_context *pipe,
                        const struct pipe_blend_state *cso)
@@ -38,28 +55,37 @@ nv50_blend_state_create(struct pipe_context *pipe,
        struct nouveau_stateobj *so = so_new(5, 24, 0);
        struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla;
        struct nv50_blend_stateobj *bso = CALLOC_STRUCT(nv50_blend_stateobj);
-       unsigned cmask = 0, i;
+       unsigned i, blend_enabled = 0;
 
        /*XXX ignored:
         *      - dither
         */
 
-       if (cso->blend_enable == 0) {
-               so_method(so, tesla, NV50TCL_BLEND_ENABLE(0), 8);
+       so_method(so, tesla, NV50TCL_BLEND_ENABLE(0), 8);
+       if (cso->independent_blend_enable) {
+               for (i = 0; i < 8; ++i) {
+                       so_data(so, cso->rt[i].blend_enable);
+                       if (cso->rt[i].blend_enable)
+                               blend_enabled = 1;
+               }
+       } else
+       if (cso->rt[0].blend_enable) {
+               blend_enabled = 1;
                for (i = 0; i < 8; i++)
-                       so_data(so, 0);
+                       so_data(so, 1);
        } else {
-               so_method(so, tesla, NV50TCL_BLEND_ENABLE(0), 8);
                for (i = 0; i < 8; i++)
-                       so_data(so, 1);
+                       so_data(so, 0);
+       }
+       if (blend_enabled) {
                so_method(so, tesla, NV50TCL_BLEND_EQUATION_RGB, 5);
-               so_data  (so, nvgl_blend_eqn(cso->rgb_func));
-               so_data  (so, 0x4000 | nvgl_blend_func(cso->rgb_src_factor));
-               so_data  (so, 0x4000 | nvgl_blend_func(cso->rgb_dst_factor));
-               so_data  (so, nvgl_blend_eqn(cso->alpha_func));
-               so_data  (so, 0x4000 | nvgl_blend_func(cso->alpha_src_factor));
+               so_data  (so, nvgl_blend_eqn(cso->rt[0].rgb_func));
+               so_data  (so, 0x4000 | nvgl_blend_func(cso->rt[0].rgb_src_factor));
+               so_data  (so, 0x4000 | nvgl_blend_func(cso->rt[0].rgb_dst_factor));
+               so_data  (so, nvgl_blend_eqn(cso->rt[0].alpha_func));
+               so_data  (so, 0x4000 | nvgl_blend_func(cso->rt[0].alpha_src_factor));
                so_method(so, tesla, NV50TCL_BLEND_FUNC_DST_ALPHA, 1);
-               so_data  (so, 0x4000 | nvgl_blend_func(cso->alpha_dst_factor));
+               so_data  (so, 0x4000 | nvgl_blend_func(cso->rt[0].alpha_dst_factor));
        }
 
        if (cso->logicop_enable == 0 ) {
@@ -71,17 +97,15 @@ nv50_blend_state_create(struct pipe_context *pipe,
                so_data  (so, nvgl_logicop_func(cso->logicop_func));
        }
 
-       if (cso->colormask & PIPE_MASK_R)
-               cmask |= (1 << 0);
-       if (cso->colormask & PIPE_MASK_G)
-               cmask |= (1 << 4);
-       if (cso->colormask & PIPE_MASK_B)
-               cmask |= (1 << 8);
-       if (cso->colormask & PIPE_MASK_A)
-               cmask |= (1 << 12);
        so_method(so, tesla, NV50TCL_COLOR_MASK(0), 8);
-       for (i = 0; i < 8; i++)
-               so_data(so, cmask);
+       if (cso->independent_blend_enable)
+               for (i = 0; i < 8; ++i)
+                       so_data(so, nv50_colormask(cso->rt[i].colormask));
+       else {
+               uint32_t cmask = nv50_colormask(cso->rt[0].colormask);
+               for (i = 0; i < 8; i++)
+                       so_data(so, cmask);
+       }
 
        bso->pipe = *cso;
        so_ref(so, &bso->so);
index a4a0e5281593f27130d8b0e2c9866d75eefaf898..b8fbf03d3a9792f8ff957ac5978bfea22f961aa9 100644 (file)
@@ -149,6 +149,9 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
             } else {
                 return 0;
             }
+        case PIPE_CAP_INDEP_BLEND_ENABLE:
+        case PIPE_CAP_INDEP_BLEND_FUNC:
+            return 0;
         default:
             debug_printf("r300: Implementation error: Bad param %d\n",
                 param);
index 1b920563a5f4ff33534be74abc2ef180a757cf57..3cdcf94274c041c89110fcf7be67a41137e3039f 100644 (file)
@@ -163,15 +163,15 @@ static void* r300_create_blend_state(struct pipe_context* pipe,
 {
     struct r300_blend_state* blend = CALLOC_STRUCT(r300_blend_state);
 
-    if (state->blend_enable)
+    if (state->rt[0].blend_enable)
     {
-        unsigned eqRGB = state->rgb_func;
-        unsigned srcRGB = state->rgb_src_factor;
-        unsigned dstRGB = state->rgb_dst_factor;
+        unsigned eqRGB = state->rt[0].rgb_func;
+        unsigned srcRGB = state->rt[0].rgb_src_factor;
+        unsigned dstRGB = state->rt[0].rgb_dst_factor;
 
-        unsigned eqA = state->alpha_func;
-        unsigned srcA = state->alpha_src_factor;
-        unsigned dstA = state->alpha_dst_factor;
+        unsigned eqA = state->rt[0].alpha_func;
+        unsigned srcA = state->rt[0].alpha_src_factor;
+        unsigned dstA = state->rt[0].alpha_dst_factor;
 
         /* despite the name, ALPHA_BLEND_ENABLE has nothing to do with alpha,
          * this is just the crappy D3D naming */
@@ -289,16 +289,16 @@ static void* r300_create_blend_state(struct pipe_context* pipe,
     }
 
     /* Color Channel Mask */
-    if (state->colormask & PIPE_MASK_R) {
+    if (state->rt[0].colormask & PIPE_MASK_R) {
         blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_RED_MASK0;
     }
-    if (state->colormask & PIPE_MASK_G) {
+    if (state->rt[0].colormask & PIPE_MASK_G) {
         blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_GREEN_MASK0;
     }
-    if (state->colormask & PIPE_MASK_B) {
+    if (state->rt[0].colormask & PIPE_MASK_B) {
         blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_BLUE_MASK0;
     }
-    if (state->colormask & PIPE_MASK_A) {
+    if (state->rt[0].colormask & PIPE_MASK_A) {
         blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK0;
     }
 
index 3b8c2d5789c8eb87d30e28c0dd2362d0f9e366ef..d65307b7f60498c0ddd844c958177968b35c83c8 100644 (file)
@@ -223,7 +223,8 @@ logicop_quad(struct quad_stage *qs,
 static void
 blend_quad(struct quad_stage *qs, 
            float (*quadColor)[4],
-           float (*dest)[4])
+           float (*dest)[4],
+           unsigned cbuf)
 {
    static const float zero[4] = { 0, 0, 0, 0 };
    static const float one[4] = { 1, 1, 1, 1 };
@@ -233,7 +234,7 @@ blend_quad(struct quad_stage *qs,
    /*
     * Compute src/first term RGB
     */
-   switch (softpipe->blend->rgb_src_factor) {
+   switch (softpipe->blend->rt[cbuf].rgb_src_factor) {
    case PIPE_BLENDFACTOR_ONE:
       VEC4_COPY(source[0], quadColor[0]); /* R */
       VEC4_COPY(source[1], quadColor[1]); /* G */
@@ -383,7 +384,7 @@ blend_quad(struct quad_stage *qs,
    /*
     * Compute src/first term A
     */
-   switch (softpipe->blend->alpha_src_factor) {
+   switch (softpipe->blend->rt[cbuf].alpha_src_factor) {
    case PIPE_BLENDFACTOR_ONE:
       VEC4_COPY(source[3], quadColor[3]); /* A */
       break;
@@ -452,7 +453,7 @@ blend_quad(struct quad_stage *qs,
    /*
     * Compute dest/second term RGB
     */
-   switch (softpipe->blend->rgb_dst_factor) {
+   switch (softpipe->blend->rt[cbuf].rgb_dst_factor) {
    case PIPE_BLENDFACTOR_ONE:
       /* dest = dest * 1   NO-OP, leave dest as-is */
       break;
@@ -592,7 +593,7 @@ blend_quad(struct quad_stage *qs,
    /*
     * Compute dest/second term A
     */
-   switch (softpipe->blend->alpha_dst_factor) {
+   switch (softpipe->blend->rt[cbuf].alpha_dst_factor) {
    case PIPE_BLENDFACTOR_ONE:
       /* dest = dest * 1   NO-OP, leave dest as-is */
       break;
@@ -655,7 +656,7 @@ blend_quad(struct quad_stage *qs,
    /*
     * Combine RGB terms
     */
-   switch (softpipe->blend->rgb_func) {
+   switch (softpipe->blend->rt[cbuf].rgb_func) {
    case PIPE_BLEND_ADD:
       VEC4_ADD_SAT(quadColor[0], source[0], dest[0]); /* R */
       VEC4_ADD_SAT(quadColor[1], source[1], dest[1]); /* G */
@@ -688,7 +689,7 @@ blend_quad(struct quad_stage *qs,
    /*
     * Combine A terms
     */
-   switch (softpipe->blend->alpha_func) {
+   switch (softpipe->blend->rt[cbuf].alpha_func) {
    case PIPE_BLEND_ADD:
       VEC4_ADD_SAT(quadColor[3], source[3], dest[3]); /* A */
       break;
@@ -710,26 +711,24 @@ blend_quad(struct quad_stage *qs,
 }
 
 static void
-colormask_quad(struct quad_stage *qs,
+colormask_quad(unsigned colormask,
                float (*quadColor)[4],
                float (*dest)[4])
 {
-   struct softpipe_context *softpipe = qs->softpipe;
-
    /* R */
-   if (!(softpipe->blend->colormask & PIPE_MASK_R))
+   if (!(colormask & PIPE_MASK_R))
       COPY_4V(quadColor[0], dest[0]);
 
    /* G */
-   if (!(softpipe->blend->colormask & PIPE_MASK_G))
+   if (!(colormask & PIPE_MASK_G))
       COPY_4V(quadColor[1], dest[1]);
 
    /* B */
-   if (!(softpipe->blend->colormask & PIPE_MASK_B))
+   if (!(colormask & PIPE_MASK_B))
       COPY_4V(quadColor[2], dest[2]);
 
    /* A */
-   if (!(softpipe->blend->colormask & PIPE_MASK_A))
+   if (!(colormask & PIPE_MASK_A))
       COPY_4V(quadColor[3], dest[3]);
 }
 
@@ -772,12 +771,12 @@ blend_fallback(struct quad_stage *qs,
          if (blend->logicop_enable) {
             logicop_quad( qs, quadColor, dest );
          }
-         else if (blend->blend_enable) {
-            blend_quad( qs, quadColor, dest );
+         else if (blend->rt[cbuf].blend_enable) {
+            blend_quad( qs, quadColor, dest, cbuf );
          }
 
-         if (blend->colormask != 0xf)
-            colormask_quad( qs, quadColor, dest );
+         if (blend->rt[cbuf].colormask != 0xf)
+            colormask_quad( blend->rt[cbuf].colormask, quadColor, dest);
    
          /* Output color values
           */
@@ -953,23 +952,23 @@ choose_blend_quad(struct quad_stage *qs,
       qs->run = blend_noop;
    }
    else if (!softpipe->blend->logicop_enable &&
-            softpipe->blend->colormask == 0xf &&
+            softpipe->blend->rt[0].colormask == 0xf &&
             softpipe->framebuffer.nr_cbufs == 1)
    {
-      if (!blend->blend_enable) {
+      if (!blend->rt[0].blend_enable) {
          qs->run = single_output_color;
       }
-      else if (blend->rgb_src_factor == blend->alpha_src_factor &&
-               blend->rgb_dst_factor == blend->alpha_dst_factor &&
-               blend->rgb_func == blend->alpha_func)
+      else if (blend->rt[0].rgb_src_factor == blend->rt[0].alpha_src_factor &&
+               blend->rt[0].rgb_dst_factor == blend->rt[0].alpha_dst_factor &&
+               blend->rt[0].rgb_func == blend->rt[0].alpha_func)
       {
-         if (blend->alpha_func == PIPE_BLEND_ADD) {
-            if (blend->rgb_src_factor == PIPE_BLENDFACTOR_ONE &&
-                blend->rgb_dst_factor == PIPE_BLENDFACTOR_ONE) {
+         if (blend->rt[0].alpha_func == PIPE_BLEND_ADD) {
+            if (blend->rt[0].rgb_src_factor == PIPE_BLENDFACTOR_ONE &&
+                blend->rt[0].rgb_dst_factor == PIPE_BLENDFACTOR_ONE) {
                qs->run = blend_single_add_one_one;
             }
-            else if (blend->rgb_src_factor == PIPE_BLENDFACTOR_SRC_ALPHA &&
-                blend->rgb_dst_factor == PIPE_BLENDFACTOR_INV_SRC_ALPHA)
+            else if (blend->rt[0].rgb_src_factor == PIPE_BLENDFACTOR_SRC_ALPHA &&
+                blend->rt[0].rgb_dst_factor == PIPE_BLENDFACTOR_INV_SRC_ALPHA)
                qs->run = blend_single_add_src_alpha_inv_src_alpha;
 
          }
index 69f40dc7b64cdf8b50808a01d80cbb20786522db..b2841f410314c9685d852c48a658bb0b05d1aa33 100644 (file)
@@ -95,6 +95,10 @@ softpipe_get_param(struct pipe_screen *screen, int param)
       return PIPE_MAX_CONSTANT_BUFFERS;
    case PIPE_CAP_MAX_CONST_BUFFER_SIZE:
       return 4096 * 4 * sizeof(float);
+   case PIPE_CAP_INDEP_BLEND_ENABLE:
+      return 1;
+   case PIPE_CAP_INDEP_BLEND_FUNC:
+      return 1;
    default:
       return 0;
    }
index cae2d3efc589317c42e5bde7c69e6279a8803b21..d0723ebe9e05b945bd7acf31b7eab12b8a0b3ade 100644 (file)
@@ -185,17 +185,18 @@ init_pipe_state(struct sp_mpeg12_context *ctx)
    ctx->rast = ctx->pipe->create_rasterizer_state(ctx->pipe, &rast);
    ctx->pipe->bind_rasterizer_state(ctx->pipe, ctx->rast);
 
-   blend.blend_enable = 0;
-   blend.rgb_func = PIPE_BLEND_ADD;
-   blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
-   blend.rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
-   blend.alpha_func = PIPE_BLEND_ADD;
-   blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-   blend.alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
+   blend.independent_blend_enable = 0;
+   blend.rt[0].blend_enable = 0;
+   blend.rt[0].rgb_func = PIPE_BLEND_ADD;
+   blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].alpha_func = PIPE_BLEND_ADD;
+   blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
    blend.logicop_enable = 0;
    blend.logicop_func = PIPE_LOGICOP_CLEAR;
    /* Needed to allow color writes to FB, even if blending disabled */
-   blend.colormask = PIPE_MASK_RGBA;
+   blend.rt[0].colormask = PIPE_MASK_RGBA;
    blend.dither = 0;
    ctx->blend = ctx->pipe->create_blend_state(ctx->pipe, &blend);
    ctx->pipe->bind_blend_state(ctx->pipe, ctx->blend);
index 3ad3f97816c1f0aa7b0e6d5b0493bdd6490619ee..9df5485f462e93609dce23b033726aa7fad8b0fe 100644 (file)
@@ -181,15 +181,15 @@ svga_create_blend_state(struct pipe_context *pipe,
          }
       }
       else {
-         blend->rt[i].blend_enable   = templ->blend_enable;
+         blend->rt[i].blend_enable   = templ->rt[0].blend_enable;
 
-         if (templ->blend_enable) {
-            blend->rt[i].srcblend       = svga_translate_blend_factor(templ->rgb_src_factor);
-            blend->rt[i].dstblend       = svga_translate_blend_factor(templ->rgb_dst_factor);
-            blend->rt[i].blendeq        = svga_translate_blend_func(templ->rgb_func);
-            blend->rt[i].srcblend_alpha = svga_translate_blend_factor(templ->alpha_src_factor);
-            blend->rt[i].dstblend_alpha = svga_translate_blend_factor(templ->alpha_dst_factor);
-            blend->rt[i].blendeq_alpha  = svga_translate_blend_func(templ->alpha_func);
+         if (templ->rt[0].blend_enable) {
+            blend->rt[i].srcblend       = svga_translate_blend_factor(templ->rt[0].rgb_src_factor);
+            blend->rt[i].dstblend       = svga_translate_blend_factor(templ->rt[0].rgb_dst_factor);
+            blend->rt[i].blendeq        = svga_translate_blend_func(templ->rt[0].rgb_func);
+            blend->rt[i].srcblend_alpha = svga_translate_blend_factor(templ->rt[0].alpha_src_factor);
+            blend->rt[i].dstblend_alpha = svga_translate_blend_factor(templ->rt[0].alpha_dst_factor);
+            blend->rt[i].blendeq_alpha  = svga_translate_blend_func(templ->rt[0].alpha_func);
 
             if (blend->rt[i].srcblend_alpha != blend->rt[i].srcblend ||
                 blend->rt[i].dstblend_alpha != blend->rt[i].dstblend ||
@@ -200,7 +200,7 @@ svga_create_blend_state(struct pipe_context *pipe,
          }
       }
 
-      blend->rt[i].writemask = templ->colormask;
+      blend->rt[i].writemask = templ->rt[0].colormask;
    }
 
    return blend;
index 32f61f8c9445b100c3d6838b95040d7b2bb4b464..dbca5de0a5290989787dfca83d074dc3639756c9 100644 (file)
@@ -323,9 +323,23 @@ void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_
    trace_dump_struct_end();
 }
 
+static void trace_dump_rt_blend_state(const struct pipe_rt_blend_state *state)
+{
+   trace_dump_member(uint, state, rgb_func);
+   trace_dump_member(uint, state, rgb_src_factor);
+   trace_dump_member(uint, state, rgb_dst_factor);
+
+   trace_dump_member(uint, state, alpha_func);
+   trace_dump_member(uint, state, alpha_src_factor);
+   trace_dump_member(uint, state, alpha_dst_factor);
+
+   trace_dump_member(uint, state, colormask);
+
+}
 
 void trace_dump_blend_state(const struct pipe_blend_state *state)
 {
+   unsigned valid_entries = 1;
    if (!trace_dumping_enabled_locked())
       return;
 
@@ -336,21 +350,17 @@ void trace_dump_blend_state(const struct pipe_blend_state *state)
 
    trace_dump_struct_begin("pipe_blend_state");
 
-   trace_dump_member(bool, state, blend_enable);
-
-   trace_dump_member(uint, state, rgb_func);
-   trace_dump_member(uint, state, rgb_src_factor);
-   trace_dump_member(uint, state, rgb_dst_factor);
-
-   trace_dump_member(uint, state, alpha_func);
-   trace_dump_member(uint, state, alpha_src_factor);
-   trace_dump_member(uint, state, alpha_dst_factor);
+   trace_dump_member(bool, state, dither);
 
    trace_dump_member(bool, state, logicop_enable);
    trace_dump_member(uint, state, logicop_func);
 
-   trace_dump_member(uint, state, colormask);
-   trace_dump_member(bool, state, dither);
+   trace_dump_member(bool, state, independent_blend_enable);
+
+   if (state->independent_blend_enable)
+      valid_entries = PIPE_MAX_COLOR_BUFS;
+
+   trace_dump_struct_array(rt_blend_state, state->rt, valid_entries);
 
    trace_dump_struct_end();
 }
index 353d79a6a7ebb37602752ef37e705f0028823eac..b28441dca9c24f05e5a64e02123370ad83d68248 100644 (file)
@@ -377,7 +377,7 @@ enum pipe_transfer_usage {
 #define PIPE_CAP_NPOT_TEXTURES           2
 #define PIPE_CAP_TWO_SIDED_STENCIL       3
 #define PIPE_CAP_GLSL                    4  /* XXX need something better */
-#define PIPE_CAP_S3TC                    5  /* XXX: deprecated; cap determined via supported sampler formats */
+#define PIPE_CAP_DUAL_SOURCE_BLEND       5  
 #define PIPE_CAP_ANISOTROPIC_FILTER      6
 #define PIPE_CAP_POINT_SPRITE            7
 #define PIPE_CAP_MAX_RENDER_TARGETS      8
@@ -407,6 +407,8 @@ enum pipe_transfer_usage {
                                                  and fragment shaders combined */
 #define PIPE_CAP_MAX_CONST_BUFFERS       32
 #define PIPE_CAP_MAX_CONST_BUFFER_SIZE   33  /*< In bytes */
+#define PIPE_CAP_INDEP_BLEND_ENABLE      34  /*< blend enables and write masks per rendertarget */
+#define PIPE_CAP_INDEP_BLEND_FUNC        35  /*< different blend funcs per rendertarget */
 
 
 /**
index b250ed9440455f1d5483388c2d3266939a3a7380..03cd74efed3a8d98d3a5f4b60fde6ae79eede2e1 100644 (file)
@@ -217,7 +217,7 @@ struct pipe_depth_stencil_alpha_state
 };
 
 
-struct pipe_blend_state
+struct pipe_rt_blend_state
 {
    unsigned blend_enable:1;
 
@@ -229,11 +229,16 @@ struct pipe_blend_state
    unsigned alpha_src_factor:5;  /**< PIPE_BLENDFACTOR_x */
    unsigned alpha_dst_factor:5;  /**< PIPE_BLENDFACTOR_x */
 
+   unsigned colormask:4;         /**< bitmask of PIPE_MASK_R/G/B/A */
+};
+
+struct pipe_blend_state
+{
+   unsigned independent_blend_enable:1;
    unsigned logicop_enable:1;
    unsigned logicop_func:4;      /**< PIPE_LOGICOP_x */
-
-   unsigned colormask:4;         /**< bitmask of PIPE_MASK_R/G/B/A */
    unsigned dither:1;
+   struct pipe_rt_blend_state rt[PIPE_MAX_COLOR_BUFS];
 };
 
 
@@ -269,7 +274,7 @@ struct pipe_sampler_state
    unsigned compare_mode:1;      /**< PIPE_TEX_COMPARE_x */
    unsigned compare_func:3;      /**< PIPE_FUNC_x */
    unsigned normalized_coords:1; /**< Are coords normalized to [0,1]? */
-   unsigned prefilter:4;         /**< Wierd sampling state exposed by some api's */
+   unsigned prefilter:4;         /**< Cylindrical texcoord wrap, per coord, exposed by some api's */
    float lod_bias;               /**< LOD/lambda bias */
    float min_lod, max_lod;       /**< LOD clamp range, after bias */
    float border_color[4];
index 8b014a2a8b8bf897b5939febdfb72114a3ca664e..1259813a4129273fd834a7b781ca296c3c621424 100644 (file)
@@ -50,6 +50,7 @@
 #define need_GL_EXT_blend_func_separate
 #define need_GL_EXT_blend_minmax
 #define need_GL_EXT_cull_vertex
+#define need_GL_EXT_draw_buffers2
 #define need_GL_EXT_fog_coord
 #define need_GL_EXT_framebuffer_object
 #define need_GL_EXT_multi_draw_arrays
@@ -98,6 +99,7 @@ static const struct dri_extension card_extensions[] = {
    {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions},
    {"GL_EXT_blend_subtract", NULL},
    {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions},
+   {"GL_EXT_draw_buffers2", GL_EXT_draw_buffers2_functions},
    {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions},
    {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions},
    {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions},
@@ -130,6 +132,9 @@ dri_init_extensions(struct dri_context *ctx)
    /* The card_extensions list should be pruned according to the
     * capabilities of the pipe_screen. This is actually something
     * that can/should be done inside st_create_context().
+    * XXX Not pruning is very bogus. Always all these extensions above
+    * will be advertized, regardless what st_init_extensions
+    * (which depends on the pipe cap bits) does.
     */
    driInitExtensions(ctx->st->ctx, card_extensions, GL_TRUE);
 }
index a07cf557f2f14f4d4d2b849da5315ca9a98955c0..cd68abac9a163ab4c7d7d565b57a33f587c41afe 100644 (file)
@@ -72,11 +72,11 @@ def test(dev):
 
     # disabled blending/masking
     blend = Blend()
-    blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE
-    blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE
-    blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
-    blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
-    blend.colormask = PIPE_MASK_RGBA
+    blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE
+    blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE
+    blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
+    blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
+    blend.rt[0].colormask = PIPE_MASK_RGBA
     ctx.set_blend(blend)
 
     # depth/stencil/alpha
index e5e168bdc8df06c2a39ca5791fde789d0f65b9f6..f0b5e3dc9842d597de7c79640bbc1cdd9806bc8e 100644 (file)
@@ -72,11 +72,11 @@ def test(dev):
 
     # disabled blending/masking
     blend = Blend()
-    blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE
-    blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE
-    blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
-    blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
-    blend.colormask = PIPE_MASK_RGBA
+    blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE
+    blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE
+    blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
+    blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
+    blend.rt[0].colormask = PIPE_MASK_RGBA
     ctx.set_blend(blend)
 
     # depth/stencil/alpha
index d144af2447d1d8c0955f9b8acd5ba0ee1d723694..e41125f6f9940d24be280300eae613d2795fbdd0 100644 (file)
@@ -180,11 +180,11 @@ st_context_create(struct st_device *st_dev)
    {
       struct pipe_blend_state blend;
       memset(&blend, 0, sizeof(blend));
-      blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
-      blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-      blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
-      blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
-      blend.colormask = PIPE_MASK_RGBA;
+      blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+      blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+      blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.rt[0].colormask = PIPE_MASK_RGBA;
       cso_set_blend(st_ctx->cso, &blend);
    }
 
index 9e668d2ac69c75045f94c9fd6e0b2ddcbeb645e0..41dd69d2542575a6d2324974fc88734bfa718ca3 100644 (file)
@@ -51,11 +51,11 @@ def test(dev, name):
 
     # disabled blending/masking
     blend = Blend()
-    blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE
-    blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE
-    blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
-    blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
-    blend.colormask = PIPE_MASK_RGBA
+    blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE
+    blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE
+    blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
+    blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
+    blend.rt[0].colormask = PIPE_MASK_RGBA
     ctx.set_blend(blend)
 
     # depth/stencil/alpha
index 96503778ae88a401e5df1ef806fd94ce4263f0a2..2c44f872e1de32ec3844152e3b11cc284fce0826 100644 (file)
@@ -52,11 +52,11 @@ def test(dev, name):
 
     # disabled blending/masking
     blend = Blend()
-    blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE
-    blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE
-    blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
-    blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
-    blend.colormask = PIPE_MASK_RGBA
+    blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE
+    blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE
+    blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
+    blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
+    blend.rt[0].colormask = PIPE_MASK_RGBA
     ctx.set_blend(blend)
 
     # depth/stencil/alpha
index 79287f2caceaa115907cd1b9d7a588ea71d13598..0fac1ea5ef303c9b937ec951123e3e6b2b50b2e0 100755 (executable)
@@ -115,11 +115,11 @@ class TextureTest(TestCase):
     
         # disabled blending/masking
         blend = Blend()
-        blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE
-        blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE
-        blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
-        blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
-        blend.colormask = PIPE_MASK_RGBA
+        blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE
+        blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE
+        blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
+        blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
+        blend.rt[0].colormask = PIPE_MASK_RGBA
         ctx.set_blend(blend)
     
         # no-op depth/stencil/alpha
index 520961c8051ef9e98f002c9312827dbfe1bab747..db32b537a1733f0d79c99f81045376be639a95a7 100755 (executable)
@@ -140,11 +140,11 @@ class TextureColorSampleTest(TestCase):
     
         # disabled blending/masking
         blend = Blend()
-        blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE
-        blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE
-        blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
-        blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
-        blend.colormask = PIPE_MASK_RGBA
+        blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE
+        blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE
+        blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
+        blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
+        blend.rt[0].colormask = PIPE_MASK_RGBA
         ctx.set_blend(blend)
     
         # no-op depth/stencil/alpha
@@ -327,11 +327,11 @@ class TextureDepthSampleTest(TestCase):
     
         # disabled blending/masking
         blend = Blend()
-        blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE
-        blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE
-        blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
-        blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
-        blend.colormask = PIPE_MASK_RGBA
+        blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE
+        blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE
+        blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
+        blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
+        blend.rt[0].colormask = PIPE_MASK_RGBA
         ctx.set_blend(blend)
     
         # depth/stencil/alpha
index 8f69ee0109993815bdb74f366ffdd43c9d71525a..cf4a11bb142ce0ef349600767f136c0c7a9ec8de 100644 (file)
@@ -127,19 +127,19 @@ static void setup_blend()
    struct vg_context *ctx = vg_current_context();
    struct pipe_blend_state blend;
    memset(&blend, 0, sizeof(blend));
-   blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
-   blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-   blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
-   blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+   blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+   blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
    if (ctx->state.vg.filter_channel_mask & VG_RED)
-      blend.colormask |= PIPE_MASK_R;
+      blend.rt[0].colormask |= PIPE_MASK_R;
    if (ctx->state.vg.filter_channel_mask & VG_GREEN)
-      blend.colormask |= PIPE_MASK_G;
+      blend.rt[0].colormask |= PIPE_MASK_G;
    if (ctx->state.vg.filter_channel_mask & VG_BLUE)
-      blend.colormask |= PIPE_MASK_B;
+      blend.rt[0].colormask |= PIPE_MASK_B;
    if (ctx->state.vg.filter_channel_mask & VG_ALPHA)
-      blend.colormask |= PIPE_MASK_A;
-   blend.blend_enable = 1;
+      blend.rt[0].colormask |= PIPE_MASK_A;
+   blend.rt[0].blend_enable = 0;
    cso_set_blend(ctx->cso_context, &blend);
 }
 
index 97cbe69205e0e2841965b60206f98fa7b29af749..e6070c7353b49988743096bb9acffd2940e02acc 100644 (file)
@@ -128,14 +128,11 @@ clear_with_quad(struct vg_context *st, float x0, float y0,
    {
       struct pipe_blend_state blend;
       memset(&blend, 0, sizeof(blend));
-      blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
-      blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-      blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
-      blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
-      blend.colormask |= PIPE_MASK_R;
-      blend.colormask |= PIPE_MASK_G;
-      blend.colormask |= PIPE_MASK_B;
-      blend.colormask |= PIPE_MASK_A;
+      blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+      blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+      blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.rt[0].colormask = PIPE_MASK_RGBA;
       cso_set_blend(st->cso_context, &blend);
    }
 
index 3e260e70736972e0205687f1e2b4b92bb262a316..ba8ecef1d2db6bf100a2edc0b937feb8a41c6989 100644 (file)
@@ -354,15 +354,12 @@ static void setup_mask_blend()
    struct pipe_blend_state blend;
 
    memset(&blend, 0, sizeof(struct pipe_blend_state));
-   blend.blend_enable = 1;
-   blend.colormask |= PIPE_MASK_R;
-   blend.colormask |= PIPE_MASK_G;
-   blend.colormask |= PIPE_MASK_B;
-   blend.colormask |= PIPE_MASK_A;
-   blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
-   blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-   blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
-   blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+   blend.rt[0].blend_enable = 0;
+   blend.rt[0].colormask = PIPE_MASK_RGBA;
+   blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+   blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
 
    cso_set_blend(ctx->cso_context, &blend);
 }
index d385ee567fa1673d81db2c9179accc8293df81aa..f5352ee84e52539a89db36207ac96b0a9cf950e2 100644 (file)
@@ -248,12 +248,12 @@ VGboolean polygon_is_closed(struct polygon *p)
 static void set_blend_for_fill(struct pipe_blend_state *blend)
 {
    memset(blend, 0, sizeof(struct pipe_blend_state));
-   blend->colormask = 0; /*disable colorwrites*/
+   blend->rt[0].colormask = 0; /*disable colorwrites*/
 
-   blend->rgb_src_factor = PIPE_BLENDFACTOR_ONE;
-   blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-   blend->rgb_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA;
-   blend->alpha_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA;
+   blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA;
+   blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA;
 }
 
 static void draw_polygon(struct vg_context *ctx,
index 64e3a7c5453573189e36202573ebb0bf9b992088..47e18dc1e23199a2b81992a01f6699b61ab8c968 100644 (file)
@@ -317,11 +317,11 @@ void renderer_copy_texture(struct renderer *ctx,
    {
       struct pipe_blend_state blend;
       memset(&blend, 0, sizeof(blend));
-      blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
-      blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-      blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
-      blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
-      blend.colormask = PIPE_MASK_RGBA;
+      blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+      blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+      blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.rt[0].colormask = PIPE_MASK_RGBA;
       cso_set_blend(ctx->cso, &blend);
    }
 
@@ -486,11 +486,11 @@ void renderer_copy_surface(struct renderer *ctx,
    {
       struct pipe_blend_state blend;
       memset(&blend, 0, sizeof(blend));
-      blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
-      blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-      blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
-      blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
-      blend.colormask = PIPE_MASK_RGBA;
+      blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+      blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+      blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.rt[0].colormask = PIPE_MASK_RGBA;
       cso_set_blend(ctx->cso, &blend);
    }
 
index c16ac036e3b78a53915fe51d50b6a55e51ed559e..64207d97bac620101e45a2d11bdf04e3db34f03f 100644 (file)
@@ -252,7 +252,7 @@ static void update_clip_state(struct vg_context *ctx)
       ctx->pipe->clear(ctx->pipe, PIPE_CLEAR_DEPTHSTENCIL, NULL, 1.0, 0);
 
       /* disable color writes */
-      blend->colormask = 0; /*disable colorwrites*/
+      blend->rt[0].colormask = 0; /*disable colorwrites*/
       cso_set_blend(ctx->cso_context, blend);
 
       /* enable scissoring */
@@ -286,7 +286,6 @@ static void update_clip_state(struct vg_context *ctx)
          renderer_draw_quad(ctx->renderer, minx, miny, maxx, maxy, 0.0f);
       }
 
-      blend->colormask = 1; /*enable colorwrites*/
       cso_restore_blend(ctx->cso_context);
       cso_restore_fragment_shader(ctx->cso_context);
 
@@ -301,57 +300,56 @@ void vg_validate_state(struct vg_context *ctx)
    if ((ctx->state.dirty & BLEND_DIRTY)) {
       struct pipe_blend_state *blend = &ctx->state.g3d.blend;
       memset(blend, 0, sizeof(struct pipe_blend_state));
-      blend->blend_enable = 1;
-      blend->colormask |= PIPE_MASK_R;
-      blend->colormask |= PIPE_MASK_G;
-      blend->colormask |= PIPE_MASK_B;
-      blend->colormask |= PIPE_MASK_A;
+      blend->rt[0].blend_enable = 1;
+      blend->rt[0].colormask = PIPE_MASK_RGBA;
 
       switch (ctx->state.vg.blend_mode) {
       case VG_BLEND_SRC:
-         blend->rgb_src_factor   = PIPE_BLENDFACTOR_ONE;
-         blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-         blend->rgb_dst_factor   = PIPE_BLENDFACTOR_ZERO;
-         blend->alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+         blend->rt[0].rgb_src_factor   = PIPE_BLENDFACTOR_ONE;
+         blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+         blend->rt[0].rgb_dst_factor   = PIPE_BLENDFACTOR_ZERO;
+         blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+         blend->rt[0].blend_enable = 0;
          break;
       case VG_BLEND_SRC_OVER:
-         blend->rgb_src_factor   = PIPE_BLENDFACTOR_SRC_ALPHA;
-         blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-         blend->rgb_dst_factor   = PIPE_BLENDFACTOR_INV_SRC_ALPHA;
-         blend->alpha_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA;
+         blend->rt[0].rgb_src_factor   = PIPE_BLENDFACTOR_SRC_ALPHA;
+         blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+         blend->rt[0].rgb_dst_factor   = PIPE_BLENDFACTOR_INV_SRC_ALPHA;
+         blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA;
          break;
       case VG_BLEND_DST_OVER:
-         blend->rgb_src_factor   = PIPE_BLENDFACTOR_INV_DST_ALPHA;
-         blend->alpha_src_factor = PIPE_BLENDFACTOR_INV_DST_ALPHA;
-         blend->rgb_dst_factor   = PIPE_BLENDFACTOR_DST_ALPHA;
-         blend->alpha_dst_factor = PIPE_BLENDFACTOR_DST_ALPHA;
+         blend->rt[0].rgb_src_factor   = PIPE_BLENDFACTOR_INV_DST_ALPHA;
+         blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_INV_DST_ALPHA;
+         blend->rt[0].rgb_dst_factor   = PIPE_BLENDFACTOR_DST_ALPHA;
+         blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_DST_ALPHA;
          break;
       case VG_BLEND_SRC_IN:
-         blend->rgb_src_factor   = PIPE_BLENDFACTOR_DST_ALPHA;
-         blend->alpha_src_factor = PIPE_BLENDFACTOR_DST_ALPHA;
-         blend->rgb_dst_factor   = PIPE_BLENDFACTOR_ZERO;
-         blend->alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+         blend->rt[0].rgb_src_factor   = PIPE_BLENDFACTOR_DST_ALPHA;
+         blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_DST_ALPHA;
+         blend->rt[0].rgb_dst_factor   = PIPE_BLENDFACTOR_ZERO;
+         blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
          break;
       case VG_BLEND_DST_IN:
-         blend->rgb_src_factor   = PIPE_BLENDFACTOR_ZERO;
-         blend->alpha_src_factor = PIPE_BLENDFACTOR_ZERO;
-         blend->rgb_dst_factor   = PIPE_BLENDFACTOR_SRC_ALPHA;
-         blend->alpha_dst_factor = PIPE_BLENDFACTOR_SRC_ALPHA;
+         blend->rt[0].rgb_src_factor   = PIPE_BLENDFACTOR_ZERO;
+         blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ZERO;
+         blend->rt[0].rgb_dst_factor   = PIPE_BLENDFACTOR_SRC_ALPHA;
+         blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_SRC_ALPHA;
          break;
       case VG_BLEND_MULTIPLY:
       case VG_BLEND_SCREEN:
       case VG_BLEND_DARKEN:
       case VG_BLEND_LIGHTEN:
-         blend->rgb_src_factor   = PIPE_BLENDFACTOR_ONE;
-         blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-         blend->rgb_dst_factor   = PIPE_BLENDFACTOR_ZERO;
-         blend->alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+         blend->rt[0].rgb_src_factor   = PIPE_BLENDFACTOR_ONE;
+         blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+         blend->rt[0].rgb_dst_factor   = PIPE_BLENDFACTOR_ZERO;
+         blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+         blend->rt[0].blend_enable = 0;
          break;
       case VG_BLEND_ADDITIVE:
-         blend->rgb_src_factor   = PIPE_BLENDFACTOR_ONE;
-         blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-         blend->rgb_dst_factor   = PIPE_BLENDFACTOR_ONE;
-         blend->alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
+         blend->rt[0].rgb_src_factor   = PIPE_BLENDFACTOR_ONE;
+         blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+         blend->rt[0].rgb_dst_factor   = PIPE_BLENDFACTOR_ONE;
+         blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
          break;
       default:
          assert(!"not implemented blend mode");
index 0324441c067a873b593ceec3a22fff7fc3aa926f..c50873c15088c102206e48968bf25d94cf602bdf 100644 (file)
@@ -217,13 +217,13 @@ bind_blend_state(struct exa_context *exa, int op,
    blend_for_op(&blend_opt, op, pSrcPicture, pMaskPicture, pDstPicture);
 
    memset(&blend, 0, sizeof(struct pipe_blend_state));
-   blend.blend_enable = 1;
-   blend.colormask |= PIPE_MASK_RGBA;
+   blend.rt[0].blend_enable = 1;
+   blend.rt[0].colormask = PIPE_MASK_RGBA;
 
-   blend.rgb_src_factor   = blend_opt.rgb_src;
-   blend.alpha_src_factor = blend_opt.rgb_src;
-   blend.rgb_dst_factor   = blend_opt.rgb_dst;
-   blend.alpha_dst_factor = blend_opt.rgb_dst;
+   blend.rt[0].rgb_src_factor   = blend_opt.rgb_src;
+   blend.rt[0].alpha_src_factor = blend_opt.rgb_src;
+   blend.rt[0].rgb_dst_factor   = blend_opt.rgb_dst;
+   blend.rt[0].alpha_dst_factor = blend_opt.rgb_dst;
 
    cso_set_blend(exa->renderer->cso, &blend);
 }
index db3330bc40a022c265ea0813d5653016ac3bbedb..a3c3993ab8198bec088129ab14293cc6d46b923d 100644 (file)
@@ -444,11 +444,11 @@ void renderer_copy_prepare(struct xorg_renderer *r,
    {
       struct pipe_blend_state blend;
       memset(&blend, 0, sizeof(blend));
-      blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
-      blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-      blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
-      blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
-      blend.colormask = PIPE_MASK_RGBA;
+      blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+      blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+      blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.rt[0].colormask = PIPE_MASK_RGBA;
       cso_set_blend(r->cso, &blend);
    }
 
index a3bcd7cb4c9944bd32f13c1c2618065749e26002..3dcef22c132078578012593ad570b44d1392a508 100644 (file)
@@ -400,14 +400,14 @@ bind_blend_state(struct xorg_xv_port_priv *port)
    struct pipe_blend_state blend;
 
    memset(&blend, 0, sizeof(struct pipe_blend_state));
-   blend.blend_enable = 1;
-   blend.colormask |= PIPE_MASK_RGBA;
+   blend.rt[0].blend_enable = 0;
+   blend.rt[0].colormask = PIPE_MASK_RGBA;
 
    /* porter&duff src */
-   blend.rgb_src_factor   = PIPE_BLENDFACTOR_ONE;
-   blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-   blend.rgb_dst_factor   = PIPE_BLENDFACTOR_ZERO;
-   blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+   blend.rt[0].rgb_src_factor   = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].rgb_dst_factor   = PIPE_BLENDFACTOR_ZERO;
+   blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
 
    cso_set_blend(port->r->cso, &blend);
 }
index 43e62c29f3e4fc65a70f687f056f811436c35848..1511b88dd1fd1233166d5ea67d7cd7b0c7928105 100644 (file)
@@ -152,14 +152,54 @@ translate_logicop(GLenum logicop)
    }
 }
 
+/**
+ * Figure out if colormasks are different per rt.
+ */
+static GLboolean
+colormask_per_rt(GLcontext *ctx)
+{
+   /* a bit suboptimal have to compare lots of values */
+   unsigned i;
+   for (i = 1; i < ctx->Const.MaxDrawBuffers; i++) {
+      if (memcmp(ctx->Color.ColorMask[0], ctx->Color.ColorMask[i], 4)) {
+         return GL_TRUE;
+      }
+   }
+   return GL_FALSE;
+}
+
+/**
+ * Figure out if blend enables are different per rt.
+ */
+static GLboolean
+blend_per_rt(GLcontext *ctx)
+{
+   if (ctx->Color.BlendEnabled &&
+      (ctx->Color.BlendEnabled != ((1 << ctx->Const.MaxDrawBuffers) - 1))) {
+      return GL_TRUE;
+   }
+   return GL_FALSE;
+}
 
 static void 
 update_blend( struct st_context *st )
 {
    struct pipe_blend_state *blend = &st->state.blend;
+   unsigned num_state = 1;
+   unsigned i;
 
    memset(blend, 0, sizeof(*blend));
 
+   if (blend_per_rt(st->ctx) || colormask_per_rt(st->ctx)) {
+      num_state = st->ctx->Const.MaxDrawBuffers;
+      blend->independent_blend_enable = 1;
+   }
+   /* Note it is impossible to correctly deal with EXT_blend_logic_op and
+      EXT_draw_buffers2/EXT_blend_equation_separate at the same time.
+      These combinations would require support for per-rt logicop enables
+      and separate alpha/rgb logicop/blend support respectively. Neither
+      possible in gallium nor most hardware. Assume these combinations
+      don't happen. */
    if (st->ctx->Color.ColorLogicOpEnabled ||
        (st->ctx->Color.BlendEnabled &&
         st->ctx->Color.BlendEquationRGB == GL_LOGIC_OP)) {
@@ -169,30 +209,33 @@ update_blend( struct st_context *st )
    }
    else if (st->ctx->Color.BlendEnabled) {
       /* blending enabled */
-      blend->blend_enable = 1;
-
-      blend->rgb_func = translate_blend(st->ctx->Color.BlendEquationRGB);
-      if (st->ctx->Color.BlendEquationRGB == GL_MIN ||
-          st->ctx->Color.BlendEquationRGB == GL_MAX) {
-         /* Min/max are special */
-         blend->rgb_src_factor = PIPE_BLENDFACTOR_ONE;
-         blend->rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
-      }
-      else {
-         blend->rgb_src_factor = translate_blend(st->ctx->Color.BlendSrcRGB);
-         blend->rgb_dst_factor = translate_blend(st->ctx->Color.BlendDstRGB);
-      }
+      for (i = 0; i < num_state; i++) {
 
-      blend->alpha_func = translate_blend(st->ctx->Color.BlendEquationA);
-      if (st->ctx->Color.BlendEquationA == GL_MIN ||
-          st->ctx->Color.BlendEquationA == GL_MAX) {
-         /* Min/max are special */
-         blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-         blend->alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
-      }
-      else {
-         blend->alpha_src_factor = translate_blend(st->ctx->Color.BlendSrcA);
-         blend->alpha_dst_factor = translate_blend(st->ctx->Color.BlendDstA);
+         blend->rt[i].blend_enable = (st->ctx->Color.BlendEnabled >> i) & 0x1;
+
+         blend->rt[i].rgb_func = translate_blend(st->ctx->Color.BlendEquationRGB);
+         if (st->ctx->Color.BlendEquationRGB == GL_MIN ||
+             st->ctx->Color.BlendEquationRGB == GL_MAX) {
+            /* Min/max are special */
+            blend->rt[i].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+            blend->rt[i].rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
+         }
+         else {
+            blend->rt[i].rgb_src_factor = translate_blend(st->ctx->Color.BlendSrcRGB);
+            blend->rt[i].rgb_dst_factor = translate_blend(st->ctx->Color.BlendDstRGB);
+         }
+
+         blend->rt[i].alpha_func = translate_blend(st->ctx->Color.BlendEquationA);
+         if (st->ctx->Color.BlendEquationA == GL_MIN ||
+             st->ctx->Color.BlendEquationA == GL_MAX) {
+            /* Min/max are special */
+            blend->rt[i].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+            blend->rt[i].alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
+         }
+         else {
+            blend->rt[i].alpha_src_factor = translate_blend(st->ctx->Color.BlendSrcA);
+            blend->rt[i].alpha_dst_factor = translate_blend(st->ctx->Color.BlendDstA);
+         }
       }
    }
    else {
@@ -200,14 +243,16 @@ update_blend( struct st_context *st )
    }
 
    /* Colormask - maybe reverse these bits? */
-   if (st->ctx->Color.ColorMask[0][0])
-      blend->colormask |= PIPE_MASK_R;
-   if (st->ctx->Color.ColorMask[0][1])
-      blend->colormask |= PIPE_MASK_G;
-   if (st->ctx->Color.ColorMask[0][2])
-      blend->colormask |= PIPE_MASK_B;
-   if (st->ctx->Color.ColorMask[0][3])
-      blend->colormask |= PIPE_MASK_A;
+   for (i = 0; i < num_state; i++) {
+      if (st->ctx->Color.ColorMask[i][0])
+         blend->rt[i].colormask |= PIPE_MASK_R;
+      if (st->ctx->Color.ColorMask[i][1])
+         blend->rt[i].colormask |= PIPE_MASK_G;
+      if (st->ctx->Color.ColorMask[i][2])
+         blend->rt[i].colormask |= PIPE_MASK_B;
+      if (st->ctx->Color.ColorMask[i][3])
+         blend->rt[i].colormask |= PIPE_MASK_A;
+   }
 
    if (st->ctx->Color.DitherFlag)
       blend->dither = 1;
index 398587ac4b1e5af476990c1847143674ea7a26f7..94693d91f3903bf268bb19536143edadc7780568 100644 (file)
@@ -224,19 +224,19 @@ clear_with_quad(GLcontext *ctx,
    {
       struct pipe_blend_state blend;
       memset(&blend, 0, sizeof(blend));
-      blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
-      blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-      blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
-      blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+      blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+      blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
       if (color) {
          if (ctx->Color.ColorMask[0][0])
-            blend.colormask |= PIPE_MASK_R;
+            blend.rt[0].colormask |= PIPE_MASK_R;
          if (ctx->Color.ColorMask[0][1])
-            blend.colormask |= PIPE_MASK_G;
+            blend.rt[0].colormask |= PIPE_MASK_G;
          if (ctx->Color.ColorMask[0][2])
-            blend.colormask |= PIPE_MASK_B;
+            blend.rt[0].colormask |= PIPE_MASK_B;
          if (ctx->Color.ColorMask[0][3])
-            blend.colormask |= PIPE_MASK_A;
+            blend.rt[0].colormask |= PIPE_MASK_A;
          if (st->ctx->Color.DitherFlag)
             blend.dither = 1;
       }
index 89a16c1cbccdd202e4d593927b80dec348df6136..31c03c078358b125e5932996a7569cf2e3d04db5 100644 (file)
@@ -314,4 +314,14 @@ void st_init_extensions(struct st_context *st)
    if (st->pipe->render_condition) {
       ctx->Extensions.NV_conditional_render = GL_TRUE;
    }
+
+   if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_ENABLE)) {
+      ctx->Extensions.EXT_draw_buffers2 = GL_TRUE;
+   }
+
+#if 0 /* not yet */
+   if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_FUNC)) {
+      ctx->Extensions.ARB_draw_buffers_blend = GL_TRUE;
+   }
+#endif
 }