st/nine: Rework rasterizer states
authorAxel Davy <axel.davy@ens.fr>
Tue, 24 Mar 2015 09:16:59 +0000 (10:16 +0100)
committerAxel Davy <axel.davy@ens.fr>
Fri, 21 Aug 2015 20:21:47 +0000 (22:21 +0200)
Separate state preparation and state commit

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

index 0538957e9af0b7f31e0c1aee33eb07f03f43e1d0..364cab90eb2ac807d36dce697efe8a79af9e4a1d 100644 (file)
@@ -69,13 +69,12 @@ nine_convert_dsa_state(struct pipe_depth_stencil_alpha_state *dsa_state,
     *dsa_state = dsa;
 }
 
-/* TODO: Keep a static copy in device so we don't have to memset every time ? */
 void
-nine_convert_rasterizer_state(struct cso_context *ctx, const DWORD *rs)
+nine_convert_rasterizer_state(struct pipe_rasterizer_state *rast_state, const DWORD *rs)
 {
     struct pipe_rasterizer_state rast;
 
-    memset(&rast, 0, sizeof(rast)); /* memcmp safety */
+    memset(&rast, 0, sizeof(rast));
 
     rast.flatshade = rs[D3DRS_SHADEMODE] == D3DSHADE_FLAT;
  /* rast.light_twoside = 0; */
@@ -122,7 +121,7 @@ nine_convert_rasterizer_state(struct cso_context *ctx, const DWORD *rs)
     rast.offset_scale = asfloat(rs[D3DRS_SLOPESCALEDEPTHBIAS]);
  /* rast.offset_clamp = 0.0f; */
 
-    cso_set_rasterizer(ctx, &rast);
+    *rast_state = rast;
 }
 
 static inline void
index 2f2e9cb815b245ccb555e85d7a221fdeb90405e1..e2680f6f5e6bd2c67104749dc6954c9656ff0195 100644 (file)
@@ -38,7 +38,7 @@ extern const enum pipe_format nine_d3d9_to_pipe_format_map[120];
 extern const D3DFORMAT nine_pipe_to_d3d9_format_map[PIPE_FORMAT_COUNT];
 
 void nine_convert_dsa_state(struct pipe_depth_stencil_alpha_state *, const DWORD *);
-void nine_convert_rasterizer_state(struct cso_context *, const DWORD *);
+void nine_convert_rasterizer_state(struct pipe_rasterizer_state *, const DWORD *);
 void nine_convert_blend_state(struct cso_context *, const DWORD *);
 void nine_convert_sampler_state(struct cso_context *, int idx, const DWORD *);
 
index 7875d31d9b4ba7ebc2ffc6d1bb0ec9bb6329803f..b29556b56ee6a4615cf446afb2752dc6c0e23d1c 100644 (file)
@@ -46,6 +46,13 @@ prepare_dsa(struct NineDevice9 *device)
     device->state.commit |= NINE_STATE_COMMIT_DSA;
 }
 
+static inline void
+prepare_rasterizer(struct NineDevice9 *device)
+{
+    nine_convert_rasterizer_state(&device->state.pipe.rast, device->state.rs);
+    device->state.commit |= NINE_STATE_COMMIT_RASTERIZER;
+}
+
 /* State preparation incremental */
 
 /* State preparation + State commit */
@@ -195,12 +202,6 @@ update_blend(struct NineDevice9 *device)
     nine_convert_blend_state(device->cso, device->state.rs);
 }
 
-static inline void
-update_rasterizer(struct NineDevice9 *device)
-{
-    nine_convert_rasterizer_state(device->cso, device->state.rs);
-}
-
 /* Loop through VS inputs and pick the vertex elements with the declared
  * usage from the vertex declaration, then insert the instance divisor from
  * the stream source frequency setting.
@@ -858,6 +859,12 @@ commit_scissor(struct NineDevice9 *device)
     pipe->set_scissor_states(pipe, 0, 1, &device->state.scissor);
 }
 
+static inline void
+commit_rasterizer(struct NineDevice9 *device)
+{
+    cso_set_rasterizer(device->cso, &device->state.pipe.rast);
+}
+
 static inline void
 commit_index_buffer(struct NineDevice9 *device)
 {
@@ -958,7 +965,7 @@ nine_update_state(struct NineDevice9 *device)
             group |= update_vs(device);
 
         if (group & NINE_STATE_RASTERIZER)
-            update_rasterizer(device);
+            prepare_rasterizer(device);
 
         if (group & NINE_STATE_PS)
             group |= update_ps(device);
@@ -1012,6 +1019,8 @@ nine_update_state(struct NineDevice9 *device)
 
     if (state->commit & NINE_STATE_COMMIT_DSA)
         commit_dsa(device);
+    if (state->commit & NINE_STATE_COMMIT_RASTERIZER)
+        commit_rasterizer(device);
 
     state->commit = 0;
 
index e833225d35efa6b95e496de308e8d99c6174475f..bd2ad380d7a097c881eb1c32b25ff2d00a8fcb08 100644 (file)
@@ -79,6 +79,7 @@
 #define NINE_STATE_UNHANDLED   (1 << 24)
 
 #define NINE_STATE_COMMIT_DSA  (1 << 0)
+#define NINE_STATE_COMMIT_RASTERIZER (1 << 1)
 
 
 #define NINE_MAX_SIMULTANEOUS_RENDERTARGETS 4
@@ -214,6 +215,7 @@ struct nine_state
     uint32_t commit;
     struct {
         struct pipe_depth_stencil_alpha_state dsa;
+        struct pipe_rasterizer_state rast;
     } pipe;
 };