[Mesa-dev] [PATCH 38/43] st/nine: Fix update_framebuffer binding cbufs the pixel shader wouldn't render to

Axel Davy axel.davy at ens.fr
Fri Jan 30 12:34:37 PST 2015


Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
 src/gallium/state_trackers/nine/device9.c    |  8 ++++++++
 src/gallium/state_trackers/nine/nine_state.c | 16 ++++------------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 5eb9d54..25e1444 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -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;
 }
 
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index 02fef9a..86a6ca8 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -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;
-- 
2.1.0



More information about the mesa-dev mailing list