[Mesa-dev] [PATCH 4/6] dri/intel: the aligned_alloc/free over the _mesa_* wrappers

Emil Velikov emil.l.velikov at gmail.com
Fri Mar 6 08:32:53 PST 2015


Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/mesa/drivers/dri/i915/intel_buffer_objects.c | 19 ++++++++++---------
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c    |  5 +++--
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/intel_buffer_objects.c b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
index ef06743..ca8fc8c 100644
--- a/src/mesa/drivers/dri/i915/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
@@ -25,6 +25,7 @@
  * 
  **************************************************************************/
 
+#include "c11_stdlib.h"
 
 #include "main/imports.h"
 #include "main/mtypes.h"
@@ -96,7 +97,7 @@ intel_bufferobj_free(struct gl_context * ctx, struct gl_buffer_object *obj)
     */
    _mesa_buffer_unmap_all_mappings(ctx, obj);
 
-   _mesa_align_free(intel_obj->sys_buffer);
+   aligned_free(intel_obj->sys_buffer);
 
    drm_intel_bo_unreference(intel_obj->buffer);
    free(intel_obj);
@@ -133,7 +134,7 @@ intel_bufferobj_data(struct gl_context * ctx,
    if (intel_obj->buffer != NULL)
       release_buffer(intel_obj);
 
-   _mesa_align_free(intel_obj->sys_buffer);
+   aligned_free(intel_obj->sys_buffer);
    intel_obj->sys_buffer = NULL;
 
    if (size != 0) {
@@ -142,7 +143,7 @@ intel_bufferobj_data(struct gl_context * ctx,
        */
       if (target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER) {
 	 intel_obj->sys_buffer =
-            _mesa_align_malloc(size, ctx->Const.MinMapBufferAlignment);
+            aligned_alloc(ctx->Const.MinMapBufferAlignment, size);
 	 if (intel_obj->sys_buffer != NULL) {
 	    if (data != NULL)
 	       memcpy(intel_obj->sys_buffer, data, size);
@@ -193,7 +194,7 @@ intel_bufferobj_subdata(struct gl_context * ctx,
 	 return;
       }
 
-      _mesa_align_free(intel_obj->sys_buffer);
+      aligned_free(intel_obj->sys_buffer);
       intel_obj->sys_buffer = NULL;
    }
 
@@ -301,7 +302,7 @@ intel_bufferobj_map_range(struct gl_context * ctx,
 	 return obj->Mappings[index].Pointer;
       }
 
-      _mesa_align_free(intel_obj->sys_buffer);
+      aligned_free(intel_obj->sys_buffer);
       intel_obj->sys_buffer = NULL;
    }
 
@@ -350,7 +351,7 @@ intel_bufferobj_map_range(struct gl_context * ctx,
 
       if (access & GL_MAP_FLUSH_EXPLICIT_BIT) {
          intel_obj->range_map_buffer[index] =
-            _mesa_align_malloc(length + extra, alignment);
+            aligned_alloc(alignment, length + extra);
          obj->Mappings[index].Pointer =
             intel_obj->range_map_buffer[index] + extra;
       } else {
@@ -445,7 +446,7 @@ intel_bufferobj_unmap(struct gl_context * ctx, struct gl_buffer_object *obj,
        * usage inside of a batchbuffer.
        */
       intel_batchbuffer_emit_mi_flush(intel);
-      _mesa_align_free(intel_obj->range_map_buffer[index]);
+      aligned_free(intel_obj->range_map_buffer[index]);
       intel_obj->range_map_buffer[index] = NULL;
    } else if (intel_obj->range_map_bo[index] != NULL) {
       const unsigned extra = obj->Mappings[index].Pointer -
@@ -490,7 +491,7 @@ intel_bufferobj_buffer(struct intel_context *intel,
 			   0, intel_obj->Base.Size,
 			   intel_obj->sys_buffer);
 
-      _mesa_align_free(intel_obj->sys_buffer);
+      aligned_free(intel_obj->sys_buffer);
       intel_obj->sys_buffer = NULL;
       intel_obj->offset = 0;
    }
@@ -677,7 +678,7 @@ intel_buffer_object_purgeable(struct gl_context * ctx,
       return intel_buffer_purgeable(intel_obj->buffer);
 
    if (option == GL_RELEASED_APPLE) {
-      _mesa_align_free(intel_obj->sys_buffer);
+      aligned_free(intel_obj->sys_buffer);
       intel_obj->sys_buffer = NULL;
 
       return GL_RELEASED_APPLE;
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 36c3b26..e7265f3 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -27,6 +27,7 @@
 
 #include <GL/gl.h>
 #include <GL/internal/dri_interface.h>
+#include "c11_stdlib.h"
 
 #include "intel_batchbuffer.h"
 #include "intel_mipmap_tree.h"
@@ -1945,7 +1946,7 @@ intel_miptree_map_movntdqa(struct brw_context *brw,
 
    map->stride = ALIGN(misalignment + width_bytes, 16);
 
-   map->buffer = _mesa_align_malloc(map->stride * map->h, 16);
+   map->buffer = aligned_alloc(16, map->stride * map->h);
    /* Offset the destination so it has the same misalignment as src. */
    map->ptr = map->buffer + misalignment;
 
@@ -1968,7 +1969,7 @@ intel_miptree_unmap_movntdqa(struct brw_context *brw,
                              unsigned int level,
                              unsigned int slice)
 {
-   _mesa_align_free(map->buffer);
+   aligned_free(map->buffer);
    map->buffer = NULL;
    map->ptr = NULL;
 }
-- 
2.1.3



More information about the mesa-dev mailing list