From 38ac6b556dae914325980d135a81719c9dfda000 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 5 Feb 2017 20:58:37 +0000 Subject: [PATCH] sna/gen2: Cap number of vertices emitted in a single 3DPRIM There's a maximum of 2^18 dwords in a single command, or else we overflow the lenth field. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99620 Signed-off-by: Chris Wilson --- src/sna/gen2_render.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index c6eceda5..11e8e52b 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -49,6 +49,7 @@ #define MAX_3D_SIZE 2048 #define MAX_3D_PITCH 8192 +#define MAX_INLINE (1 << 18) #define BATCH(v) batch_emit(sna, v) #define BATCH_F(v) batch_emit_float(sna, v) @@ -1165,6 +1166,9 @@ inline static int gen2_get_rectangles(struct sna *sna, { int rem = batch_space(sna), size, need; + if (rem > MAX_INLINE) + rem = MAX_INLINE; + DBG(("%s: want=%d, floats_per_vertex=%d, rem=%d\n", __FUNCTION__, want, op->floats_per_vertex, rem)); @@ -3230,6 +3234,9 @@ gen2_get_inline_rectangles(struct sna *sna, int want, int floats_per_vertex) int size = floats_per_vertex * 3; int rem = batch_space(sna) - 1; + if (rem > MAX_INLINE) + rem = MAX_INLINE; + if (size * want > rem) want = rem / size;