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

20 files changed:
1  2 
src/gallium/auxiliary/util/u_blit.c
src/gallium/auxiliary/util/u_gen_mipmap.c
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/gallium/drivers/llvmpipe/lp_test_blend.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/svga/svga_pipe_blend.c
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_state.h
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/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_cb_clear.c
src/mesa/state_tracker/st_extensions.c

index 236f1e4feee0d7cd5563de3d373d4c0231e9ca05,ebc9d3415fc3cac4b036463363722d0960431383..eb63bec7b50f4c6d18e6cba72c8025b7d0527f69
@@@ -92,7 -92,7 +92,7 @@@ util_create_blit(struct pipe_context *p
  
     /* 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));
@@@ -226,8 -226,8 +226,8 @@@ setup_vertex_data_tex(struct blit_stat
  
     offset = get_next_slot( ctx );
  
 -   pipe_buffer_write(ctx->pipe->screen, ctx->vbuf,
 -                     offset, sizeof(ctx->vertices), ctx->vertices);
 +   pipe_buffer_write_nooverlap(ctx->pipe->screen, ctx->vbuf,
 +                               offset, sizeof(ctx->vertices), ctx->vertices);
  
     return offset;
  }
index 5426c91152da3187de33d0c4ea05d5305178b323,67027ec1a52dd740e4684dd6fdd2e2ca28a03660..8611231ed705041d7bbff6920d5fd127d6e9a0aa
@@@ -1287,7 -1287,7 +1287,7 @@@ util_create_gen_mipmap(struct pipe_cont
  
     /* 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));
@@@ -1411,8 -1411,8 +1411,8 @@@ set_vertex_data(struct gen_mipmap_stat
  
     offset = get_next_slot( ctx );
  
 -   pipe_buffer_write(ctx->pipe->screen, ctx->vbuf,
 -                     offset, sizeof(ctx->vertices), ctx->vertices);
 +   pipe_buffer_write_nooverlap(ctx->pipe->screen, ctx->vbuf,
 +                               offset, sizeof(ctx->vertices), ctx->vertices);
  
     return offset;
  }
index 06949c15f88178205567ccd99dfa18a928cbf74a,db98256d2a15055e056ad6d69f071709350e656f..23e4d6b993889af9e2eb578a6dfb86c3611e77a2
@@@ -30,6 -30,7 +30,6 @@@
  
  
  #include "draw/draw_context.h"
 -#include "pipe/internal/p_winsys_screen.h"
  #include "pipe/p_inlines.h"
  #include "util/u_math.h"
  #include "util/u_memory.h"
@@@ -37,6 -38,7 +37,6 @@@
  
  #include "i915_context.h"
  #include "i915_reg.h"
 -#include "i915_state.h"
  #include "i915_state_inlines.h"
  #include "i915_fpc.h"
  
@@@ -103,13 -105,13 +103,13 @@@ i915_create_blend_state(struct pipe_con
     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.
     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 5d5ca7a5d43015effa64f11cefd711459a83423a,284977b7c3bbb11b9251494893c9d57463254025..a73d1158e79261c7144689f31251440222ad1115
@@@ -71,6 -71,7 +71,6 @@@
  #include "pipe/p_state.h"
  
  #include "lp_bld_type.h"
 -#include "lp_bld_const.h"
  #include "lp_bld_arit.h"
  #include "lp_bld_blend.h"
  
@@@ -217,7 -218,7 +217,7 @@@ lp_build_blend_soa(LLVMBuilderRef build
     }
  
     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]);
              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 */
  
              /* 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 0cb335fe27a4c8b671945bf88b6ece9934c1d85f,c6d97bb3e95e833e39dfea60ba9f66f3e8ac0e3f..ddd0740f1b4054ba6114cf787c5bc95172aaf92d
@@@ -62,6 -62,7 +62,6 @@@
  #include "util/u_memory.h"
  #include "util/u_format.h"
  #include "util/u_debug_dump.h"
 -#include "pipe/internal/p_winsys_screen.h"
  #include "pipe/p_shader_tokens.h"
  #include "draw/draw_context.h"
  #include "tgsi/tgsi_dump.h"
@@@ -84,6 -85,7 +84,6 @@@
  #include "lp_context.h"
  #include "lp_buffer.h"
  #include "lp_state.h"
 -#include "lp_quad.h"
  #include "lp_tex_sample.h"
  #include "lp_debug.h"
  
@@@ -352,7 -354,7 +352,7 @@@ generate_blend(const struct pipe_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 -423,15 +421,15 @@@ generate_fragment(struct llvmpipe_conte
        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);
@@@ -731,7 -733,7 +731,7 @@@ llvmpipe_set_constant_buffer(struct pip
     }
  
     if(shader == PIPE_SHADER_VERTEX) {
 -      draw_set_mapped_constant_buffer(llvmpipe->draw, PIPE_SHADER_VERTEX,
 +      draw_set_mapped_constant_buffer(llvmpipe->draw, PIPE_SHADER_VERTEX, 0,
                                        data, size);
     }
  
@@@ -780,7 -782,7 +780,7 @@@ make_variant_key(struct llvmpipe_contex
        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,07f636f8e7214ce9f970ac800cb2d6fbe56f9dd6..ee72f6ce4fcc4d315d3b267a2f9a37323cf0060f
@@@ -38,6 -38,7 +38,6 @@@
  
  
  #include "lp_bld_type.h"
 -#include "lp_bld_arit.h"
  #include "lp_bld_blend.h"
  #include "lp_bld_debug.h"
  #include "lp_test.h"
@@@ -103,18 -104,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 -137,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 -401,15 +400,15 @@@ compute_blend_ref(const struct pipe_ble
     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 */
     /*
      * 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 -808,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 -867,14 +866,14 @@@ test_some(unsigned verbose, FILE *fp, u
        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 a4a0e5281593f27130d8b0e2c9866d75eefaf898,ebe879348670b686efbaf41813feed73acc7d80c..b8fbf03d3a9792f8ff957ac5978bfea22f961aa9
@@@ -149,6 -149,9 +149,9 @@@ static int r300_get_param(struct pipe_s
              } 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);
@@@ -219,7 -222,6 +222,7 @@@ static boolean r300_is_format_supported
          case PIPE_FORMAT_DXT5_RGBA:
          case PIPE_FORMAT_YCBCR:
          case PIPE_FORMAT_L8_UNORM:
 +        case PIPE_FORMAT_A8_UNORM:
          case PIPE_FORMAT_A8L8_UNORM:
              retval = usage & PIPE_TEXTURE_USAGE_SAMPLER;
              break;
index 1b920563a5f4ff33534be74abc2ef180a757cf57,c5e313ce437a11b56eaa809e870f59008684210c..3cdcf94274c041c89110fcf7be67a41137e3039f
@@@ -30,6 -30,7 +30,6 @@@
  #include "tgsi/tgsi_parse.h"
  
  #include "pipe/p_config.h"
 -#include "pipe/internal/p_winsys_screen.h"
  
  #include "r300_context.h"
  #include "r300_reg.h"
@@@ -163,15 -164,15 +163,15 @@@ static void* r300_create_blend_state(st
  {
      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 */
      }
  
      /* 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;
      }
  
@@@ -487,30 -488,20 +487,30 @@@ static voi
      struct r300_context* r300 = r300_context(pipe);
      uint32_t zbuffer_bpp = 0;
  
 +    r300->fb_state.size = (10 * state->nr_cbufs) +
 +        (2 * (4 - state->nr_cbufs)) +
 +        (state->zsbuf ? 10 : 0) + 6;
 +
 +    if (state->nr_cbufs > 4) {
 +        debug_printf("r300: Implementation error: Too many MRTs in %s, "
 +            "refusing to bind framebuffer state!\n", __FUNCTION__);
 +        return;
 +    }
 +
      if (r300->draw) {
          draw_flush(r300->draw);
      }
  
 -    r300->framebuffer_state = *state;
 +    r300->fb_state.state = state;
  
      /* Don't rely on the order of states being set for the first time. */
 -    r300->dirty_state |= R300_NEW_FRAMEBUFFERS;
 -
 +    /* XXX wait what */
      r300->blend_state.dirty = TRUE;
      r300->dsa_state.dirty = TRUE;
 +    r300->fb_state.dirty = TRUE;
      r300->scissor_state.dirty = TRUE;
  
 -    /* Polyfon offset depends on the zbuffer bit depth. */
 +    /* Polygon offset depends on the zbuffer bit depth. */
      if (state->zsbuf && r300->polygon_offset_enabled) {
          switch (util_format_get_blocksize(state->zsbuf->texture->format)) {
              case 2:
@@@ -561,7 -552,7 +561,7 @@@ static void r300_bind_fs_state(struct p
      r300_pick_fragment_shader(r300);
  
      if (r300->vs && r300_vertex_shader_setup_wpos(r300)) {
 -        r300->dirty_state |= R300_NEW_VERTEX_FORMAT;
 +        r300->vertex_format_state.dirty = TRUE;
      }
  
      r300->dirty_state |= R300_NEW_FRAGMENT_SHADER | R300_NEW_FRAGMENT_SHADER_CONSTANTS;
@@@ -729,6 -720,7 +729,6 @@@ static void r300_bind_rs_state(struct p
      r300->viewport_state.dirty = TRUE;
  
      /* XXX Clean these up when we move to atom emits */
 -    r300->dirty_state |= R300_NEW_RS_BLOCK;
      if (r300->fs && r300->fs->inputs.wpos != ATTR_UNUSED) {
          r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
      }
@@@ -929,23 -921,7 +929,23 @@@ static void r300_set_vertex_buffers(str
          draw_set_vertex_buffers(r300->draw, count, buffers);
      }
  
 -    r300->dirty_state |= R300_NEW_VERTEX_FORMAT;
 +    r300->vertex_format_state.dirty = TRUE;
 +}
 +
 +static boolean r300_validate_aos(struct r300_context *r300)
 +{
 +    struct pipe_vertex_buffer *vbuf = r300->vertex_buffer;
 +    struct pipe_vertex_element *velem = r300->vertex_element;
 +    int i;
 +
 +    /* Check if formats and strides are aligned to the size of DWORD. */
 +    for (i = 0; i < r300->vertex_element_count; i++) {
 +        if (vbuf[velem[i].vertex_buffer_index].stride % 4 != 0 ||
 +            util_format_get_blocksize(velem[i].src_format) % 4 != 0) {
 +            return FALSE;
 +        }
 +    }
 +    return TRUE;
  }
  
  static void r300_set_vertex_elements(struct pipe_context* pipe,
          draw_flush(r300->draw);
          draw_set_vertex_elements(r300->draw, count, elements);
      }
 +
 +    if (!r300_validate_aos(r300)) {
 +        /* XXX We should fallback using draw. */
 +        assert(0);
 +        abort();
 +    }
  }
  
  static void* r300_create_vs_state(struct pipe_context* pipe,
@@@ -1009,10 -979,9 +1009,10 @@@ static void r300_bind_vs_state(struct p
              r300_vertex_shader_setup_wpos(r300);
          }
  
 +        r300->vertex_format_state.dirty = TRUE;
 +
          r300->dirty_state |=
 -            R300_NEW_VERTEX_SHADER | R300_NEW_VERTEX_SHADER_CONSTANTS |
 -            R300_NEW_VERTEX_FORMAT;
 +            R300_NEW_VERTEX_SHADER | R300_NEW_VERTEX_SHADER_CONSTANTS;
      } else {
          draw_flush(r300->draw);
          draw_bind_vertex_shader(r300->draw,
index 3b8c2d5789c8eb87d30e28c0dd2362d0f9e366ef,a1fe5192b03897dc9d57679adcda4646a903f0af..d65307b7f60498c0ddd844c958177968b35c83c8
@@@ -35,6 -35,7 +35,6 @@@
  #include "util/u_memory.h"
  #include "sp_context.h"
  #include "sp_quad.h"
 -#include "sp_surface.h"
  #include "sp_tile_cache.h"
  #include "sp_quad_pipe.h"
  
@@@ -223,7 -224,8 +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 };
     /*
      * 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 */
     /*
      * 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;
     /*
      * 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;
     /*
      * 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;
     /*
      * 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 */
     /*
      * 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;
  }
  
  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 -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 -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,e36f9ec5dab869ac90d961aa64fc1e3da8d03d0a..b2841f410314c9685d852c48a658bb0b05d1aa33
@@@ -91,10 -91,10 +91,14 @@@ softpipe_get_param(struct pipe_screen *
        return 1;
     case PIPE_CAP_BLEND_EQUATION_SEPARATE:
        return 1;
 +   case PIPE_CAP_MAX_CONST_BUFFERS:
 +      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 3ad3f97816c1f0aa7b0e6d5b0493bdd6490619ee,40292993115a11ea8279360af7558db8548bf976..9df5485f462e93609dce23b033726aa7fad8b0fe
@@@ -29,6 -29,7 +29,6 @@@
  #include "util/u_memory.h"
  
  #include "svga_context.h"
 -#include "svga_state.h"
  
  #include "svga_hw_reg.h"
  
@@@ -181,15 -182,15 +181,15 @@@ svga_create_blend_state(struct pipe_con
           }
        }
        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 ||
           }
        }
  
-       blend->rt[i].writemask = templ->colormask;
+       blend->rt[i].writemask = templ->rt[0].colormask;
     }
  
     return blend;
index 353d79a6a7ebb37602752ef37e705f0028823eac,41a4f209019241a9b26dd2457edf185ead90d9a1..b28441dca9c24f05e5a64e02123370ad83d68248
@@@ -377,7 -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
  #define PIPE_CAP_MAX_PREDICATE_REGISTERS 30
  #define PIPE_CAP_MAX_COMBINED_SAMPLERS   31  /*< Maximum texture image units accessible from vertex
                                                   and fragment shaders combined */
 -#define PIPE_CAP_INDEP_BLEND_ENABLE      32  /*< blend enables and write masks per rendertarget */
 -#define PIPE_CAP_INDEP_BLEND_FUNC        33  /*< different blend funcs per rendertarget */
 +#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,b9ac2db5915f1fb4c797b450294b43e672eabb60..03cd74efed3a8d98d3a5f4b60fde6ae79eede2e1
@@@ -58,7 -58,7 +58,7 @@@ extern "C" 
  #define PIPE_MAX_ATTRIBS          32
  #define PIPE_MAX_CLIP_PLANES       6
  #define PIPE_MAX_COLOR_BUFS        8
 -#define PIPE_MAX_CONSTANT         32
 +#define PIPE_MAX_CONSTANT_BUFFERS 32
  #define PIPE_MAX_SAMPLERS         16
  #define PIPE_MAX_VERTEX_SAMPLERS  16
  #define PIPE_MAX_SHADER_INPUTS    16
@@@ -217,7 -217,7 +217,7 @@@ struct pipe_depth_stencil_alpha_stat
  };
  
  
- struct pipe_blend_state
+ struct pipe_rt_blend_state
  {
     unsigned blend_enable:1;
  
     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 +274,7 @@@ struct pipe_sampler_stat
     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 9e668d2ac69c75045f94c9fd6e0b2ddcbeb645e0,e9d844c71895e355522185055ff541bc926d20bc..41dd69d2542575a6d2324974fc88734bfa718ca3
@@@ -26,7 -26,6 +26,7 @@@
  # 
  ##########################################################################
  
 +import struct
  
  from gallium import *
  
@@@ -51,11 -50,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
      fs = Shader(file('frag-' + name + '.sh', 'rt').read())
      ctx.set_fragment_shader(fs)
  
 +    constbuf0 = dev.buffer_create(64,
 +                                  (PIPE_BUFFER_USAGE_CONSTANT |
 +                                   PIPE_BUFFER_USAGE_GPU_READ |
 +                                   PIPE_BUFFER_USAGE_CPU_WRITE),
 +                                  4 * 4 * 4)
 +
 +    cbdata = ''
 +    cbdata += struct.pack('4f', 0.4, 0.0, 0.0, 1.0)
 +    cbdata += struct.pack('4f', 1.0, 1.0, 1.0, 1.0)
 +    cbdata += struct.pack('4f', 2.0, 2.0, 2.0, 2.0)
 +    cbdata += struct.pack('4f', 4.0, 8.0, 16.0, 32.0)
 +
 +    constbuf0.write(cbdata, 0)
 +
 +    ctx.set_constant_buffer(PIPE_SHADER_FRAGMENT,
 +                            0,
 +                            constbuf0)
 +
 +    constbuf1 = dev.buffer_create(64,
 +                                  (PIPE_BUFFER_USAGE_CONSTANT |
 +                                   PIPE_BUFFER_USAGE_GPU_READ |
 +                                   PIPE_BUFFER_USAGE_CPU_WRITE),
 +                                  4 * 4 * 4)
 +
 +    cbdata = ''
 +    cbdata += struct.pack('4f', 0.1, 0.1, 0.1, 0.1)
 +    cbdata += struct.pack('4f', 0.25, 0.25, 0.25, 0.25)
 +    cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5)
 +    cbdata += struct.pack('4f', 0.75, 0.75, 0.75, 0.75)
 +
 +    constbuf1.write(cbdata, 0)
 +
 +    ctx.set_constant_buffer(PIPE_SHADER_FRAGMENT,
 +                            1,
 +                            constbuf1)
 +
      xy = [
          -0.8, -0.8,
           0.8, -0.8,
@@@ -221,8 -184,6 +221,8 @@@ def main()
      tests = [
          'abs',
          'add',
 +        'cb-1d',
 +        'cb-2d',
          'dp3',
          'dp4',
          'dst',
index 96503778ae88a401e5df1ef806fd94ce4263f0a2,a185474fa39e74a377046d7b885b2ff53c2b819e..2c44f872e1de32ec3844152e3b11cc284fce0826
@@@ -27,8 -27,6 +27,8 @@@
  ##########################################################################
  
  
 +import struct
 +
  from gallium import *
  
  def make_image(surface):
@@@ -52,11 -50,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
      ''')
      ctx.set_fragment_shader(fs)
  
 +    constbuf0 = dev.buffer_create(64,
 +                                  (PIPE_BUFFER_USAGE_CONSTANT |
 +                                   PIPE_BUFFER_USAGE_GPU_READ |
 +                                   PIPE_BUFFER_USAGE_CPU_WRITE),
 +                                  4 * 4 * 4)
 +
 +    cbdata = ''
 +    cbdata += struct.pack('4f', 0.4, 0.0, 0.0, 1.0)
 +    cbdata += struct.pack('4f', 1.0, 1.0, 1.0, 1.0)
 +    cbdata += struct.pack('4f', 2.0, 2.0, 2.0, 2.0)
 +    cbdata += struct.pack('4f', 4.0, 8.0, 16.0, 32.0)
 +
 +    constbuf0.write(cbdata, 0)
 +
 +    ctx.set_constant_buffer(PIPE_SHADER_VERTEX,
 +                            0,
 +                            constbuf0)
 +
 +    constbuf1 = dev.buffer_create(64,
 +                                  (PIPE_BUFFER_USAGE_CONSTANT |
 +                                   PIPE_BUFFER_USAGE_GPU_READ |
 +                                   PIPE_BUFFER_USAGE_CPU_WRITE),
 +                                  4 * 4 * 4)
 +
 +    cbdata = ''
 +    cbdata += struct.pack('4f', 0.1, 0.1, 0.1, 0.1)
 +    cbdata += struct.pack('4f', 0.25, 0.25, 0.25, 0.25)
 +    cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5)
 +    cbdata += struct.pack('4f', 0.75, 0.75, 0.75, 0.75)
 +
 +    constbuf1.write(cbdata, 0)
 +
 +    ctx.set_constant_buffer(PIPE_SHADER_VERTEX,
 +                            1,
 +                            constbuf1)
 +
      xy = [
           0.0,  0.8,
          -0.2,  0.4,
@@@ -251,8 -213,6 +251,8 @@@ def main()
          'add',
          'arl',
          'arr',
 +        'cb-1d',
 +        'cb-2d',
          'dp3',
          'dp4',
          'dst',
index 0324441c067a873b593ceec3a22fff7fc3aa926f,66f83f566c5ac5833f86ed5b8623c72fa9e464c3..c50873c15088c102206e48968bf25d94cf602bdf
@@@ -4,7 -4,10 +4,7 @@@
  #include "xorg_exa_tgsi.h"
  
  #include "cso_cache/cso_context.h"
 -#include "util/u_draw_quad.h"
 -#include "util/u_math.h"
  
 -#include "pipe/p_inlines.h"
  
  /*XXX also in Xrender.h but the including it here breaks compilition */
  #define XFixedToDouble(f)    (((double) (f)) / 65536.)
@@@ -217,13 -220,13 +217,13 @@@ bind_blend_state(struct exa_context *ex
     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,0b6600da6f5b50575903badb8ab120173862ae2b..a3c3993ab8198bec088129ab14293cc6d46b923d
@@@ -5,6 -5,7 +5,6 @@@
  
  #include "cso_cache/cso_context.h"
  #include "util/u_draw_quad.h"
 -#include "util/u_format.h"
  #include "util/u_math.h"
  #include "util/u_memory.h"
  #include "util/u_rect.h"
@@@ -444,11 -445,11 +444,11 @@@ void renderer_copy_prepare(struct xorg_
     {
        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,73c076fac43ca2607b0f3cc39b93580a89781372..3dcef22c132078578012593ad570b44d1392a508
@@@ -11,6 -11,9 +11,6 @@@
  #include "cso_cache/cso_context.h"
  
  #include "pipe/p_screen.h"
 -#include "pipe/p_inlines.h"
 -
 -#include "util/u_format.h"
  
  /*XXX get these from pipe's texture limits */
  #define IMAGE_MAX_WIDTH               2048
@@@ -400,14 -403,14 +400,14 @@@ bind_blend_state(struct xorg_xv_port_pr
     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 398587ac4b1e5af476990c1847143674ea7a26f7,2c1be41ad83b63fd1085682b0884b067d1acb350..94693d91f3903bf268bb19536143edadc7780568
  #include "st_cb_accum.h"
  #include "st_cb_clear.h"
  #include "st_cb_fbo.h"
 -#include "st_draw.h"
  #include "st_program.h"
  #include "st_public.h"
 -#include "st_mesa_to_tgsi.h"
  #include "st_inlines.h"
  
  #include "pipe/p_context.h"
@@@ -51,6 -53,7 +51,6 @@@
  #include "pipe/p_state.h"
  #include "pipe/p_defines.h"
  #include "util/u_format.h"
 -#include "util/u_pack_color.h"
  #include "util/u_simple_shaders.h"
  #include "util/u_draw_quad.h"
  
@@@ -163,10 -166,10 +163,10 @@@ draw_quad(GLcontext *ctx
     }
  
     /* put vertex data into vbuf */
 -   st_no_flush_pipe_buffer_write(st, st->clear.vbuf,
 -                               st->clear.vbuf_slot * sizeof(st->clear.vertices),
 -                               sizeof(st->clear.vertices),
 -                               st->clear.vertices);
 +   st_no_flush_pipe_buffer_write_nooverlap(st, st->clear.vbuf,
 +                                           st->clear.vbuf_slot * sizeof(st->clear.vertices),
 +                                           sizeof(st->clear.vertices),
 +                                           st->clear.vertices);
  
     /* draw */
     util_draw_vertex_buffer(pipe, 
@@@ -224,19 -227,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,a7411c86439687aa8d3b1d37921c827ddfeba717..31c03c078358b125e5932996a7569cf2e3d04db5
@@@ -28,6 -28,7 +28,6 @@@
  
  #include "main/imports.h"
  #include "main/context.h"
 -#include "main/extensions.h"
  #include "main/macros.h"
  
  #include "pipe/p_context.h"
@@@ -314,4 -315,14 +314,14 @@@ void st_init_extensions(struct st_conte
     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
  }