diff options
author | Maarten Lankhorst <[email protected]> | 2013-01-17 12:35:38 +0100 |
---|---|---|
committer | Maarten Lankhorst <[email protected]> | 2013-01-17 12:37:25 +0100 |
commit | edc8e8cbef874a37c721b576c3ecd2a9f2fd399b (patch) | |
tree | 9d2e4ce5d7076c0749579e4390b74b99b26ae826 /src | |
parent | 5dc76c76709e46dc29a667eea3d52a4fe55b40bb (diff) |
nvc0: add space checks to clear functions
Thanks to calim for helping me find and fix the issue.
Diffstat (limited to 'src')
-rw-r--r-- | 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 591f67c07dc..281d740b218 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)); } |