Mesa (master): nvc0: add space checks to clear functions

Maarten Lankhorst mlankhorst at kemper.freedesktop.org
Thu Jan 17 11:39:36 UTC 2013


Module: Mesa
Branch: master
Commit: edc8e8cbef874a37c721b576c3ecd2a9f2fd399b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=edc8e8cbef874a37c721b576c3ecd2a9f2fd399b

Author: Maarten Lankhorst <maarten.lankhorst at canonical.com>
Date:   Thu Jan 17 12:35:38 2013 +0100

nvc0: add space checks to clear functions

Thanks to calim for helping me find and fix the issue.

---

 src/gallium/drivers/nvc0/nvc0_surface.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/nvc0/nvc0_surface.c b/src/gallium/drivers/nvc0/nvc0_surface.c
index 591f67c..281d740 100644
--- a/src/gallium/drivers/nvc0/nvc0_surface.c
+++ b/src/gallium/drivers/nvc0/nvc0_surface.c
@@ -158,9 +158,8 @@ nvc0_2d_texture_do_copy(struct nouveau_pushbuf *push,
    const enum pipe_format sfmt = src->base.base.format;
    int ret;
 
-   ret = PUSH_SPACE(push, 2 * 16 + 32);
-   if (ret)
-      return ret;
+   if (!PUSH_SPACE(push, 2 * 16 + 32))
+      return PIPE_ERROR;
 
    ret = nvc0_2d_texture_set(push, TRUE, dst, dst_level, dz, dfmt);
    if (ret)
@@ -278,6 +277,11 @@ nvc0_clear_render_target(struct pipe_context *pipe,
    struct nv04_resource *res = nv04_resource(sf->base.texture);
    unsigned z;
 
+   if (!PUSH_SPACE(push, 32 + sf->depth))
+      return;
+
+   PUSH_REFN (push, res->bo, res->domain | NOUVEAU_BO_WR);
+
    BEGIN_NVC0(push, NVC0_3D(CLEAR_COLOR(0)), 4);
    PUSH_DATAf(push, color->f[0]);
    PUSH_DATAf(push, color->f[1]);
@@ -324,8 +328,8 @@ nvc0_clear_render_target(struct pipe_context *pipe,
       nvc0_resource_fence(res, NOUVEAU_BO_WR);
    }
 
+   BEGIN_NIC0(push, NVC0_3D(CLEAR_BUFFERS), sf->depth);
    for (z = 0; z < sf->depth; ++z) {
-      BEGIN_NVC0(push, NVC0_3D(CLEAR_BUFFERS), 1);
       PUSH_DATA (push, 0x3c |
                  (z << NVC0_3D_CLEAR_BUFFERS_LAYER__SHIFT));
    }
@@ -350,6 +354,11 @@ nvc0_clear_depth_stencil(struct pipe_context *pipe,
 	int unk = mt->base.base.target == PIPE_TEXTURE_2D;
 	unsigned z;
 
+	if (!PUSH_SPACE(push, 32 + sf->depth))
+		return;
+
+	PUSH_REFN (push, mt->base.bo, mt->base.domain | NOUVEAU_BO_WR);
+
 	if (clear_flags & PIPE_CLEAR_DEPTH) {
 		BEGIN_NVC0(push, NVC0_3D(CLEAR_DEPTH), 1);
 		PUSH_DATAf(push, depth);
@@ -381,8 +390,8 @@ nvc0_clear_depth_stencil(struct pipe_context *pipe,
 	BEGIN_NVC0(push, NVC0_3D(ZETA_BASE_LAYER), 1);
 	PUSH_DATA (push, dst->u.tex.first_layer);
 
+	BEGIN_NIC0(push, NVC0_3D(CLEAR_BUFFERS), sf->depth);
 	for (z = 0; z < sf->depth; ++z) {
-		BEGIN_NVC0(push, NVC0_3D(CLEAR_BUFFERS), 1);
 		PUSH_DATA (push, mode |
 			   (z << NVC0_3D_CLEAR_BUFFERS_LAYER__SHIFT));
 	}




More information about the mesa-commit mailing list