1
0
forked from 0ad/0ad

add instrumentation to see what's slow when starting a session

renderer: also move list of alpha maps here from InitResources

This was SVN commit r2007.
This commit is contained in:
janwas 2005-03-18 22:02:20 +00:00
parent af0800fbdd
commit 308535d58d
8 changed files with 55 additions and 23 deletions

View File

@ -24,6 +24,7 @@
#include "sdl.h"
#include "input.h"
#include "lib.h"
#include "timer.h"
extern int g_xres, g_yres;
extern bool g_active;
@ -165,27 +166,12 @@ void CGameView::RenderNoCull()
void CGameView::InitResources()
{
TIMER(CGameView__InitResources);
g_TexMan.LoadTerrainTextures();
g_ObjMan.LoadObjects();
const char* fns[CRenderer::NumAlphaMaps] = {
"art/textures/terrain/alphamaps/special/blendcircle.png",
"art/textures/terrain/alphamaps/special/blendlshape.png",
"art/textures/terrain/alphamaps/special/blendedge.png",
"art/textures/terrain/alphamaps/special/blendedgecorner.png",
"art/textures/terrain/alphamaps/special/blendedgetwocorners.png",
"art/textures/terrain/alphamaps/special/blendfourcorners.png",
"art/textures/terrain/alphamaps/special/blendtwooppositecorners.png",
"art/textures/terrain/alphamaps/special/blendlshapecorner.png",
"art/textures/terrain/alphamaps/special/blendtwocorners.png",
"art/textures/terrain/alphamaps/special/blendcorner.png",
"art/textures/terrain/alphamaps/special/blendtwoedges.png",
"art/textures/terrain/alphamaps/special/blendthreecorners.png",
"art/textures/terrain/alphamaps/special/blendushape.png",
"art/textures/terrain/alphamaps/special/blendbad.png"
};
g_Renderer.LoadAlphaMaps(fns);
g_Renderer.LoadAlphaMaps();
}
void CGameView::UnloadResources()

View File

