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:54:39 +0000 (20:54 +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 06f7c42bbe5320c9165770b07613fe91f6cc091c..f3faf8ad18a298f8f99a39987816e00285a5c8b5 100644 (file)
@@ -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;
 
index 1155c93e8f4316c1fd97dadbd549f0fe98899e8c..b1a9c4d6dde80630fde56101d14a7c6b2ce187e4 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 de0513baff17c16ab407190be03f45ad484b0f42..46bb797e53f61f30d2b7d72e9861f6b3ba26f2ff 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;