Delete profiler

This commit is contained in:
sfan5 2023-01-02 21:05:07 +01:00
parent b5a6dc0a15
commit a9230e5f49
10 changed files with 0 additions and 769 deletions

View File

@ -91,9 +91,6 @@ enum EGUI_ELEMENT_TYPE
//! The root of the GUI
EGUIET_ROOT,
//! IGUIProfiler
EGUIET_PROFILER,
//! Not an element, amount of elements in there
EGUIET_COUNT,

View File

@ -1,480 +0,0 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// Written by Michael Zeilfelder
#ifndef __I_PROFILER_H_INCLUDED__
#define __I_PROFILER_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "irrString.h"
#include "irrArray.h"
#include "ITimer.h"
#include <limits.h> // for INT_MAX (we should have a S32_MAX...)
namespace irr
{
class ITimer;
//! Used to store the profile data (and also used for profile group data).
struct SProfileData
{
friend class IProfiler;
SProfileData()
{
GroupIndex = 0;
reset();
}
bool operator<(const SProfileData& pd) const
{
return Id < pd.Id;
}
bool operator==(const SProfileData& pd) const
{
return Id == pd.Id;
}
u32 getGroupIndex() const
{
return GroupIndex;
}
const core::stringw& getName() const
{
return Name;
}
//! Each time profiling for this data is stopped it increases the counter by 1.
u32 getCallsCounter() const
{
return CountCalls;
}
//! Longest time a profile call for this id took from start until it was stopped again.
u32 getLongestTime() const
{
return LongestTime;
}
//! Time spend between start/stop
u32 getTimeSum() const
{
return TimeSum;
}
private:
// just to be used for searching as it does no initialization besides id
SProfileData(u32 id) : Id(id) {}
void reset()
{
CountCalls = 0;
LongestTime = 0;
TimeSum = 0;
LastTimeStarted = 0;
StartStopCounter = 0;
}
s32 Id;
u32 GroupIndex;
core::stringw Name;
s32 StartStopCounter; // 0 means stopped > 0 means it runs.
u32 CountCalls;
u32 LongestTime;
u32 TimeSum;
u32 LastTimeStarted;
};
//! Code-profiler. Please check the example in the Irrlicht examples folder about how to use it.
// Implementer notes:
// The design is all about allowing to use the central start/stop mechanism with minimal time overhead.
// This is why the class works without a virtual functions interface contrary to the usual Irrlicht design.
// And also why it works with id's instead of strings in the start/stop functions even if it makes using
// the class slightly harder.
// The class comes without reference-counting because the profiler instance is never released (TBD).
class IProfiler
{
public:
//! Constructor. You could use this to create a new profiler, but usually getProfiler() is used to access the global instance.
IProfiler() : Timer(0), NextAutoId(INT_MAX)
{}
virtual ~IProfiler()
{}
//! Add an id with given name and group which can be used for profiling with start/stop
/** After calling this once you can start/stop profiling for the given id.
\param id: Should be >= 0 as negative id's are reserved for Irrlicht. Also very large numbers (near INT_MAX) might
have been added automatically by the other add function.
\param name: Name for displaying profile data.
\param groupName: Each id belongs into a group - this helps on displaying profile data. */
inline void add(s32 id, const core::stringw &name, const core::stringw &groupName);
//! Add an automatically generated for the given name and group which can be used for profiling with start/stop.
/** After calling this once you can start/stop profiling with the returned id.
\param name: Name for displaying profile data.
\param groupName: Each id belongs into a group - this helps on displaying profile data.
\return Automatic id's start at INT_MAX and count down for each new id. If the name already has an id then that id will be returned. */
inline s32 add(const core::stringw &name, const core::stringw &groupName);
//! Return the number of profile data blocks. There is one for each id.
u32 getProfileDataCount() const
{
return ProfileDatas.size();
}
//! Search for the index of the profile data by name
/** \param result Receives the resulting data index when one was found.
\param name String with name to search for
\return true when found, false when not found */
inline bool findDataIndex(u32 & result, const core::stringw &name) const;
//! Get the profile data
/** \param index A value between 0 and getProfileDataCount()-1. Indices can change when new id's are added.*/
const SProfileData& getProfileDataByIndex(u32 index) const
{
return ProfileDatas[index];
}
//! Get the profile data
/** \param id Same value as used in ::add
\return Profile data for the given id or 0 when it does not exist. */
inline const SProfileData* getProfileDataById(u32 id);
//! Get the number of profile groups. Will be at least 1.
/** NOTE: The first groups is always L"overview" which is an overview for all existing groups */
inline u32 getGroupCount() const
{
return ProfileGroups.size();
}
//! Get profile data for a group.
/** NOTE: The first groups is always L"overview" which is an overview for all existing groups */
inline const SProfileData& getGroupData(u32 index) const
{
return ProfileGroups[index];
}
//! Find the group index by the group-name
/** \param result Receives the resulting group index when one was found.
\param name String with name to search for
\return true when found, false when not found */
inline bool findGroupIndex(u32 & result, const core::stringw &name) const;
//! Start profile-timing for the given id
/** This increases an internal run-counter for the given id. It will profile as long as that counter is > 0.
NOTE: you have to add the id first with one of the ::add functions
*/
inline void start(s32 id);
//! Stop profile-timing for the given id
/** This increases an internal run-counter for the given id. If it reaches 0 the time since start is recorded.
You should have the same amount of start and stop calls. If stop is called more often than start
then the additional stop calls will be ignored (counter never goes below 0)
*/
inline void stop(s32 id);
//! Reset profile data for the given id
inline void resetDataById(s32 id);
//! Reset profile data for the given index
inline void resetDataByIndex(u32 index);
//! Reset profile data for a whole group
inline void resetGroup(u32 index);
//! Reset all profile data
/** NOTE: This is not deleting id's or groups, just resetting all timers to 0. */
inline void resetAll();
//! Write all profile-data into a string
/** \param result Receives the result string.
\param includeOverview When true a group-overview is attached first
\param suppressUncalled When true elements which got never called are not printed */
virtual void printAll(core::stringw &result, bool includeOverview=false,bool suppressUncalled=true) const = 0;
//! Write the profile data of one group into a string
/** \param result Receives the result string.
\param groupIndex_ */
virtual void printGroup(core::stringw &result, u32 groupIndex, bool suppressUncalled) const = 0;
protected:
inline u32 addGroup(const core::stringw &name);
// I would prefer using os::Timer, but os.h is not in the public interface so far.
// Timer must be initialized by the implementation.
ITimer * Timer;
core::array<SProfileData> ProfileDatas;
core::array<SProfileData> ProfileGroups;
private:
s32 NextAutoId; // for giving out id's automatically
};
//! Access the Irrlicht profiler object.
/** Profiler is always accessible, except in destruction of global objects.
If you want to get internal profiling information about the engine itself
you will have to re-compile the engine with _IRR_COMPILE_WITH_PROFILING_ enabled.
But you can use the profiler for profiling your own projects without that. */
IRRLICHT_API IProfiler& IRRCALLCONV getProfiler();
//! Class where the objects profile their own life-time.
/** This is a comfort wrapper around the IProfiler start/stop mechanism which is easier to use
when you want to profile a scope. You only have to create an object and it will profile it's own lifetime
for the given id. */
class CProfileScope
{
public:
//! Construct with an known id.
/** This is the fastest scope constructor, but the id must have been added before.
\param id Any id which you did add to the profiler before. */
CProfileScope(s32 id)
: Id(id), Profiler(getProfiler())
{
Profiler.start(Id);
}
//! Object will create the given name, groupName combination for the id if it doesn't exist already
/** \param id: Should be >= 0 as negative id's are reserved for Irrlicht. Also very large numbers (near INT_MAX) might
have been created already by the automatic add function of ::IProfiler.
\param name: Name for displaying profile data.
\param groupName: Each id belongs into a group - this helps on displaying profile data. */
CProfileScope(s32 id, const core::stringw &name, const core::stringw &groupName)
: Id(id), Profiler(getProfiler())
{
Profiler.add(Id, name, groupName);
Profiler.start(Id);
}
//! Object will create an id for the given name, groupName combination if they don't exist already
/** Slowest scope constructor, but usually still fine unless speed is very critical.
\param name: Name for displaying profile data.
\param groupName: Each id belongs into a group - this helps on displaying profile data. */
CProfileScope(const core::stringw &name, const core::stringw &groupName)
: Profiler(getProfiler())
{
Id = Profiler.add(name, groupName);
Profiler.start(Id);
}
~CProfileScope()
{
Profiler.stop(Id);
}
protected:
s32 Id;
IProfiler& Profiler;
};
// IMPLEMENTATION for in-line stuff
void IProfiler::start(s32 id)
{
s32 idx = ProfileDatas.binary_search(SProfileData(id));
if ( idx >= 0 && Timer )
{
++ProfileDatas[idx].StartStopCounter;
if (ProfileDatas[idx].StartStopCounter == 1 )
ProfileDatas[idx].LastTimeStarted = Timer->getRealTime();
}
}
void IProfiler::stop(s32 id)
{
if ( Timer )
{
u32 timeNow = Timer->getRealTime();
s32 idx = ProfileDatas.binary_search(SProfileData(id));
if ( idx >= 0 )
{
SProfileData &data = ProfileDatas[idx];
--ProfileDatas[idx].StartStopCounter;
if ( data.LastTimeStarted != 0 && ProfileDatas[idx].StartStopCounter == 0)
{
// update data for this id
++data.CountCalls;
u32 diffTime = timeNow - data.LastTimeStarted;
data.TimeSum += diffTime;
if ( diffTime > data.LongestTime )
data.LongestTime = diffTime;
data.LastTimeStarted = 0;
// update data of it's group
SProfileData & group = ProfileGroups[data.GroupIndex];
++group.CountCalls;
group.TimeSum += diffTime;
if ( diffTime > group.LongestTime )
group.LongestTime = diffTime;
group.LastTimeStarted = 0;
}
else if ( ProfileDatas[idx].StartStopCounter < 0 )
{
// ignore additional stop calls
ProfileDatas[idx].StartStopCounter = 0;
}
}
}
}
s32 IProfiler::add(const core::stringw &name, const core::stringw &groupName)
{
u32 index;
if ( findDataIndex(index, name) )
{
add( ProfileDatas[index].Id, name, groupName );
return ProfileDatas[index].Id;
}
else
{
s32 id = NextAutoId;
--NextAutoId;
add( id, name, groupName );
return id;
}
}
void IProfiler::add(s32 id, const core::stringw &name, const core::stringw &groupName)
{
u32 groupIdx;
if ( !findGroupIndex(groupIdx, groupName) )
{
groupIdx = addGroup(groupName);
}
SProfileData data(id);
s32 idx = ProfileDatas.binary_search(data);
if ( idx < 0 )
{
data.reset();
data.GroupIndex = groupIdx;
data.Name = name;
ProfileDatas.push_back(data);
ProfileDatas.sort();
}
else
{
// only reset on group changes, otherwise we want to keep the data or coding CProfileScope would become tricky.
if ( groupIdx != ProfileDatas[idx].GroupIndex )
{
resetDataByIndex((u32)idx);
ProfileDatas[idx].GroupIndex = groupIdx;
}
ProfileDatas[idx].Name = name;
}
}
u32 IProfiler::addGroup(const core::stringw &name)
{
SProfileData group;
group.Id = -1; // Id for groups doesn't matter so far
group.Name = name;
ProfileGroups.push_back(group);
return ProfileGroups.size()-1;
}
bool IProfiler::findDataIndex(u32 & result, const core::stringw &name) const
{
for ( u32 i=0; i < ProfileDatas.size(); ++i )
{
if ( ProfileDatas[i].Name == name )
{
result = i;
return true;
}
}
return false;
}
const SProfileData* IProfiler::getProfileDataById(u32 id)
{
SProfileData data(id);
s32 idx = ProfileDatas.binary_search(data);
if ( idx >= 0 )
return &ProfileDatas[idx];
return NULL;
}
bool IProfiler::findGroupIndex(u32 & result, const core::stringw &name) const
{
for ( u32 i=0; i < ProfileGroups.size(); ++i )
{
if ( ProfileGroups[i].Name == name )
{
result = i;
return true;
}
}
return false;
}
void IProfiler::resetDataById(s32 id)
{
s32 idx = ProfileDatas.binary_search(SProfileData(id));
if ( idx >= 0 )
{
resetDataByIndex((u32)idx);
}
}
void IProfiler::resetDataByIndex(u32 index)
{
SProfileData &data = ProfileDatas[index];
SProfileData & group = ProfileGroups[data.GroupIndex];
group.CountCalls -= data.CountCalls;
group.TimeSum -= data.TimeSum;
data.reset();
}
//! Reset profile data for a whole group
void IProfiler::resetGroup(u32 index)
{
for ( u32 i=0; i<ProfileDatas.size(); ++i )
{
if ( ProfileDatas[i].GroupIndex == index )
ProfileDatas[i].reset();
}
if ( index < ProfileGroups.size() )
ProfileGroups[index].reset();
}
void IProfiler::resetAll()
{
for ( u32 i=0; i<ProfileDatas.size(); ++i )
{
ProfileDatas[i].reset();
}
for ( u32 i=0; i<ProfileGroups.size(); ++i )
{
ProfileGroups[i].reset();
}
}
//! For internal engine use:
//! Code inside IRR_PROFILE is only executed when _IRR_COMPILE_WITH_PROFILING_ is set
//! This allows disabling all profiler code completely by changing that define.
//! It's generally useful to wrap profiler-calls in application code with a similar macro.
#ifdef _IRR_COMPILE_WITH_PROFILING_
#define IRR_PROFILE(X) X
#else
#define IRR_PROFILE(X)
#endif // IRR_PROFILE
} // namespace irr
#endif // __I_PROFILER_H_INCLUDED__

