From: Kenneth Graunke Date: Fri, 6 Jul 2018 18:29:51 +0000 (-0700) Subject: iris: slab allocate transfers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a3f77eceb4d08fbb83c3a853f339cb77d9b46aa4;p=mesa.git iris: slab allocate transfers apparently we need this for u_threaded_context --- diff --git a/src/gallium/drivers/iris/iris_context.c b/src/gallium/drivers/iris/iris_context.c index 155d3932cb6..9d0ec83afb4 100644 --- a/src/gallium/drivers/iris/iris_context.c +++ b/src/gallium/drivers/iris/iris_context.c @@ -84,6 +84,8 @@ iris_destroy_context(struct pipe_context *ctx) u_upload_destroy(ice->state.surface_uploader); u_upload_destroy(ice->state.dynamic_uploader); + slab_destroy_child(&ice->transfer_pool); + iris_batch_free(&ice->render_batch); ralloc_free(ice); @@ -138,6 +140,8 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags) iris_init_program_cache(ice); iris_init_border_color_pool(ice); + slab_create_child(&ice->transfer_pool, &screen->transfer_pool); + ice->state.surface_uploader = u_upload_create(&ice->ctx, 16384, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, IRIS_RESOURCE_FLAG_SURFACE_MEMZONE); diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index 6f3112ab4af..4d1b616750a 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -229,6 +229,8 @@ struct iris_context { struct pipe_debug_callback dbg; + struct slab_child_pool transfer_pool; + struct iris_vtable vtbl; struct { diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index 9327fbc6672..3a16e54b2b3 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -394,18 +394,6 @@ iris_resource_get_handle(struct pipe_screen *pscreen, return false; } -struct iris_transfer { - struct pipe_transfer base; - struct pipe_debug_callback *dbg; - void *buffer; - void *ptr; - - /** Stride of the temporary image (not the actual surface) */ - int temp_stride; - - void (*unmap)(struct iris_transfer *); -}; - /* Compute extent parameters for use with tiled_memcpy functions. * xs are in units of bytes and ys are in units of strides. */ @@ -535,7 +523,7 @@ iris_transfer_map(struct pipe_context *ctx, if ((usage & PIPE_TRANSFER_DONTBLOCK) && iris_bo_busy(res->bo)) return NULL; - struct iris_transfer *map = calloc(1, sizeof(struct iris_transfer)); + struct iris_transfer *map = slab_alloc(&ice->transfer_pool); struct pipe_transfer *xfer = &map->base; // PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE @@ -544,6 +532,7 @@ iris_transfer_map(struct pipe_context *ctx, if (!map) return NULL; + memset(map, 0, sizeof(*map)); map->dbg = &ice->dbg; pipe_resource_reference(&xfer->resource, resource); @@ -578,15 +567,16 @@ iris_transfer_flush_region(struct pipe_context *pipe, } static void -iris_transfer_unmap(struct pipe_context *pipe, struct pipe_transfer *xfer) +iris_transfer_unmap(struct pipe_context *ctx, struct pipe_transfer *xfer) { + struct iris_context *ice = (struct iris_context *)ctx; struct iris_transfer *map = (void *) xfer; if (map->unmap) map->unmap(map); pipe_resource_reference(&xfer->resource, NULL); - free(map); + slab_free(&ice->transfer_pool, map); } static void diff --git a/src/gallium/drivers/iris/iris_resource.h b/src/gallium/drivers/iris/iris_resource.h index 3280dc1c49c..22817193795 100644 --- a/src/gallium/drivers/iris/iris_resource.h +++ b/src/gallium/drivers/iris/iris_resource.h @@ -61,4 +61,16 @@ struct iris_surface { struct iris_state_ref surface_state; }; +struct iris_transfer { + struct pipe_transfer base; + struct pipe_debug_callback *dbg; + void *buffer; + void *ptr; + + /** Stride of the temporary image (not the actual surface) */ + int temp_stride; + + void (*unmap)(struct iris_transfer *); +}; + #endif diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c index 98bbd680e8a..0401bd230bf 100644 --- a/src/gallium/drivers/iris/iris_screen.c +++ b/src/gallium/drivers/iris/iris_screen.c @@ -547,6 +547,9 @@ iris_screen_create(int fd) screen->compiler->shader_debug_log = iris_shader_debug_log; screen->compiler->shader_perf_log = iris_shader_perf_log; + slab_create_parent(&screen->transfer_pool, + sizeof(struct iris_transfer), 64); + struct pipe_screen *pscreen = &screen->base; iris_init_screen_resource_functions(pscreen); diff --git a/src/gallium/drivers/iris/iris_screen.h b/src/gallium/drivers/iris/iris_screen.h index a06d2c34391..4798f2255db 100644 --- a/src/gallium/drivers/iris/iris_screen.h +++ b/src/gallium/drivers/iris/iris_screen.h @@ -38,6 +38,9 @@ struct iris_bo; struct iris_screen { struct pipe_screen base; + + struct slab_parent_pool transfer_pool; + int fd; int pci_id;