Optimize mobile rendering and extend live-client launch options
This commit is contained in:
@@ -354,6 +354,45 @@ bool CParticleSystemInstance::OnUpdate(float fElapsedTime)
|
||||
|
||||
namespace NParticleRenderer
|
||||
{
|
||||
static std::vector<TPTVertex> s_batchedVertices;
|
||||
static std::vector<WORD> s_batchedIndices;
|
||||
|
||||
void FlushBatch()
|
||||
{
|
||||
if (s_batchedVertices.empty())
|
||||
return;
|
||||
|
||||
const UINT primCount = static_cast<UINT>(s_batchedIndices.size() / 3);
|
||||
STATEMANAGER.DrawIndexedPrimitiveUP(
|
||||
D3DPT_TRIANGLELIST,
|
||||
0,
|
||||
static_cast<UINT>(s_batchedVertices.size()),
|
||||
primCount,
|
||||
s_batchedIndices.data(),
|
||||
D3DFMT_INDEX16,
|
||||
s_batchedVertices.data(),
|
||||
sizeof(TPTVertex));
|
||||
|
||||
s_batchedVertices.clear();
|
||||
s_batchedIndices.clear();
|
||||
}
|
||||
|
||||
inline void AppendQuad(const TPTVertex* quadMesh)
|
||||
{
|
||||
if (s_batchedVertices.size() + 4 > 65530)
|
||||
FlushBatch();
|
||||
|
||||
const WORD baseIndex = static_cast<WORD>(s_batchedVertices.size());
|
||||
s_batchedVertices.insert(s_batchedVertices.end(), quadMesh, quadMesh + 4);
|
||||
|
||||
s_batchedIndices.push_back(baseIndex + 0);
|
||||
s_batchedIndices.push_back(baseIndex + 1);
|
||||
s_batchedIndices.push_back(baseIndex + 2);
|
||||
s_batchedIndices.push_back(baseIndex + 2);
|
||||
s_batchedIndices.push_back(baseIndex + 1);
|
||||
s_batchedIndices.push_back(baseIndex + 3);
|
||||
}
|
||||
|
||||
struct TwoSideRenderer
|
||||
{
|
||||
const D3DXMATRIX * pmat;
|
||||
@@ -365,10 +404,10 @@ namespace NParticleRenderer
|
||||
inline void operator () (CParticleInstance * pInstance)
|
||||
{
|
||||
pInstance->Transform(pmat,D3DXToRadian(-30.0f));
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
AppendQuad(pInstance->GetParticleMeshPointer());
|
||||
|
||||
pInstance->Transform(pmat,D3DXToRadian(+30.0f));
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
AppendQuad(pInstance->GetParticleMeshPointer());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -383,11 +422,11 @@ namespace NParticleRenderer
|
||||
inline void operator () (CParticleInstance * pInstance)
|
||||
{
|
||||
pInstance->Transform(pmat);
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
AppendQuad(pInstance->GetParticleMeshPointer());
|
||||
pInstance->Transform(pmat,D3DXToRadian(-60.0f));
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
AppendQuad(pInstance->GetParticleMeshPointer());
|
||||
pInstance->Transform(pmat,D3DXToRadian(+60.0f));
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
AppendQuad(pInstance->GetParticleMeshPointer());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -396,7 +435,7 @@ namespace NParticleRenderer
|
||||
inline void operator () (CParticleInstance * pInstance)
|
||||
{
|
||||
pInstance->Transform();
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
AppendQuad(pInstance->GetParticleMeshPointer());
|
||||
}
|
||||
};
|
||||
struct AttachRenderer
|
||||
@@ -410,7 +449,7 @@ namespace NParticleRenderer
|
||||
inline void operator () (CParticleInstance * pInstance)
|
||||
{
|
||||
pInstance->Transform(pmat);
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
AppendQuad(pInstance->GetParticleMeshPointer());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -460,6 +499,7 @@ void CParticleSystemInstance::OnRender()
|
||||
ForEachParticleRendering(obj);
|
||||
}
|
||||
}
|
||||
NParticleRenderer::FlushBatch();
|
||||
}
|
||||
|
||||
void CParticleSystemInstance::OnSetDataPointer(CEffectElementBase * pElement)
|
||||
|
||||
Reference in New Issue
Block a user