summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorTilman Sauerbeck <[email protected]>2010-09-26 19:26:24 +0200
committerTilman Sauerbeck <[email protected]>2010-09-28 22:12:23 +0200
commit35f94b1942d9b99463ef9e179ebf70809e3bea69 (patch)
tree4d0166c19d8f57ec1ca56b21a30c29ef65b77da1 /src/gallium/drivers
parent89f6783d1769c61b835b49a5fb4405a3249031f4 (diff)
r600g: Cleaned up index buffer reference handling in the draw module.
This fixes a buffer leak. Signed-off-by: Tilman Sauerbeck <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/r600/r600_buffer.c5
-rw-r--r--src/gallium/drivers/r600/r600_draw.c4
-rw-r--r--src/gallium/drivers/r600/r600_state2.c9
3 files changed, 14 insertions, 4 deletions
diff --git a/src/gallium/drivers/r600/r600_buffer.c b/src/gallium/drivers/r600/r600_buffer.c
index 1621b2ab63f..d734e2349fb 100644
--- a/src/gallium/drivers/r600/r600_buffer.c
+++ b/src/gallium/drivers/r600/r600_buffer.c
@@ -280,7 +280,10 @@ int r600_upload_index_buffer(struct r600_context *rctx,
goto done;
}
draw->index_buffer_offset = index_offset;
- draw->index_buffer = upload_buffer;
+
+ /* Transfer ownership. */
+ pipe_resource_reference(&draw->index_buffer, upload_buffer);
+ pipe_resource_reference(&upload_buffer, NULL);
}
done:
diff --git a/src/gallium/drivers/r600/r600_draw.c b/src/gallium/drivers/r600/r600_draw.c
index afc3b7bba16..c41156f15fd 100644
--- a/src/gallium/drivers/r600/r600_draw.c
+++ b/src/gallium/drivers/r600/r600_draw.c
@@ -168,7 +168,7 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
info->count);
draw.index_size = rctx->index_buffer.index_size;
- draw.index_buffer = rctx->index_buffer.buffer;
+ pipe_resource_reference(&draw.index_buffer, rctx->index_buffer.buffer);
draw.index_buffer_offset = draw.start * draw.index_size;
draw.start = 0;
r600_upload_index_buffer(rctx, &draw);
@@ -185,4 +185,6 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
r = r600_draw_common(&draw);
if (r)
fprintf(stderr,"draw common failed %d\n", r);
+
+ pipe_resource_reference(&draw.index_buffer, NULL);
}
diff --git a/src/gallium/drivers/r600/r600_state2.c b/src/gallium/drivers/r600/r600_state2.c
index 796442f5a4b..bbbf2790ccc 100644
--- a/src/gallium/drivers/r600/r600_state2.c
+++ b/src/gallium/drivers/r600/r600_state2.c
@@ -672,7 +672,7 @@ static void r600_draw_vbo2(struct pipe_context *ctx, const struct pipe_draw_info
info->count);
draw.index_size = rctx->index_buffer.index_size;
- draw.index_buffer = rctx->index_buffer.buffer;
+ pipe_resource_reference(&draw.index_buffer, rctx->index_buffer.buffer);
draw.index_buffer_offset = draw.start * draw.index_size;
draw.start = 0;
r600_upload_index_buffer2(rctx, &draw);
@@ -684,6 +684,8 @@ static void r600_draw_vbo2(struct pipe_context *ctx, const struct pipe_draw_info
draw.index_bias = info->start;
}
r600_draw_common(&draw);
+
+ pipe_resource_reference(&draw.index_buffer, NULL);
}
static void r600_flush2(struct pipe_context *ctx, unsigned flags,
@@ -2463,7 +2465,10 @@ int r600_upload_index_buffer2(struct r600_pipe_context *rctx, struct r600_drawl
goto done;
}
draw->index_buffer_offset = index_offset;
- draw->index_buffer = upload_buffer;
+
+ /* Transfer ownership. */
+ pipe_resource_reference(&draw->index_buffer, upload_buffer);
+ pipe_resource_reference(&upload_buffer, NULL);
}
done: