st/nine: Back viewport to nine_context
authorAxel Davy <axel.davy@ens.fr>
Wed, 19 Oct 2016 19:57:52 +0000 (21:57 +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_ff.c
src/gallium/state_trackers/nine/nine_state.c
src/gallium/state_trackers/nine/nine_state.h

index 8f9872c15601547a47faf20e424212225fddb792..d8ff4cb56caf261c8d4ac0f9ff1d089f2b0b4ea2 100644 (file)
@@ -100,6 +100,8 @@ NineDevice9_SetDefaultState( struct NineDevice9 *This, boolean is_reset )
     This->state.viewport.Width = refSurf->desc.Width;
     This->state.viewport.Height = refSurf->desc.Height;
 
+    nine_context_set_viewport(This, &This->state.viewport);
+
     This->state.scissor.minx = 0;
     This->state.scissor.miny = 0;
     This->state.scissor.maxx = refSurf->desc.Width;
@@ -2025,7 +2027,7 @@ NineDevice9_SetViewport( struct NineDevice9 *This,
         pViewport->MinZ, pViewport->MaxZ);
 
     state->viewport = *pViewport;
-    state->changed.group |= NINE_STATE_VIEWPORT;
+    nine_context_set_viewport(This, pViewport);
 
     return D3D_OK;
 }
index 8a550cbde21aa6de05a79b20494628d3b49f37cc..bfabf183a17b0d2761c3fcf1fe18dc93c5f10782 100644 (file)
@@ -2019,7 +2019,7 @@ nine_ff_load_ps_params(struct NineDevice9 *device)
 static void
 nine_ff_load_viewport_info(struct NineDevice9 *device)
 {
-    D3DVIEWPORT9 *viewport = &device->state.viewport;
+    D3DVIEWPORT9 *viewport = &device->context.viewport;
     struct fvec4 *dst = (struct fvec4 *)device->ff.vs_const;
     float diffZ = viewport->MaxZ - viewport->MinZ;
 
index 89d7b1004ecd4b6c84e5a1172654dc4fdefd73cf..c99c37347501c7811f4a17d913b9f12c74f298d0 100644 (file)
@@ -494,7 +494,7 @@ update_framebuffer(struct NineDevice9 *device, bool is_clear)
 static void
 update_viewport(struct NineDevice9 *device)
 {
-    const D3DVIEWPORT9 *vport = &device->state.viewport;
+    const D3DVIEWPORT9 *vport = &device->context.viewport;
     struct pipe_viewport_state pvport;
 
     /* D3D coordinates are:
@@ -1441,12 +1441,18 @@ nine_context_set_render_target(struct NineDevice9 *device,
     const unsigned i = RenderTargetIndex;
 
     if (i == 0) {
+        context->viewport.X = 0;
+        context->viewport.Y = 0;
+        context->viewport.Width = rt->desc.Width;
+        context->viewport.Height = rt->desc.Height;
+        context->viewport.MinZ = 0.0f;
+        context->viewport.MaxZ = 1.0f;
+
         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] &&
@@ -1461,6 +1467,17 @@ nine_context_set_render_target(struct NineDevice9 *device,
     }
 }
 
+void
+nine_context_set_viewport(struct NineDevice9 *device,
+                          const D3DVIEWPORT9 *viewport)
+{
+    struct nine_state *state = &device->state;
+    struct nine_context *context = &device->context;
+
+    context->viewport = *viewport;
+    state->changed.group |= NINE_STATE_VIEWPORT;
+}
+
 void
 nine_context_set_scissor(struct NineDevice9 *device,
                          const struct pipe_scissor_state *scissor)
@@ -1622,6 +1639,10 @@ nine_context_apply_stateblock(struct NineDevice9 *device,
         context->changed.ps_const_b = !!src->changed.ps_const_b;
     }
 
+    /* Viewport */
+    if (src->changed.group & NINE_STATE_VIEWPORT)
+        context->viewport = src->viewport;
+
     /* Scissor */
     if (src->changed.group & NINE_STATE_SCISSOR)
         context->scissor = src->scissor;
@@ -1672,10 +1693,10 @@ nine_context_clear_fb(struct NineDevice9 *device,
         return;
     d3dcolor_to_pipe_color_union(&rgba, Color);
 
-    rect.x1 = device->state.viewport.X;
-    rect.y1 = device->state.viewport.Y;
-    rect.x2 = device->state.viewport.Width + rect.x1;
-    rect.y2 = device->state.viewport.Height + rect.y1;
+    rect.x1 = context->viewport.X;
+    rect.y1 = context->viewport.Y;
+    rect.x2 = context->viewport.Width + rect.x1;
+    rect.y2 = context->viewport.Height + rect.y1;
 
     /* Both rectangles apply, which is weird, but that's D3D9. */
     if (context->rs[D3DRS_SCISSORTESTENABLE]) {
@@ -2120,8 +2141,8 @@ nine_state_set_defaults(struct NineDevice9 *device, const D3DCAPS9 *caps,
     state->ff.changed.transform[D3DTS_WORLD / 32] |= 1 << (D3DTS_WORLD % 32);
 
     if (!is_reset) {
-        state->viewport.MinZ = 0.0f;
-        state->viewport.MaxZ = 1.0f;
+        state->viewport.MinZ = context->viewport.MinZ = 0.0f;
+        state->viewport.MaxZ = context->viewport.MaxZ = 1.0f;
     }
 
     for (s = 0; s < NINE_MAX_SAMPLERS; ++s)
index 28a6d6cfeee2420e68172f024748ac7b58fbd793..a6f20ab5dd32ae12ad9646ca942a557c10eb2623 100644 (file)
@@ -238,6 +238,8 @@ struct nine_context {
 
     uint8_t rt_mask;
 
+    D3DVIEWPORT9 viewport;
+
     struct pipe_scissor_state scissor;
 
     struct NineVertexShader9 *vs;
@@ -384,6 +386,10 @@ nine_context_set_pixel_shader_constant_b(struct NineDevice9 *device,
                                          const BOOL *pConstantData,
                                          UINT BoolCount);
 
+void
+nine_context_set_viewport(struct NineDevice9 *device,
+                          const D3DVIEWPORT9 *viewport);
+
 void
 nine_context_set_scissor(struct NineDevice9 *device,
                          const struct pipe_scissor_state *scissor);