[Mesa-dev] [PATCH 24/84] st/nine: Back User Clip Planes to nine_context

Axel Davy axel.davy at ens.fr
Wed Dec 7 22:54:57 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    |  5 ++++-
 src/gallium/state_trackers/nine/nine_state.c | 30 +++++++++++++++++++++++-----
 src/gallium/state_trackers/nine/nine_state.h | 10 +++++++++-
 3 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 2e82689..f3616c5 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -2193,7 +2193,10 @@ NineDevice9_SetClipPlane( struct NineDevice9 *This,
     user_assert(Index < PIPE_MAX_CLIP_PLANES, D3DERR_INVALIDCALL);
 
     memcpy(&state->clip.ucp[Index][0], pPlane, sizeof(state->clip.ucp[0]));
-    state->changed.ucp |= 1 << Index;
+    if (unlikely(This->is_recording))
+        state->changed.ucp |= 1 << Index;
+    else
+        nine_context_set_clip_plane(This, Index, pPlane);
 
     return D3D_OK;
 }
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index de22ebd..b03067b 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -1026,9 +1026,9 @@ nine_update_state(struct NineDevice9 *device)
 
     context->commit = 0;
 
-    if (unlikely(state->changed.ucp)) {
-        pipe->set_clip_state(pipe, &state->clip);
-        state->changed.ucp = 0;
+    if (unlikely(context->changed.ucp)) {
+        pipe->set_clip_state(pipe, &context->clip);
+        context->changed.ucp = FALSE;
     }
 
     if (unlikely(group & NINE_STATE_RARE)) {
@@ -1616,6 +1616,17 @@ nine_context_set_texture_stage_state(struct NineDevice9 *device,
 }
 
 void
+nine_context_set_clip_plane(struct NineDevice9 *device,
+                            DWORD Index,
+                            const float *pPlane)
+{
+    struct nine_context *context = &device->context;
+
+    memcpy(&context->clip.ucp[Index][0], pPlane, sizeof(context->clip.ucp[0]));
+    context->changed.ucp = TRUE;
+}
+
+void
 nine_context_apply_stateblock(struct NineDevice9 *device,
                               const struct nine_state *src)
 {
@@ -1777,6 +1788,15 @@ nine_context_apply_stateblock(struct NineDevice9 *device,
     if (src->changed.group & NINE_STATE_SCISSOR)
         context->scissor = src->scissor;
 
+    /* User Clip Planes */
+    if (src->changed.ucp) {
+        for (i = 0; i < PIPE_MAX_CLIP_PLANES; ++i)
+            if (src->changed.ucp & (1 << i))
+                memcpy(context->clip.ucp[i],
+                       src->clip.ucp[i], sizeof(src->clip.ucp[0]));
+        context->changed.ucp = TRUE;
+    }
+
     if (!(src->changed.group & NINE_STATE_FF))
         return;
 
@@ -2268,7 +2288,7 @@ void nine_state_restore_non_cso(struct NineDevice9 *device)
 
     state->changed.group = NINE_STATE_ALL;
     context->changed.vtxbuf = (1ULL << device->caps.MaxStreams) - 1;
-    state->changed.ucp = (1 << PIPE_MAX_CLIP_PLANES) - 1;
+    context->changed.ucp = TRUE;
     context->commit |= NINE_STATE_COMMIT_CONST_VS | NINE_STATE_COMMIT_CONST_PS;
 }
 
@@ -2330,7 +2350,7 @@ nine_state_set_defaults(struct NineDevice9 *device, const D3DCAPS9 *caps,
      */
     state->changed.group = NINE_STATE_ALL;
     context->changed.vtxbuf = (1ULL << device->caps.MaxStreams) - 1;
-    state->changed.ucp = (1 << PIPE_MAX_CLIP_PLANES) - 1;
+    context->changed.ucp = TRUE;
 
     context->ff.changed.transform[0] = ~0;
     context->ff.changed.transform[D3DTS_WORLD / 32] |= 1 << (D3DTS_WORLD % 32);
diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h
index acd9ac5..dd3331c 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -174,7 +174,7 @@ struct nine_state
         uint16_t ps_const_i; /* NINE_MAX_CONST_I == 16 */
         struct nine_range *vs_const_b; /* stateblocks only */
         uint16_t ps_const_b; /* NINE_MAX_CONST_B == 16 */
-        uint8_t ucp;
+        uint8_t ucp; /* stateblocks only */
     } changed;
 
     struct NineSurface9 *rt[NINE_MAX_SIMULTANEOUS_RENDERTARGETS];
@@ -227,6 +227,7 @@ struct nine_context {
         BOOL ps_const_f;
         BOOL ps_const_i;
         BOOL ps_const_b;
+        BOOL ucp;
     } changed;
 
     uint32_t bumpmap_vars[6 * NINE_MAX_TEXTURE_STAGES];
@@ -268,6 +269,8 @@ struct nine_context {
 
     struct pipe_index_buffer idxbuf;
 
+    struct pipe_clip_state clip;
+
     DWORD rs[NINED3DRS_COUNT];
 
     struct NineBaseTexture9 *texture[NINE_MAX_SAMPLERS];
@@ -439,6 +442,11 @@ nine_context_set_depth_stencil(struct NineDevice9 *device,
                                struct NineSurface9 *ds);
 
 void
+nine_context_set_clip_plane(struct NineDevice9 *device,
+                            DWORD Index,
+                            const float *pPlane);
+
+void
 nine_context_apply_stateblock(struct NineDevice9 *device,
                               const struct nine_state *src);
 
-- 
2.10.2



More information about the mesa-dev mailing list