Mesa (master): draw: Handle failure to allocate aligned_constant_storage.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Mon Nov 14 10:42:32 UTC 2011


Module: Mesa
Branch: master
Commit: 9e29cdbe95810de8658dfd1cabf1a7d87264c2f7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9e29cdbe95810de8658dfd1cabf1a7d87264c2f7

Author: José Fonseca <jfonseca at vmware.com>
Date:   Wed Nov  9 18:58:28 2011 +0000

draw: Handle failure to allocate aligned_constant_storage.

Also, actually update const_storage_size, therefore avoiding to
unnecessarily reallocate aligned_constant_storage every single time
draw_vs_set_constants() is called.

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/gallium/auxiliary/draw/draw_vs.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c
index 957bbe5..bc1c90b 100644
--- a/src/gallium/auxiliary/draw/draw_vs.c
+++ b/src/gallium/auxiliary/draw/draw_vs.c
@@ -69,14 +69,20 @@ draw_vs_set_constants(struct draw_context *draw,
       if (size > draw->vs.const_storage_size[slot]) {
          if (draw->vs.aligned_constant_storage[slot]) {
             align_free((void *)draw->vs.aligned_constant_storage[slot]);
+            draw->vs.const_storage_size[slot] = 0;
          }
          draw->vs.aligned_constant_storage[slot] =
             align_malloc(size, alignment);
+         if (draw->vs.aligned_constant_storage[slot]) {
+            draw->vs.const_storage_size[slot] = size;
+         }
       }
       assert(constants);
-      memcpy((void *)draw->vs.aligned_constant_storage[slot],
-             constants,
-             size);
+      if (draw->vs.aligned_constant_storage[slot]) {
+         memcpy((void *)draw->vs.aligned_constant_storage[slot],
+                constants,
+                size);
+      }
       constants = draw->vs.aligned_constant_storage[slot];
    }
 




More information about the mesa-commit mailing list