st/nine: Move stream freq data to nine_context
authorAxel Davy <axel.davy@ens.fr>
Sun, 16 Oct 2016 17:16:31 +0000 (19:16 +0200)
committerAxel Davy <axel.davy@ens.fr>
Tue, 20 Dec 2016 22:44:21 +0000 (23:44 +0100)
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_state.c
src/gallium/state_trackers/nine/nine_state.h
src/gallium/state_trackers/nine/stateblock9.c

index 102e5fc59195d315a6e5c14f81195729653947a4..d11f3d1903cc872e71c1c37bb5c75f7830079fad 100644 (file)
@@ -3469,19 +3469,20 @@ NineDevice9_SetStreamSourceFreq( struct NineDevice9 *This,
                   (Setting & D3DSTREAMSOURCE_INDEXEDDATA)), D3DERR_INVALIDCALL);
     user_assert(Setting, D3DERR_INVALIDCALL);
 
-    if (likely(!This->is_recording) && state->stream_freq[StreamNumber] == Setting)
+    if (unlikely(This->is_recording)) {
+        state->stream_freq[StreamNumber] = Setting;
+        state->changed.stream_freq |= 1 << StreamNumber;
+        if (StreamNumber != 0)
+            state->changed.group |= NINE_STATE_STREAMFREQ;
         return D3D_OK;
+    }
 
-    state->stream_freq[StreamNumber] = Setting;
+    if (state->stream_freq[StreamNumber] == Setting)
+        return D3D_OK;
 
-    if (Setting & D3DSTREAMSOURCE_INSTANCEDATA)
-        state->stream_instancedata_mask |= 1 << StreamNumber;
-    else
-        state->stream_instancedata_mask &= ~(1 << StreamNumber);
+    state->stream_freq[StreamNumber] = Setting;
 
-    state->changed.stream_freq |= 1 << StreamNumber; /* Used for stateblocks */
-    if (StreamNumber != 0)
-        state->changed.group |= NINE_STATE_STREAMFREQ;
+    nine_context_set_stream_source_freq(This, StreamNumber, Setting);
     return D3D_OK;
 }
 
index 066ed7f4aec18bd12c4748a4f550dcd822db3a0e..cde38ee662264db601b393d14416ae86d338221a 100644 (file)
@@ -677,8 +677,6 @@ update_vertex_elements(struct NineDevice9 *device)
     }
 
     cso_set_vertex_elements(device->cso, vs->num_inputs, ve);
-
-    state->changed.stream_freq = 0;
 }
 
 static void
@@ -1259,6 +1257,25 @@ nine_context_set_stream_source(struct NineDevice9 *device,
                             pVBuf9 ? NineVertexBuffer9_GetResource(pVBuf9) : NULL);
 }
 
+void
+nine_context_set_stream_source_freq(struct NineDevice9 *device,
+                                    UINT StreamNumber,
+                                    UINT Setting)
+{
+    struct nine_state *state = &device->state;
+    struct nine_context *context = &device->context;
+
+    context->stream_freq[StreamNumber] = Setting;
+
+    if (Setting & D3DSTREAMSOURCE_INSTANCEDATA)
+        context->stream_instancedata_mask |= 1 << StreamNumber;
+    else
+        context->stream_instancedata_mask &= ~(1 << StreamNumber);
+
+    if (StreamNumber != 0)
+        state->changed.group |= NINE_STATE_STREAMFREQ;
+}
+
 void
 nine_context_apply_stateblock(struct NineDevice9 *device,
                               const struct nine_state *src)
@@ -1304,6 +1321,13 @@ nine_context_apply_stateblock(struct NineDevice9 *device,
                     context->vtxbuf[i].stride = src->vtxbuf[i].stride;
                 }
             }
+            if (src->changed.stream_freq & (1 << i)) {
+                context->stream_freq[i] = src->stream_freq[i];
+                if (src->stream_freq[i] & D3DSTREAMSOURCE_INSTANCEDATA)
+                    context->stream_instancedata_mask |= 1 << i;
+                else
+                    context->stream_instancedata_mask &= ~(1 << i);
+            }
         }
         context->changed.vtxbuf |= src->changed.vtxbuf;
     }
