Too bad there were a bug in this patch so here is fix and a improvement to
debug output.
On Tue, Aug 18, 2009 at 8:38 PM, Alex Deucher <[email protected]> wrote:
> On Tue, Aug 18, 2009 at 1:04 PM, Pauli Nieminen<[email protected]> wrote:
> > There has been some updates to master branch again which conflict with
> these
> > patches so here is updated versions.
> >
>
> These looks good and fix the geometry corruption issues on r6xx/r7xx.
> I've gone ahead and pushed them. As you mentioned we still seem to be
> leaking some bo's in the r600 driver, but things are much better and
> should be easier to track down. Thanks!
>
> Alex
>
From e7e087e1ec56fe7313336d91315930c30e1ecef0 Mon Sep 17 00:00:00 2001
From: Pauli Nieminen <[email protected]>
Date: Wed, 19 Aug 2009 14:47:25 +0300
Subject: [PATCH 1/2] radeon: Fix dma buffer object pool to scale object sizes.
This fixes problems when application is using large vertex arrays for drawing.
Signed-off-by: Pauli Nieminen <[email protected]>
---
.../drivers/dri/radeon/radeon_common_context.h | 5 +-
src/mesa/drivers/dri/radeon/radeon_dma.c | 48 ++++++++++++++++----
2 files changed, 42 insertions(+), 11 deletions(-)
diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.h b/src/mesa/drivers/dri/radeon/radeon_common_context.h
index 39fab66..9e9c356 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.h
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.h
@@ -313,8 +313,9 @@ struct radeon_dma {
struct radeon_dma_bo free;
struct radeon_dma_bo wait;
struct radeon_dma_bo reserved;
- int current_used; /** Number of bytes allocated and forgotten about */
- int current_vertexptr; /** End of active vertex region */
+ size_t current_used; /** Number of bytes allocated and forgotten about */
+ size_t current_vertexptr; /** End of active vertex region */
+ size_t minimum_size;
/**
* If current_vertexptr != current_used then flush must be non-zero.
diff --git a/src/mesa/drivers/dri/radeon/radeon_dma.c b/src/mesa/drivers/dri/radeon/radeon_dma.c
index 3019184..edf9ea0 100644
--- a/src/mesa/drivers/dri/radeon/radeon_dma.c
+++ b/src/mesa/drivers/dri/radeon/radeon_dma.c
@@ -164,14 +164,18 @@ void rcommon_emit_vector(GLcontext * ctx, struct radeon_aos *aos,
void radeon_init_dma(radeonContextPtr rmesa)
{
- make_empty_list(&rmesa->dma.free);
- make_empty_list(&rmesa->dma.wait);
- make_empty_list(&rmesa->dma.reserved);
+ make_empty_list(&rmesa->dma.free);
+ make_empty_list(&rmesa->dma.wait);
+ make_empty_list(&rmesa->dma.reserved);
+ rmesa->dma.minimum_size = MAX_DMA_BUF_SZ;
}
void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size)
{
- size = MAX2(size, MAX_DMA_BUF_SZ);
+ /* we set minimum sizes to at least requested size
+ aligned to next 16 bytes. */
+ if (size > rmesa->dma.minimum_size)
+ rmesa->dma.minimum_size = (size + 15) & (~15);
if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA))
fprintf(stderr, "%s\n", __FUNCTION__);
@@ -184,14 +188,15 @@ void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size)
if (!is_empty_list(&rmesa->dma.reserved))
radeon_bo_unmap(first_elem(&rmesa->dma.reserved)->bo);
- if (is_empty_list(&rmesa->dma.free)) {
+ if (is_empty_list(&rmesa->dma.free)
+ || last_elem(&rmesa->dma.free)->bo->size < size) {
struct radeon_dma_bo *dma_bo = CALLOC(sizeof(struct radeon_dma_bo));
assert(dma_bo);
again_alloc:
dma_bo->bo = radeon_bo_open(rmesa->radeonScreen->bom,
- 0, size, 4, RADEON_GEM_DOMAIN_GTT,
- 0);
+ 0, rmesa->dma.minimum_size, 4,
+ RADEON_GEM_DOMAIN_GTT, 0);
if (!dma_bo->bo) {
rcommonFlushCmdBuf(rmesa, __FUNCTION__);
@@ -241,7 +246,7 @@ void radeonAllocDmaRegion(radeonContextPtr rmesa,
if (is_empty_list(&rmesa->dma.reserved)
|| rmesa->dma.current_used + bytes > first_elem(&rmesa->dma.reserved)->bo->size)
- radeonRefillCurrentDmaRegion(rmesa, (bytes + 15) & ~15);
+ radeonRefillCurrentDmaRegion(rmesa, bytes);
*poffset = rmesa->dma.current_used;
*pbo = first_elem(&rmesa->dma.reserved)->bo;
@@ -267,6 +272,12 @@ void radeonFreeDmaRegions(radeonContextPtr rmesa)
FREE(dma_bo);
}
+ foreach_s(dma_bo, temp, &rmesa->dma.free) {
+ remove_from_list(dma_bo);
+ radeon_bo_unref(dma_bo->bo);
+ FREE(dma_bo);
+ }
+
foreach_s(dma_bo, temp, &rmesa->dma.reserved) {
remove_from_list(dma_bo);
radeon_bo_unmap(dma_bo->bo);
@@ -286,6 +297,11 @@ void radeonReturnDmaRegion(radeonContextPtr rmesa, int return_bytes)
rmesa->dma.current_vertexptr = rmesa->dma.current_used;
}
+static int radeon_bo_is_idle(struct radeon_bo* bo)
+{
+ return bo->cref == 1;
+}
+
void radeonReleaseDmaRegions(radeonContextPtr rmesa)
{
struct radeon_dma_bo *dma_bo;
@@ -305,7 +321,14 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa)
FREE(dma_bo);
continue;
}
- if (dma_bo->bo->cref > 1)
+ /* free objects that are too small to be used because of large request */
+ if (dma_bo->bo->size < rmesa->dma.minimum_size) {
+ radeon_bo_unref(dma_bo->bo);
+ remove_from_list(dma_bo);
+ FREE(dma_bo);
+ continue;
+ }
+ if (!radeon_bo_is_idle(dma_bo->bo))
continue;
remove_from_list(dma_bo);
dma_bo->expire_counter = expire_at;
@@ -317,6 +340,13 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa)
radeon_bo_unmap(first_elem(&rmesa->dma.reserved)->bo);
/* move reserved to wait list */
foreach_s(dma_bo, temp, &rmesa->dma.reserved) {
+ /* free objects that are too small to be used because of large request */
+ if (dma_bo->bo->size < rmesa->dma.minimum_size) {
+ radeon_bo_unref(dma_bo->bo);
+ remove_from_list(dma_bo);
+ FREE(dma_bo);
+ continue;
+ }
remove_from_list(dma_bo);
dma_bo->expire_counter = expire_at;
insert_at_tail(&rmesa->dma.wait, dma_bo);
--
1.6.3.3
From d8c7a8bae1bdb985b17722891cf231884073044c Mon Sep 17 00:00:00 2001
From: Pauli Nieminen <[email protected]>
Date: Wed, 19 Aug 2009 15:20:15 +0300
Subject: [PATCH 2/2] radeon: Add debug output for dma buffer object numbers.
Signed-off-by: Pauli Nieminen <[email protected]>
---
src/mesa/drivers/dri/radeon/radeon_dma.c | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/mesa/drivers/dri/radeon/radeon_dma.c b/src/mesa/drivers/dri/radeon/radeon_dma.c
index edf9ea0..a97438e 100644
--- a/src/mesa/drivers/dri/radeon/radeon_dma.c
+++ b/src/mesa/drivers/dri/radeon/radeon_dma.c
@@ -263,7 +263,7 @@ void radeonFreeDmaRegions(radeonContextPtr rmesa)
{
struct radeon_dma_bo *dma_bo;
struct radeon_dma_bo *temp;
- if (RADEON_DEBUG & DEBUG_IOCTL)
+ if (RADEON_DEBUG & DEBUG_DMA)
fprintf(stderr, "%s\n", __FUNCTION__);
foreach_s(dma_bo, temp, &rmesa->dma.free) {
@@ -308,8 +308,23 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa)
struct radeon_dma_bo *temp;
const int expire_at = ++rmesa->dma.free.expire_counter + DMA_BO_FREE_TIME;
const int time = rmesa->dma.free.expire_counter;
- if (RADEON_DEBUG & DEBUG_IOCTL)
- fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (RADEON_DEBUG & DEBUG_DMA) {
+ size_t free = 0,
+ wait = 0,
+ reserved = 0;
+ foreach(dma_bo, &rmesa->dma.free)
+ ++free;
+
+ foreach(dma_bo, &rmesa->dma.wait)
+ ++wait;
+
+ foreach(dma_bo, &rmesa->dma.reserved)
+ ++reserved;
+
+ fprintf(stderr, "%s: free %u, wait %u, reserved %u, minimum_size: %u\n",
+ __FUNCTION__, free, wait, reserved, rmesa->dma.minimum_size);
+ }
/* move waiting bos to free list.
wait list provides gpu time to handle data before reuse */
--
1.6.3.3
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev