diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-07-12 16:53:52 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-07-15 08:03:34 -0700 |
commit | 318d641cd9f51f0058d973caf907d68f88566ac2 (patch) | |
tree | 0633fc1b48c5c33f687ea86cd782de237d564eeb /src/gallium/drivers/panfrost | |
parent | 1ffca961abe7d4f3dfc7884745ed9a96209c2731 (diff) |
panfrost: Cleanup shader upload code
The old algorithm is still used (and the same issue -- namely, leaking
all shaders -- applies) but we're way more concise about it since we're
*only* using the routine for shaders nowadays; everything else is a
BO-proper or transient.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/gallium/drivers/panfrost')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_allocate.c | 76 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_allocate.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_assemble.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_blend_shaders.c | 2 |
4 files changed, 14 insertions, 71 deletions
diff --git a/src/gallium/drivers/panfrost/pan_allocate.c b/src/gallium/drivers/panfrost/pan_allocate.c index 3f83e3f29c2..9d78fab85d6 100644 --- a/src/gallium/drivers/panfrost/pan_allocate.c +++ b/src/gallium/drivers/panfrost/pan_allocate.c @@ -140,73 +140,15 @@ panfrost_upload_transient(struct panfrost_context *ctx, const void *data, size_t return transfer.gpu; } -// TODO: An actual allocator, perhaps -// TODO: Multiple stacks for multiple bases? - -int hack_stack_bottom = 4096; /* Don't interfere with constant offsets */ -int last_offset = 0; - -static inline int -pandev_allocate_offset(int *stack, size_t sz) -{ - /* First, align the stack bottom to something nice; it's not critical - * at this point if we waste a little space to do so. */ - - int excess = *stack & (ALIGNMENT - 1); - - /* Add the secret of my */ - if (excess) - *stack += ALIGNMENT - excess; - - /* Finally, use the new bottom for the allocation and move down the - * stack */ - - int ret = *stack; - *stack += sz; - return ret; -} - -inline mali_ptr -pandev_upload(int cheating_offset, int *stack_bottom, mali_ptr base, void *base_map, const void *data, size_t sz, bool no_pad) -{ - int offset; - - /* We're not positive about the sizes of all objects, but we don't want - * them to crash against each other either. Let the caller disable - * padding if they so choose, though. */ - - size_t padded_size = no_pad ? sz : sz * 2; - - /* If no specific bottom is specified, use a global one... don't do - * this in production, kids */ - - if (!stack_bottom) - stack_bottom = &hack_stack_bottom; - - /* Allocate space for the new GPU object, if required */ - - if (cheating_offset == -1) { - offset = pandev_allocate_offset(stack_bottom, padded_size); - } else { - offset = cheating_offset; - *stack_bottom = offset + sz; - } - - /* Save last offset for sequential uploads (job descriptors) */ - last_offset = offset + padded_size; - - /* Upload it */ - memcpy((uint8_t *) base_map + offset, data, sz); - - /* Return the GPU address */ - return base + offset; -} - -/* Simplified APIs for the real driver, rather than replays */ +/* The code below is exclusively for the use of shader memory and is subject to + * be rewritten soon enough since it never frees the memory it allocates. Here + * be dragons, etc. */ mali_ptr -panfrost_upload(struct panfrost_memory *mem, const void *data, size_t sz, bool no_pad) +panfrost_upload(struct panfrost_memory *mem, const void *data, size_t sz) { + sz = ALIGN_POT(sz, ALIGNMENT); + /* Bounds check */ if ((mem->stack_bottom + sz) >= mem->bo->size) { printf("Out of memory, tried to upload %zd but only %zd available\n", @@ -214,5 +156,9 @@ panfrost_upload(struct panfrost_memory *mem, const void *data, size_t sz, bool n assert(0); } - return pandev_upload(-1, &mem->stack_bottom, mem->bo->gpu, mem->bo->cpu, data, sz, no_pad); + memcpy((uint8_t *) mem->bo->cpu + mem->stack_bottom, data, sz); + mali_ptr gpu = mem->bo->gpu + mem->stack_bottom; + + mem->stack_bottom += sz; + return gpu; } diff --git a/src/gallium/drivers/panfrost/pan_allocate.h b/src/gallium/drivers/panfrost/pan_allocate.h index fcb00bfcfd1..43f69b4aceb 100644 --- a/src/gallium/drivers/panfrost/pan_allocate.h +++ b/src/gallium/drivers/panfrost/pan_allocate.h @@ -62,11 +62,8 @@ struct panfrost_memory { int stack_bottom; }; -/* Functions for replay */ -mali_ptr pandev_upload(int cheating_offset, int *stack_bottom, mali_ptr base, void *base_map, const void *data, size_t sz, bool no_pad); - /* Functions for the actual Galliumish driver */ -mali_ptr panfrost_upload(struct panfrost_memory *mem, const void *data, size_t sz, bool no_pad); +mali_ptr panfrost_upload(struct panfrost_memory *mem, const void *data, size_t sz); struct panfrost_transfer panfrost_allocate_transient(struct panfrost_context *ctx, size_t sz); diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c index de8a53ce05d..1bf32f1171b 100644 --- a/src/gallium/drivers/panfrost/pan_assemble.c +++ b/src/gallium/drivers/panfrost/pan_assemble.c @@ -77,7 +77,7 @@ panfrost_shader_compile(struct panfrost_context *ctx, struct mali_shader_meta *m * I bet someone just thought that would be a cute pun. At least, * that's how I'd do it. */ - meta->shader = panfrost_upload(&ctx->shaders, dst, size, true) | program.first_tag; + meta->shader = panfrost_upload(&ctx->shaders, dst, size) | program.first_tag; util_dynarray_fini(&program.compiled); diff --git a/src/gallium/drivers/panfrost/pan_blend_shaders.c b/src/gallium/drivers/panfrost/pan_blend_shaders.c index 02ebf8ef7fd..a58808ba7be 100644 --- a/src/gallium/drivers/panfrost/pan_blend_shaders.c +++ b/src/gallium/drivers/panfrost/pan_blend_shaders.c @@ -178,7 +178,7 @@ panfrost_compile_blend_shader( uint8_t *dst = program.compiled.data; res.shader.cpu = mem_dup(dst, size); - res.shader.gpu = panfrost_upload(&ctx->shaders, dst, size, true); + res.shader.gpu = panfrost_upload(&ctx->shaders, dst, size); /* At least two work registers are needed due to an encoding quirk */ res.work_count = MAX2(program.work_register_count, 2); |