swr: Align swr_context allocation to SIMD alignment.
authorBruce Cherniak <bruce.cherniak@intel.com>
Wed, 12 Apr 2017 23:43:25 +0000 (18:43 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Fri, 14 Apr 2017 20:22:44 +0000 (15:22 -0500)
The context now contains SIMD vectors which must be aligned (specifically
samplePositions in the rastState in the derived state).  Failure to align
can result in segv crash on unaligned memory access in vector
instructions.

Reviewed-by: Tim Rowley <timothy.o.rowley@intel.com>
src/gallium/drivers/swr/swr_context.cpp

index 8c5a2692db7145c2f293b1a5cf9cbc4ac8064cba..6f46d666ac59909f1bb790e9c8599b545b8363bb 100644 (file)
@@ -386,7 +386,7 @@ swr_destroy(struct pipe_context *pipe)
    if (screen->pipe == pipe)
       screen->pipe = NULL;
 
-   FREE(ctx);
+   AlignedFree(ctx);
 }
 
 
@@ -452,7 +452,10 @@ swr_UpdateStatsFE(HANDLE hPrivateContext, const SWR_STATS_FE *pStats)
 struct pipe_context *
 swr_create_context(struct pipe_screen *p_screen, void *priv, unsigned flags)
 {
-   struct swr_context *ctx = CALLOC_STRUCT(swr_context);
+   struct swr_context *ctx = (struct swr_context *)
+      AlignedMalloc(sizeof(struct swr_context), KNOB_SIMD_BYTES);
+   memset(ctx, 0, sizeof(struct swr_context));
+
    ctx->blendJIT =
       new std::unordered_map<BLEND_COMPILE_STATE, PFN_BLEND_JIT_FUNC>;