Mesa (9.0): nouveau: fix undefined behaviour when testing sample_count

Christoph Bumiller chrisbmr at kemper.freedesktop.org
Sat Jan 19 20:03:30 UTC 2013


Module: Mesa
Branch: 9.0
Commit: 3703e9920c2a4d1a022871624bd0d7bd16073867
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3703e9920c2a4d1a022871624bd0d7bd16073867

Author: Christoph Bumiller <christoph.bumiller at speed.at>
Date:   Sat Jan 19 20:53:22 2013 +0100

nouveau: fix undefined behaviour when testing sample_count

NOTE: This is a candidate for the 9.0 branch.

---

 src/gallium/drivers/nv30/nv30_screen.c |    2 ++
 src/gallium/drivers/nv50/nv50_screen.c |    2 ++
 src/gallium/drivers/nvc0/nvc0_screen.c |    2 ++
 3 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c
index 1752d10..9d104f1 100644
--- a/src/gallium/drivers/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nv30/nv30_screen.c
@@ -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;
 
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index 982948e..06b0f37 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 8bb9ff6..3a78aad 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;
 




More information about the mesa-commit mailing list