nvc0: update tic in-place when buffer address changes
authorIlia Mirkin <imirkin@alum.mit.edu>
Sat, 30 Dec 2017 06:07:30 +0000 (01:07 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Sun, 7 Jan 2018 16:15:23 +0000 (11:15 -0500)
This is helpful for bindless, where changing TIC id's is undesirable.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/nouveau/nvc0/nvc0_context.h
src/gallium/drivers/nouveau/nvc0/nvc0_tex.c

index 6f631b993c0af42331cfdd4d8e9fa05ee1bc10f2..f0eabb02fe21155fc5df69170c0bf76f9a6c7ca9 100644 (file)
@@ -345,7 +345,7 @@ void nvc0_validate_surfaces(struct nvc0_context *);
 void nve4_set_surface_info(struct nouveau_pushbuf *, struct pipe_image_view *,
                            struct nvc0_context *);
 void nvc0_mark_image_range_valid(const struct pipe_image_view *);
-void nvc0_update_tic(struct nvc0_context *, struct nv50_tic_entry *,
+bool nvc0_update_tic(struct nvc0_context *, struct nv50_tic_entry *,
                      struct nv04_resource *);
 
 struct pipe_sampler_view *
index e57391e9a3292a28412f56b8c4ef3e9fc7354aeb..5ed1d06ce2a1ecda0b77f5f3d95a88aa7eb4daca 100644 (file)
@@ -449,23 +449,30 @@ nvc0_create_texture_view(struct pipe_context *pipe,
    return gf100_create_texture_view(pipe, texture, templ, flags, target);
 }
 
-void
+bool
 nvc0_update_tic(struct nvc0_context *nvc0, struct nv50_tic_entry *tic,
                 struct nv04_resource *res)
 {
    uint64_t address = res->address;
    if (res->base.target != PIPE_BUFFER)
-      return;
+      return false;
    address += tic->pipe.u.buf.offset;
    if (tic->tic[1] == (uint32_t)address &&
        (tic->tic[2] & 0xff) == address >> 32)
-      return;
+      return false;
 
-   nvc0_screen_tic_unlock(nvc0->screen, tic);
-   tic->id = -1;
    tic->tic[1] = address;
    tic->tic[2] &= 0xffffff00;
    tic->tic[2] |= address >> 32;
+
+   if (tic->id >= 0) {
+      nvc0->base.push_data(&nvc0->base, nvc0->screen->txc, tic->id * 32,
+                           NV_VRAM_DOMAIN(&nvc0->screen->base), 32,
+                           tic->tic);
+      return true;
+   }
+
+   return false;
 }
 
 bool
@@ -488,14 +495,14 @@ nvc0_validate_tic(struct nvc0_context *nvc0, int s)
          continue;
       }
       res = nv04_resource(tic->pipe.texture);
-      nvc0_update_tic(nvc0, tic, res);
+      need_flush |= nvc0_update_tic(nvc0, tic, res);
 
       if (tic->id < 0) {
          tic->id = nvc0_screen_tic_alloc(nvc0->screen, tic);
 
-         nvc0_m2mf_push_linear(&nvc0->base, nvc0->screen->txc, tic->id * 32,
-                               NV_VRAM_DOMAIN(&nvc0->screen->base), 32,
-                               tic->tic);
+         nvc0->base.push_data(&nvc0->base, nvc0->screen->txc, tic->id * 32,
+                              NV_VRAM_DOMAIN(&nvc0->screen->base), 32,
+                              tic->tic);
          need_flush = true;
       } else
       if (res->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING) {
@@ -554,14 +561,14 @@ nve4_validate_tic(struct nvc0_context *nvc0, unsigned s)
          continue;
       }
       res = nv04_resource(tic->pipe.texture);
-      nvc0_update_tic(nvc0, tic, res);
+      need_flush |= nvc0_update_tic(nvc0, tic, res);
 
       if (tic->id < 0) {
          tic->id = nvc0_screen_tic_alloc(nvc0->screen, tic);
 
-         nve4_p2mf_push_linear(&nvc0->base, nvc0->screen->txc, tic->id * 32,
-                               NV_VRAM_DOMAIN(&nvc0->screen->base), 32,
-                               tic->tic);
+         nvc0->base.push_data(&nvc0->base, nvc0->screen->txc, tic->id * 32,
+                              NV_VRAM_DOMAIN(&nvc0->screen->base), 32,
+                              tic->tic);
          need_flush = true;
       } else
       if (res->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING) {