st/nine: Back scissor to nine_context
authorAxel Davy <axel.davy@ens.fr>
Wed, 19 Oct 2016 19:47:02 +0000 (21:47 +0200)
committerAxel Davy <axel.davy@ens.fr>
Tue, 20 Dec 2016 22:44:22 +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

index 7b0009d934995739dffa62f18de711f77c808949..8f9872c15601547a47faf20e424212225fddb792 100644 (file)
@@ -105,6 +105,8 @@ NineDevice9_SetDefaultState( struct NineDevice9 *This, boolean is_reset )
     This->state.scissor.maxx = refSurf->desc.Width;
     This->state.scissor.maxy = refSurf->desc.Height;
 
+    nine_context_set_scissor(This, &This->state.scissor);
+
     if (This->nswapchains && This->swapchains[0]->params.EnableAutoDepthStencil) {
         nine_context_set_render_state(This, D3DRS_ZENABLE, TRUE);
         This->state.rs_advertised[D3DRS_ZENABLE] = TRUE;
@@ -2711,7 +2713,10 @@ NineDevice9_SetScissorRect( struct NineDevice9 *This,
     state->scissor.maxx = pRect->right;
     state->scissor.maxy = pRect->bottom;
 
-    state->changed.group |= NINE_STATE_SCISSOR;
+    if (unlikely(This->is_recording))
+        state->changed.group |= NINE_STATE_SCISSOR;
+    else
+        nine_context_set_scissor(This, &state->scissor);
 
     return D3D_OK;
 }
index 4b5b199e560a05ce3f3a6a977ed078c9698f9354..89d7b1004ecd4b6c84e5a1172654dc4fdefd73cf 100644 (file)
@@ -824,7 +824,7 @@ commit_scissor(struct NineDevice9 *device)
 {
     struct pipe_context *pipe = device->pipe;
 
-    pipe->set_scissor_states(pipe, 0, 1, &device->state.scissor);
+    pipe->set_scissor_states(pipe, 0, 1, &device->context.scissor);
 }
 
 static inline void
@@ -1441,7 +1441,12 @@ nine_context_set_render_target(struct NineDevice9 *device,
     const unsigned i = RenderTargetIndex;
 
     if (i == 0) {
-        /* viewport and scissor changes */
+        context->scissor.minx = 0;
+        context->scissor.miny = 0;
+        context->scissor.maxx = rt->desc.Width;
+        context->scissor.maxy = rt->desc.Height;
+
+        /* viewport changes */
         state->changed.group |= NINE_STATE_VIEWPORT | NINE_STATE_SCISSOR | NINE_STATE_MULTISAMPLE;
 
         if (context->rt[0] &&
@@ -1456,6 +1461,17 @@ nine_context_set_render_target(struct NineDevice9 *device,
     }
 }
 
+void
+nine_context_set_scissor(struct NineDevice9 *device,
+                         const struct pipe_scissor_state *scissor)
+{
+    struct nine_state *state = &device->state;
+    struct nine_context *context = &device->context;
+
+    context->scissor = *scissor;
+    state->changed.group |= NINE_STATE_SCISSOR;
+}
+
 void
 nine_context_apply_stateblock(struct NineDevice9 *device,
                               const struct nine_state *src)
@@ -1605,6 +1621,10 @@ nine_context_apply_stateblock(struct NineDevice9 *device,
         context->changed.ps_const_i = !!src->changed.ps_const_i;
         context->changed.ps_const_b = !!src->changed.ps_const_b;
     }
+
+    /* Scissor */
+    if (src->changed.group & NINE_STATE_SCISSOR)
+        context->scissor = src->scissor;
 }
 
 static void
@@ -1659,10 +1679,10 @@ nine_context_clear_fb(struct NineDevice9 *device,
 
     /* Both rectangles apply, which is weird, but that's D3D9. */
     if (context->rs[D3DRS_SCISSORTESTENABLE]) {
-        rect.x1 = MAX2(rect.x1, device->state.scissor.minx);
-        rect.y1 = MAX2(rect.y1, device->state.scissor.miny);
-        rect.x2 = MIN2(rect.x2, device->state.scissor.maxx);
-        rect.y2 = MIN2(rect.y2, device->state.scissor.maxy);
+        rect.x1 = MAX2(rect.x1, context->scissor.minx);
+        rect.y1 = MAX2(rect.y1, context->scissor.miny);
+        rect.x2 = MIN2(rect.x2, context->scissor.maxx);
+        rect.y2 = MIN2(rect.y2, context->scissor.maxy);
     }
 
     if (Count) {
index 50fecd0f0e211f0c60dc4bcc16ede130eeae2670..28a6d6cfeee2420e68172f024748ac7b58fbd793 100644 (file)
@@ -238,6 +238,8 @@ struct nine_context {
 
     uint8_t rt_mask;
 
+    struct pipe_scissor_state scissor;
+
     struct NineVertexShader9 *vs;
     BOOL programmable_vs;
     float *vs_const_f;
@@ -382,6 +384,10 @@ nine_context_set_pixel_shader_constant_b(struct NineDevice9 *device,
                                          const BOOL *pConstantData,
                                          UINT BoolCount);
 
+void
+nine_context_set_scissor(struct NineDevice9 *device,
+                         const struct pipe_scissor_state *scissor);
+
 void
 nine_context_set_render_target(struct NineDevice9 *device,
                                DWORD RenderTargetIndex,