On Fri, 2014-07-25 at 17:54 -0400, Tom Stellard wrote: > On Fri, Jul 25, 2014 at 11:28:19PM +0200, Bruno Jimenez wrote: > > On Fri, 2014-07-25 at 12:46 -0400, Tom Stellard wrote: > > > On Sat, Jul 19, 2014 at 07:35:51PM +0200, Bruno Jiménez wrote: > > > > This allows us two things: we now need less item copies when we have > > > > to defrag+grow the pool (to just one copy per item) and, even in the > > > > case where we don't need to defrag the pool, we reduce the data copied > > > > to just the useful data that the items use. > > > > > > > > Note: The fallback path is a bit ugly now, but hopefully we won't need > > > > it much. > > > > > > Hi, > > > > > > I pushed the first two patches, but I couldn't get this one to apply. > > > Could you send an updated version rebased on master? > > > > Hi, > > > > This patch needs this other patch first: > > http://lists.freedesktop.org/archives/mesa-dev/2014-July/062923.html > > > > As I mentioned it in the cover letter and you reviewed it when I sent it > > I thought that you would push it too. Although I forgot to say that it > > wasn't pushed, sorry. > > Sorry, I missed that. I've pushed both patches. > > -Tom
Thanks! Bruno > > > > > I can squash them and send it if needed. > > > > Sorry for any inconvenience. > > Bruno > > > > > > > > Thanks, > > > Tom > > > > > > > --- > > > > src/gallium/drivers/r600/compute_memory_pool.c | 40 > > > > ++++++++++++-------------- > > > > src/gallium/drivers/r600/compute_memory_pool.h | 2 +- > > > > 2 files changed, 19 insertions(+), 23 deletions(-) > > > > > > > > diff --git a/src/gallium/drivers/r600/compute_memory_pool.c > > > > b/src/gallium/drivers/r600/compute_memory_pool.c > > > > index ca36240..32f5892 100644 > > > > --- a/src/gallium/drivers/r600/compute_memory_pool.c > > > > +++ b/src/gallium/drivers/r600/compute_memory_pool.c > > > > @@ -169,10 +169,12 @@ struct list_head *compute_memory_postalloc_chunk( > > > > * Reallocates pool, conserves data. > > > > * @returns -1 if it fails, 0 otherwise > > > > */ > > > > -int compute_memory_grow_pool(struct compute_memory_pool* pool, > > > > - struct pipe_context * pipe, int new_size_in_dw) > > > > +int compute_memory_grow_defrag_pool(struct compute_memory_pool *pool, > > > > + struct pipe_context *pipe, int new_size_in_dw) > > > > { > > > > - COMPUTE_DBG(pool->screen, "* compute_memory_grow_pool() " > > > > + new_size_in_dw = align(new_size_in_dw, ITEM_ALIGNMENT); > > > > + > > > > + COMPUTE_DBG(pool->screen, "* compute_memory_grow_defrag_pool() " > > > > "new_size_in_dw = %d (%d bytes)\n", > > > > new_size_in_dw, new_size_in_dw * 4); > > > > > > > > @@ -183,27 +185,17 @@ int compute_memory_grow_pool(struct > > > > compute_memory_pool* pool, > > > > } else { > > > > struct r600_resource *temp = NULL; > > > > > > > > - new_size_in_dw = align(new_size_in_dw, ITEM_ALIGNMENT); > > > > - > > > > - COMPUTE_DBG(pool->screen, " Aligned size = %d (%d > > > > bytes)\n", > > > > - new_size_in_dw, new_size_in_dw * 4); > > > > - > > > > temp = (struct r600_resource > > > > *)r600_compute_buffer_alloc_vram( > > > > pool->screen, > > > > new_size_in_dw * 4); > > > > > > > > if (temp != NULL) { > > > > - struct r600_context *rctx = (struct > > > > r600_context *)pipe; > > > > struct pipe_resource *src = (struct > > > > pipe_resource *)pool->bo; > > > > struct pipe_resource *dst = (struct > > > > pipe_resource *)temp; > > > > - struct pipe_box box; > > > > > > > > - COMPUTE_DBG(pool->screen, " Growing the pool > > > > using a temporary resource\n"); > > > > + COMPUTE_DBG(pool->screen, " Growing and > > > > defragmenting the pool " > > > > + "using a temporary resource\n"); > > > > > > > > - u_box_1d(0, pool->size_in_dw * 4, &box); > > > > - > > > > - rctx->b.b.resource_copy_region(pipe, > > > > - dst, 0, 0, 0 ,0, > > > > - src, 0, &box); > > > > + compute_memory_defrag(pool, src, dst, pipe); > > > > > > > > pool->screen->b.b.resource_destroy( > > > > (struct pipe_screen > > > > *)pool->screen, > > > > @@ -229,6 +221,11 @@ int compute_memory_grow_pool(struct > > > > compute_memory_pool* pool, > > > > pool->screen, > > > > pool->size_in_dw * 4); > > > > compute_memory_shadow(pool, pipe, 0); > > > > + > > > > + if (pool->status & POOL_FRAGMENTED) { > > > > + struct pipe_resource *src = (struct > > > > pipe_resource *)pool->bo; > > > > + compute_memory_defrag(pool, src, src, > > > > pipe); > > > > + } > > > > } > > > > } > > > > > > > > @@ -292,16 +289,15 @@ int compute_memory_finalize_pending(struct > > > > compute_memory_pool* pool, > > > > return 0; > > > > } > > > > > > > > - if (pool->status & POOL_FRAGMENTED) { > > > > - struct pipe_resource *src = (struct pipe_resource > > > > *)pool->bo; > > > > - compute_memory_defrag(pool, src, src, pipe); > > > > - } > > > > - > > > > if (pool->size_in_dw < allocated + unallocated) { > > > > - err = compute_memory_grow_pool(pool, pipe, allocated + > > > > unallocated); > > > > + err = compute_memory_grow_defrag_pool(pool, pipe, > > > > allocated + unallocated); > > > > if (err == -1) > > > > return -1; > > > > } > > > > + else if (pool->status & POOL_FRAGMENTED) { > > > > + struct pipe_resource *src = (struct pipe_resource > > > > *)pool->bo; > > > > + compute_memory_defrag(pool, src, src, pipe); > > > > + } > > > > > > > > /* After defragmenting the pool, allocated is equal to the > > > > first available > > > > * position for new items in the pool */ > > > > diff --git a/src/gallium/drivers/r600/compute_memory_pool.h > > > > b/src/gallium/drivers/r600/compute_memory_pool.h > > > > index 5f1d72b..c7eb237 100644 > > > > --- a/src/gallium/drivers/r600/compute_memory_pool.h > > > > +++ b/src/gallium/drivers/r600/compute_memory_pool.h > > > > @@ -81,7 +81,7 @@ int64_t compute_memory_prealloc_chunk(struct > > > > compute_memory_pool* pool, int64_t > > > > > > > > struct list_head *compute_memory_postalloc_chunk(struct > > > > compute_memory_pool* pool, int64_t start_in_dw); ///search for the > > > > chunk where we can link our new chunk after it > > > > > > > > -int compute_memory_grow_pool(struct compute_memory_pool* pool, struct > > > > pipe_context * pipe, > > > > +int compute_memory_grow_defrag_pool(struct compute_memory_pool* pool, > > > > struct pipe_context * pipe, > > > > int new_size_in_dw); > > > > > > > > void compute_memory_shadow(struct compute_memory_pool* pool, > > > > -- > > > > 2.0.2 > > > > > > > > _______________________________________________ > > > > mesa-dev mailing list > > > > mesa-dev@lists.freedesktop.org > > > > http://lists.freedesktop.org/mailman/listinfo/mesa-dev > > > > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev