llvmpipe: adapt to per-rendertarget blend changes
authorRoland Scheidegger <sroland@vmware.com>
Wed, 20 Jan 2010 17:27:53 +0000 (18:27 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Wed, 20 Jan 2010 17:27:53 +0000 (18:27 +0100)
src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c
src/gallium/drivers/llvmpipe/lp_state_fs.c

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 9511299d558daea791b6c04e130fe5bd8bd8505e..284977b7c3bbb11b9251494893c9d57463254025 100644 (file)
@@ -218,7 +218,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]);
@@ -226,10 +226,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 */
@@ -270,7 +270,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 9f4bbef73fb7aba647bd696c30aa51448885ed84..c6d97bb3e95e833e39dfea60ba9f66f3e8ac0e3f 100644 (file)
@@ -354,7 +354,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]);
@@ -423,15 +423,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);
@@ -782,7 +782,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);
       }
    }