st/nine: Reorder nine_state.
authorAxel Davy <axel.davy@ens.fr>
Tue, 24 Mar 2015 08:35:18 +0000 (09:35 +0100)
committerAxel Davy <axel.davy@ens.fr>
Fri, 21 Aug 2015 20:21:47 +0000 (22:21 +0200)
Instead of mixing state preparation (filling pipe_****)
and state commit (pipe->set_*****),
begin doing so in two separate functions.

This will allow to implement efficient Stateblocks,
and eventually lead to optimisation where the complete
pipe_*** structure is only partially updated.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/nine_state.c

index 68f14d2419ada0f3afefe8af5d374af0d1729e21..47e4148b8f6a1f884521781787d7b27aa5f776cb 100644 (file)
 
 #define DBG_CHANNEL DBG_DEVICE
 
+/* State preparation only */
+
+/* State preparation incremental */
+
+/* State preparation + State commit */
+
 static uint32_t
 update_framebuffer(struct NineDevice9 *device)
 {
@@ -176,14 +182,6 @@ update_viewport(struct NineDevice9 *device)
     pipe->set_viewport_states(pipe, 0, 1, &pvport);
 }
 
-static inline void
-update_scissor(struct NineDevice9 *device)
-{
-    struct pipe_context *pipe = device->pipe;
-
-    pipe->set_scissor_states(pipe, 0, 1, &device->state.scissor);
-}
-
 static inline void
 update_blend(struct NineDevice9 *device)
 {
@@ -665,27 +663,6 @@ update_vertex_buffers(struct NineDevice9 *device)
     state->changed.vtxbuf = 0;
 }
 
-static inline void
-update_index_buffer(struct NineDevice9 *device)
-{
-    struct pipe_context *pipe = device->pipe;
-    if (device->state.idxbuf)
-        pipe->set_index_buffer(pipe, &device->state.idxbuf->buffer);
-    else
-        pipe->set_index_buffer(pipe, NULL);
-}
-
-/* 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 inline boolean
 update_sampler_derived(struct nine_state *state, unsigned s)
 {
@@ -864,6 +841,27 @@ update_textures_and_samplers(struct NineDevice9 *device)
     state->changed.texture = 0;
 }
 
+/* State commit only */
+
+static inline void
+commit_scissor(struct NineDevice9 *device)
+{
+    struct pipe_context *pipe = device->pipe;
+
+    pipe->set_scissor_states(pipe, 0, 1, &device->state.scissor);
+}
+
+static inline void
+commit_index_buffer(struct NineDevice9 *device)
+{
+    struct pipe_context *pipe = device->pipe;
+    if (device->state.idxbuf)
+        pipe->set_index_buffer(pipe, &device->state.idxbuf->buffer);
+    else
+        pipe->set_index_buffer(pipe, NULL);
+}
+
+/* State Update */
 
 #define NINE_STATE_FREQ_GROUP_0 \
    (NINE_STATE_FB |             \
@@ -885,6 +883,17 @@ update_textures_and_samplers(struct NineDevice9 *device)
      NINE_STATE_VS | \
      NINE_STATE_PS)
 
+/* 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);
+    }
+}
+
 void
 nine_update_state_framebuffer(struct NineDevice9 *device)
 {
@@ -931,7 +940,7 @@ nine_update_state(struct NineDevice9 *device)
         if (group & NINE_STATE_VIEWPORT)
             update_viewport(device);
         if (group & NINE_STATE_SCISSOR)
-            update_scissor(device);
+            commit_scissor(device);
 
         if (group & NINE_STATE_DSA)
             update_dsa(device);
@@ -973,7 +982,7 @@ nine_update_state(struct NineDevice9 *device)
             update_textures_and_samplers(device);
 
         if (group & NINE_STATE_IDXBUF)
-            update_index_buffer(device);
+            commit_index_buffer(device);
 
         if ((group & (NINE_STATE_VDECL | NINE_STATE_VS)) ||
             state->changed.stream_freq & ~1)
@@ -1002,6 +1011,7 @@ nine_update_state(struct NineDevice9 *device)
     return TRUE;
 }
 
+/* State defaults */
 
 static const DWORD nine_render_state_defaults[NINED3DRS_LAST + 1] =
 {
@@ -1469,6 +1479,8 @@ const uint32_t nine_render_state_group[NINED3DRS_LAST + 1] =
     [D3DRS_BLENDOPALPHA] = NINE_STATE_BLEND
 };
 
+/* Misc */
+
 D3DMATRIX *
 nine_state_access_transform(struct nine_state *state, D3DTRANSFORMSTATETYPE t,
                             boolean alloc)