From 475fb28377fa4f5293c1a0853f2c4260418aea7f Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Sun, 17 May 2020 01:42:06 -0400 Subject: [PATCH] freedreno: fix off-by-one in assertions checking for const sizes Caused assertions to trip even though everything was fine. The number of constants can be equal to length, so we need less-than-or-equal. Signed-off-by: Ilia Mirkin Reviewed-by: Rob Clark Part-of: --- src/gallium/drivers/freedreno/a3xx/fd3_emit.c | 2 +- src/gallium/drivers/freedreno/a4xx/fd4_emit.c | 2 +- src/gallium/drivers/freedreno/a5xx/fd5_emit.c | 2 +- src/gallium/drivers/freedreno/ir3/ir3_const.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c index acb09f58e0d..d03949177a3 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c @@ -145,7 +145,7 @@ emit_const_bo(struct fd_ringbuffer *ring, uint32_t num, struct pipe_resource **prscs, uint32_t *offsets) { /* TODO inline this */ - assert(dst_offset + num < v->constlen * 4); + assert(dst_offset + num <= v->constlen * 4); fd3_emit_const_bo(ring, v->type, dst_offset, num, prscs, offsets); } diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c index ff5a6a31271..0aff8fe3e2f 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c @@ -140,7 +140,7 @@ emit_const_bo(struct fd_ringbuffer *ring, uint32_t num, struct pipe_resource **prscs, uint32_t *offsets) { /* TODO inline this */ - assert(dst_offset + num < v->constlen * 4); + assert(dst_offset + num <= v->constlen * 4); fd4_emit_const_bo(ring, v->type, dst_offset, num, prscs, offsets); } diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c index 570eb7dc1d8..ac8a5f59df0 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c @@ -148,7 +148,7 @@ emit_const_bo(struct fd_ringbuffer *ring, uint32_t num, struct pipe_resource **prscs, uint32_t *offsets) { /* TODO inline this */ - assert(dst_offset + num < v->constlen * 4); + assert(dst_offset + num <= v->constlen * 4); fd5_emit_const_bo(ring, v->type, dst_offset, num, prscs, offsets); } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_const.h b/src/gallium/drivers/freedreno/ir3/ir3_const.h index a0076991b86..64cd39684ad 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_const.h +++ b/src/gallium/drivers/freedreno/ir3/ir3_const.h @@ -155,7 +155,7 @@ ir3_emit_ubos(struct fd_screen *screen, const struct ir3_shader_variant *v, } } - assert(offset * 4 + params < v->constlen * 4); + assert(offset * 4 + params <= v->constlen * 4); emit_const_bo(ring, v, offset * 4, params, prscs, offsets); } @@ -309,7 +309,7 @@ emit_tfbos(struct fd_context *ctx, const struct ir3_shader_variant *v, } } - assert(offset * 4 + params < v->constlen * 4); + assert(offset * 4 + params <= v->constlen * 4); emit_const_bo(ring, v, offset * 4, params, prscs, offsets); } -- 2.30.2