mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 11:10:47 +00:00
Align cache1d memory blocks to system page size
git-svn-id: https://svn.eduke32.com/eduke32@8072 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
e262135463
commit
c835219de0
4 changed files with 24 additions and 5 deletions
|
@ -1278,12 +1278,11 @@ char *Bstrlwr(char *);
|
||||||
char *Bstrupr(char *);
|
char *Bstrupr(char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
////////// Miscellaneous //////////
|
////////// Miscellaneous //////////
|
||||||
|
|
||||||
|
int Bgetpagesize(void);
|
||||||
uint32_t Bgetsysmemsize(void);
|
uint32_t Bgetsysmemsize(void);
|
||||||
|
|
||||||
|
|
||||||
////////// PANICKING ALLOCATION WRAPPERS //////////
|
////////// PANICKING ALLOCATION WRAPPERS //////////
|
||||||
|
|
||||||
#ifdef DEBUGGINGAIDS
|
#ifdef DEBUGGINGAIDS
|
||||||
|
|
|
@ -224,8 +224,9 @@ int32_t cacheFindBlock(int32_t newbytes, int32_t *besto, int32_t *bestz)
|
||||||
|
|
||||||
void cacheAllocateBlock(intptr_t* newhandle, int32_t newbytes, char* newlockptr)
|
void cacheAllocateBlock(intptr_t* newhandle, int32_t newbytes, char* newlockptr)
|
||||||
{
|
{
|
||||||
// Make all requests a multiple of 16 bytes
|
// Make all requests a multiple of the system page size
|
||||||
newbytes = (newbytes + 15) & ~0xf;
|
int const pageSize = Bgetpagesize();
|
||||||
|
newbytes = (newbytes + pageSize-1) & ~(pageSize-1);
|
||||||
|
|
||||||
#ifdef DEBUGGINGAIDS
|
#ifdef DEBUGGINGAIDS
|
||||||
if (EDUKE32_PREDICT_FALSE(!newlockptr || *newlockptr == 0))
|
if (EDUKE32_PREDICT_FALSE(!newlockptr || *newlockptr == 0))
|
||||||
|
|
|
@ -577,6 +577,25 @@ char *Bstrupr(char *s)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define BMAXPAGESIZE 8192
|
||||||
|
|
||||||
|
int Bgetpagesize(void)
|
||||||
|
{
|
||||||
|
static int pageSize = -1;
|
||||||
|
|
||||||
|
if (pageSize == -1)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
SYSTEM_INFO system_info;
|
||||||
|
GetSystemInfo(&system_info);
|
||||||
|
pageSize = system_info.dwPageSize;
|
||||||
|
#else
|
||||||
|
pageSize = sysconf(_SC_PAGESIZE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return (unsigned)pageSize < BMAXPAGESIZE ? pageSize : BMAXPAGESIZE;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Bgetsysmemsize() -- gets the amount of system memory in the machine
|
// Bgetsysmemsize() -- gets the amount of system memory in the machine
|
||||||
|
|
|
@ -603,7 +603,7 @@ int32_t artLoadFiles(const char *filename, int32_t askedsize)
|
||||||
|
|
||||||
//cachesize = min((int32_t)((Bgetsysmemsize()/100)*60),max(artsize,askedsize));
|
//cachesize = min((int32_t)((Bgetsysmemsize()/100)*60),max(artsize,askedsize));
|
||||||
cachesize = (Bgetsysmemsize() <= (uint32_t)askedsize) ? (int32_t)((Bgetsysmemsize() / 100) * 60) : askedsize;
|
cachesize = (Bgetsysmemsize() <= (uint32_t)askedsize) ? (int32_t)((Bgetsysmemsize() / 100) * 60) : askedsize;
|
||||||
pic = Xaligned_alloc(16, cachesize);
|
pic = Xaligned_alloc(Bgetpagesize(), cachesize);
|
||||||
cacheInitBuffer((intptr_t) pic, cachesize);
|
cacheInitBuffer((intptr_t) pic, cachesize);
|
||||||
|
|
||||||
artUpdateManifest();
|
artUpdateManifest();
|
||||||
|
|
Loading…
Reference in a new issue