From fdfa4c85297d5d25e7256bf73e35309b358af86c Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Sat, 23 Jan 2010 17:27:21 +0100 Subject: st/mesa: fix unsigned/signed breakage in scissor commit 53174afeeb introduced a portability change that converted GLint x,y to GLuint. That breaks when x and y are negative, which seems to be allowed, and which at least one game uses : teeworlds. Rather than simply reverting the change, it seems possible to convert the 16bit unsigned to GLint so that comparisons are made between signed integers instead. This hopefully does not break anything while keeping MSVC happy. Signed-off-by: Xavier Chantry Signed-off-by: Brian Paul --- src/mesa/state_tracker/st_atom_scissor.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_atom_scissor.c b/src/mesa/state_tracker/st_atom_scissor.c index 3fd59e1945..fb666b8546 100644 --- a/src/mesa/state_tracker/st_atom_scissor.c +++ b/src/mesa/state_tracker/st_atom_scissor.c @@ -52,14 +52,14 @@ update_scissor( struct st_context *st ) scissor.maxy = fb->Height; if (st->ctx->Scissor.Enabled) { - if ((GLuint)st->ctx->Scissor.X > scissor.minx) + if (st->ctx->Scissor.X > (GLint)scissor.minx) scissor.minx = st->ctx->Scissor.X; - if ((GLuint)st->ctx->Scissor.Y > scissor.miny) + if (st->ctx->Scissor.Y > (GLint)scissor.miny) scissor.miny = st->ctx->Scissor.Y; - if ((GLuint)st->ctx->Scissor.X + st->ctx->Scissor.Width < scissor.maxx) + if (st->ctx->Scissor.X + st->ctx->Scissor.Width < (GLint)scissor.maxx) scissor.maxx = st->ctx->Scissor.X + st->ctx->Scissor.Width; - if ((GLuint)st->ctx->Scissor.Y + st->ctx->Scissor.Height < scissor.maxy) + if (st->ctx->Scissor.Y + st->ctx->Scissor.Height < (GLint)scissor.maxy) scissor.maxy = st->ctx->Scissor.Y + st->ctx->Scissor.Height; /* check for null space */ -- cgit v1.2.3 From 47d30b0c2c36f952cc14deefb9f937f1b0a9b531 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 24 Jan 2010 18:18:17 -0700 Subject: st/mesa: fix int->uint conversion for negative scissor bound values Based on a patch by Xavier Chantry : If x+width or y+height is negative, then maxx or maxy will get a bogus value when converting that to unsigned. Fix this by setting 0 as minimal value. This was also triggered by teeworlds, but only with some combination of resolution and map section. For example upper part of dm2 at 1280x1024. --- src/mesa/state_tracker/st_atom_scissor.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_atom_scissor.c b/src/mesa/state_tracker/st_atom_scissor.c index fb666b8546..5e0c51cff0 100644 --- a/src/mesa/state_tracker/st_atom_scissor.c +++ b/src/mesa/state_tracker/st_atom_scissor.c @@ -31,6 +31,7 @@ */ +#include "main/macros.h" #include "st_context.h" #include "pipe/p_context.h" #include "st_atom.h" @@ -52,15 +53,19 @@ update_scissor( struct st_context *st ) scissor.maxy = fb->Height; if (st->ctx->Scissor.Enabled) { + /* need to be careful here with xmax or ymax < 0 */ + GLint xmax = MAX2(0, st->ctx->Scissor.X + st->ctx->Scissor.Width); + GLint ymax = MAX2(0, st->ctx->Scissor.Y + st->ctx->Scissor.Height); + if (st->ctx->Scissor.X > (GLint)scissor.minx) scissor.minx = st->ctx->Scissor.X; if (st->ctx->Scissor.Y > (GLint)scissor.miny) scissor.miny = st->ctx->Scissor.Y; - if (st->ctx->Scissor.X + st->ctx->Scissor.Width < (GLint)scissor.maxx) - scissor.maxx = st->ctx->Scissor.X + st->ctx->Scissor.Width; - if (st->ctx->Scissor.Y + st->ctx->Scissor.Height < (GLint)scissor.maxy) - scissor.maxy = st->ctx->Scissor.Y + st->ctx->Scissor.Height; + if (xmax < (GLint) scissor.maxx) + scissor.maxx = xmax; + if (ymax < (GLint) scissor.maxy) + scissor.maxy = ymax; /* check for null space */ if (scissor.minx >= scissor.maxx || scissor.miny >= scissor.maxy) -- cgit v1.2.3