@@ -1473,8 +1497,8 @@ init_draw_info(struct pipe_draw_info *info,
     info->count = prim_count_to_vertex_count(type, count);
     info->start_instance = 0;
     info->instance_count = 1;
-    if (dev->state.stream_instancedata_mask & dev->context.stream_usage_mask)
-        info->instance_count = MAX2(dev->state.stream_freq[0] & 0x7FFFFF, 1);
+    if (dev->context.stream_instancedata_mask & dev->context.stream_usage_mask)
+        info->instance_count = MAX2(dev->context.stream_freq[0] & 0x7FFFFF, 1);
     info->primitive_restart = FALSE;
     info->restart_index = 0;
     info->count_from_stream_output = NULL;
index e111f091443656dd0f78126ae59fcb5c90fdd31a..5bc9f70702389be5f821fae268d84dad974f21f5 100644 (file)
@@ -137,7 +137,7 @@ struct nine_state
         uint32_t group;
         uint32_t rs[(NINED3DRS_COUNT + 31) / 32]; /* stateblocks only */
         uint32_t vtxbuf; /* stateblocks only */
-        uint32_t stream_freq;
+        uint32_t stream_freq; /* stateblocks only */
         uint32_t texture; /* stateblocks only */
         uint16_t sampler[NINE_MAX_SAMPLERS];
         struct nine_range *vs_const_f;
@@ -180,7 +180,6 @@ struct nine_state
     struct NineVertexBuffer9  *stream[PIPE_MAX_ATTRIBS];
     struct pipe_vertex_buffer  vtxbuf[PIPE_MAX_ATTRIBS]; /* vtxbuf.buffer unused */
     UINT stream_freq[PIPE_MAX_ATTRIBS];
-    uint32_t stream_instancedata_mask; /* derived from stream_freq */
 
     struct pipe_clip_state clip;
 
@@ -229,6 +228,8 @@ struct nine_context {
     uint8_t rt_mask;
 
     struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
+    UINT stream_freq[PIPE_MAX_ATTRIBS];
+    uint32_t stream_instancedata_mask; /* derived from stream_freq */
     uint32_t stream_usage_mask; /* derived from VS and vdecl */
 
     DWORD rs[NINED3DRS_COUNT];
@@ -292,6 +293,11 @@ nine_context_set_stream_source(struct NineDevice9 *device,
                                UINT OffsetInBytes,
                                UINT Stride);
 
+void
+nine_context_set_stream_source_freq(struct NineDevice9 *device,
+                                    UINT StreamNumber,
+                                    UINT Setting);
+
 void
 nine_context_apply_stateblock(struct NineDevice9 *device,
                               const struct nine_state *src);
index 3ebee84471f88f48490d1e758d37b74f94b2c59d..4af370ec94db96fbf4ba3bf196e1030d08b8b67c 100644 (file)
@@ -282,9 +282,6 @@ nine_state_copy_common(struct NineDevice9 *device,
             if (mask->changed.stream_freq & (1 << i))
                 dst->stream_freq[i] = src->stream_freq[i];
         }
-        dst->stream_instancedata_mask &= ~mask->changed.stream_freq;
-        dst->stream_instancedata_mask |=
-            src->stream_instancedata_mask & mask->changed.stream_freq;
         if (apply) {
             dst->changed.vtxbuf |= mask->changed.vtxbuf;
             dst->changed.stream_freq |= mask->changed.stream_freq;
@@ -466,7 +463,6 @@ nine_state_copy_common_all(struct NineDevice9 *device,
             }
             dst->stream_freq[i] = src->stream_freq[i];
         }
-        dst->stream_instancedata_mask = src->stream_instancedata_mask;
         if (apply) {
             dst->changed.vtxbuf = (1ULL << MaxStreams) - 1;
             dst->changed.stream_freq = (1ULL << MaxStreams) - 1;