mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-22 02:11:19 +00:00
[util] Force 32-bit windows malloc to be 16-byte aligned
By replacing it :P (and its friends). This gets the non-sw renderers working with recent scene changes.
This commit is contained in:
parent
747494c03a
commit
dce1a4d292
2 changed files with 33 additions and 11 deletions
|
@ -40,17 +40,6 @@
|
|||
|
||||
#include "scn_internal.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)
|
||||
|
|
|
@ -646,6 +646,39 @@ Sys_PageIn (void *ptr, size_t size)
|
|||
//#endif
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && !defined(_WIN64)
|
||||
// this is a hack to make memory allocations 16-byte aligned on 32-bit
|
||||
// systems (in particular for this case, windows) as vectors and
|
||||
// matrices require 16-byte alignment but system malloc (etc) provide only
|
||||
// 8-byte alignment.
|
||||
void *__cdecl
|
||||
calloc (size_t nume, size_t sizee)
|
||||
{
|
||||
size_t size = nume * sizee;
|
||||
void *mem = _aligned_malloc (size, 16);
|
||||
memset (mem, 0, size);
|
||||
return mem;
|
||||
}
|
||||
|
||||
void __cdecl
|
||||
free (void *mem)
|
||||
{
|
||||
_aligned_free (mem);
|
||||
}
|
||||
|
||||
void *__cdecl
|
||||
malloc (size_t size)
|
||||
{
|
||||
return _aligned_malloc (size, 16);
|
||||
}
|
||||
|
||||
void *__cdecl
|
||||
realloc (void *mem, size_t size)
|
||||
{
|
||||
return _aligned_realloc (mem, size, 16);
|
||||
}
|
||||
#endif
|
||||
|
||||
VISIBLE size_t
|
||||
Sys_PageSize (void)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue