-
Notifications
You must be signed in to change notification settings - Fork 3
/
0005-drivers-dri-i965-gen6-Clamp-scissor-state-instead-of.patch
64 lines (59 loc) · 2.57 KB
/
0005-drivers-dri-i965-gen6-Clamp-scissor-state-instead-of.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From d99d3a8a4cbede67d02c13149f1a090c170ba127 Mon Sep 17 00:00:00 2001
From: Corbin Simpson <[email protected]>
Date: Thu, 28 Aug 2014 14:48:31 -0700
Subject: [PATCH 05/13] drivers/dri/i965/gen6: Clamp scissor state instead of
truncating.
Replaces one undefined behavior with another, slightly more friendly,
undefined behavior.
BUG=chromium:360217
TEST=Watched some Youtube on Link; can't reproduce original bug as reported.
Change-Id: I7ae0e053ffb6c7a57cb7b3232d27700b6703b3ff
Signed-off-by: Corbin Simpson <[email protected]>
---
src/mesa/drivers/dri/i965/gen6_scissor_state.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/gen6_scissor_state.c b/src/mesa/drivers/dri/i965/gen6_scissor_state.c
index 6b01cd1..1d52e95 100644
--- a/src/mesa/drivers/dri/i965/gen6_scissor_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_scissor_state.c
@@ -32,6 +32,13 @@
#include "main/fbobject.h"
#include "main/framebuffer.h"
+/* Clamp scissors to 16-bit unsigned values; otherwise, the compiler truncates
+ * them to fit inside the bitfields, which is often not what is desired.
+ * My reading of GL and GLES specs suggests that overly-large scissor values are
+ * not an erroring condition and that the actual behavior is undefined, so
+ * switching from truncation to clamping is probably not a problem. ~ C. */
+#define CLAMP_SCISSOR(X) CLAMP(X, 0x0000, 0xffff)
+
static void
gen6_upload_scissor_state(struct brw_context *brw)
{
@@ -71,17 +78,17 @@ gen6_upload_scissor_state(struct brw_context *brw)
scissor[i].ymax = 0;
} else if (render_to_fbo) {
/* texmemory: Y=0=bottom */
- scissor[i].xmin = bbox[0];
- scissor[i].xmax = bbox[1] - 1;
- scissor[i].ymin = bbox[2];
- scissor[i].ymax = bbox[3] - 1;
+ scissor[i].xmin = CLAMP_SCISSOR(bbox[0]);
+ scissor[i].xmax = CLAMP_SCISSOR(bbox[1] - 1);
+ scissor[i].ymin = CLAMP_SCISSOR(bbox[2]);
+ scissor[i].ymax = CLAMP_SCISSOR(bbox[3] - 1);
}
else {
/* memory: Y=0=top */
- scissor[i].xmin = bbox[0];
- scissor[i].xmax = bbox[1] - 1;
- scissor[i].ymin = ctx->DrawBuffer->Height - bbox[3];
- scissor[i].ymax = ctx->DrawBuffer->Height - bbox[2] - 1;
+ scissor[i].xmin = CLAMP_SCISSOR(bbox[0]);
+ scissor[i].xmax = CLAMP_SCISSOR(bbox[1] - 1);
+ scissor[i].ymin = CLAMP_SCISSOR(ctx->DrawBuffer->Height - bbox[3]);
+ scissor[i].ymax = CLAMP_SCISSOR(ctx->DrawBuffer->Height - bbox[2] - 1);
}
}
BEGIN_BATCH(2);
--
1.9.1