[Mesa-dev] [PATCH] swr: Align swr_context allocation to SIMD alignment.

Rowley, Timothy O timothy.o.rowley at intel.com
Thu Apr 13 17:25:25 UTC 2017


Reviewed-by: Tim Rowley <timothy.o.rowley at intel.com<mailto:timothy.o.rowley at intel.com>>

On Apr 12, 2017, at 6:43 PM, Bruce Cherniak <bruce.cherniak at intel.com<mailto:bruce.cherniak at intel.com>> wrote:

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.

---
src/gallium/drivers/swr/swr_context.cpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp
index 8c5a269..6f46d66 100644
--- a/src/gallium/drivers/swr/swr_context.cpp
+++ b/src/gallium/drivers/swr/swr_context.cpp
@@ -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>;

--
2.7.4

_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org<mailto:mesa-dev at lists.freedesktop.org>
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170413/fa705065/attachment.html>


More information about the mesa-dev mailing list