| From f390b920db89fd332f6c1398c886de43cdc4e868 Mon Sep 17 00:00:00 2001 |
| From: Corbin Simpson <simpsoco@chromium.org> |
| Date: Thu, 28 Aug 2014 14:48:31 -0700 |
| Subject: [PATCH 11/39] CHROMIUM: i965: Clamp scissor state instead of |
| truncating on gen6. |
| |
| Replaces one undefined behavior with another, slightly more friendly, |
| undefined behavior. |
| |
| This changes glScissor() behavior on i965 to clamp instead of truncate |
| out-of-range scissors. Technically either behavior is acceptable, but |
| clamping has more predictable results on out-of-range scissors. |
| |
| BUG=chromium:360217 |
| TEST=Watched some Youtube on Link; can't reproduce original bug as reported. |
| |
| Signed-off-by: Corbin Simpson <simpsoco@chromium.org> |
| Signed-off-by: Prince Agyeman <prince.agyeman@intel.com> |
| Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com> |
| Signed-off-by: James Ausmus <james.ausmus@intel.com> |
| Signed-off-by: Tomasz Figa <tfiga@chromium.org> |
| Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org> |
| --- |
| src/mesa/drivers/dri/i965/genX_state_upload.c | 23 +++++++++++++++-------- |
| 1 file changed, 15 insertions(+), 8 deletions(-) |
| |
| diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c |
| index ef04603..092cef1 100644 |
| --- a/src/mesa/drivers/dri/i965/genX_state_upload.c |
| +++ b/src/mesa/drivers/dri/i965/genX_state_upload.c |
| @@ -2243,6 +2243,13 @@ const struct brw_tracked_state genX(cc_vp) = { |
| |
| /* ---------------------------------------------------------------------- */ |
| |
| +/* 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 inline void |
| set_scissor_bits(const struct gl_context *ctx, int i, |
| bool render_to_fbo, unsigned fb_width, unsigned fb_height, |
| @@ -2269,16 +2276,16 @@ set_scissor_bits(const struct gl_context *ctx, int i, |
| sc->ScissorRectangleYMax = 0; |
| } else if (render_to_fbo) { |
| /* texmemory: Y=0=bottom */ |
| - sc->ScissorRectangleXMin = bbox[0]; |
| - sc->ScissorRectangleXMax = bbox[1] - 1; |
| - sc->ScissorRectangleYMin = bbox[2]; |
| - sc->ScissorRectangleYMax = bbox[3] - 1; |
| + sc->ScissorRectangleXMin = CLAMP_SCISSOR(bbox[0]); |
| + sc->ScissorRectangleXMax = CLAMP_SCISSOR(bbox[1] - 1); |
| + sc->ScissorRectangleYMin = CLAMP_SCISSOR(bbox[2]); |
| + sc->ScissorRectangleYMax = CLAMP_SCISSOR(bbox[3] - 1); |
| } else { |
| /* memory: Y=0=top */ |
| - sc->ScissorRectangleXMin = bbox[0]; |
| - sc->ScissorRectangleXMax = bbox[1] - 1; |
| - sc->ScissorRectangleYMin = fb_height - bbox[3]; |
| - sc->ScissorRectangleYMax = fb_height - bbox[2] - 1; |
| + sc->ScissorRectangleXMin = CLAMP_SCISSOR(bbox[0]); |
| + sc->ScissorRectangleXMax = CLAMP_SCISSOR(bbox[1] - 1); |
| + sc->ScissorRectangleYMin = CLAMP_SCISSOR(fb_height - bbox[3]); |
| + sc->ScissorRectangleYMax = CLAMP_SCISSOR(fb_height - bbox[2] - 1); |
| } |
| } |
| |
| -- |
| 2.7.4 |
| |