[Mesa-dev] [PATCH 34/84] st/nine: Move Managed Pool handling out of nine_context

Axel Davy axel.davy at ens.fr
Wed Dec 7 22:55:07 UTC 2016


Part of the refactor to move all gallium calls to
nine_state.c, and have all internal states required
for those calls in nine_context.

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

diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 5a590d2..c5b6e57 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -2706,6 +2706,55 @@ NineDevice9_GetNPatchMode( struct NineDevice9 *This )
     STUB(0);
 }
 
+/* TODO: only go through dirty textures */
+static void
+validate_textures(struct NineDevice9 *device)
+{
+    struct NineBaseTexture9 *tex, *ptr;
+    LIST_FOR_EACH_ENTRY_SAFE(tex, ptr, &device->update_textures, list) {
+        list_delinit(&tex->list);
+        NineBaseTexture9_Validate(tex);
+    }
+}
+
+static void
+update_managed_buffers(struct NineDevice9 *device)
+{
+    struct NineBuffer9 *buf, *ptr;
+    LIST_FOR_EACH_ENTRY_SAFE(buf, ptr, &device->update_buffers, managed.list) {
+        list_delinit(&buf->managed.list);
+        NineBuffer9_Upload(buf);
+    }
+}
+
+static void
+NineBeforeDraw( struct NineDevice9 *This )
+{
+    /* Upload Managed dirty content */
+    validate_textures(This); /* may clobber state */
+    update_managed_buffers(This);
+}
+
+static void
+NineAfterDraw( struct NineDevice9 *This )
+{
+    unsigned i;
+    struct nine_state *state = &This->state;
+    unsigned ps_mask = state->ps ? state->ps->rt_mask : 1;
+
+    /* Flag render-targets with autogenmipmap for mipmap regeneration */
+    for (i = 0; i < This->caps.NumSimultaneousRTs; ++i) {
+        struct NineSurface9 *rt = state->rt[i];
+
+        if (rt && rt->desc.Format != D3DFMT_NULL && (ps_mask & (1 << i)) &&
+            rt->desc.Usage & D3DUSAGE_AUTOGENMIPMAP) {
+            assert(rt->texture == D3DRTYPE_TEXTURE ||
+                   rt->texture == D3DRTYPE_CUBETEXTURE);
+            NineBaseTexture9(rt->base.base.container)->dirty_mip = TRUE;
+        }
+    }
+}
+
 HRESULT NINE_WINAPI
 NineDevice9_DrawPrimitive( struct NineDevice9 *This,
                            D3DPRIMITIVETYPE PrimitiveType,
@@ -2715,7 +2764,9 @@ NineDevice9_DrawPrimitive( struct NineDevice9 *This,
     DBG("iface %p, PrimitiveType %u, StartVertex %u, PrimitiveCount %u\n",
         This, PrimitiveType, StartVertex, PrimitiveCount);
 
+    NineBeforeDraw(This);
     nine_context_draw_primitive(This, PrimitiveType, StartVertex, PrimitiveCount);
+    NineAfterDraw(This);
 
     return D3D_OK;
 }
@@ -2737,9 +2788,11 @@ NineDevice9_DrawIndexedPrimitive( struct NineDevice9 *This,
     user_assert(This->state.idxbuf, D3DERR_INVALIDCALL);
     user_assert(This->state.vdecl, D3DERR_INVALIDCALL);
 
+    NineBeforeDraw(This);
     nine_context_draw_indexed_primitive(This, PrimitiveType, BaseVertexIndex,
                                         MinVertexIndex, NumVertices, StartIndex,
                                         PrimitiveCount);
+    NineAfterDraw(This);
 
     return D3D_OK;
 }
@@ -2778,7 +2831,9 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This,
         vtxbuf.user_buffer = NULL;
     }
 
+    NineBeforeDraw(This);
     nine_context_draw_primitive_from_vtxbuf(This, PrimitiveType, PrimitiveCount, &vtxbuf);
+    NineAfterDraw(This);
 
     NineDevice9_PauseRecording(This);
     NineDevice9_SetStreamSource(This, 0, NULL, 0, 0);
@@ -2850,12 +2905,14 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
         ibuf.user_buffer = NULL;
     }
 
+    NineBeforeDraw(This);
     nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(This, PrimitiveType,
                                                            MinVertexIndex,
                                                            NumVertices,
                                                            PrimitiveCount,
                                                            &vbuf,
                                                            &ibuf);
+    NineAfterDraw(This);
 
     NineDevice9_PauseRecording(This);
     NineDevice9_SetIndices(This, NULL);
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index b832db4..b81675c 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -455,12 +455,6 @@ update_framebuffer(struct NineDevice9 *device, bool is_clear)
             fb->cbufs[i] = NineSurface9_GetSurface(rt, sRGB);
             context->rt_mask |= 1 << i;
             fb->nr_cbufs = i + 1;
-
-            if (unlikely(rt->desc.Usage & D3DUSAGE_AUTOGENMIPMAP)) {
-                assert(rt->texture == D3DRTYPE_TEXTURE ||
-                       rt->texture == D3DRTYPE_CUBETEXTURE);
-                NineBaseTexture9(rt->base.base.container)->dirty_mip = TRUE;
-            }
         } else {
             /* Color outputs must match RT slot,
              * drivers will have to handle NULL entries for GL, too.
@@ -931,28 +925,6 @@ commit_ps(struct NineDevice9 *device)
     NINE_STATE_STENCIL_REF | \
     NINE_STATE_SAMPLE_MASK)
 
-
-/* TODO: only go through dirty textures */
-static void
-validate_textures(struct NineDevice9 *device)
-{
-    struct NineBaseTexture9 *tex, *ptr;
-    LIST_FOR_EACH_ENTRY_SAFE(tex, ptr, &device->update_textures, list) {
-        list_delinit(&tex->list);
-        NineBaseTexture9_Validate(tex);
-    }
-}
-
-static void
-update_managed_buffers(struct NineDevice9 *device)
-{
-    struct NineBuffer9 *buf, *ptr;
-    LIST_FOR_EACH_ENTRY_SAFE(buf, ptr, &device->update_buffers, managed.list) {
-        list_delinit(&buf->managed.list);
-        NineBuffer9_Upload(buf);
-    }
-}
-
 static void
 nine_update_state(struct NineDevice9 *device)
 {
@@ -968,8 +940,6 @@ nine_update_state(struct NineDevice9 *device)
      * into update_textures. Except, we also need to re-validate textures that
      * may be dirty anyway, even if no texture bindings changed.
      */
-    validate_textures(device); /* may clobber state */
-    update_managed_buffers(device);
 
     /* ff_update may change VS/PS dirty bits */
     if (unlikely(!context->programmable_vs || !context->ps))
@@ -1842,8 +1812,6 @@ nine_update_state_framebuffer_clear(struct NineDevice9 *device)
 {
     struct nine_context *context = &device->context;
 
-    validate_textures(device);
-
     if (context->changed.group & NINE_STATE_FB)
         update_framebuffer(device, TRUE);
 }
-- 
2.10.2



More information about the mesa-dev mailing list