summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/radeon
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2016-09-09 18:50:34 +0200
committerNicolai Hähnle <[email protected]>2016-09-12 13:55:53 +0200
commitd66bbfbeded04cb728a2d8e4356c8e2b5e67ace1 (patch)
tree462b253d08a0b528f063e0875093f6284662ffc7 /src/gallium/winsys/radeon
parentf47da2e34fd2480a15b50df2ac43487c7505674b (diff)
winsys/radeon: don't pre-allocate the relocations array
It's really not necessary. Switch to an exponential resizing strategy. Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/winsys/radeon')
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_cs.c15
1 files changed, 1 insertions, 14 deletions
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
index 9de00c23f4f..4f2501ef505 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
@@ -98,19 +98,6 @@ static bool radeon_init_cs_context(struct radeon_cs_context *csc,
int i;
csc->fd = ws->fd;
- csc->nrelocs = 512;
- csc->relocs_bo = (struct radeon_bo_item*)
- CALLOC(1, csc->nrelocs * sizeof(csc->relocs_bo[0]));
- if (!csc->relocs_bo) {
- return false;
- }
-
- csc->relocs = (struct drm_radeon_cs_reloc*)
- CALLOC(1, csc->nrelocs * sizeof(struct drm_radeon_cs_reloc));
- if (!csc->relocs) {
- FREE(csc->relocs_bo);
- return false;
- }
csc->chunks[0].chunk_id = RADEON_CHUNK_ID_IB;
csc->chunks[0].length_dw = 0;
@@ -285,7 +272,7 @@ static unsigned radeon_add_buffer(struct radeon_drm_cs *cs,
/* New relocation, check if the backing array is large enough. */
if (csc->crelocs >= csc->nrelocs) {
uint32_t size;
- csc->nrelocs += 10;
+ csc->nrelocs = MAX2(csc->nrelocs + 16, (unsigned)(csc->nrelocs * 1.3));
size = csc->nrelocs * sizeof(csc->relocs_bo[0]);
csc->relocs_bo = realloc(csc->relocs_bo, size);