mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-07 00:47:15 +00:00
refactor: remove vec3 tls
This commit is contained in:
parent
e887c8cf45
commit
9fe3315112
|
|
@ -724,7 +724,6 @@ void Minecraft::run()
|
|||
// try { // 4J - removed try/catch
|
||||
// if (minecraftApplet != null && !minecraftApplet.isActive()) break; // 4J - removed
|
||||
AABB::resetPool();
|
||||
Vec3::resetPool();
|
||||
|
||||
// if (parent == NULL && Display.isCloseRequested()) { // 4J - removed
|
||||
// stop();
|
||||
|
|
@ -1281,7 +1280,6 @@ void Minecraft::run_middle() {
|
|||
// if (minecraftApplet != null &&
|
||||
// !minecraftApplet.isActive()) break; // 4J - removed
|
||||
AABB::resetPool();
|
||||
Vec3::resetPool();
|
||||
|
||||
// if (parent == NULL && Display.isCloseRequested()) {
|
||||
// // 4J - removed
|
||||
|
|
@ -2223,7 +2221,6 @@ void Minecraft::emergencySave() {
|
|||
// 4J - lots of try/catches removed here, and garbage collector things
|
||||
levelRenderer->clear();
|
||||
AABB::clearPool();
|
||||
Vec3::clearPool();
|
||||
setLevel(NULL);
|
||||
}
|
||||
|
||||
|
|
@ -2400,7 +2397,6 @@ void Minecraft::levelTickUpdateFunc(void* pParam) {
|
|||
|
||||
void Minecraft::levelTickThreadInitFunc() {
|
||||
AABB::CreateNewThreadStorage();
|
||||
Vec3::CreateNewThreadStorage();
|
||||
Compression::UseDefaultThreadStorage();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -315,7 +315,6 @@ int MinecraftServer::runPostUpdate(void* lpParam) {
|
|||
Entity::useSmallIds(); // This thread can end up spawning entities as
|
||||
// resources
|
||||
AABB::CreateNewThreadStorage();
|
||||
Vec3::CreateNewThreadStorage();
|
||||
Compression::UseDefaultThreadStorage();
|
||||
Level::enableLightingCache();
|
||||
Tile::CreateNewThreadStorage();
|
||||
|
|
@ -365,7 +364,6 @@ int MinecraftServer::runPostUpdate(void* lpParam) {
|
|||
// #endif //__PS3__
|
||||
Tile::ReleaseThreadStorage();
|
||||
AABB::ReleaseThreadStorage();
|
||||
Vec3::ReleaseThreadStorage();
|
||||
Level::destroyLightingCache();
|
||||
|
||||
ShutdownManager::HasFinished(ShutdownManager::ePostProcessThread);
|
||||
|
|
@ -1651,7 +1649,6 @@ void MinecraftServer::tick() {
|
|||
}
|
||||
|
||||
AABB::resetPool();
|
||||
Vec3::resetPool();
|
||||
|
||||
tickCount++;
|
||||
|
||||
|
|
|
|||
|
|
@ -4706,7 +4706,6 @@ int CMinecraftApp::SignoutExitWorldThreadProc(void* lpParameter) {
|
|||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||
// as we don't tick the main thread whilst this thread is running
|
||||
AABB::UseDefaultThreadStorage();
|
||||
Vec3::UseDefaultThreadStorage();
|
||||
Compression::UseDefaultThreadStorage();
|
||||
|
||||
// app.SetGameStarted(false);
|
||||
|
|
@ -7698,7 +7697,6 @@ int CMinecraftApp::RemoteSaveThreadProc(void* lpParameter) {
|
|||
// The game should be stopped while we are doing this, but the connections
|
||||
// ticks may try to create some AABB's or Vec3's
|
||||
AABB::UseDefaultThreadStorage();
|
||||
Vec3::UseDefaultThreadStorage();
|
||||
Compression::UseDefaultThreadStorage();
|
||||
|
||||
// 4J-PB - Xbox 360 - 163153 - [CRASH] TU17: Code: Multiplayer: During the
|
||||
|
|
|
|||
|
|
@ -948,7 +948,6 @@ int CGameNetworkManager::RunNetworkGameThreadProc(void* lpParameter) {
|
|||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||
// as we don't tick the main thread whilst this thread is running
|
||||
AABB::UseDefaultThreadStorage();
|
||||
Vec3::UseDefaultThreadStorage();
|
||||
Compression::UseDefaultThreadStorage();
|
||||
Tile::CreateNewThreadStorage();
|
||||
|
||||
|
|
@ -1008,7 +1007,6 @@ int CGameNetworkManager::ServerThreadProc(void* lpParameter) {
|
|||
|
||||
SetThreadName(-1, "Minecraft Server thread");
|
||||
AABB::CreateNewThreadStorage();
|
||||
Vec3::CreateNewThreadStorage();
|
||||
Compression::UseDefaultThreadStorage();
|
||||
OldChunkStorage::UseDefaultThreadStorage();
|
||||
Entity::useSmallIds();
|
||||
|
|
@ -1022,7 +1020,6 @@ int CGameNetworkManager::ServerThreadProc(void* lpParameter) {
|
|||
|
||||
Tile::ReleaseThreadStorage();
|
||||
AABB::ReleaseThreadStorage();
|
||||
Vec3::ReleaseThreadStorage();
|
||||
Level::destroyLightingCache();
|
||||
|
||||
if (lpParameter != NULL) delete (NetworkGameInitData*)lpParameter;
|
||||
|
|
@ -1034,7 +1031,6 @@ int CGameNetworkManager::ExitAndJoinFromInviteThreadProc(void* lpParam) {
|
|||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||
// as we don't tick the main thread whilst this thread is running
|
||||
AABB::UseDefaultThreadStorage();
|
||||
Vec3::UseDefaultThreadStorage();
|
||||
Compression::UseDefaultThreadStorage();
|
||||
|
||||
// app.SetGameStarted(false);
|
||||
|
|
@ -1187,7 +1183,6 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc(void* lpParam) {
|
|||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||
// as we don't tick the main thread whilst this thread is running
|
||||
AABB::UseDefaultThreadStorage();
|
||||
Vec3::UseDefaultThreadStorage();
|
||||
Compression::UseDefaultThreadStorage();
|
||||
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
|
|
|||
|
|
@ -381,7 +381,6 @@ int IUIScene_PauseMenu::SaveWorldThreadProc(void* lpParameter) {
|
|||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||
// as we don't tick the main thread whilst this thread is running
|
||||
AABB::UseDefaultThreadStorage();
|
||||
Vec3::UseDefaultThreadStorage();
|
||||
Compression::UseDefaultThreadStorage();
|
||||
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
|
@ -419,7 +418,6 @@ int IUIScene_PauseMenu::ExitWorldThreadProc(void* lpParameter) {
|
|||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||
// as we don't tick the main thread whilst this thread is running
|
||||
AABB::UseDefaultThreadStorage();
|
||||
Vec3::UseDefaultThreadStorage();
|
||||
Compression::UseDefaultThreadStorage();
|
||||
|
||||
// app.SetGameStarted(false);
|
||||
|
|
|
|||
|
|
@ -220,7 +220,6 @@ HRESULT CScene_Death::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) {
|
|||
|
||||
int CScene_Death::RespawnThreadProc(void* lpParameter) {
|
||||
AABB::UseDefaultThreadStorage();
|
||||
Vec3::UseDefaultThreadStorage();
|
||||
Compression::UseDefaultThreadStorage();
|
||||
size_t iPad = (size_t)lpParameter;
|
||||
|
||||
|
|
|
|||
|
|
@ -1074,7 +1074,6 @@ int UIScene_PauseMenu::SaveWorldThreadProc(LPVOID lpParameter) {
|
|||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||
// as we don't tick the main thread whilst this thread is running
|
||||
AABB::UseDefaultThreadStorage();
|
||||
Vec3::UseDefaultThreadStorage();
|
||||
Compression::UseDefaultThreadStorage();
|
||||
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
|
@ -1107,7 +1106,6 @@ int UIScene_PauseMenu::ExitWorldThreadProc(void* lpParameter) {
|
|||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||
// as we don't tick the main thread whilst this thread is running
|
||||
AABB::UseDefaultThreadStorage();
|
||||
Vec3::UseDefaultThreadStorage();
|
||||
Compression::UseDefaultThreadStorage();
|
||||
|
||||
// app.SetGameStarted(false);
|
||||
|
|
|
|||
|
|
@ -795,7 +795,6 @@ void oldWinMainInit() {
|
|||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||
AABB::CreateNewThreadStorage();
|
||||
Vec3::CreateNewThreadStorage();
|
||||
OldChunkStorage::CreateNewThreadStorage();
|
||||
Level::enableLightingCache();
|
||||
Tile::CreateNewThreadStorage();
|
||||
|
|
@ -1143,9 +1142,6 @@ void oldWinMainTick() {
|
|||
}
|
||||
|
||||
// Fix for #7318 - Title crashes after short soak in the leaderboards menu
|
||||
// A memory leak was caused because the icon renderer kept creating new
|
||||
// Vec3's because the pool wasn't reset
|
||||
Vec3::resetPool();
|
||||
}
|
||||
|
||||
#ifdef MEMORY_TRACKING
|
||||
|
|
|
|||
|
|
@ -711,7 +711,6 @@ void CleanupDevice() {
|
|||
#endif
|
||||
|
||||
int StartMinecraftThreadProc(void* lpParameter) {
|
||||
Vec3::UseDefaultThreadStorage();
|
||||
AABB::UseDefaultThreadStorage();
|
||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||
RenderManager.InitialiseContext();
|
||||
|
|
@ -868,7 +867,6 @@ return -1;
|
|||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||
AABB::CreateNewThreadStorage();
|
||||
Vec3::CreateNewThreadStorage();
|
||||
Compression::CreateNewThreadStorage();
|
||||
OldChunkStorage::CreateNewThreadStorage();
|
||||
Level::enableLightingCache();
|
||||
|
|
@ -1103,9 +1101,6 @@ PIXEndNamedEvent();
|
|||
}
|
||||
|
||||
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||
// menu A memory leak was caused because the icon renderer kept creating
|
||||
// new Vec3's because the pool wasn't reset
|
||||
Vec3::resetPool();
|
||||
} // end game loop
|
||||
|
||||
// Graceful shutdown: destroy GL context and GLFW before any C++ dtors run.
|
||||
|
|
|
|||
|
|
@ -1040,7 +1040,6 @@ void RegisterAwardsWithProfileManager() {
|
|||
}
|
||||
|
||||
int StartMinecraftThreadProc(void* lpParameter) {
|
||||
Vec3::UseDefaultThreadStorage();
|
||||
AABB::UseDefaultThreadStorage();
|
||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||
RenderManager.InitialiseContext();
|
||||
|
|
@ -1378,7 +1377,6 @@ int main(int argc, const char* argv[]) {
|
|||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||
AABB::CreateNewThreadStorage();
|
||||
Vec3::CreateNewThreadStorage();
|
||||
Compression::CreateNewThreadStorage();
|
||||
OldChunkStorage::CreateNewThreadStorage();
|
||||
Level::enableLightingCache();
|
||||
|
|
@ -1737,9 +1735,6 @@ int main(int argc, const char* argv[]) {
|
|||
app.PatchAvailableDialogTick();
|
||||
|
||||
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||
// menu A memory leak was caused because the icon renderer kept creating
|
||||
// new Vec3's because the pool wasn't reset
|
||||
Vec3::resetPool();
|
||||
}
|
||||
|
||||
// Free resources, unregister custom classes, and exit.
|
||||
|
|
|
|||
|
|
@ -1211,7 +1211,6 @@ int main() {
|
|||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||
AABB::CreateNewThreadStorage();
|
||||
Vec3::CreateNewThreadStorage();
|
||||
OldChunkStorage::CreateNewThreadStorage();
|
||||
Level::enableLightingCache();
|
||||
Tile::CreateNewThreadStorage();
|
||||
|
|
@ -1547,7 +1546,6 @@ int main() {
|
|||
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||
// menu A memory leak was caused because the icon renderer kept creating
|
||||
// new Vec3's because the pool wasn't reset
|
||||
Vec3::resetPool();
|
||||
}
|
||||
|
||||
// Free resources, unregister custom classes, and exit.
|
||||
|
|
|
|||
|
|
@ -5413,19 +5413,20 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionOldLighting(
|
|||
// // 4J - added these faceFlags so we can detect whether this block is
|
||||
// going to have no visible faces and early out
|
||||
// // the original code checked noCulling and shouldRenderFace directly
|
||||
// where faceFlags is used now int faceFlags = 0; if ( noCulling )
|
||||
// where faceFlags is used now int faceFlags = 0; if (
|
||||
// noCulling )
|
||||
// {
|
||||
// faceFlags = 0x3f;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// faceFlags |= tt->shouldRenderFace( level, pX, pY - 1, pZ, 0 ) ?
|
||||
// 0x01 : 0; faceFlags |= tt->shouldRenderFace( level, pX, pY + 1, pZ, 1 ) ?
|
||||
// 0x02 : 0; faceFlags |= tt->shouldRenderFace( level, pX, pY, pZ - 1, 2 ) ?
|
||||
// 0x04 : 0; faceFlags |= tt->shouldRenderFace( level, pX, pY, pZ + 1, 3 ) ?
|
||||
// 0x08 : 0; faceFlags |= tt->shouldRenderFace( level, pX - 1, pY, pZ, 4 ) ?
|
||||
// 0x10 : 0; faceFlags |= tt->shouldRenderFace( level, pX + 1, pY, pZ, 5 ) ?
|
||||
// 0x20 : 0;
|
||||
// 0x01 : 0; faceFlags |= tt->shouldRenderFace( level, pX, pY
|
||||
// + 1, pZ, 1 ) ? 0x02 : 0; faceFlags |=
|
||||
// tt->shouldRenderFace( level, pX, pY, pZ - 1, 2 ) ? 0x04 : 0;
|
||||
// faceFlags |= tt->shouldRenderFace( level, pX, pY, pZ + 1, 3 ) ? 0x08 : 0;
|
||||
// faceFlags |= tt->shouldRenderFace( level, pX - 1, pY, pZ, 4 ) ? 0x10 : 0;
|
||||
// faceFlags |= tt->shouldRenderFace( level, pX + 1, pY, pZ, 5 ) ? 0x20 : 0;
|
||||
// }
|
||||
// if ( faceFlags == 0 )
|
||||
// {
|
||||
|
|
@ -5454,21 +5455,24 @@ bool TileRenderer_SPU::tesselateBlockInWorldWithAmbienceOcclusionOldLighting(
|
|||
// ll00Z = tt->getBrightness( level, pX, pY, pZ + 1 );
|
||||
//
|
||||
// llTransXY0 = level->m_tileData.transculent[level->getTile( pX + 1, pY +
|
||||
// 1, pZ )]; llTransXy0 = level->m_tileData.transculent[level->getTile( pX +
|
||||
// 1, pY - 1, pZ )]; llTransX0Z =
|
||||
// level->m_tileData.transculent[level->getTile( pX + 1, pY, pZ + 1 )];
|
||||
// llTransX0z = level->m_tileData.transculent[level->getTile( pX + 1, pY,
|
||||
// pZ - 1 )]; llTransxY0 = level->m_tileData.transculent[level->getTile( pX
|
||||
// 1, pZ )]; llTransXy0 =
|
||||
// level->m_tileData.transculent[level->getTile( pX + 1, pY - 1, pZ )];
|
||||
// llTransX0Z = level->m_tileData.transculent[level->getTile( pX + 1, pY, pZ
|
||||
// + 1 )]; llTransX0z = level->m_tileData.transculent[level->getTile( pX +
|
||||
// 1, pY, pZ - 1 )]; llTransxY0 =
|
||||
// level->m_tileData.transculent[level->getTile( pX
|
||||
// - 1, pY + 1, pZ )]; llTransxy0 =
|
||||
// level->m_tileData.transculent[level->getTile( pX - 1, pY - 1, pZ )];
|
||||
// llTransx0z = level->m_tileData.transculent[level->getTile( pX - 1, pY,
|
||||
// pZ - 1 )]; llTransx0Z = level->m_tileData.transculent[level->getTile( pX
|
||||
// pZ - 1 )]; llTransx0Z =
|
||||
// level->m_tileData.transculent[level->getTile( pX
|
||||
// - 1, pY, pZ + 1 )]; llTrans0YZ =
|
||||
// level->m_tileData.transculent[level->getTile( pX, pY + 1, pZ + 1 )];
|
||||
// llTrans0Yz = level->m_tileData.transculent[level->getTile( pX, pY + 1,
|
||||
// pZ - 1 )]; llTrans0yZ = level->m_tileData.transculent[level->getTile( pX,
|
||||
// pY - 1, pZ + 1 )]; llTrans0yz =
|
||||
// level->m_tileData.transculent[level->getTile( pX, pY - 1, pZ - 1 )];
|
||||
// pZ - 1 )]; llTrans0yZ =
|
||||
// level->m_tileData.transculent[level->getTile( pX, pY - 1, pZ + 1 )];
|
||||
// llTrans0yz = level->m_tileData.transculent[level->getTile( pX, pY - 1, pZ
|
||||
// - 1 )];
|
||||
//
|
||||
// spu_print("Have to add texture name check here\n");
|
||||
// if ( getTexture(tt)->getName().compare(L"grass_top") == 0 ) tint0 =
|
||||
|
|
@ -6097,7 +6101,7 @@ bool TileRenderer_SPU::tesselateBlockInWorld(Tile_SPU* tt, int x, int y, int z,
|
|||
float br = tt->getBrightness(level, x, y + 1, z);
|
||||
// spu_print("need to add material settings\n");
|
||||
// if ( tileShapeY1 != 1 &&
|
||||
//!tt->material->isLiquid() ) br = centerBrightness;
|
||||
//! tt->material->isLiquid() ) br = centerBrightness;
|
||||
t->color(r11 * br, g11 * br, b11 * br);
|
||||
}
|
||||
renderFaceUp(tt, x, y, z, getTexture(tt, level, x, y, z, 1));
|
||||
|
|
@ -6537,8 +6541,8 @@ bool TileRenderer_SPU::tesselateFenceGateInWorld(FenceGateTile_SPU* tt, int x,
|
|||
// level->getTile(x - 1, y, z) == Tile_SPU::cobbleWall_Id &&
|
||||
// level->getTile(x + 1, y, z) == Tile_SPU::cobbleWall_Id)
|
||||
// || ((direction == Direction::EAST || direction == Direction::WEST) &&
|
||||
//level->getTile(x, y, z - 1) == Tile_SPU::cobbleWall_Id &&
|
||||
//level->getTile(x, y, z + 1) == Tile_SPU::cobbleWall_Id))
|
||||
// level->getTile(x, y, z - 1) == Tile_SPU::cobbleWall_Id &&
|
||||
// level->getTile(x, y, z + 1) == Tile_SPU::cobbleWall_Id))
|
||||
//{
|
||||
// h00 -= 3.0f / 16.0f;
|
||||
// h01 -= 3.0f / 16.0f;
|
||||
|
|
@ -7582,7 +7586,7 @@ Icon_SPU* TileRenderer_SPU::getTextureOrMissing(Icon_SPU* Icon_SPU) {
|
|||
if (Icon_SPU == NULL) {
|
||||
assert(0);
|
||||
// return
|
||||
//minecraft->textures->getMissingIcon_SPU(Icon_SPU::TYPE_TERRAIN);
|
||||
// minecraft->textures->getMissingIcon_SPU(Icon_SPU::TYPE_TERRAIN);
|
||||
}
|
||||
return Icon_SPU;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -661,7 +661,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
|||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||
AABB::CreateNewThreadStorage();
|
||||
Vec3::CreateNewThreadStorage();
|
||||
Level::enableLightingCache();
|
||||
|
||||
Minecraft::main();
|
||||
|
|
@ -961,9 +960,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
|||
#endif
|
||||
|
||||
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||
// menu A memory leak was caused because the icon renderer kept creating
|
||||
// new Vec3's because the pool wasn't reset
|
||||
Vec3::resetPool();
|
||||
}
|
||||
|
||||
// Free resources, unregister custom classes, and exit.
|
||||
|
|
|
|||
|
|
@ -896,7 +896,6 @@ int main() {
|
|||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||
AABB::CreateNewThreadStorage();
|
||||
Vec3::CreateNewThreadStorage();
|
||||
Compression::CreateNewThreadStorage();
|
||||
OldChunkStorage::CreateNewThreadStorage();
|
||||
Level::enableLightingCache();
|
||||
|
|
@ -1250,9 +1249,6 @@ int main() {
|
|||
app.SaveDataTick();
|
||||
|
||||
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||
// menu A memory leak was caused because the icon renderer kept creating
|
||||
// new Vec3's because the pool wasn't reset
|
||||
Vec3::resetPool();
|
||||
|
||||
// sceRazorCpuSync();
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
|
|
|
|||
|
|
@ -941,7 +941,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
|||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||
AABB::CreateNewThreadStorage();
|
||||
Vec3::CreateNewThreadStorage();
|
||||
Compression::CreateNewThreadStorage();
|
||||
OldChunkStorage::CreateNewThreadStorage();
|
||||
Level::enableLightingCache();
|
||||
|
|
@ -1269,9 +1268,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
|||
}
|
||||
|
||||
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||
// menu A memory leak was caused because the icon renderer kept creating
|
||||
// new Vec3's because the pool wasn't reset
|
||||
Vec3::resetPool();
|
||||
}
|
||||
|
||||
// Free resources, unregister custom classes, and exit.
|
||||
|
|
|
|||
|
|
@ -700,7 +700,6 @@ int __cdecl main() {
|
|||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||
AABB::CreateNewThreadStorage();
|
||||
Vec3::CreateNewThreadStorage();
|
||||
Compression::CreateNewThreadStorage();
|
||||
OldChunkStorage::CreateNewThreadStorage();
|
||||
Level::enableLightingCache();
|
||||
|
|
@ -1029,9 +1028,6 @@ int __cdecl main() {
|
|||
}
|
||||
|
||||
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||
// menu A memory leak was caused because the icon renderer kept creating
|
||||
// new Vec3's because the pool wasn't reset
|
||||
Vec3::resetPool();
|
||||
}
|
||||
|
||||
// Free resources, unregister custom classes, and exit.
|
||||
|
|
|
|||
|
|
@ -1115,7 +1115,6 @@ void GameRenderer::FinishedReassigning() {
|
|||
|
||||
int GameRenderer::runUpdate(void* lpParam) {
|
||||
Minecraft* minecraft = Minecraft::GetInstance();
|
||||
Vec3::CreateNewThreadStorage();
|
||||
AABB::CreateNewThreadStorage();
|
||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||
Compression::UseDefaultThreadStorage();
|
||||
|
|
@ -1196,7 +1195,6 @@ int GameRenderer::runUpdate(void* lpParam) {
|
|||
// PIXEndNamedEvent();
|
||||
|
||||
AABB::resetPool();
|
||||
Vec3::resetPool();
|
||||
m_updateEvents->Set(eUpdateEventIsFinished);
|
||||
}
|
||||
|
||||
|
|
@ -1866,9 +1864,8 @@ void GameRenderer::setupClearColor(float a) {
|
|||
fb = (float)fogColor.z;
|
||||
|
||||
if (mc->options->viewDistance < 2) {
|
||||
Vec3 sunAngle = Mth::sin(level->getSunAngle(a)) > 0
|
||||
? Vec3(-1, 0, 0)
|
||||
: Vec3(1, 0, 0);
|
||||
Vec3 sunAngle = Mth::sin(level->getSunAngle(a)) > 0 ? Vec3(-1, 0, 0)
|
||||
: Vec3(1, 0, 0);
|
||||
float d = (float)player->getViewVector(a).dot(sunAngle);
|
||||
if (d < 0) d = 0;
|
||||
if (d > 0) {
|
||||
|
|
|
|||
|
|
@ -4039,7 +4039,6 @@ void LevelRenderer::staticCtor() {
|
|||
}
|
||||
|
||||
int LevelRenderer::rebuildChunkThreadProc(void* lpParam) {
|
||||
Vec3::CreateNewThreadStorage();
|
||||
AABB::CreateNewThreadStorage();
|
||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||
RenderManager.InitialiseContext();
|
||||
|
|
|
|||
|
|
@ -5,52 +5,6 @@
|
|||
|
||||
#include "AABB.h"
|
||||
|
||||
unsigned int Vec3::tlsIdx = 0;
|
||||
Vec3::ThreadStorage* Vec3::tlsDefault = NULL;
|
||||
|
||||
Vec3::ThreadStorage::ThreadStorage() {
|
||||
pool = new Vec3[POOL_SIZE];
|
||||
poolPointer = 0;
|
||||
}
|
||||
|
||||
Vec3::ThreadStorage::~ThreadStorage() { delete[] pool; }
|
||||
|
||||
void Vec3::CreateNewThreadStorage() {
|
||||
ThreadStorage* tls = new ThreadStorage();
|
||||
if (tlsDefault == NULL) {
|
||||
tlsIdx = TlsAlloc();
|
||||
tlsDefault = tls;
|
||||
}
|
||||
TlsSetValue(tlsIdx, tls);
|
||||
}
|
||||
|
||||
void Vec3::UseDefaultThreadStorage() { TlsSetValue(tlsIdx, tlsDefault); }
|
||||
|
||||
void Vec3::ReleaseThreadStorage() {
|
||||
ThreadStorage* tls = (ThreadStorage*)TlsGetValue(tlsIdx);
|
||||
if (tls == tlsDefault) return;
|
||||
|
||||
delete tls;
|
||||
}
|
||||
|
||||
Vec3* Vec3::newPermanent(double x, double y, double z) {
|
||||
assert(0);
|
||||
return new Vec3(x, y, z);
|
||||
};
|
||||
|
||||
void Vec3::clearPool() {}
|
||||
|
||||
void Vec3::resetPool() {}
|
||||
|
||||
Vec3* Vec3::newTemp(double x, double y, double z) {
|
||||
assert(0);
|
||||
ThreadStorage* tls = (ThreadStorage*)TlsGetValue(tlsIdx);
|
||||
Vec3* thisVec = &tls->pool[tls->poolPointer];
|
||||
thisVec->set(x, y, z);
|
||||
tls->poolPointer = (tls->poolPointer + 1) % ThreadStorage::POOL_SIZE;
|
||||
return thisVec;
|
||||
}
|
||||
|
||||
Vec3::Vec3(double x, double y, double z) {
|
||||
if (x == -0.0) x = 0.0;
|
||||
if (y == -0.0) y = 0.0;
|
||||
|
|
@ -60,13 +14,6 @@ Vec3::Vec3(double x, double y, double z) {
|
|||
this->z = z;
|
||||
}
|
||||
|
||||
Vec3* Vec3::set(double x, double y, double z) {
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->z = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
Vec3 Vec3::vectorTo(const Vec3& p) const { return {p.x - x, p.y - y, p.z - z}; }
|
||||
|
||||
Vec3 Vec3::normalize() const {
|
||||
|
|
|
|||
|
|
@ -6,39 +6,12 @@
|
|||
class AABB;
|
||||
|
||||
class Vec3 {
|
||||
// 4J added so we can have separate pools for different threads
|
||||
class ThreadStorage {
|
||||
public:
|
||||
static const int POOL_SIZE = 1024;
|
||||
Vec3* pool;
|
||||
unsigned int poolPointer;
|
||||
ThreadStorage();
|
||||
~ThreadStorage();
|
||||
};
|
||||
static unsigned int tlsIdx;
|
||||
static ThreadStorage* tlsDefault;
|
||||
|
||||
public:
|
||||
// Each new thread that needs to use Vec3 pools will need to call one of the
|
||||
// following 2 functions, to either create its own local storage, or share
|
||||
// the default storage already allocated by the main thread
|
||||
static void CreateNewThreadStorage();
|
||||
static void UseDefaultThreadStorage();
|
||||
static void ReleaseThreadStorage();
|
||||
|
||||
static Vec3* newPermanent(double x, double y, double z);
|
||||
static void clearPool();
|
||||
static void resetPool();
|
||||
static Vec3* newTemp(double x, double y, double z);
|
||||
double x, y, z;
|
||||
|
||||
Vec3() {}
|
||||
Vec3(double x, double y, double z);
|
||||
|
||||
private:
|
||||
Vec3* set(double x, double y, double z);
|
||||
|
||||
public:
|
||||
Vec3 vectorTo(const Vec3& p) const;
|
||||
Vec3 normalize() const;
|
||||
double dot(const Vec3& p) const;
|
||||
|
|
|
|||
Loading…
Reference in a new issue