helping branch prediction
This commit is contained in:
@@ -71,7 +71,7 @@ struct FEffectUpdator
|
||||
}
|
||||
void operator () (CEffectElementBaseInstance * pInstance)
|
||||
{
|
||||
if (pInstance->Update(fElapsedTime))
|
||||
if (pInstance->Update(fElapsedTime)) [[likely]]
|
||||
isAlive = TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -67,16 +67,13 @@ void CEffectManager::Update()
|
||||
|
||||
pEffectInstance->Update(/*fElapsedTime*/);
|
||||
|
||||
if (!pEffectInstance->isAlive())
|
||||
{
|
||||
itor = m_kEftInstMap.erase(itor);
|
||||
|
||||
CEffectInstance::Delete(pEffectInstance);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pEffectInstance->isAlive()) [[likely]] {
|
||||
++itor;
|
||||
continue;
|
||||
}
|
||||
|
||||
itor = m_kEftInstMap.erase(itor);
|
||||
CEffectInstance::Delete(pEffectInstance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -300,15 +300,13 @@ bool CParticleSystemInstance::OnUpdate(float fElapsedTime)
|
||||
{
|
||||
CParticleInstance * pInstance = *itor;
|
||||
|
||||
if (!pInstance->Update(fElapsedTime,fAngularVelocity))
|
||||
{
|
||||
if (!pInstance->Update(fElapsedTime,fAngularVelocity)) [[unlikely]] {
|
||||
pInstance->DeleteThis();
|
||||
|
||||
itor = m_ParticleInstanceListVector[dwFrameIndex].erase(itor);
|
||||
m_dwCurrentEmissionCount--;
|
||||
}
|
||||
else
|
||||
{
|
||||
else [[likely]] {
|
||||
if (pInstance->m_byFrameIndex != dwFrameIndex)
|
||||
{
|
||||
m_ParticleInstanceListVector[dwFrameCount+pInstance->m_byFrameIndex].push_back(*itor);
|
||||
|
||||
@@ -144,10 +144,10 @@ void DeformPWNT3432toGrannyPNGBT33332(granny_int32x Count, void const* SourceIni
|
||||
granny_int32x const* TransformTable, granny_matrix_4x4 const* Transforms,
|
||||
granny_int32x CopySize, granny_int32x SourceStride, granny_int32x DestStride)
|
||||
{
|
||||
if (TransformTable) {
|
||||
if (TransformTable) [[likely]] {
|
||||
DeformPWNT3432toGrannyPNGBT33332I(Count, SourceInit, DestInit, TransformTable, Transforms, CopySize, SourceStride, DestStride);
|
||||
}
|
||||
else {
|
||||
else [[unlikely]] {
|
||||
DeformPWNT3432toGrannyPNGBT33332D(Count, SourceInit, DestInit, Transforms, CopySize, SourceStride, DestStride);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,8 +591,7 @@ void CGraphicTextInstance::Render(RECT * pClipRect)
|
||||
fFontHeight=float(pCurCharInfo->height);
|
||||
fFontAdvance=float(pCurCharInfo->advance);
|
||||
|
||||
if ((fCurX+fFontWidth)-m_v3Position.x > m_fLimitWidth)
|
||||
{
|
||||
if ((fCurX+fFontWidth)-m_v3Position.x > m_fLimitWidth) [[unlikely]] {
|
||||
if (m_isMultiLine)
|
||||
{
|
||||
fCurX=fStanX;
|
||||
@@ -693,8 +692,7 @@ void CGraphicTextInstance::Render(RECT * pClipRect)
|
||||
fFontMaxHeight=(std::max)(fFontHeight, (float)pCurCharInfo->height);
|
||||
fFontAdvance=float(pCurCharInfo->advance);
|
||||
|
||||
if ((fCurX+fFontWidth)-m_v3Position.x > m_fLimitWidth)
|
||||
{
|
||||
if ((fCurX + fFontWidth) - m_v3Position.x > m_fLimitWidth) [[unlikely]] {
|
||||
if (m_isMultiLine)
|
||||
{
|
||||
fCurX=fStanX;
|
||||
|
||||
@@ -36,7 +36,6 @@ class IAbstractApplication : public TAbstractSingleton<IAbstractApplication>
|
||||
virtual float GetGlobalTime() = 0;
|
||||
virtual float GetGlobalElapsedTime() = 0;
|
||||
|
||||
virtual void SkipRenderBuffering(DWORD dwSleepMSec) = 0;
|
||||
virtual void SetServerTime(time_t tTime) = 0;
|
||||
virtual void SetCenterPosition(float fx, float fy, float fz) = 0;
|
||||
|
||||
|
||||
@@ -718,8 +718,6 @@ bool CInstanceBase::__FindRaceType(DWORD dwRace, BYTE* pbType)
|
||||
|
||||
bool CInstanceBase::Create(const SCreateData& c_rkCreateData)
|
||||
{
|
||||
IAbstractApplication::GetSingleton().SkipRenderBuffering(300);
|
||||
|
||||
SetInstanceType(c_rkCreateData.m_bType);
|
||||
|
||||
|
||||
|
||||
@@ -256,11 +256,6 @@ void CPythonApplication::UpdateGame()
|
||||
SetCenterPosition(kPPosMainActor.x, kPPosMainActor.y, kPPosMainActor.z);
|
||||
}
|
||||
|
||||
void CPythonApplication::SkipRenderBuffering(DWORD dwSleepMSec)
|
||||
{
|
||||
m_dwBufSleepSkipTime=ELTimer_GetMSec()+dwSleepMSec;
|
||||
}
|
||||
|
||||
bool CPythonApplication::Process()
|
||||
{
|
||||
ELTimer_SetFrameMSec();
|
||||
@@ -275,8 +270,7 @@ bool CPythonApplication::Process()
|
||||
static UINT s_uiLoad = 0;
|
||||
static DWORD s_dwCheckTime = ELTimer_GetMSec();
|
||||
|
||||
if (ELTimer_GetMSec() - s_dwCheckTime > 1000)
|
||||
{
|
||||
if (ELTimer_GetMSec() - s_dwCheckTime > 1000) [[unlikely]] {
|
||||
m_dwUpdateFPS = s_dwUpdateFrameCount;
|
||||
m_dwRenderFPS = s_dwRenderFrameCount;
|
||||
m_dwLoad = s_uiLoad;
|
||||
@@ -329,8 +323,7 @@ bool CPythonApplication::Process()
|
||||
#endif
|
||||
// Mouse
|
||||
POINT Point;
|
||||
if (GetCursorPos(&Point))
|
||||
{
|
||||
if (GetCursorPos(&Point)) [[likely]] {
|
||||
ScreenToClient(m_hWnd, &Point);
|
||||
OnMouseMove(Point.x, Point.y);
|
||||
}
|
||||
@@ -531,14 +524,11 @@ bool CPythonApplication::Process()
|
||||
|
||||
bool canRender = true;
|
||||
|
||||
if (m_isMinimizedWnd)
|
||||
{
|
||||
if (m_isMinimizedWnd) [[unlikely]] {
|
||||
canRender = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_pyGraphic.IsLostDevice())
|
||||
{
|
||||
else [[likely]] {
|
||||
if (m_pyGraphic.IsLostDevice()) [[unlikely]] {
|
||||
CPythonBackground& rkBG = CPythonBackground::Instance();
|
||||
rkBG.ReleaseCharacterShadowTexture();
|
||||
|
||||
@@ -549,22 +539,11 @@ bool CPythonApplication::Process()
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsActive())
|
||||
{
|
||||
SkipRenderBuffering(3000);
|
||||
}
|
||||
|
||||
// ¸®½ºÅä¾î 󸮶§¸¦ °í·ÁÇØ ÀÏÁ¤ ½Ã°£µ¿¾ÈÀº ¹öÆÛ¸µÀ» ÇÏÁö ¾Ê´Â´Ù
|
||||
if (!canRender)
|
||||
{
|
||||
SkipRenderBuffering(3000);
|
||||
}
|
||||
else
|
||||
if (canRender) [[likely]]
|
||||
{
|
||||
// RestoreLostDevice
|
||||
CCullingManager::Instance().Update();
|
||||
if (m_pyGraphic.Begin())
|
||||
{
|
||||
if (m_pyGraphic.Begin()) [[likely]] {
|
||||
|
||||
m_pyGraphic.ClearDepthBuffer();
|
||||
|
||||
@@ -597,8 +576,7 @@ bool CPythonApplication::Process()
|
||||
s_dwRenderRangeTime += m_dwCurRenderTime;
|
||||
++s_dwRenderRangeFrame;
|
||||
|
||||
if (dwRenderEndTime-s_dwRenderCheckTime>1000)
|
||||
{
|
||||
if (dwRenderEndTime-s_dwRenderCheckTime>1000) [[unlikely]] {
|
||||
m_fAveRenderTime=float(double(s_dwRenderRangeTime)/double(s_dwRenderRangeFrame));
|
||||
|
||||
s_dwRenderCheckTime=ELTimer_GetMSec();
|
||||
@@ -612,52 +590,6 @@ bool CPythonApplication::Process()
|
||||
|
||||
if (dwCurFaceCount > 5000)
|
||||
{
|
||||
// ÇÁ·¹ÀÓ ¿ÏÃæ ó¸®
|
||||
if (dwRenderEndTime > m_dwBufSleepSkipTime)
|
||||
{
|
||||
static float s_fBufRenderTime = 0.0f;
|
||||
|
||||
float fCurRenderTime = m_dwCurRenderTime;
|
||||
|
||||
if (fCurRenderTime > s_fBufRenderTime)
|
||||
{
|
||||
float fRatio = fMAX(0.5f, (fCurRenderTime - s_fBufRenderTime) / 30.0f);
|
||||
s_fBufRenderTime = (s_fBufRenderTime * (100.0f - fRatio) + (fCurRenderTime + 5) * fRatio) / 100.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float fRatio = 0.5f;
|
||||
s_fBufRenderTime = (s_fBufRenderTime * (100.0f - fRatio) + fCurRenderTime * fRatio) / 100.0f;
|
||||
}
|
||||
|
||||
// ÇѰèÄ¡¸¦ Á¤ÇÑ´Ù
|
||||
if (s_fBufRenderTime > 100.0f)
|
||||
s_fBufRenderTime = 100.0f;
|
||||
|
||||
DWORD dwBufRenderTime = s_fBufRenderTime;
|
||||
|
||||
if (m_isWindowed)
|
||||
{
|
||||
if (dwBufRenderTime>58)
|
||||
dwBufRenderTime=64;
|
||||
else if (dwBufRenderTime>42)
|
||||
dwBufRenderTime=48;
|
||||
else if (dwBufRenderTime>26)
|
||||
dwBufRenderTime=32;
|
||||
else if (dwBufRenderTime>10)
|
||||
dwBufRenderTime=16;
|
||||
else
|
||||
dwBufRenderTime=8;
|
||||
}
|
||||
|
||||
// ÀÏÁ¤ ÇÁ·¹ÀÓ ¼Óµµ¿¡ ¸ÂÃß¾îÁÖ´ÂÂÊ¿¡ ´«¿¡ ÆíÇÏ´Ù
|
||||
// ¾Æ·¡¿¡¼ Çѹø Çϸé ç´?
|
||||
//if (m_dwCurRenderTime<dwBufRenderTime)
|
||||
// Sleep(dwBufRenderTime-m_dwCurRenderTime);
|
||||
|
||||
m_fAveRenderTime=s_fBufRenderTime;
|
||||
}
|
||||
|
||||
m_dwFaceAccCount += dwCurFaceCount;
|
||||
m_dwFaceAccTime += m_dwCurRenderTime;
|
||||
|
||||
|
||||
@@ -158,7 +158,6 @@ class CPythonApplication : public CMSApplication, public CInputKeyboard, public
|
||||
|
||||
void SetMinFog(float fMinFog);
|
||||
void SetFrameSkip(bool isEnable);
|
||||
void SkipRenderBuffering(DWORD dwSleepMSec);
|
||||
|
||||
bool Create(PyObject* poSelf, const char* c_szName, int width, int height, int Windowed);
|
||||
bool CreateDevice(int width, int height, int Windowed, int bit = 32, int frequency = 0);
|
||||
@@ -437,7 +436,6 @@ class CPythonApplication : public CMSApplication, public CInputKeyboard, public
|
||||
BOOL m_isWindowFullScreenEnable;
|
||||
|
||||
DWORD m_dwStickyKeysFlag;
|
||||
DWORD m_dwBufSleepSkipTime;
|
||||
int m_iForceSightRange;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -84,12 +84,6 @@ void CPythonApplication::__UpdateCamera()
|
||||
if (0.0f != m_kCmrPos.m_fUpDir)
|
||||
pMainCamera->MoveVertical(m_kCmrPos.m_fUpDir);
|
||||
|
||||
//////////////////////
|
||||
|
||||
if (pMainCamera->IsDraging())
|
||||
SkipRenderBuffering(3000);
|
||||
|
||||
//////////////////////
|
||||
// Sound Setting
|
||||
const D3DXVECTOR3 & c_rv3CameraDirection = pMainCamera->GetView();
|
||||
const D3DXVECTOR3 & c_rv3CameraUp = pMainCamera->GetUp();
|
||||
|
||||
@@ -172,8 +172,7 @@ void CPythonCharacterManager::Update()
|
||||
|
||||
if (pkInstMain)
|
||||
{
|
||||
if (pkInstEach->IsForceVisible())
|
||||
{
|
||||
if (pkInstEach->IsForceVisible()) [[unlikely]] {
|
||||
dwForceVisibleInstCount++;
|
||||
continue;
|
||||
}
|
||||
@@ -181,8 +180,7 @@ void CPythonCharacterManager::Update()
|
||||
// Optimized: Use squared distance to avoid sqrt
|
||||
float fDistanceSquared = pkInstEach->NEW_GetDistanceFromDestInstanceSquared(*pkInstMain);
|
||||
const float fViewBoundSquared = (CHAR_STAGE_VIEW_BOUND + 10) * (CHAR_STAGE_VIEW_BOUND + 10);
|
||||
if (fDistanceSquared > fViewBoundSquared)
|
||||
{
|
||||
if (fDistanceSquared > fViewBoundSquared) [[unlikely]] {
|
||||
__DeleteBlendOutInstance(pkInstEach);
|
||||
m_kAliveInstMap.erase(c);
|
||||
dwDeadInstCount++;
|
||||
@@ -342,12 +340,10 @@ void CPythonCharacterManager::UpdateDeleting()
|
||||
{
|
||||
CInstanceBase * pInstance = *itor;
|
||||
|
||||
if (pInstance->UpdateDeleting())
|
||||
{
|
||||
if (pInstance->UpdateDeleting()) [[likely]] {
|
||||
++itor;
|
||||
}
|
||||
else
|
||||
{
|
||||
else [[unlikely]] {
|
||||
CInstanceBase::Delete(pInstance);
|
||||
itor = m_kDeadInstList.erase(itor);
|
||||
}
|
||||
@@ -473,7 +469,7 @@ void CPythonCharacterManager::__RenderSortedAliveActorList()
|
||||
s_kVct_pkInstAliveSort.clear();
|
||||
|
||||
CCamera* pCamera = CCameraManager::instance().GetCurrentCamera();
|
||||
if (!pCamera)
|
||||
if (!pCamera) [[unlikely]]
|
||||
return;
|
||||
|
||||
TCharacterInstanceMap& rkMap_pkInstAlive=m_kAliveInstMap;
|
||||
@@ -495,7 +491,7 @@ void CPythonCharacterManager::__RenderSortedDeadActorList()
|
||||
s_kVct_pkInstDeadSort.clear();
|
||||
|
||||
CCamera* pCamera = CCameraManager::instance().GetCurrentCamera();
|
||||
if (!pCamera)
|
||||
if (!pCamera) [[unlikely]]
|
||||
return;
|
||||
|
||||
TCharacterInstanceList& rkLst_pkInstDead=m_kDeadInstList;
|
||||
@@ -575,13 +571,13 @@ void CPythonCharacterManager::RenderCollision()
|
||||
CInstanceBase * CPythonCharacterManager::CreateInstance(const CInstanceBase::SCreateData& c_rkCreateData)
|
||||
{
|
||||
CInstanceBase * pCharacterInstance = RegisterInstance(c_rkCreateData.m_dwVID);
|
||||
if (!pCharacterInstance)
|
||||
if (!pCharacterInstance) [[unlikely]]
|
||||
{
|
||||
TraceError("CPythonCharacterManager::CreateInstance: VID[%d] - ALREADY EXIST\n", c_rkCreateData);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!pCharacterInstance->Create(c_rkCreateData))
|
||||
if (!pCharacterInstance->Create(c_rkCreateData)) [[unlikely]]
|
||||
{
|
||||
TraceError("CPythonCharacterManager::CreateInstance VID[%d] Race[%d]", c_rkCreateData.m_dwVID, c_rkCreateData.m_dwRace);
|
||||
DeleteInstance(c_rkCreateData.m_dwVID);
|
||||
|
||||
Reference in New Issue
Block a user