iris: slab allocate transfers

apparently we need this for u_threaded_context
This commit is contained in:
Kenneth Graunke
2018-07-06 11:29:51 -07:00
parent 5165308169
commit a3f77eceb4
6 changed files with 29 additions and 15 deletions

View File

@@ -84,6 +84,8 @@ iris_destroy_context(struct pipe_context *ctx)
u_upload_destroy(ice->state.surface_uploader); u_upload_destroy(ice->state.surface_uploader);
u_upload_destroy(ice->state.dynamic_uploader); u_upload_destroy(ice->state.dynamic_uploader);
slab_destroy_child(&ice->transfer_pool);
iris_batch_free(&ice->render_batch); iris_batch_free(&ice->render_batch);
ralloc_free(ice); 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_program_cache(ice);
iris_init_border_color_pool(ice); iris_init_border_color_pool(ice);
slab_create_child(&ice->transfer_pool, &screen->transfer_pool);
ice->state.surface_uploader = ice->state.surface_uploader =
u_upload_create(&ice->ctx, 16384, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, u_upload_create(&ice->ctx, 16384, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
IRIS_RESOURCE_FLAG_SURFACE_MEMZONE); IRIS_RESOURCE_FLAG_SURFACE_MEMZONE);

View File

@@ -229,6 +229,8 @@ struct iris_context {
struct pipe_debug_callback dbg; struct pipe_debug_callback dbg;
struct slab_child_pool transfer_pool;
struct iris_vtable vtbl; struct iris_vtable vtbl;
struct { struct {

View File

@@ -394,18 +394,6 @@ iris_resource_get_handle(struct pipe_screen *pscreen,
return false; 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. /* Compute extent parameters for use with tiled_memcpy functions.
* xs are in units of bytes and ys are in units of strides. * 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)) if ((usage & PIPE_TRANSFER_DONTBLOCK) && iris_bo_busy(res->bo))
return NULL; 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; struct pipe_transfer *xfer = &map->base;
// PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE // PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE
@@ -544,6 +532,7 @@ iris_transfer_map(struct pipe_context *ctx,
if (!map) if (!map)
return NULL; return NULL;
memset(map, 0, sizeof(*map));
map->dbg = &ice->dbg; map->dbg = &ice->dbg;
pipe_resource_reference(&xfer->resource, resource); pipe_resource_reference(&xfer->resource, resource);
@@ -578,15 +567,16 @@ iris_transfer_flush_region(struct pipe_context *pipe,
} }
static void 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; struct iris_transfer *map = (void *) xfer;
if (map->unmap) if (map->unmap)
map->unmap(map); map->unmap(map);
pipe_resource_reference(&xfer->resource, NULL); pipe_resource_reference(&xfer->resource, NULL);
free(map); slab_free(&ice->transfer_pool, map);
} }
static void static void

View File

@@ -61,4 +61,16 @@ struct iris_surface {
struct iris_state_ref surface_state; 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 #endif

View File

@@ -547,6 +547,9 @@ iris_screen_create(int fd)
screen->compiler->shader_debug_log = iris_shader_debug_log; screen->compiler->shader_debug_log = iris_shader_debug_log;
screen->compiler->shader_perf_log = iris_shader_perf_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; struct pipe_screen *pscreen = &screen->base;
iris_init_screen_resource_functions(pscreen); iris_init_screen_resource_functions(pscreen);

View File

@@ -38,6 +38,9 @@ struct iris_bo;
struct iris_screen { struct iris_screen {
struct pipe_screen base; struct pipe_screen base;
struct slab_parent_pool transfer_pool;
int fd; int fd;
int pci_id; int pci_id;