Ilia Mirkin
2014-Nov-16  00:48 UTC
[Nouveau] [PATCH 1/2] nv50, nvc0: actually check constbufs for invalidation
The number of vertex buffers has nothing to do with the number of bound
constbufs.
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
Cc: "10.4 10.3" <mesa-stable at lists.freedesktop.org>
---
 src/gallium/drivers/nouveau/nv50/nv50_context.c | 5 +++--
 src/gallium/drivers/nouveau/nvc0/nvc0_context.c | 4 +++-
 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_context.c
b/src/gallium/drivers/nouveau/nv50/nv50_context.c
index 07f6378..5e907d7 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_context.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_context.c
@@ -214,8 +214,9 @@ nv50_invalidate_resource_storage(struct nouveau_context
*ctx,
 
    if (res->bind & PIPE_BIND_CONSTANT_BUFFER) {
       for (s = 0; s < 3; ++s) {
-      assert(nv50->num_vtxbufs <= NV50_MAX_PIPE_CONSTBUFS);
-      for (i = 0; i < nv50->num_vtxbufs; ++i) {
+      for (i = 0; i < NV50_MAX_PIPE_CONSTBUFS; ++i) {
+         if (!(nv50->constbuf_valid[s] & (1 << i)))
+            continue;
          if (!nv50->constbuf[s][i].user &&
              nv50->constbuf[s][i].u.buf == res) {
             nv50->dirty |= NV50_NEW_CONSTBUF;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
index b33a673..49a46ea 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
@@ -232,7 +232,9 @@ nvc0_invalidate_resource_storage(struct nouveau_context
*ctx,
 
    if (res->bind & PIPE_BIND_CONSTANT_BUFFER) {
       for (s = 0; s < 5; ++s) {
-      for (i = 0; i < nvc0->num_vtxbufs; ++i) {
+      for (i = 0; i < NVC0_MAX_PIPE_CONSTBUFS; ++i) {
+         if (!(nvc0->constbuf_valid[s] & (1 << i)))
+            continue;
          if (!nvc0->constbuf[s][i].user &&
              nvc0->constbuf[s][i].u.buf == res) {
             nvc0->dirty |= NVC0_NEW_CONSTBUF;
-- 
2.0.4
Ilia Mirkin
2014-Nov-16  00:48 UTC
[Nouveau] [PATCH 2/2] nv50, nvc0: buffer resources can be bound as other things down the line
res->bind is not an indicator of how the resource is currently bound.
buffers can be rebound across different binding points without changing
underlying storage.
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
Cc: "10.4 10.3" <mesa-stable at lists.freedesktop.org>
---
 src/gallium/drivers/nouveau/nv50/nv50_context.c | 14 +++++++-------
 src/gallium/drivers/nouveau/nvc0/nvc0_context.c | 14 +++++++-------
 2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_context.c
b/src/gallium/drivers/nouveau/nv50/nv50_context.c
index 5e907d7..1a53579 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_context.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_context.c
@@ -180,7 +180,12 @@ nv50_invalidate_resource_storage(struct nouveau_context
*ctx,
       }
    }
 
-   if (res->bind & PIPE_BIND_VERTEX_BUFFER) {
+   if (res->bind & (PIPE_BIND_VERTEX_BUFFER |
+                    PIPE_BIND_INDEX_BUFFER |
+                    PIPE_BIND_CONSTANT_BUFFER |
+                    PIPE_BIND_STREAM_OUTPUT |
+                    PIPE_BIND_SAMPLER_VIEW)) {
+
       assert(nv50->num_vtxbufs <= PIPE_MAX_ATTRIBS);
       for (i = 0; i < nv50->num_vtxbufs; ++i) {
          if (nv50->vtxbuf[i].buffer == res) {
@@ -190,14 +195,11 @@ nv50_invalidate_resource_storage(struct nouveau_context
*ctx,
                return ref;
          }
       }
-   }
-   if (res->bind & PIPE_BIND_INDEX_BUFFER) {
+
       if (nv50->idxbuf.buffer == res)
          if (!--ref)
             return ref;
-   }
 
-   if (res->bind & PIPE_BIND_SAMPLER_VIEW) {
       for (s = 0; s < 3; ++s) {
       assert(nv50->num_textures[s] <= PIPE_MAX_SAMPLERS);
       for (i = 0; i < nv50->num_textures[s]; ++i) {
@@ -210,9 +212,7 @@ nv50_invalidate_resource_storage(struct nouveau_context
*ctx,
          }
       }
       }
-   }
 
-   if (res->bind & PIPE_BIND_CONSTANT_BUFFER) {
       for (s = 0; s < 3; ++s) {
       for (i = 0; i < NV50_MAX_PIPE_CONSTBUFS; ++i) {
          if (!(nv50->constbuf_valid[s] & (1 << i)))
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
index 49a46ea..3992460 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
@@ -196,7 +196,12 @@ nvc0_invalidate_resource_storage(struct nouveau_context
*ctx,
       }
    }
 
-   if (res->bind & PIPE_BIND_VERTEX_BUFFER) {
+   if (res->bind & (PIPE_BIND_VERTEX_BUFFER |
+                    PIPE_BIND_INDEX_BUFFER |
+                    PIPE_BIND_CONSTANT_BUFFER |
+                    PIPE_BIND_STREAM_OUTPUT |
+                    PIPE_BIND_COMMAND_ARGS_BUFFER |
+                    PIPE_BIND_SAMPLER_VIEW)) {
       for (i = 0; i < nvc0->num_vtxbufs; ++i) {
          if (nvc0->vtxbuf[i].buffer == res) {
             nvc0->dirty |= NVC0_NEW_ARRAYS;
@@ -205,17 +210,14 @@ nvc0_invalidate_resource_storage(struct nouveau_context
*ctx,
                return ref;
          }
       }
-   }
-   if (res->bind & PIPE_BIND_INDEX_BUFFER) {
+
       if (nvc0->idxbuf.buffer == res) {
          nvc0->dirty |= NVC0_NEW_IDXBUF;
          nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_IDX);
          if (!--ref)
             return ref;
       }
-   }
 
-   if (res->bind & PIPE_BIND_SAMPLER_VIEW) {
       for (s = 0; s < 5; ++s) {
       for (i = 0; i < nvc0->num_textures[s]; ++i) {
          if (nvc0->textures[s][i] &&
@@ -228,9 +230,7 @@ nvc0_invalidate_resource_storage(struct nouveau_context
*ctx,
          }
       }
       }
-   }
 
-   if (res->bind & PIPE_BIND_CONSTANT_BUFFER) {
       for (s = 0; s < 5; ++s) {
       for (i = 0; i < NVC0_MAX_PIPE_CONSTBUFS; ++i) {
          if (!(nvc0->constbuf_valid[s] & (1 << i)))
-- 
2.0.4
Maybe Matching Threads
- [PATCH 0/3] nvc0: ARB_(multi_)draw_indirect support
- [PATCH 1/2] nv50: do an explicit flush on draw when there are persistent buffers
- [PATCH 1/2] nouveau: remove cb_dirty, it's never used
- [PATCH] nv50: fix setting of texture ms info to be per-stage
- [Mesa-dev] Crash with Mesa-10.4.4 and NV68