From: Christoph Bumiller Date: Sat, 19 Jan 2013 19:53:22 +0000 (+0100) Subject: nouveau: fix undefined behaviour when testing sample_count X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7d2d450ea6d8082db14cd3f86c6c25442bf771c5;p=mesa.git nouveau: fix undefined behaviour when testing sample_count NOTE: This is a candidate for the 9.0 branch. --- diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index 06f7c42bbe5..f3faf8ad18a 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -244,6 +244,8 @@ nv30_screen_is_format_supported(struct pipe_screen *pscreen, unsigned sample_count, unsigned bindings) { + if (sample_count > 4) + return FALSE; if (!(0x00000017 & (1 << sample_count))) return FALSE; diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 1155c93e8f4..b1a9c4d6dde 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -50,6 +50,8 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen, unsigned sample_count, unsigned bindings) { + if (sample_count > 8) + return FALSE; if (!(0x117 & (1 << sample_count))) /* 0, 1, 2, 4 or 8 */ return FALSE; if (sample_count == 8 && util_format_get_blocksizebits(format) >= 128) diff --git a/src/gallium/drivers/nvc0/nvc0_screen.c b/src/gallium/drivers/nvc0/nvc0_screen.c index de0513baff1..46bb797e53f 100644 --- a/src/gallium/drivers/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nvc0/nvc0_screen.c @@ -39,6 +39,8 @@ nvc0_screen_is_format_supported(struct pipe_screen *pscreen, unsigned sample_count, unsigned bindings) { + if (sample_count > 8) + return FALSE; if (!(0x117 & (1 << sample_count))) /* 0, 1, 2, 4 or 8 */ return FALSE;