View File

@ -35,7 +35,6 @@
#include "CMeshBuffer.h"
#include "coreutil.h"
#include "CVertexBuffer.h"
#include "IProfiler.h"
#include "dimension2d.h"
#include "ECullingTypes.h"
#include "EDebugSceneTypes.h"

View File

@ -241,7 +241,6 @@ add_library(IRROTHEROBJ OBJECT
COSOperator.cpp
Irrlicht.cpp
os.cpp
CProfiler.cpp
)
if(ANDROID)

View File

@ -20,8 +20,6 @@
#include "EVertexAttributes.h"
#include "CImage.h"
#include "os.h"
#include "EProfileIDs.h"
#include "IProfiler.h"
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
#include "android_native_app_glue.h"
@ -46,28 +44,6 @@ COGLES2Driver::COGLES2Driver(const SIrrlichtCreationParameters& params, io::IFil
setDebugName("COGLES2Driver");
#endif
IRR_PROFILE(
static bool initProfile = false;
if (!initProfile )
{
initProfile = true;
getProfiler().add(EPID_ES2_END_SCENE, L"endScene", L"ES2");
getProfiler().add(EPID_ES2_BEGIN_SCENE, L"beginScene", L"ES2");
getProfiler().add(EPID_ES2_UPDATE_VERTEX_HW_BUF, L"upVertBuf", L"ES2");
getProfiler().add(EPID_ES2_UPDATE_INDEX_HW_BUF, L"upIdxBuf", L"ES2");
getProfiler().add(EPID_ES2_DRAW_PRIMITIVES, L"drawPrim", L"ES2");
getProfiler().add(EPID_ES2_DRAW_2DIMAGE, L"draw2dImg", L"ES2");
getProfiler().add(EPID_ES2_DRAW_2DIMAGE_BATCH, L"draw2dImgB", L"ES2");
getProfiler().add(EPID_ES2_DRAW_2DRECTANGLE, L"draw2dRect", L"ES2");
getProfiler().add(EPID_ES2_DRAW_2DLINE, L"draw2dLine", L"ES2");
getProfiler().add(EPID_ES2_DRAW_3DLINE, L"draw3dLine", L"ES2");
getProfiler().add(EPID_ES2_SET_RENDERSTATE_2D, L"rstate2d", L"ES2");
getProfiler().add(EPID_ES2_SET_RENDERSTATE_3D, L"rstate3d", L"ES2");
getProfiler().add(EPID_ES2_SET_RENDERSTATE_BASIC, L"rstateBasic", L"ES2");
getProfiler().add(EPID_ES2_SET_RENDERSTATE_TEXTURE, L"rstateTex", L"ES2");
getProfiler().add(EPID_ES2_DRAW_SHADOW, L"shadows", L"ES2");
}
)
if (!ContextManager)
return;
@ -384,8 +360,6 @@ COGLES2Driver::~COGLES2Driver()
bool COGLES2Driver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil, const SExposedVideoData& videoData, core::rect<s32>* sourceRect)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_BEGIN_SCENE);)
CNullDriver::beginScene(clearFlag, clearColor, clearDepth, clearStencil, videoData, sourceRect);
if (ContextManager)
@ -398,8 +372,6 @@ COGLES2Driver::~COGLES2Driver()
bool COGLES2Driver::endScene()
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_END_SCENE);)
CNullDriver::endScene();
glFlush();
@ -431,8 +403,6 @@ COGLES2Driver::~COGLES2Driver()
if (!HWBuffer)
return false;
IRR_PROFILE(CProfileScope p1(EPID_ES2_UPDATE_VERTEX_HW_BUF);)
const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer;
const void* vertices = mb->getVertices();
const u32 vertexCount = mb->getVertexCount();
@ -481,8 +451,6 @@ COGLES2Driver::~COGLES2Driver()
if (!HWBuffer)
return false;
IRR_PROFILE(CProfileScope p1(EPID_ES2_UPDATE_INDEX_HW_BUF);)
const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer;
const void* indices = mb->getIndices();
@ -695,8 +663,6 @@ COGLES2Driver::~COGLES2Driver()
if (!checkPrimitiveCount(primitiveCount))
return;
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_PRIMITIVES);)
CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType, iType);
setRenderStates3DMode();
@ -852,8 +818,6 @@ COGLES2Driver::~COGLES2Driver()
if (!sourceRect.isValid())
return;
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DIMAGE);)
core::position2d<s32> targetPos(destPos);
core::position2d<s32> sourcePos(sourceRect.UpperLeftCorner);
core::dimension2d<s32> sourceSize(sourceRect.getSize());
@ -986,8 +950,6 @@ COGLES2Driver::~COGLES2Driver()
if (!texture)
return;
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DIMAGE);)
// texcoords need to be flipped horizontally for RTTs
const bool isRTT = texture->isRenderTarget();
const core::dimension2du& ss = texture->getOriginalSize();
@ -1111,8 +1073,6 @@ COGLES2Driver::~COGLES2Driver()
if (!texture)
return;
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DIMAGE_BATCH);)
const irr::u32 drawCount = core::min_<u32>(positions.size(), sourceRects.size());
core::array<S3DVertex> vtx(drawCount * 4);
@ -1272,8 +1232,6 @@ COGLES2Driver::~COGLES2Driver()
if (!texture)
return;
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DIMAGE_BATCH);)
chooseMaterial2D();
if (!setMaterialTexture(0, texture))
return;
@ -1364,8 +1322,6 @@ COGLES2Driver::~COGLES2Driver()
const core::rect<s32>& position,
const core::rect<s32>* clip)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DRECTANGLE);)
chooseMaterial2D();
setMaterialTexture(0, 0);
@ -1409,8 +1365,6 @@ COGLES2Driver::~COGLES2Driver()
SColor colorLeftDown, SColor colorRightDown,
const core::rect<s32>* clip)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DRECTANGLE);)
core::rect<s32> pos = position;
if (clip)
@ -1455,8 +1409,6 @@ COGLES2Driver::~COGLES2Driver()
void COGLES2Driver::draw2DLine(const core::position2d<s32>& start,
const core::position2d<s32>& end, SColor color)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DLINE);)
if (start==end)
drawPixel(start.X, start.Y, color);
else
@ -1635,8 +1587,6 @@ COGLES2Driver::~COGLES2Driver()
void COGLES2Driver::setRenderStates3DMode()
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_SET_RENDERSTATE_3D);)
if ( LockRenderStateMode )
return;
@ -1682,8 +1632,6 @@ COGLES2Driver::~COGLES2Driver()
//! Can be called by an IMaterialRenderer to make its work easier.
void COGLES2Driver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, bool resetAllRenderStates)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_SET_RENDERSTATE_BASIC);)
// ZBuffer
switch (material.ZBuffer)
{
@ -1822,8 +1770,6 @@ COGLES2Driver::~COGLES2Driver()
//! Compare in SMaterial doesn't check texture parameters, so we should call this on each OnRender call.
void COGLES2Driver::setTextureRenderStates(const SMaterial& material, bool resetAllRenderstates)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_SET_RENDERSTATE_TEXTURE);)
// Set textures to TU/TIU and apply filters to them
for (s32 i = Feature.MaxTextureUnits - 1; i >= 0; --i)
@ -1927,8 +1873,6 @@ COGLES2Driver::~COGLES2Driver()
//! sets the needed renderstates
void COGLES2Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_SET_RENDERSTATE_2D);)
if ( LockRenderStateMode )
return;
@ -2029,8 +1973,6 @@ COGLES2Driver::~COGLES2Driver()
//! Draws a shadow volume into the stencil buffer.
void COGLES2Driver::drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_SHADOW);)
const u32 count=triangles.size();
if (!StencilBuffer || !count)
return;
@ -2109,8 +2051,6 @@ COGLES2Driver::~COGLES2Driver()
video::SColor leftUpEdge, video::SColor rightUpEdge,
video::SColor leftDownEdge, video::SColor rightDownEdge)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_SHADOW);)
if (!StencilBuffer)
return;
@ -2155,8 +2095,6 @@ COGLES2Driver::~COGLES2Driver()
void COGLES2Driver::draw3DLine(const core::vector3df& start,
const core::vector3df& end, SColor color)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_3DLINE);)
setRenderStates3DMode();
u16 indices[] = {0, 1};

View File

@ -17,8 +17,6 @@
#include "EVertexAttributes.h"
#include "CImage.h"
#include "os.h"
#include "EProfileIDs.h"
#include "IProfiler.h"
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
#include "android_native_app_glue.h"
@ -188,8 +186,6 @@ void COGLES1Driver::createMaterialRenderers()
bool COGLES1Driver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil, const SExposedVideoData& videoData, core::rect<s32>* sourceRect)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_BEGIN_SCENE);)
CNullDriver::beginScene(clearFlag, clearColor, clearDepth, clearStencil, videoData, sourceRect);
if (ContextManager)
@ -202,8 +198,6 @@ bool COGLES1Driver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth,
bool COGLES1Driver::endScene()
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_END_SCENE);)
CNullDriver::endScene();
glFlush();

View File

@ -1,95 +0,0 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// Written by Michael Zeilfelder
#include "CProfiler.h"
#include "CTimer.h"
namespace irr
{
IRRLICHT_API IProfiler& IRRCALLCONV getProfiler()
{
static CProfiler profiler;
return profiler;
}
CProfiler::CProfiler()
{
Timer = new CTimer(true);
addGroup(L"overview");
}
CProfiler::~CProfiler()
{
if ( Timer )
Timer->drop();
}
void CProfiler::printAll(core::stringw &ostream, bool includeOverview, bool suppressUncalled) const
{
ostream += makeTitleString();
ostream += L"\n";
for ( u32 i=includeOverview ?0:1; i<ProfileGroups.size(); ++i )
{
printGroup( ostream, i, suppressUncalled );
}
}
void CProfiler::printGroup(core::stringw &ostream, u32 idxGroup, bool suppressUncalled) const
{
ostream += getAsString(ProfileGroups[idxGroup]);
ostream += L"\n";
// print overview for groups
if ( idxGroup == 0 )
{
for ( u32 i=0; i<ProfileGroups.size(); ++i )
{
if ( !suppressUncalled || ProfileGroups[i].getCallsCounter() > 0)
{
ostream += getAsString(ProfileGroups[i]);
ostream += L"\n";
}
}
}
// print all data in a group
else
{
for ( u32 i=0; i<ProfileDatas.size(); ++i )
{
if ( (!suppressUncalled || ProfileDatas[i].getCallsCounter() > 0)
&& ProfileDatas[i].getGroupIndex() == idxGroup )
{
ostream += getAsString(ProfileDatas[i]);
ostream += L"\n";
}
}
}
}
//! Convert the whole data into a string
core::stringw CProfiler::getAsString(const SProfileData& data) const
{
if ( data.getCallsCounter() > 0 )
{
wchar_t dummy[512];
swprintf_irr(dummy, 512, L"%-15.15s%-12u%-12u%-12u%-12u",
data.getName().c_str(), data.getCallsCounter(), data.getTimeSum(),
data.getTimeSum() / data.getCallsCounter(), data.getLongestTime());
return core::stringw(dummy);
}
else
{
return data.getName();
}
}
//! Return a string which describes the columns returned by getAsString
core::stringw CProfiler::makeTitleString() const
{
return core::stringw("name calls time(sum) time(avg) time(max)");
}
} // namespace irr

