swr: Align query results allocation
authorGeorge Kyriazis <george.kyriazis@intel.com>
Wed, 18 Jan 2017 23:09:08 +0000 (17:09 -0600)
committerTim Rowley <timothy.o.rowley@intel.com>
Mon, 23 Jan 2017 20:15:54 +0000 (14:15 -0600)
Some query results struct contents are declared as cache line aligned.
Use aligned malloc, and align the whole struct, to be safe.

Fixes crash when compiling with clang.

CC: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/swr_query.cpp
src/gallium/drivers/swr/swr_query.h

index 6eb07810c0257c4646e6b4c1b97c1c09434c33e5..e097790892d3e03abf88a0008b2852e9b8c36a67 100644 (file)
@@ -29,7 +29,7 @@
 #include "swr_query.h"
 #include "swr_screen.h"
 #include "swr_state.h"
-
+#include "common/os.h"
 
 static struct swr_query *
 swr_query(struct pipe_query *p)
@@ -45,7 +45,8 @@ swr_create_query(struct pipe_context *pipe, unsigned type, unsigned index)
    assert(type < PIPE_QUERY_TYPES);
    assert(index < MAX_SO_STREAMS);
 
-   pq = CALLOC_STRUCT(swr_query);
+   pq = (struct swr_query *) AlignedMalloc(sizeof(struct swr_query), 64);
+   memset(pq, 0, sizeof(*pq));
 
    if (pq) {
       pq->type = type;
@@ -67,7 +68,7 @@ swr_destroy_query(struct pipe_context *pipe, struct pipe_query *q)
       swr_fence_reference(pipe->screen, &pq->fence, NULL);
    }
 
-   FREE(pq);
+   AlignedFree(pq);
 }
 
 
index c5160ceb45341e6f0e042ba9ff791a96d5e6df55..1c736e4e1bee02d3f9df6143d8bdf180195bfa03 100644 (file)
@@ -34,7 +34,7 @@ struct swr_query_result {
    uint64_t timestamp_end;
 };
 
-struct swr_query {
+OSALIGNLINE(struct) swr_query {
    unsigned type; /* PIPE_QUERY_* */
    unsigned index;