draw: Handle failure to allocate aligned_constant_storage.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 9 Nov 2011 18:58:28 +0000 (18:58 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 14 Nov 2011 10:06:00 +0000 (10:06 +0000)
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@vmware.com>
src/gallium/auxiliary/draw/draw_vs.c

index 957bbe57a82ee00b0a696d1a21eac825ffdaff09..bc1c90b0f3a1e6315fd0a2cdaf5e5a3acae35b0d 100644 (file)
@@ -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];
    }