Mesa (master): freedreno: Clamp UBO uploads to the constlen decided by the shader.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 24 21:27:11 UTC 2019


Module: Mesa
Branch: master
Commit: 572c76fd882601a189496a1f8bd3a09db1621337
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=572c76fd882601a189496a1f8bd3a09db1621337

Author: Rob Clark <robdclark at chromium.org>
Date:   Sun Jun 23 12:52:05 2019 -0700

freedreno: Clamp UBO uploads to the constlen decided by the shader.

If the NIR-level analysis decided to move UBO loads to the constant
file, but the backend decided not to load those constants, we could
upload past the end of constlen.  This is particularly relevant for
pre-a6xx, where we emit a different constlen between bin and render
variants.

(Fix by Rob, commit message by anholt)

Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/gallium/drivers/freedreno/ir3/ir3_gallium.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
index 35693f97c3b..3315afb9144 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
@@ -247,9 +247,20 @@ emit_user_consts(struct fd_context *ctx, const struct ir3_shader_variant *v,
 
 			uint32_t size = state->range[i].end - state->range[i].start;
 			uint32_t offset = cb->buffer_offset + state->range[i].start;
+
+			/* and even if the start of the const buffer is before
+			 * first_immediate, the end may not be:
+			 */
+			size = MIN2(size, (16 * v->constlen) - state->range[i].offset);
+
+			if (size == 0)
+				continue;
+
+			/* things should be aligned to vec4: */
 			debug_assert((state->range[i].offset % 16) == 0);
 			debug_assert((size % 16) == 0);
 			debug_assert((offset % 16) == 0);
+
 			ctx->emit_const(ring, v->type, state->range[i].offset / 4,
 							offset, size / 4, cb->user_buffer, cb->buffer);
 		}




More information about the mesa-commit mailing list