nouveau: fix undefined behaviour when testing sample_count
authorChristoph Bumiller <christoph.bumiller@speed.at>
Sat, 19 Jan 2013 19:53:22 +0000 (20:53 +0100)
committerChristoph Bumiller <christoph.bumiller@speed.at>
Sat, 19 Jan 2013 19:59:35 +0000 (20:59 +0100)
NOTE: This is a candidate for the 9.0 branch.

src/gallium/drivers/nv30/nv30_screen.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nvc0/nvc0_screen.c

index 1752d10..9d104f1 100644 (file)
@@ -241,6 +241,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;
 
index 982948e..06b0f37 100644 (file)
@@ -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)
index 8bb9ff6..3a78aad 100644 (file)
@@ -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;