View File

@ -1,32 +0,0 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// Written by Michael Zeilfelder
#ifndef __C_PROFILER_H_INCLUDED__
#define __C_PROFILER_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "IProfiler.h"
namespace irr
{
class CProfiler : public IProfiler
{
public:
CProfiler();
virtual ~CProfiler();
//! Write all profile-data into a string
void printAll(core::stringw &result, bool includeOverview,bool suppressUncalled) const override;
//! Write the profile data of one group into a string
void printGroup(core::stringw &result, u32 groupIndex, bool suppressUncalled) const override;
protected:
core::stringw makeTitleString() const;
core::stringw getAsString(const SProfileData& data) const;
};
} // namespace irr
#endif // __C_PROFILER_H_INCLUDED__

View File

@ -12,8 +12,6 @@
#include "IMaterialRenderer.h"
#include "IReadFile.h"
#include "IWriteFile.h"
#include "EProfileIDs.h"
#include "IProfiler.h"
#include "os.h"
@ -107,25 +105,6 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
#ifdef _IRR_COMPILE_WITH_B3D_LOADER_
MeshLoaderList.push_back(new CB3DMeshFileLoader(this));
#endif
IRR_PROFILE(
static bool initProfile = false;
if (!initProfile )
{
initProfile = true;
getProfiler().add(EPID_SM_DRAW_ALL, L"drawAll", L"Irrlicht scene");
getProfiler().add(EPID_SM_ANIMATE, L"animate", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_CAMERAS, L"cameras", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_LIGHTS, L"lights", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_SKYBOXES, L"skyboxes", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_DEFAULT, L"defaultnodes", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_SHADOWS, L"shadows", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_TRANSPARENT, L"transp.nodes", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_EFFECT, L"effectnodes", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_GUI_NODES, L"guinodes", L"Irrlicht scene");
getProfiler().add(EPID_SM_REGISTER, L"reg.render.node", L"Irrlicht scene");
}
)
}
@ -509,7 +488,6 @@ bool CSceneManager::isCulled(const ISceneNode* node) const
//! registers a node for rendering it at a specific time.
u32 CSceneManager::registerNodeForRendering(ISceneNode* node, E_SCENE_NODE_RENDER_PASS pass)
{
IRR_PROFILE(CProfileScope p1(EPID_SM_REGISTER);)
u32 taken = 0;
switch(pass)
@ -625,8 +603,6 @@ void CSceneManager::clearAllRegisteredNodesForRendering()
//! draws all scene nodes
void CSceneManager::drawAll()
{
IRR_PROFILE(CProfileScope psAll(EPID_SM_DRAW_ALL);)
if (!Driver)
return;
@ -652,29 +628,24 @@ void CSceneManager::drawAll()
Driver->setAllowZWriteOnTransparent(Parameters->getAttributeAsBool(ALLOW_ZWRITE_ON_TRANSPARENT));
// do animations and other stuff.
IRR_PROFILE(getProfiler().start(EPID_SM_ANIMATE));
OnAnimate(os::Timer::getTime());
IRR_PROFILE(getProfiler().stop(EPID_SM_ANIMATE));
/*!
First Scene Node for prerendering should be the active camera
consistent Camera is needed for culling
*/
IRR_PROFILE(getProfiler().start(EPID_SM_RENDER_CAMERAS));
camWorldPos.set(0,0,0);
if (ActiveCamera)
{
ActiveCamera->render();
camWorldPos = ActiveCamera->getAbsolutePosition();
}
IRR_PROFILE(getProfiler().stop(EPID_SM_RENDER_CAMERAS));
// let all nodes register themselves
OnRegisterSceneNode();
//render camera scenes
{
IRR_PROFILE(CProfileScope psCam(EPID_SM_RENDER_CAMERAS);)
CurrentRenderPass = ESNRP_CAMERA;
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);
@ -686,7 +657,6 @@ void CSceneManager::drawAll()
// render skyboxes
{
IRR_PROFILE(CProfileScope psSkyBox(EPID_SM_RENDER_SKYBOXES);)
CurrentRenderPass = ESNRP_SKY_BOX;
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);
@ -698,7 +668,6 @@ void CSceneManager::drawAll()
// render default objects
{
IRR_PROFILE(CProfileScope psDefault(EPID_SM_RENDER_DEFAULT);)
CurrentRenderPass = ESNRP_SOLID;
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);
@ -715,7 +684,6 @@ void CSceneManager::drawAll()
// render transparent objects.
{
IRR_PROFILE(CProfileScope psTrans(EPID_SM_RENDER_TRANSPARENT);)
CurrentRenderPass = ESNRP_TRANSPARENT;
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);
@ -731,7 +699,6 @@ void CSceneManager::drawAll()
// render transparent effect objects.
{
IRR_PROFILE(CProfileScope psEffect(EPID_SM_RENDER_EFFECT);)
CurrentRenderPass = ESNRP_TRANSPARENT_EFFECT;
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);
@ -747,7 +714,6 @@ void CSceneManager::drawAll()
// render custom gui nodes
{
IRR_PROFILE(CProfileScope psEffect(EPID_SM_RENDER_GUI_NODES);)
CurrentRenderPass = ESNRP_GUI;
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);

View File

@ -1,55 +0,0 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef E_PROFILE_IDS_H_INCLUDED__
#define E_PROFILE_IDS_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "limits.h"
namespace irr
{
#ifdef _IRR_COMPILE_WITH_PROFILING_
enum EPROFILE_ID
{
// We use negative ID's to avoid clashing with user application id's.
EPID_FIRST = -INT_MAX, // not used
//! scenemanager.
EPID_SM_DRAW_ALL,
EPID_SM_ANIMATE,
EPID_SM_RENDER_CAMERAS,
EPID_SM_RENDER_LIGHTS,
EPID_SM_RENDER_SKYBOXES,
EPID_SM_RENDER_DEFAULT,
EPID_SM_RENDER_SHADOWS,
EPID_SM_RENDER_TRANSPARENT,
EPID_SM_RENDER_EFFECT,
EPID_SM_RENDER_GUI_NODES,
EPID_SM_REGISTER,
//! octrees
EPID_OC_RENDER,
EPID_OC_CALCPOLYS,
//! es2 driver
EPID_ES2_END_SCENE,
EPID_ES2_BEGIN_SCENE,
EPID_ES2_UPDATE_VERTEX_HW_BUF,
EPID_ES2_UPDATE_INDEX_HW_BUF,
EPID_ES2_DRAW_PRIMITIVES,
EPID_ES2_DRAW_2DIMAGE,
EPID_ES2_DRAW_2DIMAGE_BATCH,
EPID_ES2_DRAW_2DRECTANGLE,
EPID_ES2_DRAW_2DLINE,
EPID_ES2_DRAW_3DLINE,
EPID_ES2_SET_RENDERSTATE_2D,
EPID_ES2_SET_RENDERSTATE_3D,
EPID_ES2_SET_RENDERSTATE_BASIC,
EPID_ES2_SET_RENDERSTATE_TEXTURE,
EPID_ES2_DRAW_SHADOW
};
#endif
} // end namespace irr
#endif // E_PROFILE_IDS_H_INCLUDED__