<div dir="auto">Ok. Is there a test that failed? I'll probably have to fix up nv50 for it.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mar 1, 2018 11:43 AM, "Brian Paul" <<a href="mailto:brianp@vmware.com">brianp@vmware.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 02/28/2018 08:36 AM, Ilia Mirkin wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Can st/mesa instead be fixed to maintain the original API? Other<br>
drivers look in rt[0] in the non-independent_blend_enable case. For<br>
example, freedreno and nouveau.<br>
</blockquote>
<br>
If independent blend is not in use, then rt[0] will have all the blending info, as before.<br>
<br>
The case that broke for us was when PIPE_CAP_INDEP_BLEND_FUNC==0 and independent blend was enabled for rt[i] where i > 0.  Before, the blend src/dst terms were in rt[0] but now they're in rt[i].<br>
<br>
I'd rather not change the semantics again.<br>
<br>
-Brian<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On Wed, Feb 28, 2018 at 10:29 AM, Brian Paul <<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The earlier Mesa commit 3d06c8afb5 ("st/mesa: don't translate blend<br>
state when it's disabled for a colorbuffer") subtly changed the<br>
details of gallium's per-RT blend state.<br>
<br>
In particular, when pipe_rt_blend_state[i].blend_e<wbr>nabled is true,<br>
we have to get the src/dst blend terms from pipe_rt_blend_state[i],<br>
not [0] as before.<br>
<br>
We now have to scan the blend targets to find the first one that's<br>
enabled (if any).  We have to use the index of that target for getting<br>
the src/dst blend terms.  And note that we have to set identical blend<br>
terms for all targets.<br>
<br>
This fixes the Piglit fbo-drawbuffers2-blend test.  VMware bug 2063493.<br>
---<br>
  src/gallium/drivers/svga/svga_<wbr>pipe_blend.c | 35 ++++++++++++++++++++----------<br>
  1 file changed, 24 insertions(+), 11 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/svga/svg<wbr>a_pipe_blend.c b/src/gallium/drivers/svga/svg<wbr>a_pipe_blend.c<br>
index 04855fa..6bb9d94 100644<br>
--- a/src/gallium/drivers/svga/svg<wbr>a_pipe_blend.c<br>
+++ b/src/gallium/drivers/svga/svg<wbr>a_pipe_blend.c<br>
@@ -148,6 +148,17 @@ svga_create_blend_state(struct pipe_context *pipe,<br>
     if (!blend)<br>
        return NULL;<br>
<br>
+   /* Find index of first target with blending enabled.  -1 means blending<br>
+    * is not enabled at all.<br>
+    */<br>
+   int first_enabled = -1;<br>
+   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {<br>
+      if (templ->rt[i].blend_enable) {<br>
+         first_enabled = i;<br>
+         break;<br>
+      }<br>
+   }<br>
+<br>
     /* Fill in the per-rendertarget blend state.  We currently only<br>
      * support independent blend enable and colormask per render target.<br>
      */<br>
@@ -260,24 +271,26 @@ svga_create_blend_state(struct pipe_context *pipe,<br>
           }<br>
        }<br>
        else {<br>
-         /* Note: the vgpu10 device does not yet support independent<br>
-          * blend terms per render target.  Target[0] always specifies the<br>
-          * blending terms.<br>
+         /* Note: the vgpu10 device does not yet support independent blend<br>
+          * terms per render target.  When blending is enabled, the blend<br>
+          * terms must match for all targets.<br>
            */<br>
-         if (templ->independent_blend_enab<wbr>le || templ->rt[0].blend_enable) {<br>
-            /* always use the 0th target's blending terms for now */<br>
+         if (first_enabled >= 0) {<br>
+            /* use first enabled target's blending terms */<br>
+            const struct pipe_rt_blend_state *rt = &templ->rt[first_enabled];<br>
+<br>
              blend->rt[i].srcblend =<br>
-               svga_translate_blend_factor(s<wbr>vga, templ->rt[0].rgb_src_factor);<br>
+               svga_translate_blend_factor(s<wbr>vga, rt->rgb_src_factor);<br>
              blend->rt[i].dstblend =<br>
-               svga_translate_blend_factor(s<wbr>vga, templ->rt[0].rgb_dst_factor);<br>
+               svga_translate_blend_factor(s<wbr>vga, rt->rgb_dst_factor);<br>
              blend->rt[i].blendeq =<br>
-               svga_translate_blend_func(tem<wbr>pl->rt[0].rgb_func);<br>
+               svga_translate_blend_func(rt-<wbr>>rgb_func);<br>
              blend->rt[i].srcblend_alpha =<br>
-               svga_translate_blend_factor(s<wbr>vga, templ->rt[0].alpha_src_factor)<wbr>;<br>
+               svga_translate_blend_factor(s<wbr>vga, rt->alpha_src_factor);<br>
              blend->rt[i].dstblend_alpha =<br>
-               svga_translate_blend_factor(s<wbr>vga, templ->rt[0].alpha_dst_factor)<wbr>;<br>
+               svga_translate_blend_factor(s<wbr>vga, rt->alpha_dst_factor);<br>
              blend->rt[i].blendeq_alpha =<br>
-               svga_translate_blend_func(tem<wbr>pl->rt[0].alpha_func);<br>
+               svga_translate_blend_func(rt-<wbr>>alpha_func);<br>
<br>
              if (blend->rt[i].srcblend_alpha != blend->rt[i].srcblend ||<br>
                  blend->rt[i].dstblend_alpha != blend->rt[i].dstblend ||<br>
--<br>
2.7.4<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=DwIBaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=72mZC9F35bZXJK1nvsVtzu5aKILU-K1dy8FEsy2WnfU&s=wzSB-UOk_lz1oaznhV3p-XBGArDxVYuIH4ThYpac5Us&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=https-3A__lists.f<wbr>reedesktop.org_mailman_listinf<wbr>o_mesa-2Ddev&d=DwIBaQ&c=<wbr>uilaK90D4TOVoH58JNXRgQ&r=Ie7_e<wbr>ncNUsqxbSRbqbNgofw0ITcfE8JKfaU<wbr>jIQhncGA&m=72mZC9F35bZXJK1nvsV<wbr>tzu5aKILU-K1dy8FEsy2WnfU&s=<wbr>wzSB-UOk_lz1oaznhV3p-XBGArDxVY<wbr>uIH4ThYpac5Us&e=</a><br>
</blockquote></blockquote>
<br>
</blockquote></div></div>