st/nine: Back ds to nine_context
authorAxel Davy <axel.davy@ens.fr>
Thu, 20 Oct 2016 19:31:43 +0000 (21:31 +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 bfbbd02a8dc2e2fefe6ede0d9a4c1be761c841ae..31765265e1c83e1ecd6ff5bd8c2b981b6e08fd34 100644 (file)
@@ -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;
 }
index 603fb894866f374d39c853e8f64adaa6bf71c0fa..fe4241af3c359151ffd9c595c05425e7f2b7fb42 100644 (file)
@@ -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;
@@ -1467,6 +1466,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;
@@ -2339,6 +2349,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)
index 754a3de7eb07ad7454d87feec563257bebe1a4f1..78b12c68a05b0c5d53e6852aa7cf2514869da769 100644 (file)
@@ -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;
@@ -428,6 +429,10 @@ nine_context_set_render_target(struct NineDevice9 *device,
                                DWORD RenderTargetIndex,
                                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);