From 962214a90cb13ae67c2b11afd66f077bce82f6a7 Mon Sep 17 00:00:00 2001 From: Beq Date: Mon, 7 Oct 2024 20:37:09 +0100 Subject: [PATCH] FIRE-34600 - minimise the change by using default operators we're never realistically gonna mess with the memory order to optimise particles so just go with the easy option --- indra/newview/llviewerpartsim.cpp | 71 +++++++++---------------------- indra/newview/llviewerpartsim.h | 35 +++------------ 2 files changed, 25 insertions(+), 81 deletions(-) diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp index eccbb5722c..69b3226ec2 100644 --- a/indra/newview/llviewerpartsim.cpp +++ b/indra/newview/llviewerpartsim.cpp @@ -82,7 +82,7 @@ LLViewerPart::LLViewerPart() : mPartSourcep = NULL; mParent = NULL; mChild = NULL; - LLViewerPartSim::incParticleCount2( 1 ); // FIRE-34600 - bugsplat AVX2 particle count mismatch + ++LLViewerPartSim::sParticleCount2 ; } LLViewerPart::~LLViewerPart() @@ -107,7 +107,7 @@ LLViewerPart::~LLViewerPart() mPartSourcep = NULL; - LLViewerPartSim::decParticleCount2( 1 ); // FIRE-34600 - bugsplat AVX2 particle count mismatch + --LLViewerPartSim::sParticleCount2 ; } void LLViewerPart::init(LLPointer sourcep, LLViewerTexture *imagep, LLVPCallback cb) @@ -205,7 +205,7 @@ LLViewerPartGroup::~LLViewerPartGroup() } mParticles.clear(); - LLViewerPartSim::decParticleCount(count); // FIRE-34600 - bugsplat AVX2 particle count mismatch + LLViewerPartSim::sParticleCount -= count; // FIRE-34600 - bugsplat AVX2 particle count mismatch } void LLViewerPartGroup::cleanup() @@ -268,7 +268,7 @@ bool LLViewerPartGroup::addPart(LLViewerPart* part, F32 desired_size) mParticles.push_back(part); part->mSkipOffset=mSkippedTime; - LLViewerPartSim::incParticleCount(1); // FIRE-34600 - bugsplat AVX2 particle count mismatch + ++LLViewerPartSim::sParticleCount; // FIRE-34600 - bugsplat AVX2 particle count mismatch return true; } @@ -279,15 +279,11 @@ void LLViewerPartGroup::updateParticles(const F32 lastdt) LLVector3 gravity(0.f, 0.f, GRAVITY); - // FIRE-34600 off by one particle count triggering bugsplat (LL_ERR) - S32 end = (S32) mParticles.size(); LLViewerPartSim::checkParticleCount(static_cast(mParticles.size())); - std::atomic_signal_fence(std::memory_order_seq_cst); - // LLViewerCamera* camera = LLViewerCamera::getInstance(); LLViewerRegion *regionp = getRegion(); - //S32 end = (S32) mParticles.size();// FIRE-34600 off by one particle count triggering bugsplat (LL_ERR) + S32 end = (S32) mParticles.size(); for (S32 i = 0 ; i < (S32)mParticles.size();) { LLVector3 a(0.f, 0.f, 0.f); @@ -432,7 +428,7 @@ void LLViewerPartGroup::updateParticles(const F32 lastdt) { gPipeline.markRebuild(mVOPartGroupp->mDrawable, LLDrawable::REBUILD_ALL); } - LLViewerPartSim::decParticleCount(removed); // FIRE-34600 - bugsplat AVX2 particle count mismatch + LLViewerPartSim::sParticleCount -= removed; // FIRE-34600 - bugsplat AVX2 particle count mismatch } // Kill the viewer object if this particle group is empty @@ -478,22 +474,14 @@ void LLViewerPartGroup::removeParticlesByID(const U32 source_id) //static void LLViewerPartSim::checkParticleCount(U32 size) { - // FIRE-34600 - bugsplat AVX2 particle count mismatch - // if(LLViewerPartSim::sParticleCount2 != LLViewerPartSim::sParticleCount) - S32 count = LLViewerPartSim::getParticleCount(); - S32 count2 = LLViewerPartSim::getParticleCount2(); - if( count != count2 ) - // + if(LLViewerPartSim::sParticleCount2 != LLViewerPartSim::sParticleCount) { - LL_ERRS() << "sParticleCount: " << count << " ; sParticleCount2: " << count2 << LL_ENDL ; // FIRE-34600 - bugsplat AVX2 particle count mismatch + LL_ERRS() << "sParticleCount: " << LLViewerPartSim::sParticleCount << " ; sParticleCount2: " << LLViewerPartSim::sParticleCount2 << LL_ENDL ; } - // FIRE-34600 - bugsplat AVX2 particle count mismatch - // if(size > (U32)LLViewerPartSim::sParticleCount2) - if( size > static_cast(count2) ) - // + if(size > (U32)LLViewerPartSim::sParticleCount2) { - LL_ERRS() << "current particle size: " << count2 << " array size: " << size << LL_ENDL ; // FIRE-34600 - bugsplat AVX2 particle count mismatch + LL_ERRS() << "current particle size: " << LLViewerPartSim::sParticleCount2 << " array size: " << size << LL_ENDL ; // FIRE-34600 - bugsplat AVX2 particle count mismatch } } @@ -539,18 +527,14 @@ void LLViewerPartSim::destroyClass() //static bool LLViewerPartSim::shouldAddPart() { - // FIRE-34600 - bugsplat AVX2 particle count mismatch - // if (sParticleCount < MAX_PART_COUNT) - auto count = LLViewerPartSim::getParticleCount(); - if ( count >= MAX_PART_COUNT) - // + if (sParticleCount < MAX_PART_COUNT) { return false; } - if ( count > PART_THROTTLE_THRESHOLD*sMaxParticleCount) // FIRE-34600 - bugsplat AVX2 particle count mismatch + if ( sParticleCount > PART_THROTTLE_THRESHOLD*sMaxParticleCount) { - F32 frac = (F32)count/(F32)sMaxParticleCount; // FIRE-34600 - bugsplat AVX2 particle count mismatch + F32 frac = (F32)sParticleCount/(F32)sMaxParticleCount; frac -= PART_THROTTLE_THRESHOLD; frac *= PART_THROTTLE_RESCALE; if (ll_frand() < frac) @@ -572,7 +556,7 @@ bool LLViewerPartSim::shouldAddPart() void LLViewerPartSim::addPart(LLViewerPart* part) { - if (LLViewerPartSim::getParticleCount() < MAX_PART_COUNT) + if (LLViewerPartSim::sParticleCount < MAX_PART_COUNT) { put(part); } @@ -806,19 +790,14 @@ void LLViewerPartSim::updateSimulation() } if (LLDrawable::getCurrentFrame()%16==0) { - // FIRE-34600 - bugsplat AVX2 particle count mismatch - // if (sParticleCount > sMaxParticleCount * 0.875f - // && sParticleAdaptiveRate < 2.0f) - auto count = LLViewerPartSim::getParticleCount(); - if ( count > sMaxParticleCount * 0.875f - && sParticleAdaptiveRate < 2.0f) - // + if (sParticleCount > sMaxParticleCount * 0.875f + && sParticleAdaptiveRate < 2.0f) { sParticleAdaptiveRate *= PART_ADAPT_RATE_MULT; } else { - if ( count < sMaxParticleCount * 0.5f // FIRE-34600 - bugsplat AVX2 particle count mismatch + if ( sParticleCount < sMaxParticleCount * 0.5f && sParticleAdaptiveRate > 0.03125f) { sParticleAdaptiveRate *= PART_ADAPT_RATE_MULT_RECIP; @@ -835,25 +814,15 @@ void LLViewerPartSim::updatePartBurstRate() { if (!(LLDrawable::getCurrentFrame() & 0xf)) { - // FIRE-34600 - bugsplat AVX2 particle count mismatch - // if (sParticleCount >= MAX_PART_COUNT) //set rate to zero - auto count = LLViewerPartSim::getParticleCount(); - if (count >= MAX_PART_COUNT) //set rate to zero - // + if (sParticleCount >= MAX_PART_COUNT) //set rate to zero { sParticleBurstRate = 0.0f ; } - // FIRE-34600 - bugsplat AVX2 particle count mismatch - // else if(sParticleCount > 0) - else if (count > 0) - // + else if(sParticleCount > 0) { if(sParticleBurstRate > 0.0000001f) { - // FIRE-34600 - bugsplat AVX2 particle count mismatch - // F32 total_particles = sParticleCount / sParticleBurstRate ; //estimated - F32 total_particles = count / sParticleBurstRate ; //estimated - // + F32 total_particles = sParticleCount / sParticleBurstRate ; //estimated F32 new_rate = llclamp(0.9f * sMaxParticleCount / total_particles, 0.0f, 1.0f) ; F32 delta_rate_threshold = llmin(0.1f * llmax(new_rate, sParticleBurstRate), 0.1f) ; F32 delta_rate = llclamp(new_rate - sParticleBurstRate, -1.0f * delta_rate_threshold, delta_rate_threshold) ; diff --git a/indra/newview/llviewerpartsim.h b/indra/newview/llviewerpartsim.h index 3e92a1988d..6c7eaf4e1f 100644 --- a/indra/newview/llviewerpartsim.h +++ b/indra/newview/llviewerpartsim.h @@ -155,25 +155,14 @@ public: static bool shouldAddPart(); // Just decides whether this particle should be added or not (for particle count capping) F32 maxRate() // Return maximum particle generation rate { - // FIRE-34600 - bugsplat AVX2 particle count mismatch - // if (sParticleCount >= MAX_PART_COUNT) - // { - // return 1.f; - // } - // if (sParticleCount > PART_THROTTLE_THRESHOLD*sMaxParticleCount) - // { - // return (((F32)sParticleCount/(F32)sMaxParticleCount)-PART_THROTTLE_THRESHOLD)*PART_THROTTLE_RESCALE; - // } - const auto count = getParticleCount(); - if ( count >= MAX_PART_COUNT) + if (sParticleCount >= MAX_PART_COUNT) { return 1.f; } - if ( count > PART_THROTTLE_THRESHOLD*sMaxParticleCount) + if (sParticleCount > PART_THROTTLE_THRESHOLD*sMaxParticleCount) { - return (((F32)count/(F32)sMaxParticleCount)-PART_THROTTLE_THRESHOLD)*PART_THROTTLE_RESCALE; + return (((F32)sParticleCount/(F32)sMaxParticleCount)-PART_THROTTLE_THRESHOLD)*PART_THROTTLE_RESCALE; } - // return 0.f; } F32 getRefRate() { return sParticleAdaptiveRate; } @@ -188,29 +177,15 @@ public: friend class LLViewerPartGroup; - // FIRE-34600 - bugsplat AVX2 particle count mismatch - // bool aboveParticleLimit() const { return sParticleCount > sMaxParticleCount; } - bool aboveParticleLimit() const { return getParticleCount() > sMaxParticleCount; } - // + bool aboveParticleLimit() const { return sParticleCount > sMaxParticleCount; } static void setMaxPartCount(const S32 max_parts) { sMaxParticleCount = max_parts; } static S32 getMaxPartCount() { return sMaxParticleCount; } // FIRE-34600 - bugsplat AVX2 particle count mismatch + // Deprecate these and use native operators for consistency // static void incPartCount(const S32 count) { sParticleCount += count; } // static void decPartCount(const S32 count) { sParticleCount -= count; } - static void incParticleCount(const S32 count, std::memory_order order = std::memory_order_seq_cst ) - { sParticleCount.fetch_add( count , std::memory_order_seq_cst ); } - static void decParticleCount(const S32 count, std::memory_order order = std::memory_order_seq_cst ) - { sParticleCount.fetch_sub( count , std::memory_order_seq_cst ); } - static void incParticleCount2(const S32 count, std::memory_order order = std::memory_order_seq_cst ) - { sParticleCount2.fetch_add( count , std::memory_order_seq_cst ); } - static void decParticleCount2(const S32 count, std::memory_order order = std::memory_order_seq_cst ) - { sParticleCount2.fetch_sub( count , std::memory_order_seq_cst ); } - static inline S32 getParticleCount(std::memory_order order = std::memory_order_seq_cst) { return sParticleCount.load(order); } - - static inline S32 getParticleCount2(std::memory_order order = std::memory_order_seq_cst) { return sParticleCount2.load(order); } // - U32 mID; protected: