[Mesa-dev] [PATCH 2/4] st/nine: Use align_calloc instead of align_malloc

Axel Davy axel.davy at ens.fr
Sat Oct 22 10:28:21 UTC 2016


We are not sure exactly what needs to be 0 initialized,
but we are missing some cases. 0 initialize all our current
aligned allocation.

Fixes Tree of Savior visual issues.

Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
 src/gallium/state_trackers/nine/buffer9.c      | 2 +-
 src/gallium/state_trackers/nine/cubetexture9.c | 2 +-
 src/gallium/state_trackers/nine/surface9.c     | 4 ++--
 src/gallium/state_trackers/nine/texture9.c     | 2 +-
 src/gallium/state_trackers/nine/volume9.c      | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/nine/buffer9.c b/src/gallium/state_trackers/nine/buffer9.c
index e7c6a2f..cbf410b 100644
--- a/src/gallium/state_trackers/nine/buffer9.c
+++ b/src/gallium/state_trackers/nine/buffer9.c
@@ -125,7 +125,7 @@ NineBuffer9_ctor( struct NineBuffer9 *This,
         return hr;
 
     if (Pool == D3DPOOL_MANAGED) {
-        This->managed.data = align_malloc(
+        This->managed.data = align_calloc(
             nine_format_get_level_alloc_size(This->base.info.format,
                                              Size, 1, 0), 32);
         if (!This->managed.data)
diff --git a/src/gallium/state_trackers/nine/cubetexture9.c b/src/gallium/state_trackers/nine/cubetexture9.c
index 912d508..0a834eb 100644
--- a/src/gallium/state_trackers/nine/cubetexture9.c
+++ b/src/gallium/state_trackers/nine/cubetexture9.c
@@ -111,7 +111,7 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This,
         face_size = nine_format_get_size_and_offsets(pf, level_offsets,
                                                      EdgeLength, EdgeLength,
                                                      info->last_level);
-        This->managed_buffer = align_malloc(6 * face_size, 32);
+        This->managed_buffer = align_calloc(6 * face_size, 32);
         if (!This->managed_buffer)
             return E_OUTOFMEMORY;
     }
diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c
index e7bb195..bcc289c 100644
--- a/src/gallium/state_trackers/nine/surface9.c
+++ b/src/gallium/state_trackers/nine/surface9.c
@@ -142,7 +142,7 @@ NineSurface9_ctor( struct NineSurface9 *This,
                                                          FALSE,
                                                          TRUE);
     if (This->base.info.format != This->format_conversion) {
-        This->data_conversion = align_malloc(
+        This->data_conversion = align_calloc(
             nine_format_get_level_alloc_size(This->format_conversion,
                                              pDesc->Width,
                                              pDesc->Height,
@@ -156,7 +156,7 @@ NineSurface9_ctor( struct NineSurface9 *This,
     if ((allocate && pDesc->Pool != D3DPOOL_DEFAULT) || pDesc->Format == D3DFMT_NULL) {
         /* Ram buffer with no parent. Has to allocate the resource itself */
         assert(!user_buffer);
-        This->data = align_malloc(
+        This->data = align_calloc(
             nine_format_get_level_alloc_size(This->base.info.format,
                                              pDesc->Width,
                                              pDesc->Height,
diff --git a/src/gallium/state_trackers/nine/texture9.c b/src/gallium/state_trackers/nine/texture9.c
index a13d7f4..bf054cc 100644
--- a/src/gallium/state_trackers/nine/texture9.c
+++ b/src/gallium/state_trackers/nine/texture9.c
@@ -161,7 +161,7 @@ NineTexture9_ctor( struct NineTexture9 *This,
          * apps access sublevels of texture even if they locked only first
          * level) */
         level_offsets = alloca(sizeof(unsigned) * (info->last_level + 1));
-        user_buffer = align_malloc(
+        user_buffer = align_calloc(
             nine_format_get_size_and_offsets(pf, level_offsets,
                                              Width, Height,
                                              info->last_level), 32);
diff --git a/src/gallium/state_trackers/nine/volume9.c b/src/gallium/state_trackers/nine/volume9.c
index e2201af..89565f2 100644
--- a/src/gallium/state_trackers/nine/volume9.c
+++ b/src/gallium/state_trackers/nine/volume9.c
@@ -42,7 +42,7 @@ NineVolume9_AllocateData( struct NineVolume9 *This )
     DBG("(%p(This=%p),level=%u) Allocating 0x%x bytes of system memory.\n",
         This->base.container, This, This->level, size);
 
-    This->data = (uint8_t *)align_malloc(size, 32);
+    This->data = (uint8_t *)align_calloc(size, 32);
     if (!This->data)
         return E_OUTOFMEMORY;
     return D3D_OK;
@@ -124,7 +124,7 @@ NineVolume9_ctor( struct NineVolume9 *This,
         This->layer_stride_conversion = util_format_get_2d_size(This->format_conversion,
                                                                 This->stride_conversion,
                                                                 pDesc->Height);
-        This->data_conversion = align_malloc(This->layer_stride_conversion *
+        This->data_conversion = align_calloc(This->layer_stride_conversion *
                                              This->desc.Depth, 32);
         if (!This->data_conversion)
             return E_OUTOFMEMORY;
-- 
2.10.0



More information about the mesa-dev mailing list