mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 19:50:11 +01:00
eg/compute: Use reference counting to handle compute memory pool.
Use pipe_reference to release old RAT surfaces.
RAT surface adds a reference to pool bo, so use reference counting for pool->bo
as well.
v2: Use the same pattern for both defrag paths
Drop confusing comment
CC: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
e01af38d6f
commit
f3521ce2c4
2 changed files with 7 additions and 12 deletions
|
|
@ -91,10 +91,7 @@ void compute_memory_pool_delete(struct compute_memory_pool* pool)
|
||||||
{
|
{
|
||||||
COMPUTE_DBG(pool->screen, "* compute_memory_pool_delete()\n");
|
COMPUTE_DBG(pool->screen, "* compute_memory_pool_delete()\n");
|
||||||
free(pool->shadow);
|
free(pool->shadow);
|
||||||
if (pool->bo) {
|
pipe_resource_reference(&pool->bo, NULL);
|
||||||
pool->screen->b.b.resource_destroy((struct pipe_screen *)
|
|
||||||
pool->screen, (struct pipe_resource *)pool->bo);
|
|
||||||
}
|
|
||||||
/* In theory, all of the items were freed in compute_memory_free.
|
/* In theory, all of the items were freed in compute_memory_free.
|
||||||
* Just delete the list heads
|
* Just delete the list heads
|
||||||
*/
|
*/
|
||||||
|
|
@ -213,10 +210,8 @@ int compute_memory_grow_defrag_pool(struct compute_memory_pool *pool,
|
||||||
|
|
||||||
compute_memory_defrag(pool, src, dst, pipe);
|
compute_memory_defrag(pool, src, dst, pipe);
|
||||||
|
|
||||||
pool->screen->b.b.resource_destroy(
|
/* Release the old buffer */
|
||||||
(struct pipe_screen *)pool->screen,
|
pipe_resource_reference(&pool->bo, NULL);
|
||||||
src);
|
|
||||||
|
|
||||||
pool->bo = temp;
|
pool->bo = temp;
|
||||||
pool->size_in_dw = new_size_in_dw;
|
pool->size_in_dw = new_size_in_dw;
|
||||||
}
|
}
|
||||||
|
|
@ -230,9 +225,8 @@ int compute_memory_grow_defrag_pool(struct compute_memory_pool *pool,
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pool->size_in_dw = new_size_in_dw;
|
pool->size_in_dw = new_size_in_dw;
|
||||||
pool->screen->b.b.resource_destroy(
|
/* Release the old buffer */
|
||||||
(struct pipe_screen *)pool->screen,
|
pipe_resource_reference(&pool->bo, NULL);
|
||||||
(struct pipe_resource *)pool->bo);
|
|
||||||
pool->bo = r600_compute_buffer_alloc_vram(pool->screen, pool->size_in_dw * 4);
|
pool->bo = r600_compute_buffer_alloc_vram(pool->screen, pool->size_in_dw * 4);
|
||||||
compute_memory_shadow(pool, pipe, 0);
|
compute_memory_shadow(pool, pipe, 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,8 @@ static void evergreen_set_rat(struct r600_pipe_compute *pipe,
|
||||||
rat_templ.u.tex.first_layer = 0;
|
rat_templ.u.tex.first_layer = 0;
|
||||||
rat_templ.u.tex.last_layer = 0;
|
rat_templ.u.tex.last_layer = 0;
|
||||||
|
|
||||||
/* Add the RAT the list of color buffers */
|
/* Add the RAT the list of color buffers. Drop the old buffer first. */
|
||||||
|
pipe_surface_reference(&pipe->ctx->framebuffer.state.cbufs[id], NULL);
|
||||||
pipe->ctx->framebuffer.state.cbufs[id] = pipe->ctx->b.b.create_surface(
|
pipe->ctx->framebuffer.state.cbufs[id] = pipe->ctx->b.b.create_surface(
|
||||||
(struct pipe_context *)pipe->ctx,
|
(struct pipe_context *)pipe->ctx,
|
||||||
(struct pipe_resource *)bo, &rat_templ);
|
(struct pipe_resource *)bo, &rat_templ);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue