[Mesa-dev] [PATCH 17/84] st/nine: Back viewport to nine_context

Axel Davy axel.davy at ens.fr
Wed Dec 7 22:54:50 UTC 2016


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 at ens.fr>
---
 src/gallium/state_trackers/nine/device9.c    |  4 ++-
 src/gallium/state_trackers/nine/nine_ff.c    |  2 +-
 src/gallium/state_trackers/nine/nine_state.c | 37 ++++++++++++++++++++++------
 src/gallium/state_trackers/nine/nine_state.h |  6 +++++
 4 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 1b0bbe5c..585c46a 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -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;
 }
diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c
index 8a550cb..bfabf18 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -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;
 
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index 77011af..5daffdd 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -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] &&
@@ -1462,6 +1468,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]) {
@@ -2125,8 +2146,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)
diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h
index 28a6d6c..a6f20ab 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -238,6 +238,8 @@ struct nine_context {
 
     uint8_t rt_mask;
 
+    D3DVIEWPORT9 viewport;
+
     struct pipe_scissor_state scissor;
 
     struct NineVertexShader9 *vs;
@@ -385,6 +387,10 @@ nine_context_set_pixel_shader_constant_b(struct NineDevice9 *device,
                                          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);
 
-- 
2.10.2



More information about the mesa-dev mailing list