mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
replace XPhysicalAlloc
This commit is contained in:
parent
7df158d266
commit
5e7cdabea3
|
|
@ -38,10 +38,6 @@ int32_t XPartyGetUserList(void* pUserList) { return 0; }
|
||||||
|
|
||||||
bool IsEqualXUID(PlayerUID a, PlayerUID b) { return false; }
|
bool IsEqualXUID(PlayerUID a, PlayerUID b) { return false; }
|
||||||
|
|
||||||
void* XPhysicalAlloc(size_t a, uintptr_t b, uintptr_t c, uint32_t d) {
|
|
||||||
return malloc(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
D3DXVECTOR3::D3DXVECTOR3() {}
|
D3DXVECTOR3::D3DXVECTOR3() {}
|
||||||
D3DXVECTOR3::D3DXVECTOR3(float x, float y, float z) : x(x), y(y), z(z) {}
|
D3DXVECTOR3::D3DXVECTOR3(float x, float y, float z) : x(x), y(y), z(z) {}
|
||||||
D3DXVECTOR3& D3DXVECTOR3::operator+=(const D3DXVECTOR3& add) {
|
D3DXVECTOR3& D3DXVECTOR3::operator+=(const D3DXVECTOR3& add) {
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,7 @@ void Level::enableLightingCache() {
|
||||||
// results, plus 128K required for toCheck array. Rounding up to 256 to keep
|
// results, plus 128K required for toCheck array. Rounding up to 256 to keep
|
||||||
// as multiple of alignement - aligning to 128K boundary for possible cache
|
// as multiple of alignement - aligning to 128K boundary for possible cache
|
||||||
// locking.
|
// locking.
|
||||||
m_tlsLightCache = (lightCache_t*)XPhysicalAlloc(
|
m_tlsLightCache = (lightCache_t*)malloc(256 * 1024);
|
||||||
256 * 1024, MAXULONG_PTR, 128 * 1024, PAGE_READWRITE | MEM_LARGE_PAGES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::destroyLightingCache() { delete m_tlsLightCache; }
|
void Level::destroyLightingCache() { delete m_tlsLightCache; }
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,7 @@ CompressedTileStorage::CompressedTileStorage(CompressedTileStorage* copyFrom) {
|
||||||
std::lock_guard<std::recursive_mutex> lock(cs_write);
|
std::lock_guard<std::recursive_mutex> lock(cs_write);
|
||||||
allocatedSize = copyFrom->allocatedSize;
|
allocatedSize = copyFrom->allocatedSize;
|
||||||
if (allocatedSize > 0) {
|
if (allocatedSize > 0) {
|
||||||
indicesAndData = (unsigned char*)XPhysicalAlloc(
|
indicesAndData = (unsigned char*)malloc(allocatedSize); //(unsigned char *)malloc(allocatedSize);
|
||||||
allocatedSize, MAXULONG_PTR, 4096,
|
|
||||||
PAGE_READWRITE); //(unsigned char *)malloc(allocatedSize);
|
|
||||||
memcpy(indicesAndData, copyFrom->indicesAndData, allocatedSize);
|
memcpy(indicesAndData, copyFrom->indicesAndData, allocatedSize);
|
||||||
} else {
|
} else {
|
||||||
indicesAndData = nullptr;
|
indicesAndData = nullptr;
|
||||||
|
|
@ -68,8 +66,7 @@ CompressedTileStorage::CompressedTileStorage(std::vector<uint8_t>& initFrom,
|
||||||
|
|
||||||
// We need 32768 bytes for a fully uncompressed chunk, plus 1024 for the
|
// We need 32768 bytes for a fully uncompressed chunk, plus 1024 for the
|
||||||
// index. Rounding up to nearest 4096 bytes for allocation
|
// index. Rounding up to nearest 4096 bytes for allocation
|
||||||
indicesAndData = (unsigned char*)XPhysicalAlloc(32768 + 4096, MAXULONG_PTR,
|
indicesAndData = (unsigned char*)malloc(32768 + 4096);
|
||||||
4096, PAGE_READWRITE);
|
|
||||||
|
|
||||||
unsigned short* indices = (unsigned short*)indicesAndData;
|
unsigned short* indices = (unsigned short*)indicesAndData;
|
||||||
unsigned char* data = indicesAndData + 1024;
|
unsigned char* data = indicesAndData + 1024;
|
||||||
|
|
@ -112,8 +109,7 @@ CompressedTileStorage::CompressedTileStorage(bool isEmpty) {
|
||||||
|
|
||||||
// Empty and already compressed, so we only need 1K. Rounding up to nearest
|
// Empty and already compressed, so we only need 1K. Rounding up to nearest
|
||||||
// 4096 bytes for allocation
|
// 4096 bytes for allocation
|
||||||
indicesAndData = (unsigned char*)XPhysicalAlloc(4096, MAXULONG_PTR, 4096,
|
indicesAndData = (unsigned char*)malloc(4096);
|
||||||
PAGE_READWRITE);
|
|
||||||
unsigned short* indices = (unsigned short*)indicesAndData;
|
unsigned short* indices = (unsigned short*)indicesAndData;
|
||||||
// unsigned char *data = indicesAndData + 1024;
|
// unsigned char *data = indicesAndData + 1024;
|
||||||
|
|
||||||
|
|
@ -330,9 +326,7 @@ void CompressedTileStorage::setData(std::vector<uint8_t>& dataIn, unsigned int i
|
||||||
// type8 / chunkTotal);
|
// type8 / chunkTotal);
|
||||||
|
|
||||||
memToAlloc += 1024; // For the indices
|
memToAlloc += 1024; // For the indices
|
||||||
unsigned char* newIndicesAndData = (unsigned char*)XPhysicalAlloc(
|
unsigned char* newIndicesAndData = (unsigned char*)malloc(memToAlloc); //(unsigned char *)malloc( memToAlloc );
|
||||||
memToAlloc, MAXULONG_PTR, 4096,
|
|
||||||
PAGE_READWRITE); //(unsigned char *)malloc( memToAlloc );
|
|
||||||
unsigned char* pucData = newIndicesAndData + 1024;
|
unsigned char* pucData = newIndicesAndData + 1024;
|
||||||
unsigned short usDataOffset = 0;
|
unsigned short usDataOffset = 0;
|
||||||
unsigned short* newIndices = (unsigned short*)newIndicesAndData;
|
unsigned short* newIndices = (unsigned short*)newIndicesAndData;
|
||||||
|
|
@ -948,9 +942,7 @@ void CompressedTileStorage::compress(int upgradeBlock /*=-1*/) {
|
||||||
// If we need to do something here, then lets allocate some memory
|
// If we need to do something here, then lets allocate some memory
|
||||||
if (needsCompressed) {
|
if (needsCompressed) {
|
||||||
memToAlloc += 1024; // For the indices
|
memToAlloc += 1024; // For the indices
|
||||||
unsigned char* newIndicesAndData = (unsigned char*)XPhysicalAlloc(
|
unsigned char* newIndicesAndData = (unsigned char*)malloc(memToAlloc); //(unsigned char *)malloc( memToAlloc );
|
||||||
memToAlloc, MAXULONG_PTR, 4096,
|
|
||||||
PAGE_READWRITE); //(unsigned char *)malloc( memToAlloc );
|
|
||||||
if (newIndicesAndData == nullptr) {
|
if (newIndicesAndData == nullptr) {
|
||||||
uint32_t lastError = GetLastError();
|
uint32_t lastError = GetLastError();
|
||||||
MEMORYSTATUS memStatus;
|
MEMORYSTATUS memStatus;
|
||||||
|
|
@ -1231,8 +1223,7 @@ void CompressedTileStorage::read(DataInputStream* dis) {
|
||||||
if (indicesAndData) {
|
if (indicesAndData) {
|
||||||
free(indicesAndData);
|
free(indicesAndData);
|
||||||
}
|
}
|
||||||
indicesAndData = (unsigned char*)XPhysicalAlloc(
|
indicesAndData = (unsigned char*)malloc(allocatedSize);
|
||||||
allocatedSize, MAXULONG_PTR, 4096, PAGE_READWRITE);
|
|
||||||
|
|
||||||
std::vector<uint8_t> wrapper(allocatedSize);
|
std::vector<uint8_t> wrapper(allocatedSize);
|
||||||
dis->readFully(wrapper);
|
dis->readFully(wrapper);
|
||||||
|
|
|
||||||
|
|
@ -351,8 +351,7 @@ LevelChunk* CustomLevelSource::getChunk(int xOffs, int zOffs) {
|
||||||
// 4J - now allocating this with a physical alloc & bypassing general memory
|
// 4J - now allocating this with a physical alloc & bypassing general memory
|
||||||
// management so that it will get cleanly freed
|
// management so that it will get cleanly freed
|
||||||
int blocksSize = Level::maxBuildHeight * 16 * 16;
|
int blocksSize = Level::maxBuildHeight * 16 * 16;
|
||||||
uint8_t* tileData = (uint8_t*)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096,
|
uint8_t* tileData = (uint8_t*)malloc(blocksSize);
|
||||||
PAGE_READWRITE);
|
|
||||||
memset(tileData, 0, blocksSize);
|
memset(tileData, 0, blocksSize);
|
||||||
std::vector<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + blocksSize);
|
std::vector<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + blocksSize);
|
||||||
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);
|
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,7 @@ LevelChunk* FlatLevelSource::getChunk(int xOffs, int zOffs) {
|
||||||
// 4J - now allocating this with a physical alloc & bypassing general memory
|
// 4J - now allocating this with a physical alloc & bypassing general memory
|
||||||
// management so that it will get cleanly freed
|
// management so that it will get cleanly freed
|
||||||
int chunksSize = Level::genDepth * 16 * 16;
|
int chunksSize = Level::genDepth * 16 * 16;
|
||||||
uint8_t* tileData = (uint8_t*)XPhysicalAlloc(chunksSize, MAXULONG_PTR, 4096,
|
uint8_t* tileData = (uint8_t*)malloc(chunksSize);
|
||||||
PAGE_READWRITE);
|
|
||||||
memset(tileData, 0, chunksSize);
|
memset(tileData, 0, chunksSize);
|
||||||
std::vector<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + chunksSize);
|
std::vector<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + chunksSize);
|
||||||
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);
|
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);
|
||||||
|
|
|
||||||
|
|
@ -304,8 +304,7 @@ LevelChunk* HellRandomLevelSource::getChunk(int xOffs, int zOffs) {
|
||||||
// 4J - now allocating this with a physical alloc & bypassing general memory
|
// 4J - now allocating this with a physical alloc & bypassing general memory
|
||||||
// management so that it will get cleanly freed
|
// management so that it will get cleanly freed
|
||||||
int blocksSize = Level::genDepth * 16 * 16;
|
int blocksSize = Level::genDepth * 16 * 16;
|
||||||
uint8_t* tileData = (uint8_t*)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096,
|
uint8_t* tileData = (uint8_t*)malloc(blocksSize);
|
||||||
PAGE_READWRITE);
|
|
||||||
memset(tileData, 0, blocksSize);
|
memset(tileData, 0, blocksSize);
|
||||||
std::vector<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + blocksSize);
|
std::vector<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + blocksSize);
|
||||||
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);
|
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);
|
||||||
|
|
|
||||||
|
|
@ -476,8 +476,7 @@ LevelChunk* RandomLevelSource::getChunk(int xOffs, int zOffs) {
|
||||||
// 4J - now allocating this with a physical alloc & bypassing general memory
|
// 4J - now allocating this with a physical alloc & bypassing general memory
|
||||||
// management so that it will get cleanly freed
|
// management so that it will get cleanly freed
|
||||||
int blocksSize = Level::genDepth * 16 * 16;
|
int blocksSize = Level::genDepth * 16 * 16;
|
||||||
uint8_t* tileData = (uint8_t*)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096,
|
uint8_t* tileData = (uint8_t*)malloc(blocksSize);
|
||||||
PAGE_READWRITE);
|
|
||||||
memset(tileData, 0, blocksSize);
|
memset(tileData, 0, blocksSize);
|
||||||
std::vector<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + blocksSize);
|
std::vector<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + blocksSize);
|
||||||
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);
|
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);
|
||||||
|
|
|
||||||
|
|
@ -177,8 +177,7 @@ LevelChunk* TheEndLevelRandomLevelSource::getChunk(int xOffs, int zOffs) {
|
||||||
// 4J - now allocating this with a physical alloc & bypassing general memory
|
// 4J - now allocating this with a physical alloc & bypassing general memory
|
||||||
// management so that it will get cleanly freed
|
// management so that it will get cleanly freed
|
||||||
unsigned int blocksSize = Level::genDepth * 16 * 16;
|
unsigned int blocksSize = Level::genDepth * 16 * 16;
|
||||||
uint8_t* tileData = (uint8_t*)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096,
|
uint8_t* tileData = (uint8_t*)malloc(blocksSize);
|
||||||
PAGE_READWRITE);
|
|
||||||
memset(tileData, 0, blocksSize);
|
memset(tileData, 0, blocksSize);
|
||||||
std::vector<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + blocksSize);
|
std::vector<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + blocksSize);
|
||||||
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);
|
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void* XPhysicalAlloc(size_t a, uintptr_t b, uintptr_t c, uint32_t d);
|
|
||||||
|
|
||||||
class DLCManager;
|
class DLCManager;
|
||||||
class LevelRuleset;
|
class LevelRuleset;
|
||||||
class ModelPart;
|
class ModelPart;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue