[Mesa-dev] [PATCH 22/84] st/nine: Back ds to nine_context

Axel Davy axel.davy at ens.fr
Wed Dec 7 22:54:55 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    |  7 +++---
 src/gallium/state_trackers/nine/nine_state.c | 33 ++++++++++++++++++----------
 src/gallium/state_trackers/nine/nine_state.h |  5 +++++
 3 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 3ad9218..16e9c30 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -1893,11 +1893,12 @@ HRESULT NINE_WINAPI
 NineDevice9_SetDepthStencilSurface( struct NineDevice9 *This,
                                     IDirect3DSurface9 *pNewZStencil )
 {
+    struct NineSurface9 *ds = NineSurface9(pNewZStencil);
     DBG("This=%p pNewZStencil=%p\n", This, pNewZStencil);
 
-    if (This->state.ds != NineSurface9(pNewZStencil)) {
-        nine_bind(&This->state.ds, pNewZStencil);
-        This->state.changed.group |= NINE_STATE_FB;
+    if (This->state.ds != ds) {
+        nine_bind(&This->state.ds, ds);
+        nine_context_set_depth_stencil(This, ds);
     }
     return D3D_OK;
 }
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index 737d621..b1576da 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -445,10 +445,10 @@ update_framebuffer(struct NineDevice9 *device, bool is_clear)
      * but render to depth buffer. We have to not take into account the render
      * target info. TODO: know what should happen when there are several render targers
      * and the first one is D3DFMT_NULL */
-    if (rt0->desc.Format == D3DFMT_NULL && state->ds) {
-        w = state->ds->desc.Width;
-        h = state->ds->desc.Height;
-        nr_samples = state->ds->base.info.nr_samples;
+    if (rt0->desc.Format == D3DFMT_NULL && context->ds) {
+        w = context->ds->desc.Width;
+        h = context->ds->desc.Height;
+        nr_samples = context->ds->base.info.nr_samples;
     }
 
     for (i = 0; i < device->caps.NumSimultaneousRTs; ++i) {
@@ -474,10 +474,10 @@ update_framebuffer(struct NineDevice9 *device, bool is_clear)
         }
     }
 
-    if (state->ds && state->ds->desc.Width >= w &&
-        state->ds->desc.Height >= h &&
-        state->ds->base.info.nr_samples == nr_samples) {
-        fb->zsbuf = NineSurface9_GetSurface(state->ds, 0);
+    if (context->ds && context->ds->desc.Width >= w &&
+        context->ds->desc.Height >= h &&
+        context->ds->base.info.nr_samples == nr_samples) {
+        fb->zsbuf = NineSurface9_GetSurface(context->ds, 0);
     } else {
         fb->zsbuf = NULL;
     }
@@ -1067,10 +1067,9 @@ nine_update_state(struct NineDevice9 *device)
 static void
 NineDevice9_ResolveZ( struct NineDevice9 *device )
 {
-    struct nine_state *state = &device->state;
     struct nine_context *context = &device->context;
     const struct util_format_description *desc;
-    struct NineSurface9 *source = state->ds;
+    struct NineSurface9 *source = context->ds;
     struct NineBaseTexture9 *destination = context->texture[0];
     struct pipe_resource *src, *dst;
     struct pipe_blit_info blit;
@@ -1468,6 +1467,17 @@ nine_context_set_render_target(struct NineDevice9 *device,
 }
 
 void
+nine_context_set_depth_stencil(struct NineDevice9 *device,
+                               struct NineSurface9 *ds)
+{
+    struct nine_state *state = &device->state;
+    struct nine_context *context = &device->context;
+
+    nine_bind(&context->ds, ds);
+    state->changed.group |= NINE_STATE_FB;
+}
+
+void
 nine_context_set_viewport(struct NineDevice9 *device,
                           const D3DVIEWPORT9 *viewport)
 {
@@ -1822,7 +1832,7 @@ nine_context_clear_fb(struct NineDevice9 *device,
     const int sRGB = context->rs[D3DRS_SRGBWRITEENABLE] ? 1 : 0;
     struct pipe_surface *cbuf, *zsbuf;
     struct pipe_context *pipe = device->pipe;
-    struct NineSurface9 *zsbuf_surf = device->state.ds;
+    struct NineSurface9 *zsbuf_surf = context->ds;
     struct NineSurface9 *rt;
     unsigned bufs = 0;
     unsigned r, i;
@@ -2344,6 +2354,7 @@ nine_context_clear(struct nine_context *context)
 
     for (i = 0; i < ARRAY_SIZE(context->rt); ++i)
        nine_bind(&context->rt[i], NULL);
+    nine_bind(&context->ds, NULL);
     nine_bind(&context->vs, NULL);
     nine_bind(&context->vdecl, NULL);
     for (i = 0; i < PIPE_MAX_ATTRIBS; ++i)
diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h
index 754a3de..78b12c6 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -232,6 +232,7 @@ struct nine_context {
     uint32_t bumpmap_vars[6 * NINE_MAX_TEXTURE_STAGES];
 
     struct NineSurface9 *rt[NINE_MAX_SIMULTANEOUS_RENDERTARGETS];
+    struct NineSurface9 *ds;
 
     struct {
         void *vs;
@@ -429,6 +430,10 @@ nine_context_set_render_target(struct NineDevice9 *device,
                                struct NineSurface9 *rt);
 
 void
+nine_context_set_depth_stencil(struct NineDevice9 *device,
+                               struct NineSurface9 *ds);
+
+void
 nine_context_apply_stateblock(struct NineDevice9 *device,
                               const struct nine_state *src);
 
-- 
2.10.2



More information about the mesa-dev mailing list