st/nine: Fix update_framebuffer binding cbufs the pixel shader wouldn't render to
authorAxel Davy <axel.davy@ens.fr>
Fri, 23 Jan 2015 22:20:17 +0000 (23:20 +0100)
committerAxel Davy <axel.davy@ens.fr>
Thu, 5 Feb 2015 23:07:19 +0000 (00:07 +0100)
Reviewed-by: Tiziano Bacocco <tizbac2@gmail.com>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/device9.c
src/gallium/state_trackers/nine/nine_state.c

index 5eb9d54f45796d489c13cf5125c0c8133421409b..25e1444f6b4e57cdb51e55c4dcf64546210f0725 100644 (file)
@@ -3297,6 +3297,8 @@ NineDevice9_SetPixelShader( struct NineDevice9 *This,
                             IDirect3DPixelShader9 *pShader )
 {
     struct nine_state *state = This->update;
+    unsigned old_mask = state->ps ? state->ps->rt_mask : 1;
+    unsigned mask;
 
     DBG("This=%p pShader=%p\n", This, pShader);
 
@@ -3304,6 +3306,12 @@ NineDevice9_SetPixelShader( struct NineDevice9 *This,
 
     state->changed.group |= NINE_STATE_PS;
 
+    mask = state->ps ? state->ps->rt_mask : 1;
+    /* We need to update cbufs if the pixel shader would
+     * write to different render targets */
+    if (mask != old_mask)
+        state->changed.group |= NINE_STATE_FB;
+
     return D3D_OK;
 }
 
index 02fef9a381da3c4146a6f225e93ac7d9d38a9310..86a6ca8ee40fa3af4d76263ef5e6c893965eaf4b 100644 (file)
@@ -48,7 +48,7 @@ update_framebuffer(struct NineDevice9 *device)
     unsigned w = rt0->desc.Width;
     unsigned h = rt0->desc.Height;
     D3DMULTISAMPLE_TYPE nr_samples = rt0->desc.MultiSampleType;
-
+    unsigned mask = state->ps ? state->ps->rt_mask : 1;
     const int sRGB = state->rs[D3DRS_SRGBWRITEENABLE] ? 1 : 0;
 
     DBG("\n");
@@ -75,8 +75,9 @@ update_framebuffer(struct NineDevice9 *device)
     for (i = 0; i < device->caps.NumSimultaneousRTs; ++i) {
         struct NineSurface9 *rt = state->rt[i];
 
-        if (rt && rt->desc.Format != D3DFMT_NULL && rt->desc.Width == w &&
-            rt->desc.Height == h && rt->desc.MultiSampleType == nr_samples) {
+        if (rt && rt->desc.Format != D3DFMT_NULL && (mask & (1 << i)) &&
+            rt->desc.Width == w && rt->desc.Height == h &&
+            rt->desc.MultiSampleType == nr_samples) {
             fb->cbufs[i] = NineSurface9_GetSurface(rt, sRGB);
             state->rt_mask |= 1 << i;
             fb->nr_cbufs = i + 1;
@@ -127,12 +128,6 @@ update_framebuffer(struct NineDevice9 *device)
         }
     }
 
-#ifdef DEBUG
-    if (state->rt_mask & (state->ps ? ~state->ps->rt_mask : 0))
-        WARN_ONCE("FIXME: writing undefined values to cbufs 0x%x\n",
-                  state->rt_mask & ~state->ps->rt_mask);
-#endif
-
     return state->changed.group;
 }
 
@@ -329,9 +324,6 @@ update_ps(struct NineDevice9 *device)
         for (s = 0; mask; ++s, mask >>= 1)
             if ((mask & 1) && !(device->state.texture[NINE_SAMPLER_PS(s)]))
                 WARN_ONCE("FIXME: unbound sampler should return alpha=1\n");
-        if (device->state.rt_mask & ~ps->rt_mask)
-            WARN_ONCE("FIXME: writing undefined values to cbufs 0x%x\n",
-                device->state.rt_mask & ~ps->rt_mask);
     }
 #endif
     return 0;