From 37be6a23a2412fe2fc36245e9e2840f71d35f970 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 2 Apr 2021 21:02:14 +0900 Subject: [PATCH] [entity] Use _aligned_malloc etc for _WIN32 This is a bit of a hack for now (need to look into maybe using cmem), but it gets 32-bit windows working for all but the software renderer (probably just refdef (and maybe viddef) getting out of sync with the assembly code. --- libs/entity/hierarchy.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libs/entity/hierarchy.c b/libs/entity/hierarchy.c index cadb3771c..39d4ed971 100644 --- a/libs/entity/hierarchy.c +++ b/libs/entity/hierarchy.c @@ -37,6 +37,17 @@ #include "QF/entity.h" +#if defined(_WIN32) && !defined(_WIN64) +// FIXME (maybe) this is a hack to make DARRAY arrrays 16-byte aligned on +// 32-bit systems (in particular for this case, windows) as the vectors and +// matrices require 16-byte alignment but system malloc (etc) provide only +// 8-byte alignment. +// Really, a custom allocator (maybe using cmem) would be better. +#define free(mem) _aligned_free(mem) +#define malloc(size) _aligned_malloc(size, 16) +#define realloc(mem, size) _aligned_realloc(mem, size, 16) +#endif + static void hierarchy_UpdateTransformIndices (hierarchy_t *hierarchy, uint32_t start, int offset)