adjust naming scheme of private TLS members

This commit is contained in:
Tropical 2026-03-25 14:46:16 -05:00
parent 9ff2fb4fef
commit 30170b8f9c
28 changed files with 90 additions and 90 deletions

View file

@ -20,18 +20,18 @@
int Chunk::updates = 0; int Chunk::updates = 0;
#ifdef _LARGE_WORLDS #ifdef _LARGE_WORLDS
thread_local uint8_t* Chunk::m_threadTileIds = nullptr; thread_local uint8_t* Chunk::m_tlsTileIds = nullptr;
void Chunk::CreateNewThreadStorage() { void Chunk::CreateNewThreadStorage() {
m_threadTileIds = new unsigned char[16 * 16 * Level::maxBuildHeight]; m_tlsTileIds = new unsigned char[16 * 16 * Level::maxBuildHeight];
} }
void Chunk::ReleaseThreadStorage() { void Chunk::ReleaseThreadStorage() {
delete m_threadTileIds; delete m_tlsTileIds;
} }
uint8_t* Chunk::GetTileIdsStorage() { uint8_t* Chunk::GetTileIdsStorage() {
return m_threadTileIds; return m_tlsTileIds;
} }
#else #else
// 4J Stu - Don't want this when multi-threaded // 4J Stu - Don't want this when multi-threaded

View file

@ -30,7 +30,7 @@ private:
#ifndef _LARGE_WORLDS #ifndef _LARGE_WORLDS
static Tesselator* t; static Tesselator* t;
#else #else
static thread_local uint8_t* m_threadTileIds; static thread_local uint8_t* m_tlsTileIds;
public: public:
static void CreateNewThreadStorage(); static void CreateNewThreadStorage();

View file

@ -24,14 +24,14 @@ int normal;
*/ */
thread_local Tesselator* Tesselator::m_threadInstance = nullptr; thread_local Tesselator* Tesselator::m_tlsInstance = nullptr;
Tesselator* Tesselator::getInstance() { Tesselator* Tesselator::getInstance() {
return m_threadInstance; return m_tlsInstance;
} }
void Tesselator::CreateNewThreadStorage(int bytes) { void Tesselator::CreateNewThreadStorage(int bytes) {
Tesselator::m_threadInstance = new Tesselator(bytes / 4); Tesselator::m_tlsInstance = new Tesselator(bytes / 4);
} }
// she tessalate my vertices till i render // she tessalate my vertices till i render

View file

@ -41,7 +41,7 @@ public:
static void CreateNewThreadStorage(int bytes); static void CreateNewThreadStorage(int bytes);
private: private:
static thread_local Tesselator* m_threadInstance; static thread_local Tesselator* m_tlsInstance;
public: public:
static Tesselator* getInstance(); static Tesselator* getInstance();

View file

@ -260,7 +260,7 @@ void ButtonTile::checkPressed(Level* level, int x, int y, int z) {
bool shouldBePressed; bool shouldBePressed;
updateShape(data); updateShape(data);
Tile::ThreadStorage* tls = m_threadShape; Tile::ThreadStorage* tls = m_tlsShape;
std::vector<std::shared_ptr<Entity> >* entities = level->getEntitiesOfClass( std::vector<std::shared_ptr<Entity> >* entities = level->getEntitiesOfClass(
typeid(Arrow), AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, typeid(Arrow), AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0,
x + tls->xx1, y + tls->yy1, z + tls->zz1)); x + tls->xx1, y + tls->yy1, z + tls->zz1));

View file

@ -266,7 +266,7 @@ void LiquidTile::animateTick(Level* level, int x, int y, int z,
if (level->getMaterial(x, y + 1, z) == Material::air && if (level->getMaterial(x, y + 1, z) == Material::air &&
!level->isSolidRenderTile(x, y + 1, z)) { !level->isSolidRenderTile(x, y + 1, z)) {
if (random->nextInt(100) == 0) { if (random->nextInt(100) == 0) {
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
double xx = x + random->nextFloat(); double xx = x + random->nextFloat();
double yy = y + tls->yy1; double yy = y + tls->yy1;
double zz = z + random->nextFloat(); double zz = z + random->nextFloat();

View file

@ -20,7 +20,7 @@ const std::wstring PistonBaseTile::INSIDE_TEX = L"piston_inner_top";
const float PistonBaseTile::PLATFORM_THICKNESS = 4.0f; const float PistonBaseTile::PLATFORM_THICKNESS = 4.0f;
thread_local bool PistonBaseTile::m_threadIgnoreUpdate = false; thread_local bool PistonBaseTile::m_tlsIgnoreUpdate = false;
// 4J - NOTE - this ignoreUpdate stuff has been removed from the java version, // 4J - NOTE - this ignoreUpdate stuff has been removed from the java version,
// but I'm not currently sure how the java version does without it... there must // but I'm not currently sure how the java version does without it... there must
@ -32,11 +32,11 @@ thread_local bool PistonBaseTile::m_threadIgnoreUpdate = false;
// 4J - ignoreUpdate is a static in java, implementing as TLS here to make // 4J - ignoreUpdate is a static in java, implementing as TLS here to make
// thread safe // thread safe
bool PistonBaseTile::ignoreUpdate() { bool PistonBaseTile::ignoreUpdate() {
return m_threadIgnoreUpdate; return m_tlsIgnoreUpdate;
} }
void PistonBaseTile::ignoreUpdate(bool set) { void PistonBaseTile::ignoreUpdate(bool set) {
m_threadIgnoreUpdate = set; m_tlsIgnoreUpdate = set;
} }
PistonBaseTile::PistonBaseTile(int id, bool isSticky) PistonBaseTile::PistonBaseTile(int id, bool isSticky)
@ -72,7 +72,7 @@ Icon* PistonBaseTile::getTexture(int face, int data) {
// when the piston is extended, either normally // when the piston is extended, either normally
// or because a piston arm animation, the top // or because a piston arm animation, the top
// texture is the furnace bottom // texture is the furnace bottom
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
if (isExtended(data) || tls->xx0 > 0 || tls->yy0 > 0 || tls->zz0 > 0 || if (isExtended(data) || tls->xx0 > 0 || tls->yy0 > 0 || tls->zz0 > 0 ||
tls->xx1 < 1 || tls->yy1 < 1 || tls->zz1 < 1) { tls->xx1 < 1 || tls->yy1 < 1 || tls->zz1 < 1) {
return iconInside; return iconInside;

View file

@ -35,7 +35,7 @@ private:
Icon* iconBack; Icon* iconBack;
Icon* iconPlatform; Icon* iconPlatform;
static thread_local bool m_threadIgnoreUpdate; static thread_local bool m_tlsIgnoreUpdate;
static TlsKey tlsIdx; static TlsKey tlsIdx;
// 4J - was just a static but implemented with TLS for our version // 4J - was just a static but implemented with TLS for our version

View file

@ -126,7 +126,7 @@ void PistonMovingPiece::updateShape(
progress = 1.0f - progress; progress = 1.0f - progress;
} }
int facing = entity->getFacing(); int facing = entity->getFacing();
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
tls->xx0 = tile->getShapeX0() - Facing::STEP_X[facing] * progress; tls->xx0 = tile->getShapeX0() - Facing::STEP_X[facing] * progress;
tls->yy0 = tile->getShapeY0() - Facing::STEP_Y[facing] * progress; tls->yy0 = tile->getShapeY0() - Facing::STEP_Y[facing] * progress;
tls->zz0 = tile->getShapeZ0() - Facing::STEP_Z[facing] * progress; tls->zz0 = tile->getShapeZ0() - Facing::STEP_Z[facing] * progress;

View file

@ -145,7 +145,7 @@ void StemTile::updateShape(
std::shared_ptr<TileEntity> std::shared_ptr<TileEntity>
forceEntity) // 4J added forceData, forceEntity param forceEntity) // 4J added forceData, forceEntity param
{ {
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
tls->yy1 = (level->getData(x, y, z) * 2 + 2) / 16.0f; tls->yy1 = (level->getData(x, y, z) * 2 + 2) / 16.0f;
float ss = 0.125f; float ss = 0.125f;
setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, (float)tls->yy1, 0.5f + ss); setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, (float)tls->yy1, 0.5f + ss);

View file

@ -9,16 +9,16 @@
#include "../Headers/net.minecraft.world.h" #include "../Headers/net.minecraft.world.h"
#include <cstdint> #include <cstdint>
thread_local bool TheEndPortal::m_threadAllowAnywhere = false; thread_local bool TheEndPortal::m_tlsAllowAnywhere = false;
// 4J - allowAnywhere is a static in java, implementing as TLS here to make // 4J - allowAnywhere is a static in java, implementing as TLS here to make
// thread safe // thread safe
bool TheEndPortal::allowAnywhere() { bool TheEndPortal::allowAnywhere() {
return m_threadAllowAnywhere; return m_tlsAllowAnywhere;
} }
void TheEndPortal::allowAnywhere(bool set) { void TheEndPortal::allowAnywhere(bool set) {
m_threadAllowAnywhere = set; m_tlsAllowAnywhere = set;
} }
TheEndPortal::TheEndPortal(int id, Material* material) TheEndPortal::TheEndPortal(int id, Material* material)

View file

@ -35,5 +35,5 @@ public:
void registerIcons(IconRegister* iconRegister); void registerIcons(IconRegister* iconRegister);
private: private:
static thread_local bool m_threadAllowAnywhere; static thread_local bool m_tlsAllowAnywhere;
}; };

View file

@ -222,7 +222,7 @@ Tile* Tile::woolCarpet = NULL;
Tile* Tile::clayHardened = NULL; Tile* Tile::clayHardened = NULL;
Tile* Tile::coalBlock = NULL; Tile* Tile::coalBlock = NULL;
thread_local Tile::ThreadStorage* Tile::m_threadShape = nullptr; thread_local Tile::ThreadStorage* Tile::m_tlsShape = nullptr;
Tile::ThreadStorage::ThreadStorage() { Tile::ThreadStorage::ThreadStorage() {
xx0 = yy0 = zz0 = xx1 = yy1 = zz1 = 0.0; xx0 = yy0 = zz0 = xx1 = yy1 = zz1 = 0.0;
@ -230,11 +230,11 @@ Tile::ThreadStorage::ThreadStorage() {
} }
void Tile::CreateNewThreadStorage() { void Tile::CreateNewThreadStorage() {
m_threadShape = new ThreadStorage(); m_tlsShape = new ThreadStorage();
} }
void Tile::ReleaseThreadStorage() { void Tile::ReleaseThreadStorage() {
delete m_threadShape; delete m_tlsShape;
} }
void Tile::staticCtor() { void Tile::staticCtor() {
@ -1868,7 +1868,7 @@ Tile* Tile::disableMipmap() {
void Tile::setShape(float x0, float y0, float z0, float x1, float y1, void Tile::setShape(float x0, float y0, float z0, float x1, float y1,
float z1) { float z1) {
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
tls->xx0 = x0; tls->xx0 = x0;
tls->yy0 = y0; tls->yy0 = y0;
tls->zz0 = z0; tls->zz0 = z0;
@ -1919,7 +1919,7 @@ bool Tile::isFaceVisible(Level* level, int x, int y, int z, int f) {
bool Tile::shouldRenderFace(LevelSource* level, int x, int y, int z, int face) { bool Tile::shouldRenderFace(LevelSource* level, int x, int y, int z, int face) {
ThreadStorage* tls = ThreadStorage* tls =
m_threadShape; m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
if (face == 0 && tls->yy0 > 0) return true; if (face == 0 && tls->yy0 > 0) return true;
@ -1936,7 +1936,7 @@ bool Tile::shouldRenderFace(LevelSource* level, int x, int y, int z, int face) {
int Tile::getFaceFlags(LevelSource* level, int x, int y, int z) { int Tile::getFaceFlags(LevelSource* level, int x, int y, int z) {
int faceFlags = 0; int faceFlags = 0;
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
@ -2009,7 +2009,7 @@ Icon* Tile::getTexture(int face, int data) { return icon; }
Icon* Tile::getTexture(int face) { return getTexture(face, 0); } Icon* Tile::getTexture(int face) { return getTexture(face, 0); }
AABB* Tile::getTileAABB(Level* level, int x, int y, int z) { AABB* Tile::getTileAABB(Level* level, int x, int y, int z) {
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1,
@ -2023,7 +2023,7 @@ void Tile::addAABBs(Level* level, int x, int y, int z, AABB* box,
} }
AABB* Tile::getAABB(Level* level, int x, int y, int z) { AABB* Tile::getAABB(Level* level, int x, int y, int z) {
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1,
@ -2128,7 +2128,7 @@ HitResult* Tile::clip(Level* level, int xt, int yt, int zt, Vec3* a, Vec3* b) {
a = a->add(-xt, -yt, -zt); a = a->add(-xt, -yt, -zt);
b = b->add(-xt, -yt, -zt); b = b->add(-xt, -yt, -zt);
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
Vec3* xh0 = a->clipX(b, tls->xx0); Vec3* xh0 = a->clipX(b, tls->xx0);
Vec3* xh1 = a->clipX(b, tls->xx1); Vec3* xh1 = a->clipX(b, tls->xx1);
@ -2176,7 +2176,7 @@ HitResult* Tile::clip(Level* level, int xt, int yt, int zt, Vec3* a, Vec3* b) {
bool Tile::containsX(Vec3* v) { bool Tile::containsX(Vec3* v) {
if (v == NULL) return false; if (v == NULL) return false;
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
return v->y >= tls->yy0 && v->y <= tls->yy1 && v->z >= tls->zz0 && return v->y >= tls->yy0 && v->y <= tls->yy1 && v->z >= tls->zz0 &&
@ -2186,7 +2186,7 @@ bool Tile::containsX(Vec3* v) {
bool Tile::containsY(Vec3* v) { bool Tile::containsY(Vec3* v) {
if (v == NULL) return false; if (v == NULL) return false;
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
return v->x >= tls->xx0 && v->x <= tls->xx1 && v->z >= tls->zz0 && return v->x >= tls->xx0 && v->x <= tls->xx1 && v->z >= tls->zz0 &&
@ -2196,7 +2196,7 @@ bool Tile::containsY(Vec3* v) {
bool Tile::containsZ(Vec3* v) { bool Tile::containsZ(Vec3* v) {
if (v == NULL) return false; if (v == NULL) return false;
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
return v->x >= tls->xx0 && v->x <= tls->xx1 && v->y >= tls->yy0 && return v->x >= tls->xx0 && v->x <= tls->xx1 && v->y >= tls->yy0 &&
@ -2260,48 +2260,48 @@ void Tile::updateShape(
std::shared_ptr<TileEntity> std::shared_ptr<TileEntity>
forceEntity) // 4J added forceData, forceEntity param forceEntity) // 4J added forceData, forceEntity param
{ {
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
} }
double Tile::getShapeX0() { double Tile::getShapeX0() {
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
return tls->xx0; return tls->xx0;
} }
double Tile::getShapeX1() { double Tile::getShapeX1() {
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
return tls->xx1; return tls->xx1;
} }
double Tile::getShapeY0() { double Tile::getShapeY0() {
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
return tls->yy0; return tls->yy0;
} }
double Tile::getShapeY1() { double Tile::getShapeY1() {
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
return tls->yy1; return tls->yy1;
} }
double Tile::getShapeZ0() { double Tile::getShapeZ0() {
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
return tls->zz0; return tls->zz0;
} }
double Tile::getShapeZ1() { double Tile::getShapeZ1() {
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
return tls->zz1; return tls->zz1;

View file

@ -66,7 +66,7 @@ protected:
int tileId; int tileId;
ThreadStorage(); ThreadStorage();
}; };
static thread_local ThreadStorage* m_threadShape; static thread_local ThreadStorage* m_tlsShape;
public: public:
// Each new thread that needs to use Vec3 pools will need to call one of the // 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 // following 2 functions, to either create its own local storage, or share

View file

@ -25,7 +25,7 @@ void TopSnowTile::registerIcons(IconRegister* iconRegister) {
AABB* TopSnowTile::getAABB(Level* level, int x, int y, int z) { AABB* TopSnowTile::getAABB(Level* level, int x, int y, int z) {
int height = level->getData(x, y, z) & HEIGHT_MASK; int height = level->getData(x, y, z) & HEIGHT_MASK;
float offset = 2.0f / SharedConstants::WORLD_RESOLUTION; float offset = 2.0f / SharedConstants::WORLD_RESOLUTION;
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1,
y + (height * offset), z + tls->zz1); y + (height * offset), z + tls->zz1);
} }

View file

@ -132,7 +132,7 @@ void TripWireTile::checkPressed(Level* level, int x, int y, int z) {
bool wasPressed = (data & MASK_POWERED) == MASK_POWERED; bool wasPressed = (data & MASK_POWERED) == MASK_POWERED;
bool shouldBePressed = false; bool shouldBePressed = false;
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
std::vector<std::shared_ptr<Entity> >* entities = level->getEntities( std::vector<std::shared_ptr<Entity> >* entities = level->getEntities(
nullptr, AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, nullptr, AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0,
x + tls->xx1, y + tls->yy1, z + tls->zz1)); x + tls->xx1, y + tls->yy1, z + tls->zz1));

View file

@ -24,7 +24,7 @@ void WaterlilyTile::addAABBs(Level* level, int x, int y, int z, AABB* box,
} }
AABB* WaterlilyTile::getAABB(Level* level, int x, int y, int z) { AABB* WaterlilyTile::getAABB(Level* level, int x, int y, int z) {
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1,

View file

@ -18,7 +18,7 @@ Icon* WoolCarpetTile::getTexture(int face, int data) {
AABB* WoolCarpetTile::getAABB(Level* level, int x, int y, int z) { AABB* WoolCarpetTile::getAABB(Level* level, int x, int y, int z) {
int height = 0; int height = 0;
float offset = 1.0f / SharedConstants::WORLD_RESOLUTION; float offset = 1.0f / SharedConstants::WORLD_RESOLUTION;
ThreadStorage* tls = m_threadShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); if (tls->tileId != this->id) updateDefaultShape();
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1,

View file

@ -26,7 +26,7 @@
#include "../../Minecraft.Client/Level/ServerLevel.h" #include "../../Minecraft.Client/Level/ServerLevel.h"
#include "../../Minecraft.Client/Network/PlayerList.h" #include "../../Minecraft.Client/Network/PlayerList.h"
thread_local bool Entity::m_threadUseSmallIds = false; thread_local bool Entity::m_tlsUseSmallIds = false;
const std::wstring Entity::RIDING_TAG = L"Riding"; const std::wstring Entity::RIDING_TAG = L"Riding";
int Entity::entityCounter = int Entity::entityCounter =
@ -54,7 +54,7 @@ int Entity::getSmallId() {
// telling the client that the entity has been removed After we have already // telling the client that the entity has been removed After we have already
// re-used its Id and created a new entity. This ends up with newly created // re-used its Id and created a new entity. This ends up with newly created
// client-side entities being removed by accident, causing invisible mobs. // client-side entities being removed by accident, causing invisible mobs.
if (m_threadUseSmallIds) { if (m_tlsUseSmallIds) {
MinecraftServer* server = MinecraftServer::getInstance(); MinecraftServer* server = MinecraftServer::getInstance();
if (server) { if (server) {
// In some attempt to optimise this, flagEntitiesToBeRemoved most of // In some attempt to optimise this, flagEntitiesToBeRemoved most of
@ -129,13 +129,13 @@ void Entity::countFlagsForPIX() {
void Entity::resetSmallId() { void Entity::resetSmallId() {
freeSmallId(entityId); freeSmallId(entityId);
if (m_threadUseSmallIds) { if (m_tlsUseSmallIds) {
entityId = getSmallId(); entityId = getSmallId();
} }
} }
void Entity::freeSmallId(int index) { void Entity::freeSmallId(int index) {
if (!m_threadUseSmallIds) if (!m_tlsUseSmallIds)
return; // Don't do anything with small ids if this isn't the server return; // Don't do anything with small ids if this isn't the server
// thread // thread
if (index >= 2048) return; // Don't do anything if this isn't a short id if (index >= 2048) return; // Don't do anything if this isn't a short id
@ -148,7 +148,7 @@ void Entity::freeSmallId(int index) {
entityIdWanderFlags[i] &= uiMask; entityIdWanderFlags[i] &= uiMask;
} }
void Entity::useSmallIds() { m_threadUseSmallIds = true; } void Entity::useSmallIds() { m_tlsUseSmallIds = true; }
// Things also added here to be able to manage the concept of a number of extra // Things also added here to be able to manage the concept of a number of extra
// "wandering" entities - normally path finding entities aren't allowed to // "wandering" entities - normally path finding entities aren't allowed to
@ -161,7 +161,7 @@ void Entity::useSmallIds() { m_threadUseSmallIds = true; }
// Let the management system here know whether or not to consider this // Let the management system here know whether or not to consider this
// particular entity for some extra wandering // particular entity for some extra wandering
void Entity::considerForExtraWandering(bool enable) { void Entity::considerForExtraWandering(bool enable) {
if (!m_threadUseSmallIds) if (!m_tlsUseSmallIds)
return; // Don't do anything with small ids if this isn't the server return; // Don't do anything with small ids if this isn't the server
// thread // thread
if (entityId >= 2048) return; // Don't do anything if this isn't a short id if (entityId >= 2048) return; // Don't do anything if this isn't a short id
@ -180,7 +180,7 @@ void Entity::considerForExtraWandering(bool enable) {
// Should this entity do wandering in addition to what the java code would have // Should this entity do wandering in addition to what the java code would have
// done? // done?
bool Entity::isExtraWanderingEnabled() { bool Entity::isExtraWanderingEnabled() {
if (!m_threadUseSmallIds) if (!m_tlsUseSmallIds)
return false; // Don't do anything with small ids if this isn't the return false; // Don't do anything with small ids if this isn't the
// server thread // server thread
if (entityId >= 2048) if (entityId >= 2048)
@ -247,7 +247,7 @@ void Entity::_init(bool useSmallId, Level* level) {
// rest of the range is used for anything we don't need to track like this, // rest of the range is used for anything we don't need to track like this,
// currently particles. We only ever want to allocate this type of id from // currently particles. We only ever want to allocate this type of id from
// the server thread, so using thread local storage to isolate this. // the server thread, so using thread local storage to isolate this.
if (useSmallId && m_threadUseSmallIds) { if (useSmallId && m_tlsUseSmallIds) {
entityId = getSmallId(); entityId = getSmallId();
} else { } else {
entityId = Entity::entityCounter++; entityId = Entity::entityCounter++;

View file

@ -429,7 +429,7 @@ private:
static int extraWanderCount; static int extraWanderCount;
static int extraWanderTicks; static int extraWanderTicks;
static thread_local bool m_threadUseSmallIds; static thread_local bool m_tlsUseSmallIds;
public: public:
static void tickExtraWandering(); static void tickExtraWandering();
static void countFlagsForPIX(); static void countFlagsForPIX();

View file

@ -17,8 +17,8 @@
#include "../../../Minecraft.Client/Platform/PS3/PS3Extras/EdgeZLib.h" #include "../../../Minecraft.Client/Platform/PS3/PS3Extras/EdgeZLib.h"
#endif //__PS3__ #endif //__PS3__
thread_local Compression::ThreadStorage* Compression::m_threadCompression = nullptr; thread_local Compression::ThreadStorage* Compression::m_tlsCompression = nullptr;
Compression::ThreadStorage* Compression::m_threadCompressionDefault = nullptr; Compression::ThreadStorage* Compression::m_tlsCompressionDefault = nullptr;
Compression::ThreadStorage::ThreadStorage() { compression = new Compression(); } Compression::ThreadStorage::ThreadStorage() { compression = new Compression(); }
@ -26,24 +26,24 @@ Compression::ThreadStorage::~ThreadStorage() { delete compression; }
void Compression::CreateNewThreadStorage() { void Compression::CreateNewThreadStorage() {
ThreadStorage* tls = new ThreadStorage(); ThreadStorage* tls = new ThreadStorage();
if (m_threadCompressionDefault == nullptr) { if (m_tlsCompressionDefault == nullptr) {
m_threadCompressionDefault = tls; m_tlsCompressionDefault = tls;
} }
m_threadCompression = tls; m_tlsCompression = tls;
} }
void Compression::UseDefaultThreadStorage() { void Compression::UseDefaultThreadStorage() {
m_threadCompression = m_threadCompressionDefault; m_tlsCompression = m_tlsCompressionDefault;
} }
void Compression::ReleaseThreadStorage() { void Compression::ReleaseThreadStorage() {
if (m_threadCompression != m_threadCompressionDefault) { if (m_tlsCompression != m_tlsCompressionDefault) {
delete m_threadCompression; delete m_tlsCompression;
} }
} }
Compression* Compression::getCompression() { Compression* Compression::getCompression() {
return m_threadCompression->compression; return m_tlsCompression->compression;
} }
HRESULT Compression::CompressLZXRLE(void* pDestination, unsigned int* pDestSize, HRESULT Compression::CompressLZXRLE(void* pDestination, unsigned int* pDestSize,

View file

@ -25,7 +25,7 @@ private:
ThreadStorage(); ThreadStorage();
~ThreadStorage(); ~ThreadStorage();
}; };
static thread_local ThreadStorage* m_threadCompression; static thread_local ThreadStorage* m_tlsCompression;
static ThreadStorage* m_threadCompressionDefault; static ThreadStorage* m_threadCompressionDefault;
public: public:

View file

@ -90,20 +90,20 @@
// W - lighting value requires write // W - lighting value requires write
#endif #endif
thread_local bool Level::m_threadInstaTick = false; thread_local bool Level::m_tlsInstaTick = false;
thread_local Level::lightCache_t* Level::m_threadLightCache = nullptr; thread_local Level::lightCache_t* Level::m_tlsLightCache = nullptr;
void Level::enableLightingCache() { void Level::enableLightingCache() {
// Allocate 16K (needs 32K for large worlds) for a 16x16x16x4 byte cache of // Allocate 16K (needs 32K for large worlds) for a 16x16x16x4 byte cache of
// 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_threadLightCache = (lightCache_t*)XPhysicalAlloc( m_tlsLightCache = (lightCache_t*)XPhysicalAlloc(
256 * 1024, MAXULONG_PTR, 128 * 1024, PAGE_READWRITE | MEM_LARGE_PAGES); 256 * 1024, MAXULONG_PTR, 128 * 1024, PAGE_READWRITE | MEM_LARGE_PAGES);
} }
void Level::destroyLightingCache() { void Level::destroyLightingCache() {
delete m_threadLightCache; delete m_tlsLightCache;
} }
inline int GetIndex(int x, int y, int z) { inline int GetIndex(int x, int y, int z) {
@ -492,11 +492,11 @@ void Level::flushCache(lightCache_t* cache, uint64_t cacheUse,
// 4J - added following 2 functions to move instaBuild flag from being a class // 4J - added following 2 functions to move instaBuild flag from being a class
// member, to TLS // member, to TLS
bool Level::getInstaTick() { bool Level::getInstaTick() {
return m_threadInstaTick; return m_tlsInstaTick;
} }
void Level::setInstaTick(bool enable) { void Level::setInstaTick(bool enable) {
m_threadInstaTick = enable; m_tlsInstaTick = enable;
} }
// 4J - added // 4J - added
@ -3143,7 +3143,7 @@ int Level::getExpectedLight(lightCache_t* cache, int x, int y, int z,
// this thread // this thread
void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc,
bool force, bool rootOnlyEmissive) { bool force, bool rootOnlyEmissive) {
lightCache_t* cache = m_threadLightCache; lightCache_t* cache = m_tlsLightCache;
uint64_t cacheUse = 0; uint64_t cacheUse = 0;
if (force) { if (force) {

View file

@ -93,8 +93,8 @@ public:
// 4J - added, making instaTick flag use TLS so we can set it in the chunk // 4J - added, making instaTick flag use TLS so we can set it in the chunk
// rebuilding thread without upsetting the main game thread // rebuilding thread without upsetting the main game thread
static thread_local bool m_threadInstaTick; static thread_local bool m_tlsInstaTick;
static thread_local lightCache_t* m_threadLightCache; static thread_local lightCache_t* m_tlsLightCache;
static void enableLightingCache(); static void enableLightingCache();
static void destroyLightingCache(); static void destroyLightingCache();
static bool getCacheTestEnabled(); static bool getCacheTestEnabled();

View file

@ -9,7 +9,7 @@
#include "../../IO/Files/FileHeader.h" #include "../../IO/Files/FileHeader.h"
#include "OldChunkStorage.h" #include "OldChunkStorage.h"
thread_local OldChunkStorage::ThreadStorage* OldChunkStorage::m_threadStorage = thread_local OldChunkStorage::ThreadStorage* OldChunkStorage::m_tlsStorage =
nullptr; nullptr;
OldChunkStorage::ThreadStorage* OldChunkStorage::m_defaultThreadStorage = OldChunkStorage::ThreadStorage* OldChunkStorage::m_defaultThreadStorage =
nullptr; nullptr;
@ -35,16 +35,16 @@ void OldChunkStorage::CreateNewThreadStorage() {
m_defaultThreadStorage = tls; m_defaultThreadStorage = tls;
} }
m_threadStorage = tls; m_tlsStorage = tls;
} }
void OldChunkStorage::UseDefaultThreadStorage() { void OldChunkStorage::UseDefaultThreadStorage() {
m_threadStorage = m_defaultThreadStorage; m_tlsStorage = m_defaultThreadStorage;
} }
void OldChunkStorage::ReleaseThreadStorage() { void OldChunkStorage::ReleaseThreadStorage() {
if (m_threadStorage != m_defaultThreadStorage) { if (m_tlsStorage != m_defaultThreadStorage) {
delete m_threadStorage; delete m_tlsStorage;
} }
} }
@ -319,7 +319,7 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, CompoundTag* tag) {
// 4J Stu - As we now save on multiple threads, the static data has been // 4J Stu - As we now save on multiple threads, the static data has been
// moved to TLS // moved to TLS
ThreadStorage* tls = m_threadStorage; ThreadStorage* tls = m_tlsStorage;
PIXBeginNamedEvent(0, "Getting block data"); PIXBeginNamedEvent(0, "Getting block data");
// static byteArray blockData = byteArray(32768); // static byteArray blockData = byteArray(32768);

View file

@ -31,7 +31,7 @@ private:
ThreadStorage(); ThreadStorage();
~ThreadStorage(); ~ThreadStorage();
}; };
static thread_local ThreadStorage* m_threadStorage; static thread_local ThreadStorage* m_tlsStorage;
static ThreadStorage* m_defaultThreadStorage; static ThreadStorage* m_defaultThreadStorage;
public: public:

View file

@ -2,7 +2,7 @@
#include "../Headers/net.minecraft.world.item.h" #include "../Headers/net.minecraft.world.item.h"
#include "FireworksRecipe.h" #include "FireworksRecipe.h"
thread_local FireworksRecipe::ThreadStorage* FireworksRecipe::m_threadStorage = thread_local FireworksRecipe::ThreadStorage* FireworksRecipe::m_tlsStorage =
nullptr; nullptr;
FireworksRecipe::ThreadStorage* FireworksRecipe::m_defaultThreadStorage = FireworksRecipe::ThreadStorage* FireworksRecipe::m_defaultThreadStorage =
nullptr; nullptr;
@ -16,21 +16,21 @@ void FireworksRecipe::CreateNewThreadStorage() {
m_defaultThreadStorage = tls; m_defaultThreadStorage = tls;
} }
m_threadStorage = tls; m_tlsStorage = tls;
} }
void FireworksRecipe::UseDefaultThreadStorage() { void FireworksRecipe::UseDefaultThreadStorage() {
m_threadStorage = m_defaultThreadStorage; m_tlsStorage = m_defaultThreadStorage;
} }
void FireworksRecipe::ReleaseThreadStorage() { void FireworksRecipe::ReleaseThreadStorage() {
if (m_threadStorage != m_defaultThreadStorage) { if (m_tlsStorage != m_defaultThreadStorage) {
delete m_threadStorage; delete m_tlsStorage;
} }
} }
void FireworksRecipe::setResultItem(std::shared_ptr<ItemInstance> item) { void FireworksRecipe::setResultItem(std::shared_ptr<ItemInstance> item) {
m_threadStorage->resultItem = item; m_tlsStorage->resultItem = item;
} }
FireworksRecipe::FireworksRecipe() { FireworksRecipe::FireworksRecipe() {
@ -216,14 +216,14 @@ bool FireworksRecipe::matches(std::shared_ptr<CraftingContainer> craftSlots,
std::shared_ptr<ItemInstance> FireworksRecipe::assemble( std::shared_ptr<ItemInstance> FireworksRecipe::assemble(
std::shared_ptr<CraftingContainer> craftSlots) { std::shared_ptr<CraftingContainer> craftSlots) {
return m_threadStorage->resultItem->copy(); return m_tlsStorage->resultItem->copy();
// return resultItem->copy(); // return resultItem->copy();
} }
int FireworksRecipe::size() { return 10; } int FireworksRecipe::size() { return 10; }
const ItemInstance* FireworksRecipe::getResultItem() { const ItemInstance* FireworksRecipe::getResultItem() {
return m_threadStorage->resultItem.get(); return m_tlsStorage->resultItem.get();
// return resultItem.get(); // return resultItem.get();
} }

View file

@ -13,7 +13,7 @@ private:
std::shared_ptr<ItemInstance> resultItem; std::shared_ptr<ItemInstance> resultItem;
ThreadStorage(); ThreadStorage();
}; };
static thread_local ThreadStorage* m_threadStorage; static thread_local ThreadStorage* m_tlsStorage;
static ThreadStorage* m_defaultThreadStorage; static ThreadStorage* m_defaultThreadStorage;
void setResultItem(std::shared_ptr<ItemInstance> item); void setResultItem(std::shared_ptr<ItemInstance> item);