[Mesa-dev] [PATCH 7/7] WIP: per context fences/pushbuf

Karol Herbst kherbst at redhat.com
Wed Dec 5 21:04:57 UTC 2018


Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
 src/gallium/drivers/nouveau/nouveau_buffer.c  | 20 +++---
 src/gallium/drivers/nouveau/nouveau_context.c | 33 ++++++++-
 src/gallium/drivers/nouveau/nouveau_context.h | 17 ++---
 src/gallium/drivers/nouveau/nouveau_fence.h   |  5 +-
 src/gallium/drivers/nouveau/nouveau_screen.c  |  8 +--
 .../drivers/nouveau/nvc0/nvc0_context.c       | 72 +++++++++++++------
 .../drivers/nouveau/nvc0/nvc0_context.h       |  4 ++
 .../drivers/nouveau/nvc0/nvc0_program.c       |  2 +-
 .../drivers/nouveau/nvc0/nvc0_query_hw.c      |  4 +-
 .../drivers/nouveau/nvc0/nvc0_screen.c        | 18 +++--
 .../drivers/nouveau/nvc0/nvc0_screen.h        | 11 ++-
 .../nouveau/nvc0/nvc0_state_validate.c        |  8 +--
 .../drivers/nouveau/nvc0/nvc0_transfer.c      |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c   |  6 +-
 14 files changed, 139 insertions(+), 71 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c
index 03f214dae4c..0172082f7e0 100644
--- a/src/gallium/drivers/nouveau/nouveau_buffer.c
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c
@@ -216,8 +216,8 @@ nouveau_transfer_write(struct nouveau_context *nv, struct nouveau_transfer *tx,
    else
       nv->push_data(nv, buf->bo, buf->offset + base, buf->domain, size, data);
 
-   nouveau_fence_ref(nv->screen->fence.current, &buf->fence);
-   nouveau_fence_ref(nv->screen->fence.current, &buf->fence_wr);
+   nouveau_fence_ref(nv->fence.current, &buf->fence);
+   nouveau_fence_ref(nv->fence.current, &buf->fence_wr);
 }
 
 /* Does a CPU wait for the buffer's backing data to become reliably accessible
@@ -286,10 +286,10 @@ nouveau_buffer_transfer_del(struct nouveau_context *nv,
 {
    if (tx->map) {
       if (likely(tx->bo)) {
-         nouveau_fence_work(nv->screen->fence.current, nv->pushbuf,
+         nouveau_fence_work(nv->fence.current, nv->pushbuf,
                             nouveau_fence_unref_bo, tx->bo);
          if (tx->mm)
-            release_allocation(&tx->mm, nv->screen->fence.current, nv->pushbuf);
+            release_allocation(&tx->mm, nv->fence.current, nv->pushbuf);
       } else {
          align_free(tx->map -
                     (tx->base.box.x & NOUVEAU_MIN_BUFFER_MAP_ALIGN_MASK));
@@ -573,11 +573,11 @@ nouveau_copy_buffer(struct nouveau_context *nv,
                     src->bo, src->offset + srcx, src->domain, size);
 
       dst->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING;
-      nouveau_fence_ref(nv->screen->fence.current, &dst->fence);
-      nouveau_fence_ref(nv->screen->fence.current, &dst->fence_wr);
+      nouveau_fence_ref(nv->fence.current, &dst->fence);
+      nouveau_fence_ref(nv->fence.current, &dst->fence_wr);
 
       src->status |= NOUVEAU_BUFFER_STATUS_GPU_READING;
-      nouveau_fence_ref(nv->screen->fence.current, &src->fence);
+      nouveau_fence_ref(nv->fence.current, &src->fence);
    } else {
       struct pipe_box src_box;
       src_box.x = srcx;
@@ -786,9 +786,9 @@ nouveau_buffer_migrate(struct nouveau_context *nv,
       nv->copy_data(nv, buf->bo, buf->offset, new_domain,
                     bo, offset, old_domain, buf->base.width0);
 
-      nouveau_fence_work(screen->fence.current, nv->pushbuf, nouveau_fence_unref_bo, bo);
+      nouveau_fence_work(nv->fence.current, nv->pushbuf, nouveau_fence_unref_bo, bo);
       if (mm)
-         release_allocation(&mm, screen->fence.current, nv->pushbuf);
+         release_allocation(&mm, nv->fence.current, nv->pushbuf);
    } else
    if (new_domain == NOUVEAU_BO_VRAM && old_domain == 0) {
       struct nouveau_transfer tx;
@@ -898,7 +898,7 @@ nouveau_scratch_runout_release(struct nouveau_context *nv)
    if (!nv->scratch.runout)
       return;
 
-   if (!nouveau_fence_work(nv->screen->fence.current, nv->pushbuf, nouveau_scratch_unref_bos,
+   if (!nouveau_fence_work(nv->fence.current, nv->pushbuf, nouveau_scratch_unref_bos,
          nv->scratch.runout))
       return;
 
diff --git a/src/gallium/drivers/nouveau/nouveau_context.c b/src/gallium/drivers/nouveau/nouveau_context.c
index 96fe8d5df9b..5fc4129d0ce 100644
--- a/src/gallium/drivers/nouveau/nouveau_context.c
+++ b/src/gallium/drivers/nouveau/nouveau_context.c
@@ -12,8 +12,39 @@ nouveau_set_debug_callback(struct pipe_context *pipe,
       memset(&context->debug, 0, sizeof(context->debug));
 }
 
-void
+int
 nouveau_context_init(struct nouveau_context *context)
 {
+   struct nouveau_screen *screen = context->screen;
+   int ret;
+
    context->pipe.set_debug_callback = nouveau_set_debug_callback;
+
+   ret = nouveau_client_new(screen->device, &context->client);
+   if (ret)
+      return ret;
+
+   ret = nouveau_pushbuf_new(context->client, screen->channel,
+                             4, 512 * 1024, 1,
+                             &context->pushbuf);
+   if (ret)
+      return ret;
+
+   nouveau_fence_list_init(&context->fence, screen, context->pushbuf);
+   return ret;
+}
+
+void
+nouveau_context_destroy(struct nouveau_context *ctx)
+{
+   int i;
+
+   for (i = 0; i < NOUVEAU_MAX_SCRATCH_BUFS; ++i)
+      if (ctx->scratch.bo[i])
+         nouveau_bo_ref(NULL, &ctx->scratch.bo[i]);
+
+   nouveau_pushbuf_del(&ctx->pushbuf);
+   nouveau_client_del(&ctx->client);
+
+   FREE(ctx);
 }
diff --git a/src/gallium/drivers/nouveau/nouveau_context.h b/src/gallium/drivers/nouveau/nouveau_context.h
index 38c19790ec3..f91f2eab971 100644
--- a/src/gallium/drivers/nouveau/nouveau_context.h
+++ b/src/gallium/drivers/nouveau/nouveau_context.h
@@ -22,6 +22,8 @@ struct nouveau_context {
    struct nouveau_pushbuf *pushbuf;
    struct pipe_debug_callback debug;
 
+   struct nouveau_fence_list fence;
+
    bool vbo_dirty;
 
    void (*copy_data)(struct nouveau_context *,
@@ -70,7 +72,7 @@ nouveau_context(struct pipe_context *pipe)
 void
 nouveau_context_init_vdec(struct nouveau_context *);
 
-void
+int
 nouveau_context_init(struct nouveau_context *);
 
 void
@@ -95,17 +97,8 @@ void *
 nouveau_scratch_get(struct nouveau_context *, unsigned size, uint64_t *gpu_addr,
                     struct nouveau_bo **);
 
-static inline void
-nouveau_context_destroy(struct nouveau_context *ctx)
-{
-   int i;
-
-   for (i = 0; i < NOUVEAU_MAX_SCRATCH_BUFS; ++i)
-      if (ctx->scratch.bo[i])
-         nouveau_bo_ref(NULL, &ctx->scratch.bo[i]);
-
-   FREE(ctx);
-}
+void
+nouveau_context_destroy(struct nouveau_context *);
 
 static inline  void
 nouveau_context_update_frame_stats(struct nouveau_context *nv)
diff --git a/src/gallium/drivers/nouveau/nouveau_fence.h b/src/gallium/drivers/nouveau/nouveau_fence.h
index d4c5f03b66f..d730078abe4 100644
--- a/src/gallium/drivers/nouveau/nouveau_fence.h
+++ b/src/gallium/drivers/nouveau/nouveau_fence.h
@@ -39,6 +39,7 @@ struct nouveau_fence_list {
    struct nouveau_fence *current;
 
    struct nouveau_screen *screen;
+   struct nouveau_pushbuf *push;
    void *data;
 
    uint32_t sequence;
@@ -61,9 +62,11 @@ void nouveau_fence_unref_bo(void *data); /* generic unref bo callback */
 
 static inline void
 nouveau_fence_list_init(struct nouveau_fence_list *list,
-                        struct nouveau_screen *screen)
+                        struct nouveau_screen *screen,
+                        struct nouveau_pushbuf *push)
 {
    list->screen = screen;
+   list->push = push;
 }
 
 static inline void
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
index ee874a1fce7..d3c02a91657 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.c
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c
@@ -80,12 +80,12 @@ nouveau_screen_fence_finish(struct pipe_screen *screen,
                             struct pipe_fence_handle *pfence,
                             uint64_t timeout)
 {
-   struct nouveau_pushbuf *push = ctx ? nouveau_context(ctx)->pushbuf : nouveau_screen(screen)->pushbuf;
+   struct nouveau_fence *fence = nouveau_fence(pfence);
 
    if (!timeout)
-      return nouveau_fence_signalled(nouveau_fence(pfence));
+      return nouveau_fence_signalled(fence);
 
-   return nouveau_fence_wait(nouveau_fence(pfence), push, NULL);
+   return nouveau_fence_wait(fence, fence->list->push, NULL);
 }
 
 
@@ -226,7 +226,7 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
    if (ret)
       return ret;
 
-   nouveau_fence_list_init(&screen->fence, screen);
+   nouveau_fence_list_init(&screen->fence, screen, screen->pushbuf);
 
    /* getting CPU time first appears to be more accurate */
    screen->cpu_gpu_time_delta = os_time_get();
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
index 471078c56b4..6cb22d0a633 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
@@ -34,11 +34,12 @@ nvc0_flush(struct pipe_context *pipe,
            unsigned flags)
 {
    struct nvc0_context *nvc0 = nvc0_context(pipe);
-   struct nouveau_screen *screen = &nvc0->screen->base;
 
    if (fence)
-      nouveau_fence_ref(screen->fence.current, (struct nouveau_fence **)fence);
+      nouveau_fence_ref(nvc0->base.fence.current, (struct nouveau_fence **)fence);
 
+//   nouveau_pushbuf_bufctx(nvc0->base.pushbuf, nvc0->bufctx);
+//   nouveau_pushbuf_validate(nvc0->base.pushbuf);
    PUSH_KICK(nvc0->base.pushbuf); /* fencing handled in kick_notify */
 
    nouveau_context_update_frame_stats(&nvc0->base);
@@ -216,20 +217,35 @@ nvc0_destroy(struct pipe_context *pipe)
       free(pos);
    }
 
+   if (nvc0->base.fence.current) {
+      struct nouveau_fence *current = NULL;
+
+      /* nouveau_fence_wait will create a new current fence, so wait on the
+       * _current_ one, and remove both.
+       */
+      nouveau_fence_ref(nvc0->base.fence.current, &current);
+      nouveau_fence_wait(current, nvc0->base.pushbuf, NULL);
+      nouveau_fence_ref(NULL, &current);
+      nouveau_fence_ref(NULL, &nvc0->base.fence.current);
+   }
+   if (nvc0->base.pushbuf)
+      nvc0->base.pushbuf->user_priv = NULL;
+
+   nouveau_bo_ref(NULL, &nvc0->fence.bo);
+
    nouveau_context_destroy(&nvc0->base);
 }
 
 void
 nvc0_default_kick_notify(struct nouveau_pushbuf *push)
 {
-   struct nvc0_screen *screen = push->user_priv;
-
-   if (screen) {
-      nouveau_fence_next(&screen->base.fence, push);
-      nouveau_fence_update(&screen->base.fence, true);
-      if (screen->cur_ctx)
-         screen->cur_ctx->state.flushed = true;
-      NOUVEAU_DRV_STAT(&screen->base, pushbuf_count, 1);
+   struct nvc0_context *nvc0 = push->user_priv;
+
+   if (nvc0) {
+      nouveau_fence_next(&nvc0->base.fence, push);
+      nouveau_fence_update(&nvc0->base.fence, true);
+      nvc0->state.flushed = true;
+      NOUVEAU_DRV_STAT(&nvc0->screen->base, pushbuf_count, 1);
    }
 }
 
@@ -369,8 +385,9 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
    if (!nvc0_blitctx_create(nvc0))
       goto out_err;
 
-   nvc0->base.pushbuf = screen->base.pushbuf;
-   nvc0->base.client = screen->base.client;
+   nvc0->screen = screen;
+   nvc0->base.screen = &screen->base;
+   nouveau_context_init(&nvc0->base);
 
    ret = nouveau_bufctx_new(nvc0->base.client, 2, &nvc0->bufctx);
    if (!ret)
@@ -382,9 +399,6 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
    if (ret)
       goto out_err;
 
-   nvc0->screen = screen;
-   nvc0->base.screen = &screen->base;
-
    pipe->screen = pscreen;
    pipe->priv = priv;
    pipe->stream_uploader = u_upload_create_default(pipe);
@@ -405,7 +419,24 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
    pipe->get_sample_position = nvc0_context_get_sample_position;
    pipe->emit_string_marker = nvc0_emit_string_marker;
 
-   nouveau_context_init(&nvc0->base);
+   flags = NOUVEAU_BO_GART | NOUVEAU_BO_MAP;
+   if (screen->base.drm->version >= 0x01000202)
+      flags |= NOUVEAU_BO_COHERENT;
+
+   ret = nouveau_bo_new(screen->base.device, flags, 0, 4096, NULL, &nvc0->fence.bo);
+   if (ret)
+      goto out_err;
+   nouveau_bo_map(nvc0->fence.bo, 0, NULL);
+   nvc0->base.fence.data = nvc0->fence.bo;
+   nvc0->base.fence.emit = nvc0_screen_fence_emit;
+   nvc0->base.fence.update = nvc0_screen_fence_update;
+
+   nouveau_fence_new(&nvc0->base.fence, &nvc0->base.fence.current);
+
+   /* initialize the pushbuffer */
+   nouveau_pushbuf_bufctx(nvc0->base.pushbuf, nvc0->bufctx);
+   nouveau_pushbuf_validate(nvc0->base.pushbuf);
+
    nvc0_init_query_functions(nvc0);
    nvc0_init_surface_functions(nvc0);
    nvc0_init_state_functions(nvc0);
@@ -441,9 +472,10 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
    if (!screen->cur_ctx) {
       nvc0->state = screen->save_state;
       screen->cur_ctx = nvc0;
-      nouveau_pushbuf_bufctx(nvc0->base.pushbuf, nvc0->bufctx);
    }
    nvc0->base.pushbuf->kick_notify = nvc0_default_kick_notify;
+   nvc0->base.pushbuf->user_priv = nvc0;
+   nvc0->base.pushbuf->rsvd_kick = 5;
 
    /* add permanently resident buffers to bufctxts */
 
@@ -467,10 +499,10 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
 
    flags = NOUVEAU_BO_GART | NOUVEAU_BO_WR;
 
-   BCTX_REFN_bo(nvc0->bufctx_3d, 3D_SCREEN, flags, screen->fence.bo);
-   BCTX_REFN_bo(nvc0->bufctx, FENCE, flags, screen->fence.bo);
+   BCTX_REFN_bo(nvc0->bufctx_3d, 3D_SCREEN, flags, nvc0->fence.bo);
+   BCTX_REFN_bo(nvc0->bufctx, FENCE, flags, nvc0->fence.bo);
    if (screen->compute)
-      BCTX_REFN_bo(nvc0->bufctx_cp, CP_SCREEN, flags, screen->fence.bo);
+      BCTX_REFN_bo(nvc0->bufctx_cp, CP_SCREEN, flags, nvc0->fence.bo);
 
    nvc0->base.scratch.bo_size = 2 << 20;
 
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
index b7cc415359d..bef31f6a702 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
@@ -180,6 +180,10 @@ struct nvc0_context {
 
    struct nvc0_screen *screen;
 
+   struct {
+      struct nouveau_bo *bo;
+   } fence;
+
    void (*m2mf_copy_rect)(struct nvc0_context *,
                           const struct nv50_m2mf_rect *dst,
                           const struct nv50_m2mf_rect *src,
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
index 57d98753f45..f937d3420b5 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
@@ -826,7 +826,7 @@ nvc0_program_upload(struct nvc0_context *nvc0, struct nvc0_program *prog)
       IMMED_NVC0(nvc0->base.pushbuf, NVC0_3D(SERIALIZE), 0);
 
       if ((screen->text->size << 1) <= (1 << 23)) {
-         ret = nvc0_screen_resize_text_area(screen, screen->text->size << 1);
+         ret = nvc0_screen_resize_text_area(screen, nvc0->base.pushbuf, screen->text->size << 1);
          if (ret) {
             NOUVEAU_ERR("Error allocating TEXT area: %d\n", ret);
             return false;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
index 40cc552a29b..7a17f0aa604 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
@@ -49,7 +49,7 @@ nvc0_hw_query_allocate(struct nvc0_context *nvc0, struct nvc0_query *q,
          if (hq->state == NVC0_HW_QUERY_STATE_READY)
             nouveau_mm_free(hq->mm);
          else
-            nouveau_fence_work(screen->base.fence.current, nvc0->base.pushbuf,
+            nouveau_fence_work(nvc0->base.fence.current, nvc0->base.pushbuf,
                                nouveau_mm_free_work, hq->mm);
       }
    }
@@ -284,7 +284,7 @@ nvc0_hw_end_query(struct nvc0_context *nvc0, struct nvc0_query *q)
       break;
    }
    if (hq->is64bit)
-      nouveau_fence_ref(nvc0->screen->base.fence.current, &hq->fence);
+      nouveau_fence_ref(nvc0->base.fence.current, &hq->fence);
 }
 
 static boolean
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index 26642c2629d..c98084f7373 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -727,7 +727,7 @@ nvc0_magic_3d_init(struct nouveau_pushbuf *push, uint16_t obj_class)
     * are supposed to do */
 }
 
-static void
+void
 nvc0_screen_fence_emit(struct nouveau_fence_list *list, struct nouveau_pushbuf *push, u32 *sequence)
 {
    struct nouveau_bo *bo = list->data;
@@ -744,7 +744,7 @@ nvc0_screen_fence_emit(struct nouveau_fence_list *list, struct nouveau_pushbuf *
               (0xf << NVC0_3D_QUERY_GET_UNIT__SHIFT));
 }
 
-static uint32_t
+uint32_t
 nvc0_screen_fence_update(struct nouveau_fence_list *list)
 {
    struct nouveau_bo *bo = list->data;
@@ -809,9 +809,8 @@ nvc0_screen_resize_tls_area(struct nvc0_screen *screen,
 }
 
 int
-nvc0_screen_resize_text_area(struct nvc0_screen *screen, uint64_t size)
+nvc0_screen_resize_text_area(struct nvc0_screen *screen, struct nouveau_pushbuf *push, uint64_t size)
 {
-   struct nouveau_pushbuf *push = screen->base.pushbuf;
    struct nouveau_bo *bo;
    int ret;
 
@@ -851,13 +850,12 @@ nvc0_screen_resize_text_area(struct nvc0_screen *screen, uint64_t size)
 }
 
 void
-nvc0_screen_bind_cb_3d(struct nvc0_screen *screen, bool *can_serialize,
-                       int stage, int index, int size, uint64_t addr)
+nvc0_screen_bind_cb_3d(struct nvc0_screen *screen, struct nouveau_pushbuf *push,
+                       bool *can_serialize, int stage, int index, int size,
+                       uint64_t addr)
 {
    assert(stage != 5);
 
-   struct nouveau_pushbuf *push = screen->base.pushbuf;
-
    if (screen->base.class_3d >= GM107_3D_CLASS) {
       struct nvc0_cb_binding *binding = &screen->cb_bindings[stage][index];
 
@@ -1149,7 +1147,7 @@ nvc0_screen_create(struct nouveau_device *dev)
 
    nvc0_magic_3d_init(push, screen->eng3d->oclass);
 
-   ret = nvc0_screen_resize_text_area(screen, 1 << 19);
+   ret = nvc0_screen_resize_text_area(screen, push, 1 << 19);
    if (ret)
       FAIL_SCREEN_INIT("Error allocating TEXT area: %d\n", ret);
 
@@ -1339,7 +1337,7 @@ nvc0_screen_create(struct nouveau_device *dev)
 
       /* TIC and TSC entries for each unit (nve4+ only) */
       /* auxiliary constants (6 user clip planes, base instance id) */
-      nvc0_screen_bind_cb_3d(screen, NULL, i, 15, NVC0_CB_AUX_SIZE,
+      nvc0_screen_bind_cb_3d(screen, push, NULL, i, 15, NVC0_CB_AUX_SIZE,
                              screen->uniform_bo->offset + NVC0_CB_AUX_INFO(i));
       if (screen->eng3d->oclass >= NVE4_3D_CLASS) {
          unsigned j;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
index aecdb3494ef..24f9367560c 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
@@ -153,10 +153,11 @@ int nvc0_screen_tsc_alloc(struct nvc0_screen *, void *);
 int nve4_screen_compute_setup(struct nvc0_screen *, struct nouveau_pushbuf *);
 int nvc0_screen_compute_setup(struct nvc0_screen *, struct nouveau_pushbuf *);
 
-int nvc0_screen_resize_text_area(struct nvc0_screen *, uint64_t);
+int nvc0_screen_resize_text_area(struct nvc0_screen *, struct nouveau_pushbuf *, uint64_t);
 
 // 3D Only
-void nvc0_screen_bind_cb_3d(struct nvc0_screen *, bool *, int, int, int, uint64_t);
+void nvc0_screen_bind_cb_3d(struct nvc0_screen *, struct nouveau_pushbuf *push,
+                            bool *, int, int, int, uint64_t);
 
 static inline void
 nvc0_resource_fence(struct nv04_resource *res, uint32_t flags)
@@ -242,4 +243,10 @@ nvc0_screen_tsc_free(struct nvc0_screen *screen, struct nv50_tsc_entry *tsc)
    }
 }
 
+void
+nvc0_screen_fence_emit(struct nouveau_fence_list *, struct nouveau_pushbuf *, u32 *sequence);
+
+uint32_t
+nvc0_screen_fence_update(struct nouveau_fence_list *);
+
 #endif
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
index 4f004a4f705..7e3689dbb8b 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
@@ -584,7 +584,7 @@ nvc0_constbufs_validate(struct nvc0_context *nvc0)
             if (!nvc0->state.uniform_buffer_bound[s]) {
                nvc0->state.uniform_buffer_bound[s] = true;
 
-               nvc0_screen_bind_cb_3d(nvc0->screen, &can_serialize, s, i,
+               nvc0_screen_bind_cb_3d(nvc0->screen, nvc0->base.pushbuf, &can_serialize, s, i,
                                       NVC0_MAX_CONSTBUF_SIZE, bo->offset + base);
             }
             nvc0_cb_bo_push(&nvc0->base, bo, NV_VRAM_DOMAIN(&nvc0->screen->base),
@@ -595,7 +595,7 @@ nvc0_constbufs_validate(struct nvc0_context *nvc0)
             struct nv04_resource *res =
                nv04_resource(nvc0->constbuf[s][i].u.buf);
             if (res) {
-               nvc0_screen_bind_cb_3d(nvc0->screen, &can_serialize, s, i,
+               nvc0_screen_bind_cb_3d(nvc0->screen, nvc0->base.pushbuf, &can_serialize, s, i,
                                       nvc0->constbuf[s][i].size,
                                       res->address + nvc0->constbuf[s][i].offset);
 
@@ -607,7 +607,7 @@ nvc0_constbufs_validate(struct nvc0_context *nvc0)
                if (i == 0)
                   nvc0->state.uniform_buffer_bound[s] = false;
             } else if (i != 0) {
-               nvc0_screen_bind_cb_3d(nvc0->screen, &can_serialize, s, i, -1, 0);
+               nvc0_screen_bind_cb_3d(nvc0->screen, nvc0->base.pushbuf, &can_serialize, s, i, -1, 0);
             }
          }
       }
@@ -708,7 +708,7 @@ nvc0_validate_driverconst(struct nvc0_context *nvc0)
    int i;
 
    for (i = 0; i < 5; ++i)
-      nvc0_screen_bind_cb_3d(screen, NULL, i, 15, NVC0_CB_AUX_SIZE,
+      nvc0_screen_bind_cb_3d(screen, nvc0->base.pushbuf, NULL, i, 15, NVC0_CB_AUX_SIZE,
                              screen->uniform_bo->offset + NVC0_CB_AUX_INFO(i));
 
    nvc0->dirty_cp |= NVC0_NEW_CP_DRIVERCONST;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c b/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c
index 440d00dcc94..02daa35921a 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c
@@ -518,7 +518,7 @@ nvc0_miptree_transfer_unmap(struct pipe_context *pctx,
       NOUVEAU_DRV_STAT(&nvc0->screen->base, tex_transfers_wr, 1);
 
       /* Allow the copies above to finish executing before freeing the source */
-      nouveau_fence_work(nvc0->screen->base.fence.current, nvc0->base.pushbuf,
+      nouveau_fence_work(nvc0->base.fence.current, nvc0->base.pushbuf,
                          nouveau_fence_unref_bo, tx->rect[1].bo);
    } else {
       nouveau_bo_ref(NULL, &tx->rect[1].bo);
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c
index 31bb910c551..9bff3123f13 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c
@@ -552,11 +552,11 @@ nvc0_prim_gl(unsigned prim)
 static void
 nvc0_draw_vbo_kick_notify(struct nouveau_pushbuf *push)
 {
-   struct nvc0_screen *screen = push->user_priv;
+   struct nvc0_context *nvc0 = push->user_priv;
 
-   nouveau_fence_update(&screen->base.fence, true);
+   nouveau_fence_update(&nvc0->base.fence, true);
 
-   NOUVEAU_DRV_STAT(&screen->base, pushbuf_count, 1);
+   NOUVEAU_DRV_STAT(&nvc0->screen->base, pushbuf_count, 1);
 }
 
 static void
-- 
2.19.2



More information about the mesa-dev mailing list