Mesa (master): llvmpipe: Align texture data to the cache line.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Tue Jul 13 16:32:52 UTC 2010


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

Author: José Fonseca <jfonseca at vmware.com>
Date:   Tue Jun 15 12:20:01 2010 +0100

llvmpipe: Align texture data to the cache line.

---

 src/gallium/drivers/llvmpipe/lp_texture.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index 1d42bdd..d236bad 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -36,6 +36,7 @@
 #include "pipe/p_defines.h"
 
 #include "util/u_inlines.h"
+#include "util/u_cpu_detect.h"
 #include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
@@ -898,13 +899,15 @@ static void
 alloc_image_data(struct llvmpipe_resource *lpr, unsigned level,
                  enum lp_texture_layout layout)
 {
+   uint alignment = MAX2(16, util_cpu_caps.cacheline);
+
    if (lpr->dt)
       assert(level == 0);
 
    if (layout == LP_TEX_LAYOUT_TILED) {
       /* tiled data is stored in regular memory */
       uint buffer_size = tex_image_size(lpr, level, layout);
-      lpr->tiled[level].data = align_malloc(buffer_size, 16);
+      lpr->tiled[level].data = align_malloc(buffer_size, alignment);
    }
    else {
       assert(layout == LP_TEX_LAYOUT_LINEAR);
@@ -920,7 +923,7 @@ alloc_image_data(struct llvmpipe_resource *lpr, unsigned level,
       else {
          /* not a display target - allocate regular memory */
          uint buffer_size = tex_image_size(lpr, level, LP_TEX_LAYOUT_LINEAR);
-         lpr->linear[level].data = align_malloc(buffer_size, 16);
+         lpr->linear[level].data = align_malloc(buffer_size, alignment);
       }
    }
 }




More information about the mesa-commit mailing list