@ -14,6 +14,8 @@
#include "Terrain.h"
#include "TextureManager.h"
#include "timer.h"
// CMapReader constructor: nothing to do at the minute
CMapReader::CMapReader()
{
@ -22,8 +24,13 @@ CMapReader::CMapReader()
// LoadMap: try to load the map from given file; reinitialise the scene to new data if successful
void CMapReader::LoadMap(const char* filename, CTerrain *pTerrain, CUnitManager *pUnitMan, CLightEnv *pLightEnv)
{
TIMER(__CMapReader__LoadMap);
CFileUnpacker unpacker;
unpacker.Read(filename,"PSMP");
{
TIMER(____CMapReader__LoadMap__read);
unpacker.Read(filename,"PSMP");
}
// check version
if (unpacker.GetVersion()<FILE_READ_VERSION) {
@ -47,6 +54,8 @@ void CMapReader::LoadMap(const char* filename, CTerrain *pTerrain, CUnitManager
// UnpackMap: unpack the given data from the raw data stream into local variables
void CMapReader::UnpackMap(CFileUnpacker& unpacker)
{
TIMER(____CMapReader__UnpackMap);
// now unpack everything into local data
UnpackTerrain(unpacker);
UnpackObjects(unpacker);
@ -129,6 +138,8 @@ void CMapReader::UnpackTerrain(CFileUnpacker& unpacker)
// ApplyData: take all the input data, and rebuild the scene from it
void CMapReader::ApplyData(CFileUnpacker& unpacker, CTerrain *pTerrain, CUnitManager *pUnitMan, CLightEnv *pLightEnv)
{
TIMER(____CMapReader__ApplyData);
// initialise the terrain
pTerrain->Initialize(m_MapSize,&m_Heightmap[0]);
@ -198,6 +209,8 @@ void CMapReader::ApplyData(CFileUnpacker& unpacker, CTerrain *pTerrain, CUnitMan
void CMapReader::ReadXML(const char* filename)
{
TIMER(____CMapReader__ReadXML);
#ifdef SCED
// HACK: ScEd uses absolute filenames, not VFS paths. I can't be bothered
// to make Xeromyces work with non-VFS, so just cheat:

View File

@ -4,6 +4,7 @@
#include <algorithm>
#include "CLogger.h"
#include "lib/res/res.h"
#include "timer.h"
#define LOG_CATEGORY "graphics"
@ -80,6 +81,8 @@ void CObjectManager::DeleteObject(CObjectEntry* entry)
void CObjectManager::LoadObjects()
{
TIMER(__CObjectManager__LoadObjects);
// find all the object types by directory name
BuildObjectTypes(0);

View File

@ -7,6 +7,7 @@
#include "ogl.h"
#include "res/ogl_tex.h"
#include "CLogger.h"
#include "timer.h"
#define LOG_CATEGORY "graphics"
@ -136,6 +137,8 @@ void CTextureManager::BuildTerrainTypes()
void CTextureManager::LoadTerrainTextures()
{
TIMER(__CTextureManager__LoadTerrainTextures);
// find all the terrain types by directory name
BuildTerrainTypes();

View File

@ -5,6 +5,7 @@
#ifndef NO_GUI
#include "gui/CGUI.h"
#endif
#include "timer.h"
CGame *g_Game=NULL;
@ -26,7 +27,7 @@ CGame::CGame():
m_pLocalPlayer(NULL),
m_GameStarted(false)
{
debug_out("CGame::CGame(): Game object CREATED\n");
debug_out("CGame::CGame(): Game object CREATED; initializing..\n");
}
#ifdef _MSC_VER
@ -62,6 +63,7 @@ PSRETURN CGame::StartGame(CGameAttributes *pAttribs)
m_World.Initialize(pAttribs);
m_Simulation.Initialize(pAttribs);
debug_out("GAME STARTED, ALL INIT COMPLETE\n");
m_GameStarted=true;
#ifndef NO_GUI
@ -88,7 +90,7 @@ CPlayer *CGame::GetPlayer(uint idx)
if (idx > m_NumPlayers)
{
// debug_warn("Invalid player ID");
LOG(ERROR, "", "Invalid player ID %d (outside 0..%d)", idx, m_NumPlayers);
// LOG(ERROR, "", "Invalid player ID %d (outside 0..%d)", idx, m_NumPlayers);
return m_Players[0];
}
// Be a bit more paranoid - maybe m_Players hasn't been set large enough

View File

@ -11,6 +11,7 @@
#include "LightEnv.h"
#include "BaseEntityCollection.h"
#include "EntityManager.h"
#include "timer.h"
#define LOG_CATEGORY "world"
@ -18,6 +19,8 @@ CLightEnv g_LightEnv;
void CWorld::Initialize(CGameAttributes *pAttribs)
{
TIMER(CWorld__Initialize);
// TODO: Find a better way of handling these global things
ONCE(g_EntityTemplateCollection.loadTemplates());

View File

@ -35,6 +35,7 @@
#include "ogl.h"
#include "res/mem.h"
#include "res/ogl_tex.h"
#include "timer.h"
#define LOG_CATEGORY "graphics"
@ -1152,10 +1153,31 @@ inline void CopyTriple(unsigned char* dst,const unsigned char* src)
// LoadAlphaMaps: load the 14 default alpha maps, pack them into one composite texture and
// calculate the coordinate of each alphamap within this packed texture .. need to add
// validation that all maps are the same size
bool CRenderer::LoadAlphaMaps(const char* fnames[])
bool CRenderer::LoadAlphaMaps()
{
TIMER(__CRenderer__LoadAlphaMaps);
Handle textures[NumAlphaMaps];
const char* fnames[CRenderer::NumAlphaMaps] = {
"art/textures/terrain/alphamaps/special/blendcircle.png",
"art/textures/terrain/alphamaps/special/blendlshape.png",
"art/textures/terrain/alphamaps/special/blendedge.png",
"art/textures/terrain/alphamaps/special/blendedgecorner.png",
"art/textures/terrain/alphamaps/special/blendedgetwocorners.png",
"art/textures/terrain/alphamaps/special/blendfourcorners.png",
"art/textures/terrain/alphamaps/special/blendtwooppositecorners.png",
"art/textures/terrain/alphamaps/special/blendlshapecorner.png",
"art/textures/terrain/alphamaps/special/blendtwocorners.png",
"art/textures/terrain/alphamaps/special/blendcorner.png",
"art/textures/terrain/alphamaps/special/blendtwoedges.png",
"art/textures/terrain/alphamaps/special/blendthreecorners.png",
"art/textures/terrain/alphamaps/special/blendushape.png",
"art/textures/terrain/alphamaps/special/blendbad.png"
};
int i;
for (i=0;i<NumAlphaMaps;i++) {

View File

@ -207,7 +207,7 @@ public:
bool IsTextureTransparent(CTexture* texture);
// load the default set of alphamaps; return false if any alphamap fails to load, true otherwise
bool LoadAlphaMaps(const char* fnames[]);
bool LoadAlphaMaps();
void UnloadAlphaMaps();