summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/panfrost/midgard
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2019-05-13 16:58:08 +0200
committerMarek Olšák <[email protected]>2019-06-12 18:30:25 -0400
commitde8a919702a377207e83434ab40d91c3013ed96c (patch)
treeba800d0375de39a447a6690b448ae52807ab01f3 /src/gallium/drivers/panfrost/midgard
parent71b45bae14be84ab09212c9ded758fa31e31e945 (diff)
u_dynarray: turn util_dynarray_{grow, resize} into element-oriented macros
The main motivation for this change is API ergonomics: most operations on dynarrays are really on elements, not on bytes, so it's weird to have grow and resize as the odd operations out. The secondary motivation is memory safety. Users of the old byte-oriented functions would often multiply a number of elements with the element size, which could overflow, and checking for overflow is tedious. With this change, we only need to implement the overflow checks once. The checks are cheap: since eltsize is a compile-time constant and the functions should be inlined, they only add a single comparison and an unlikely branch. v2: - ensure operations are no-op when allocation fails - in util_dynarray_clone, call resize_bytes with a compile-time constant element size v3: - fix iris, lima, panfrost Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/drivers/panfrost/midgard')
-rw-r--r--src/gallium/drivers/panfrost/midgard/midgard_emit.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gallium/drivers/panfrost/midgard/midgard_emit.c b/src/gallium/drivers/panfrost/midgard/midgard_emit.c
index bf6ee4508f5..3c331551dd8 100644
--- a/src/gallium/drivers/panfrost/midgard/midgard_emit.c
+++ b/src/gallium/drivers/panfrost/midgard/midgard_emit.c
@@ -147,11 +147,11 @@ emit_alu_bundle(compiler_context *ctx,
source = &scalarized;
}
- memcpy(util_dynarray_grow(emission, size), source, size);
+ memcpy(util_dynarray_grow_bytes(emission, 1, size), source, size);
}
/* Emit padding (all zero) */
- memset(util_dynarray_grow(emission, bundle->padding), 0, bundle->padding);
+ memset(util_dynarray_grow_bytes(emission, 1, bundle->padding), 0, bundle->padding);
/* Tack on constants */