On 30.01.2010 13:06, Corbin Simpson wrote:
> Handful of random things bugging me.

> 2) progs/tests/drawbuffers and progs/tests/drawbuffers2, and possibly
> others, segfault with both softpipe and the HW driver at
> sl_pp_version.c:45. I think there's some codegen going on there? At
> any rate, if anybody has any hints on how to solve it, that'd be nice.
Works for me (with softpipe).

> 
> 6) GL_ARB_shadow_ambient and texture compare-fail values. A comment in
> the fragment constants reads, "Since Gallium doesn't support
> GL_ARB_shadow_ambient, this is always (0,0,0,0), right?"
I'd think so. This extension isn't in core GL (and d3d can't do it
neither), and AFAIK there's no hardware (which doesn't emulate the
shadow functionality in the fragment shader) which could actually do it.

> Another
> comment reads, "Gallium doesn't provide us with any information
> regarding this mode, so we are screwed. I'm setting 0 = LUMINANCE,"
> above the texture compare modes. I don't really like that section of
> code, but it probably can't get cleaner, right?
Yes, that's not very clean, but there doesn't seem to be an easy
solution for this. Exposing this in gallium only seems marginally
useful, since again modern hardware can't really do anything useful with
that information neither. Maybe would need to tweak the shader if
actually the "wrong" channels are used (probably shouldn't be the
driver's responsibility to do this), but I guess assuming default
LUMINANCE works just fine usually. New OGL won't have that problem...

> 
> 7) Is there more information on the dual-source blend modes? I'm not
> sure if I can do them; might have to bug AMD for the register values.
Pretty sure most pre-DX10 hardware can't do that, the blend unit just
doesn't have access to multiple source colors.
I've attached a small patch which shows how softpipe implements it.
(But I still need to write a testcase probably for the python
statetracker to see if it actually works...).
Pretty easy really, just using pixel shader color outputs 0 and 1 for
blending (note that in this form this restricts dual source blending to
one render target, this is the same restriction DX10 enforces, and if
you look at i965 docs it actually has this restriction in hardware).

> 
> I think that's it for now. Sorry for all the questions, but I'm really
> starting to get a good handle on the hardware and interface, and I'm
> ready to start beating the classic driver in serious benchmarks; I
> think that r300's probably the most mature driver alongside nv50 and
> maybe nv40.
Great!

Roland
diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c b/src/gallium/drivers/softpipe/sp_quad_blend.c
index d65307b..85fda0b 100644
--- a/src/gallium/drivers/softpipe/sp_quad_blend.c
+++ b/src/gallium/drivers/softpipe/sp_quad_blend.c
@@ -222,7 +222,7 @@ logicop_quad(struct quad_stage *qs,
 
 static void
 blend_quad(struct quad_stage *qs, 
-           float (*quadColor)[4],
+           float (*quadColors)[4][4],
            float (*dest)[4],
            unsigned cbuf)
 {
@@ -230,6 +230,7 @@ blend_quad(struct quad_stage *qs,
    static const float one[4] = { 1, 1, 1, 1 };
    struct softpipe_context *softpipe = qs->softpipe;
    float source[4][QUAD_SIZE] = { { 0 } };
+   float (*quadColor)[4] = quadColors[cbuf];
 
    /*
     * Compute src/first term RGB
@@ -298,11 +299,23 @@ blend_quad(struct quad_stage *qs,
    }
    break;
    case PIPE_BLENDFACTOR_SRC1_COLOR:
-      assert(0); /* to do */
-      break;
+   {
+      float (*quadColor1)[4] = quadColors[1];
+      assert(cbuf == 0);
+      VEC4_MUL(source[0], quadColor[0], quadColor1[0]); /* R */
+      VEC4_MUL(source[1], quadColor[1], quadColor1[1]); /* G */
+      VEC4_MUL(source[2], quadColor[2], quadColor1[2]); /* B */
+   }
+   break;
    case PIPE_BLENDFACTOR_SRC1_ALPHA:
-      assert(0); /* to do */
-      break;
+   {
+      const float *alpha = quadColors[1][3];
+      assert(cbuf == 0);
+      VEC4_MUL(source[0], quadColor[0], alpha); /* R */
+      VEC4_MUL(source[1], quadColor[1], alpha); /* G */
+      VEC4_MUL(source[2], quadColor[2], alpha); /* B */
+   }
+   break;
    case PIPE_BLENDFACTOR_ZERO:
       VEC4_COPY(source[0], zero); /* R */
       VEC4_COPY(source[1], zero); /* G */
@@ -372,11 +385,29 @@ blend_quad(struct quad_stage *qs,
    }
    break;
    case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
-      assert(0); /* to do */
-      break;
+   {
+      float (*quadColor1)[4] = quadColors[1];
+      float inv_comp[4];
+      assert(cbuf == 0);
+      VEC4_SUB(inv_comp, one, quadColor1[0]); /* R */
+      VEC4_MUL(source[0], quadColor[0], inv_comp); /* R */
+      VEC4_SUB(inv_comp, one, quadColor1[1]); /* G */
+      VEC4_MUL(source[1], quadColor[1], inv_comp); /* G */
+      VEC4_SUB(inv_comp, one, quadColor1[2]); /* B */
+      VEC4_MUL(source[2], quadColor[2], inv_comp); /* B */
+   }
+   break;
    case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
-      assert(0); /* to do */
-      break;
+   {
+      const float *alpha = quadColors[1][3];
+      float inv_alpha[4];
+      assert(cbuf == 0);
+      VEC4_SUB(inv_alpha, one, alpha);
+      VEC4_MUL(source[0], quadColor[0], inv_alpha); /* R */
+      VEC4_MUL(source[1], quadColor[1], inv_alpha); /* G */
+      VEC4_MUL(source[2], quadColor[2], inv_alpha); /* B */
+   }
+   break;
    default:
       assert(0);
    }
@@ -414,6 +445,15 @@ blend_quad(struct quad_stage *qs,
       VEC4_MUL(source[3], quadColor[3], comp); /* A */
    }
    break;
+   case PIPE_BLENDFACTOR_SRC1_COLOR:
+      /* fall-through */
+   case PIPE_BLENDFACTOR_SRC1_ALPHA:
+   {
+      const float *alpha = quadColors[1][3];
+      assert(cbuf == 0);
+      VEC4_MUL(source[3], quadColor[3], alpha); /* R */
+   }
+   break;
    case PIPE_BLENDFACTOR_ZERO:
       VEC4_COPY(source[3], zero); /* A */
       break;
@@ -445,6 +485,16 @@ blend_quad(struct quad_stage *qs,
       VEC4_MUL(source[3], quadColor[3], inv_comp);
    }
    break;
+   case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
+      /* fall-through */
+   case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
+   {
+      float inv_alpha[4];
+      assert(cbuf == 0);
+      VEC4_SUB(inv_alpha, one, quadColors[1][3]);
+      VEC4_MUL(source[3], quadColor[3], inv_alpha); /* A */
+   }
+   break;
    default:
       assert(0);
    }
@@ -508,16 +558,29 @@ blend_quad(struct quad_stage *qs,
       VEC4_MUL(dest[2], dest[2], comp); /* B */
    }
    break;
+   case PIPE_BLENDFACTOR_SRC1_COLOR:
+   {
+      float (*quadColor1)[4] = quadColors[1];
+      assert(cbuf == 0);
+      VEC4_MUL(dest[0], dest[0], quadColor1[0]); /* R */
+      VEC4_MUL(dest[1], dest[1], quadColor1[1]); /* G */
+      VEC4_MUL(dest[2], dest[2], quadColor1[2]); /* B */
+   }
+   break;
+   case PIPE_BLENDFACTOR_SRC1_ALPHA:
+   {
+      const float *alpha = quadColors[1][3];
+      assert(cbuf == 0);
+      VEC4_MUL(dest[0], dest[0], alpha); /* R */
+      VEC4_MUL(dest[1], dest[1], alpha); /* G */
+      VEC4_MUL(dest[2], dest[2], alpha); /* B */
+   }
+   break;
    case PIPE_BLENDFACTOR_ZERO:
       VEC4_COPY(dest[0], zero); /* R */
       VEC4_COPY(dest[1], zero); /* G */
       VEC4_COPY(dest[2], zero); /* B */
       break;
-   case PIPE_BLENDFACTOR_SRC1_COLOR:
-   case PIPE_BLENDFACTOR_SRC1_ALPHA:
-      /* XXX what are these? */
-      assert(0);
-      break;
    case PIPE_BLENDFACTOR_INV_SRC_COLOR:
    {
       float inv_comp[4];
@@ -582,10 +645,29 @@ blend_quad(struct quad_stage *qs,
    }
    break;
    case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
+   {
+      float (*quadColor1)[4] = quadColors[1];
+      float inv_comp[4];
+      assert(cbuf == 0);
+      VEC4_SUB(inv_comp, one, quadColor1[0]); /* R */
+      VEC4_MUL(dest[0], dest[0], inv_comp); /* R */
+      VEC4_SUB(inv_comp, one, quadColor1[1]); /* G */
+      VEC4_MUL(dest[1], dest[1], inv_comp); /* G */
+      VEC4_SUB(inv_comp, one, quadColor1[2]); /* B */
+      VEC4_MUL(dest[2], dest[2], inv_comp); /* B */
+   }
+   break;
    case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
-      /* XXX what are these? */
-      assert(0);
-      break;
+   {
+      const float *alpha = quadColors[1][3];
+      float inv_alpha[4];
+      assert(cbuf == 0);
+      VEC4_SUB(inv_alpha, one, alpha);
+      VEC4_MUL(dest[0], dest[0], inv_alpha); /* R */
+      VEC4_MUL(dest[1], dest[1], inv_alpha); /* G */
+      VEC4_MUL(dest[2], dest[2], inv_alpha); /* B */
+   }
+   break;
    default:
       assert(0);
    }
@@ -619,6 +701,15 @@ blend_quad(struct quad_stage *qs,
       VEC4_MUL(dest[3], dest[3], comp); /* A */
    }
    break;
+   case PIPE_BLENDFACTOR_SRC1_COLOR:
+      /* fall-through */
+   case PIPE_BLENDFACTOR_SRC1_ALPHA:
+   {
+      const float *alpha = quadColors[1][3];
+      assert(cbuf == 0);
+      VEC4_MUL(dest[3], dest[3], alpha); /* R */
+   }
+   break;
    case PIPE_BLENDFACTOR_ZERO:
       VEC4_COPY(dest[3], zero); /* A */
       break;
@@ -649,6 +740,16 @@ blend_quad(struct quad_stage *qs,
       VEC4_MUL(dest[3], dest[3], inv_comp);
    }
    break;
+   case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
+      /* fall-through */
+   case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
+   {
+      float inv_alpha[4];
+      assert(cbuf == 0);
+      VEC4_SUB(inv_alpha, one, quadColors[1][3]);
+      VEC4_MUL(dest[3], dest[3], inv_alpha); /* A */
+   }
+   break;
    default:
       assert(0);
    }
@@ -772,7 +873,7 @@ blend_fallback(struct quad_stage *qs,
             logicop_quad( qs, quadColor, dest );
          }
          else if (blend->rt[cbuf].blend_enable) {
-            blend_quad( qs, quadColor, dest, cbuf );
+            blend_quad( qs, quad->output.color, dest, cbuf );
          }
 
          if (blend->rt[cbuf].colormask != 0xf)
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index b2841f4..df30ac4 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -99,6 +99,8 @@ softpipe_get_param(struct pipe_screen *screen, int param)
       return 1;
    case PIPE_CAP_INDEP_BLEND_FUNC:
       return 1;
+   case PIPE_CAP_DUAL_SOURCE_BLEND:
+      return 1;
    default:
       return 0;
    }
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to