st/nine: Never update device changed.* fields
authorAxel Davy <davyaxel0@gmail.com>
Sat, 13 Oct 2018 20:45:16 +0000 (22:45 +0200)
committerAxel Davy <davyaxel0@gmail.com>
Fri, 26 Oct 2018 20:16:16 +0000 (22:16 +0200)
The device state changed.* field are never used.
These fields are used only for stateblocks.

Avoid setting them at all for clarity.

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
src/gallium/state_trackers/nine/device9.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 25a8172b3fd9a1c954b60254f6b59575babbf668..461b212995b3b715fb0dd7d129b7070bddf8306e 100644 (file)
@@ -2178,9 +2178,11 @@ NineDevice9_LightEnable( struct NineDevice9 *This,
         NineDevice9_SetLight(This, Index, &light);
     }
 
-    nine_state_light_enable(&state->ff, &state->changed.group, Index, Enable);
+    nine_state_light_enable(&state->ff, Index, Enable);
     if (likely(!This->is_recording))
         nine_context_light_enable(This, Index, Enable);
+    else
+        state->changed.group |= NINE_STATE_FF_LIGHTING;
 
     return D3D_OK;
 }
index 569a1b472924842fe552cc90158c6ea6d04f6fd9..74aaf57a549f9d62d88129fe94d78ff8a707eb85 100644 (file)
@@ -1827,7 +1827,8 @@ CSMT_ITEM_NO_WAIT(nine_context_light_enable,
 {
     struct nine_context *context = &device->context;
 
-    nine_state_light_enable(&context->ff, &context->changed.group, Index, Enable);
+    nine_state_light_enable(&context->ff, Index, Enable);
+    context->changed.group |= NINE_STATE_FF_LIGHTING;
 }
 
 CSMT_ITEM_NO_WAIT(nine_context_set_texture_stage_state,
@@ -3480,7 +3481,7 @@ nine_state_set_light(struct nine_ff_state *ff_state, DWORD Index,
 }
 
 HRESULT
-nine_state_light_enable(struct nine_ff_state *ff_state, uint32_t *change_group,
+nine_state_light_enable(struct nine_ff_state *ff_state,
                         DWORD Index, BOOL Enable)
 {
     unsigned i;
@@ -3509,8 +3510,6 @@ nine_state_light_enable(struct nine_ff_state *ff_state, uint32_t *change_group,
             ff_state->active_light[i] = ff_state->active_light[i + 1];
     }
 
-    *change_group |= NINE_STATE_FF_LIGHTING;
-
     return D3D_OK;
 }
 
index 55ccfd0f519f1f07229de0fbdc69978a3f2f798a..51e5e3265273f432e2914d91485516eb5780167d 100644 (file)
@@ -623,7 +623,7 @@ HRESULT
 nine_state_set_light(struct nine_ff_state *, DWORD, const D3DLIGHT9 *);
 
 HRESULT
-nine_state_light_enable(struct nine_ff_state *, uint32_t *,
+nine_state_light_enable(struct nine_ff_state *,
                         DWORD, BOOL);
 
 const char *nine_d3drs_to_string(DWORD State);
index 7b2deae7f9bcd319d66e3595d01b1c8f7f39e5e0..50ed70aec3a3bae2df2710b919674b4d02829145 100644 (file)
@@ -134,8 +134,15 @@ nine_state_copy_common(struct NineDevice9 *device,
     unsigned i, s;
 
     DBG("apply:%d changed.group: %x\n", (int)apply, (int)mask->changed.group );
-    if (apply)
-       dst->changed.group |= mask->changed.group;
+
+    /* device changed.* are unused.
+     * Instead nine_context_apply_stateblock is used and will
+     * internally set the right context->changed fields.
+     * Uncomment these only if we want to apply a stateblock onto a stateblock.
+     *
+     * if (apply)
+     *     dst->changed.group |= mask->changed.group;
+     */
 
     if (mask->changed.group & NINE_STATE_VIEWPORT)
         dst->viewport = src->viewport;
@@ -202,10 +209,10 @@ nine_state_copy_common(struct NineDevice9 *device,
     /* Render states.
      * TODO: Maybe build a list ?
      */
-    for (i = 0; i < ARRAY_SIZE(dst->changed.rs); ++i) {
+    for (i = 0; i < ARRAY_SIZE(mask->changed.rs); ++i) {
         uint32_t m = mask->changed.rs[i];
-        if (apply)
-            dst->changed.rs[i] |= m;
+        /* if (apply)
+         *     dst->changed.rs[i] |= m; */
         while (m) {
             const int r = ffs(m) - 1;
             m &= ~(1 << r);
@@ -222,8 +229,8 @@ nine_state_copy_common(struct NineDevice9 *device,
             if (mask->changed.ucp & (1 << i))
                 memcpy(dst->clip.ucp[i],
                        src->clip.ucp[i], sizeof(src->clip.ucp[0]));
-        if (apply)
-           dst->changed.ucp |= mask->changed.ucp;
+        /* if (apply)
+         *    dst->changed.ucp |= mask->changed.ucp;*/
     }
 
     /* Sampler state. */
@@ -240,8 +247,8 @@ nine_state_copy_common(struct NineDevice9 *device,
                     dst->samp_advertised[s][i] = src->samp_advertised[s][i];
                 }
             }
-            if (apply)
-                dst->changed.sampler[s] |= mask->changed.sampler[s];
+            /* if (apply)
+             *     dst->changed.sampler[s] |= mask->changed.sampler[s];*/
         }
     }
 
@@ -270,10 +277,11 @@ nine_state_copy_common(struct NineDevice9 *device,
             if (mask->changed.stream_freq & (1 << i))
                 dst->stream_freq[i] = src->stream_freq[i];
         }
-        if (apply) {
-            dst->changed.vtxbuf |= mask->changed.vtxbuf;
-            dst->changed.stream_freq |= mask->changed.stream_freq;
-        }
+        /*
+         * if (apply) {
+         *     dst->changed.vtxbuf |= mask->changed.vtxbuf;
+         *     dst->changed.stream_freq |= mask->changed.stream_freq;
+         * }*/
     }
 
     /* Textures */
@@ -298,13 +306,14 @@ nine_state_copy_common(struct NineDevice9 *device,
             for (i = 0; i < NINED3DTSS_COUNT; ++i)
                 if (mask->ff.changed.tex_stage[s][i / 32] & (1 << (i % 32)))
                     dst->ff.tex_stage[s][i] = src->ff.tex_stage[s][i];
-            if (apply) {
-                /* TODO: it's 32 exactly, just offset by 1 as 0 is unused */
-                dst->ff.changed.tex_stage[s][0] |=
-                    mask->ff.changed.tex_stage[s][0];
-                dst->ff.changed.tex_stage[s][1] |=
-                    mask->ff.changed.tex_stage[s][1];
-            }
+            /*
+             * if (apply) {
+             *    TODO: it's 32 exactly, just offset by 1 as 0 is unused
+             *    dst->ff.changed.tex_stage[s][0] |=
+             *        mask->ff.changed.tex_stage[s][0];
+             *    dst->ff.changed.tex_stage[s][1] |=
+             *        mask->ff.changed.tex_stage[s][1];
+             * }*/
         }
     }
     if (mask->changed.group & NINE_STATE_FF_LIGHTING) {
@@ -359,8 +368,8 @@ nine_state_copy_common(struct NineDevice9 *device,
                 *nine_state_access_transform(&dst->ff, s, TRUE) =
                     *nine_state_access_transform(&src->ff, s, FALSE);
             }
-            if (apply)
-                dst->ff.changed.transform[i] |= mask->ff.changed.transform[i];
+            /* if (apply)
+             *     dst->ff.changed.transform[i] |= mask->ff.changed.transform[i];*/
         }
     }
 }
@@ -376,8 +385,9 @@ nine_state_copy_common_all(struct NineDevice9 *device,
 {
     unsigned i;
 
-    if (apply)
-       dst->changed.group |= src->changed.group;
+    /* if (apply)
+     *     dst->changed.group |= src->changed.group;
+     */
 
     dst->viewport = src->viewport;
     dst->scissor = src->scissor;
@@ -411,20 +421,20 @@ nine_state_copy_common_all(struct NineDevice9 *device,
 
     /* Render states. */
     memcpy(dst->rs_advertised, src->rs_advertised, sizeof(dst->rs_advertised));
-    if (apply)
-        memcpy(dst->changed.rs, src->changed.rs, sizeof(dst->changed.rs));
+    /* if (apply)
+     *     memcpy(dst->changed.rs, src->changed.rs, sizeof(dst->changed.rs));*/
 
 
     /* Clip planes. */
     memcpy(&dst->clip, &src->clip, sizeof(dst->clip));
-    if (apply)
-        dst->changed.ucp = src->changed.ucp;
+    /* if (apply)
+     *     dst->changed.ucp = src->changed.ucp;*/
 
     /* Sampler state. */
     memcpy(dst->samp_advertised, src->samp_advertised, sizeof(dst->samp_advertised));
-    if (apply)
-        memcpy(dst->changed.sampler,
-               src->changed.sampler, sizeof(dst->changed.sampler));
+    /* if (apply)
+     *     memcpy(dst->changed.sampler,
+     *            src->changed.sampler, sizeof(dst->changed.sampler));*/
 
     /* Index buffer. */
     NineStateBlock9_BindBuffer(device,
@@ -445,10 +455,10 @@ nine_state_copy_common_all(struct NineDevice9 *device,
             }
             dst->stream_freq[i] = src->stream_freq[i];
         }
-        if (apply) {
-            dst->changed.vtxbuf = (1ULL << MaxStreams) - 1;
-            dst->changed.stream_freq = (1ULL << MaxStreams) - 1;
-        }
+        /* if (apply) {
+         *     dst->changed.vtxbuf = (1ULL << MaxStreams) - 1;
+         *     dst->changed.stream_freq = (1ULL << MaxStreams) - 1;
+         *  }*/
     }
 
     /* Textures */
@@ -466,9 +476,9 @@ nine_state_copy_common_all(struct NineDevice9 *device,
     dst->ff.material = src->ff.material;
 
     memcpy(dst->ff.tex_stage, src->ff.tex_stage, sizeof(dst->ff.tex_stage));
-    if (apply) /* TODO: memset */
-        memcpy(dst->ff.changed.tex_stage,
-               src->ff.changed.tex_stage, sizeof(dst->ff.changed.tex_stage));
+    /* if (apply) TODO: memset
+     *     memcpy(dst->ff.changed.tex_stage,
+     *            src->ff.changed.tex_stage, sizeof(dst->ff.changed.tex_stage));*/
 
     /* Lights. */
     if (1) {
@@ -500,10 +510,10 @@ nine_state_copy_common_all(struct NineDevice9 *device,
         /* Apply is always used on device state.
          * src is then the D3DSBT_ALL stateblock which
          * ff.changed.transform indicates all matrices are dirty.
-         */
-        if (apply)
-            memcpy(dst->ff.changed.transform,
-                   src->ff.changed.transform, sizeof(dst->ff.changed.transform));
+         *
+         * if (apply)
+         *     memcpy(dst->ff.changed.transform,
+         *            src->ff.changed.transform, sizeof(dst->ff.changed.transform));*/
     }
 }