st/nine: Put ff data in a separate structure
authorAxel Davy <axel.davy@ens.fr>
Wed, 19 Oct 2016 21:06:05 +0000 (23:06 +0200)
committerAxel Davy <axel.davy@ens.fr>
Tue, 20 Dec 2016 22:44:22 +0000 (23:44 +0100)
And make nine_state_access_transform take this
new structure as input.
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@ens.fr>
src/gallium/state_trackers/nine/device9.c
src/gallium/state_trackers/nine/nine_ff.c
src/gallium/state_trackers/nine/nine_state.c
src/gallium/state_trackers/nine/nine_state.h
src/gallium/state_trackers/nine/stateblock9.c

index d8ff4cb56caf261c8d4ac0f9ff1d089f2b0b4ea2..2587ad1d7aeadb654520402da82eefba8266233b 100644 (file)
@@ -1975,7 +1975,7 @@ NineDevice9_SetTransform( struct NineDevice9 *This,
                           const D3DMATRIX *pMatrix )
 {
     struct nine_state *state = This->update;
-    D3DMATRIX *M = nine_state_access_transform(state, State, TRUE);
+    D3DMATRIX *M = nine_state_access_transform(&state->ff, State, TRUE);
 
     DBG("This=%p State=%d pMatrix=%p\n", This, State, pMatrix);
 
@@ -1993,7 +1993,7 @@ NineDevice9_GetTransform( struct NineDevice9 *This,
                           D3DTRANSFORMSTATETYPE State,
                           D3DMATRIX *pMatrix )
 {
-    D3DMATRIX *M = nine_state_access_transform(&This->state, State, FALSE);
+    D3DMATRIX *M = nine_state_access_transform(&This->state.ff, State, FALSE);
     user_assert(M, D3DERR_INVALIDCALL);
     *pMatrix = *M;
     return D3D_OK;
@@ -2006,7 +2006,7 @@ NineDevice9_MultiplyTransform( struct NineDevice9 *This,
 {
     struct nine_state *state = This->update;
     D3DMATRIX T;
-    D3DMATRIX *M = nine_state_access_transform(state, State, TRUE);
+    D3DMATRIX *M = nine_state_access_transform(&state->ff, State, TRUE);
 
     DBG("This=%p State=%d pMatrix=%p\n", This, State, pMatrix);
 
index bfabf183a17b0d2761c3fcf1fe18dc93c5f10782..0c92bd13e8b67be9fc9d1bd30c6aea2b870cd6b2 100644 (file)
@@ -1708,7 +1708,7 @@ nine_ff_get_vs(struct NineDevice9 *device)
     return vs;
 }
 
-#define GET_D3DTS(n) nine_state_access_transform(state, D3DTS_##n, FALSE)
+#define GET_D3DTS(n) nine_state_access_transform(&state->ff, D3DTS_##n, FALSE)
 #define IS_D3DTS_DIRTY(s,n) ((s)->ff.changed.transform[(D3DTS_##n) / 32] & (1 << ((D3DTS_##n) % 32)))
 
 static struct NinePixelShader9 *
@@ -1977,7 +1977,7 @@ nine_ff_load_tex_matrices(struct NineDevice9 *device)
         return;
     for (s = 0; s < 8; ++s) {
         if (IS_D3DTS_DIRTY(state, TEXTURE0 + s))
-            nine_d3d_matrix_transpose(&M[32 + s], nine_state_access_transform(state, D3DTS_TEXTURE0 + s, FALSE));
+            nine_d3d_matrix_transpose(&M[32 + s], nine_state_access_transform(&state->ff, D3DTS_TEXTURE0 + s, FALSE));
     }
 }
 
index c99c37347501c7811f4a17d913b9f12c74f298d0..47fe31d391c4c07d0ef9f3c28569114a1aa8048e 100644 (file)
@@ -2783,7 +2783,7 @@ const uint32_t nine_render_state_group[NINED3DRS_LAST + 1] =
 /* Misc */
 
 D3DMATRIX *
-nine_state_access_transform(struct nine_state *state, D3DTRANSFORMSTATETYPE t,
+nine_state_access_transform(struct nine_ff_state *ff_state, D3DTRANSFORMSTATETYPE t,
                             boolean alloc)
 {
     static D3DMATRIX Identity = { .m[0] = { 1, 0, 0, 0 },
@@ -2810,20 +2810,20 @@ nine_state_access_transform(struct nine_state *state, D3DTRANSFORMSTATETYPE t,
         break;
     }
 
-    if (index >= state->ff.num_transforms) {
+    if (index >= ff_state->num_transforms) {
         unsigned N = index + 1;
-        unsigned n = state->ff.num_transforms;
+        unsigned n = ff_state->num_transforms;
 
         if (!alloc)
             return &Identity;
-        state->ff.transform = REALLOC(state->ff.transform,
+        ff_state->transform = REALLOC(ff_state->transform,
                                       n * sizeof(D3DMATRIX),
                                       N * sizeof(D3DMATRIX));
         for (; n < N; ++n)
-            state->ff.transform[n] = Identity;
-        state->ff.num_transforms = N;
+            ff_state->transform[n] = Identity;
+        ff_state->num_transforms = N;
     }
-    return &state->ff.transform[index];
+    return &ff_state->transform[index];
 }
 
 #define D3DRS_TO_STRING_CASE(n) case D3DRS_##n: return "D3DRS_"#n
index a6f20ab5dd32ae12ad9646ca942a557c10eb2623..d73c40681f85046c724d636e9735d06535fc4311 100644 (file)
 #define NINE_PS_SAMPLERS_MASK 0x00ffff
 #define NINE_VS_SAMPLERS_MASK 0x1e0000
 
+struct nine_ff_state {
+    struct {
+        uint32_t tex_stage[NINE_MAX_TEXTURE_STAGES][(NINED3DTSS_COUNT + 31) / 32];
+        uint32_t transform[(NINED3DTS_COUNT + 31) / 32];
+    } changed;
+
+    D3DMATRIX *transform; /* access only via nine_state_access_transform */
+    unsigned num_transforms;
+
+    /* XXX: Do state blocks just change the set of active lights or do we
+     * have to store which lights have been disabled, too ?
+     */
+    D3DLIGHT9 *light;
+    uint16_t active_light[NINE_MAX_LIGHTS_ACTIVE]; /* 8 */
+    unsigned num_lights;
+    unsigned num_lights_active;
+
+    D3DMATERIAL9 material;
+
+    DWORD tex_stage[NINE_MAX_TEXTURE_STAGES][NINED3DTSS_COUNT];
+};
+
 struct nine_state
 {
     struct {
@@ -192,27 +214,7 @@ struct nine_state
 
     DWORD samp_advertised[NINE_MAX_SAMPLERS][D3DSAMP_COUNT];
 
-    struct {
-        struct {
-            uint32_t tex_stage[NINE_MAX_TEXTURE_STAGES][(NINED3DTSS_COUNT + 31) / 32];
-            uint32_t transform[(NINED3DTS_COUNT + 31) / 32];
-        } changed;
-
-        D3DMATRIX *transform; /* access only via nine_state_access_transform */
-        unsigned num_transforms;
-
-        /* XXX: Do state blocks just change the set of active lights or do we
-         * have to store which lights have been disabled, too ?
-         */
-        D3DLIGHT9 *light;
-        uint16_t active_light[NINE_MAX_LIGHTS_ACTIVE]; /* 8 */
-        unsigned num_lights;
-        unsigned num_lights_active;
-
-        D3DMATERIAL9 material;
-
-        DWORD tex_stage[NINE_MAX_TEXTURE_STAGES][NINED3DTSS_COUNT];
-    } ff;
+    struct nine_ff_state ff;
 };
 
 struct nine_context {
@@ -457,7 +459,7 @@ void nine_state_destroy_sw(struct NineDevice9 *device);
  * Therefore, do not modify if you set alloc to FALSE !
  */
 D3DMATRIX *
-nine_state_access_transform(struct nine_state *, D3DTRANSFORMSTATETYPE,
+nine_state_access_transform(struct nine_ff_state *, D3DTRANSFORMSTATETYPE,
                             boolean alloc);
 
 const char *nine_d3drs_to_string(DWORD State);
index 0aa69be16b95d426b3c41ac73afe7689ab265e2f..cc802d4af2805509356a1226c37b161e1e13def1 100644 (file)
@@ -316,9 +316,9 @@ nine_state_copy_common(struct NineDevice9 *device,
             for (s = i * 32; s < (i * 32 + 32); ++s) {
                 if (!(mask->ff.changed.transform[i] & (1 << (s % 32))))
                     continue;
-                *nine_state_access_transform(dst, s, TRUE) =
+                *nine_state_access_transform(&dst->ff, s, TRUE) =
                     *nine_state_access_transform( /* const because !alloc */
-                        (struct nine_state *)src, s, FALSE);
+                        (struct nine_ff_state *)&src->ff, s, FALSE);
             }
             if (apply)
                 dst->ff.changed.transform[i] |= mask->ff.changed.transform[i];