On-screen Profiler / Debug visualizations in progress
This commit is contained in:
@@ -643,48 +643,40 @@ void KRCamera::renderPost()
|
||||
|
||||
const char *szText = settings.m_debug_text.c_str();
|
||||
|
||||
bool show_active_textures = false;
|
||||
std::string debug_text = "";
|
||||
if(show_active_textures) {
|
||||
|
||||
|
||||
std::set<KRTexture *> active_textures = m_pContext->getTextureManager()->getActiveTextures();
|
||||
for(std::set<KRTexture *>::iterator itr=active_textures.begin(); itr != active_textures.end(); itr++) {
|
||||
KRTexture *texture = *itr;
|
||||
if(debug_text.length()) {
|
||||
debug_text += "\n";
|
||||
}
|
||||
debug_text += texture->getName();
|
||||
debug_text += " ";
|
||||
debug_text += texture->getMemSize() / 1024;
|
||||
debug_text += "kB";
|
||||
debug_text += " ";
|
||||
debug_text += texture->getMaxMipMap();
|
||||
if(texture->getCurrentLodMaxDim() != texture->getMaxMipMap()) {
|
||||
debug_text += "px => ";
|
||||
debug_text += texture->getCurrentLodMaxDim();
|
||||
}
|
||||
debug_text += "px";
|
||||
}
|
||||
|
||||
bool show_active_textures = true;
|
||||
std::string debug_text = getDebugText();
|
||||
if(debug_text.length() > 0) {
|
||||
szText = debug_text.c_str();
|
||||
}
|
||||
|
||||
if(*szText) {
|
||||
int row_count = 1;
|
||||
int col_count = 0;
|
||||
const int MAX_TABS = 5;
|
||||
const int TAB_EXTRA = 2;
|
||||
int tab_cols[MAX_TABS] = {0, 0, 0, 0, 0};
|
||||
int iCol = 0;
|
||||
int iTab = 0;
|
||||
const char *pChar = szText;
|
||||
while(*pChar) {
|
||||
char c = *pChar++;
|
||||
if(c == '\n') {
|
||||
row_count++;
|
||||
iCol = 0;
|
||||
iTab = 0;
|
||||
} else if(c == '\t') {
|
||||
iCol = 0;
|
||||
iTab++;
|
||||
} else {
|
||||
iCol++;
|
||||
if(iCol > col_count) col_count = iCol;
|
||||
if(iCol > tab_cols[iTab]) tab_cols[iTab] = iCol;
|
||||
}
|
||||
}
|
||||
|
||||
iCol = 0;
|
||||
for(iTab=0; iTab < MAX_TABS; iTab++) {
|
||||
iCol += tab_cols[iTab] + TAB_EXTRA;
|
||||
tab_cols[iTab] = iCol;
|
||||
}
|
||||
|
||||
const int DEBUG_TEXT_COLUMNS = 256;
|
||||
const int DEBUG_TEXT_ROWS = 128;
|
||||
@@ -697,17 +689,18 @@ void KRCamera::renderPost()
|
||||
|
||||
|
||||
pChar = szText;
|
||||
float dScaleX = 2.0 / (2048 / 16);
|
||||
float dScaleY = 2.0 / (1536 / 16);
|
||||
float dScaleX = 2.0 / (1024 / 16);
|
||||
float dScaleY = 2.0 / (768 / 16);
|
||||
float dTexScale = 1.0 / 16.0;
|
||||
int iRow = row_count - 1; iCol = 0;
|
||||
int iRow = row_count - 1; iCol = 0, iTab = 0;
|
||||
while(*pChar) {
|
||||
char c = *pChar++;
|
||||
if(c == ' ') {
|
||||
iCol++;
|
||||
} else if(c == '\n') {
|
||||
if(c == '\n') {
|
||||
iCol = 0;
|
||||
iTab = 0;
|
||||
iRow--;
|
||||
} else if(c == '\t') {
|
||||
iCol = tab_cols[iTab++];
|
||||
} else {
|
||||
if(iCol < DEBUG_TEXT_COLUMNS && iRow < DEBUG_TEXT_ROWS) {
|
||||
int iChar = c - '\0';
|
||||
@@ -805,3 +798,75 @@ void KRCamera::renderPost()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string KRCamera::getDebugText()
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream.precision(std::numeric_limits<long double>::digits10);
|
||||
|
||||
switch(settings.debug_display) {
|
||||
case 0: // ----====---- No debug display ----====----
|
||||
break;
|
||||
|
||||
case 1: // ----====---- Memory Utilization ----=====----
|
||||
{
|
||||
int texture_count_active = m_pContext->getTextureManager()->getActiveTextures().size();
|
||||
int texture_count_pooled = m_pContext->getTextureManager()->getPoolTextures().size();
|
||||
int texture_count = texture_count_active + texture_count_pooled;
|
||||
long texture_mem_active = m_pContext->getTextureManager()->getMemActive();
|
||||
long texture_mem_used = m_pContext->getTextureManager()->getMemUsed();
|
||||
long texture_mem_throughput = m_pContext->getTextureManager()->getMemoryTransferedThisFrame();
|
||||
|
||||
int vbo_count_active = m_pContext->getModelManager()->getActiveVBOCount();
|
||||
int vbo_count_pooled = m_pContext->getModelManager()->getPoolVBOCount();
|
||||
long vbo_mem_active = m_pContext->getModelManager()->getMemActive();
|
||||
long vbo_mem_used = m_pContext->getModelManager()->getMemUsed();
|
||||
long vbo_mem_throughput = m_pContext->getModelManager()->getMemoryTransferedThisFrame();
|
||||
|
||||
long total_mem_active = texture_mem_active + vbo_mem_active;
|
||||
long total_mem_used = texture_mem_used + vbo_mem_used;
|
||||
long total_mem_throughput = texture_mem_throughput + vbo_mem_throughput;
|
||||
|
||||
stream << "\t# Active\t# Used\tActive\tUsed\tThroughput\n";
|
||||
|
||||
stream << "Textures\t" << texture_count_active << "\t" << texture_count << "\t" << (texture_mem_active / 1024) << " Kb\t" << (texture_mem_used / 1024) << " Kb\t" << (texture_mem_throughput / 1024) << " Kb / frame\n";
|
||||
stream << "VBO's\t" << vbo_count_active << "\t" << vbo_count_active + vbo_count_pooled << "\t" << (vbo_mem_active / 1024) <<" Kb\t" << (vbo_mem_used / 1024) << " Kb\t" << (vbo_mem_throughput / 1024) << " Kb / frame\n";
|
||||
stream << "\nTOTAL\t\t\t" << (total_mem_active / 1024) << " Kb\t" << (total_mem_used / 1024) << " Kb\t" << (total_mem_throughput / 1024) << " Kb / frame";
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: // ----====---- Show active textures ----====----
|
||||
{
|
||||
bool first = true;
|
||||
int texture_count = 0;
|
||||
std::set<KRTexture *> active_textures = m_pContext->getTextureManager()->getActiveTextures();
|
||||
for(std::set<KRTexture *>::iterator itr=active_textures.begin(); itr != active_textures.end(); itr++) {
|
||||
KRTexture *texture = *itr;
|
||||
if(first) {
|
||||
first = false;
|
||||
} else {
|
||||
stream << "\n";
|
||||
}
|
||||
stream << texture->getName();
|
||||
stream << "\t";
|
||||
stream << texture->getMemSize() / 1024;
|
||||
stream << "kB";
|
||||
stream << "\t";
|
||||
stream << texture->getMaxMipMap();
|
||||
if(texture->getCurrentLodMaxDim() != texture->getMaxMipMap()) {
|
||||
stream << "px => ";
|
||||
stream << texture->getCurrentLodMaxDim();
|
||||
}
|
||||
stream << "px";
|
||||
texture_count++;
|
||||
}
|
||||
|
||||
stream << "\n\nTOTAL: ";
|
||||
stream << texture_count;
|
||||
stream << " textures\t";
|
||||
stream << (m_pContext->getTextureManager()->getMemActive() / 1024) << " Kb\t" << (m_pContext->getTextureManager()->getMemoryTransferedThisFrame() / 1024) << " Kb / Frame";
|
||||
}
|
||||
break;
|
||||
}
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ private:
|
||||
} DebugTextVertexData;
|
||||
|
||||
DebugTextVertexData *m_debug_text_vertices;
|
||||
|
||||
std::string getDebugText();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -195,6 +195,7 @@ void KRContext::startFrame(float deltaTime)
|
||||
m_pTextureManager->startFrame(deltaTime);
|
||||
m_pAnimationManager->startFrame(deltaTime);
|
||||
m_pSoundManager->startFrame(deltaTime);
|
||||
m_pModelManager->startFrame(deltaTime);
|
||||
}
|
||||
|
||||
void KRContext::endFrame(float deltaTime)
|
||||
|
||||
@@ -159,7 +159,8 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
||||
@"fog_color_g": @44,
|
||||
@"fog_color_b": @45,
|
||||
@"dust_enable" : @46,
|
||||
@"dust_intensity" : @47
|
||||
@"dust_intensity" : @47,
|
||||
@"debug_display" : @48
|
||||
|
||||
} copy];
|
||||
[self loadShaders];
|
||||
@@ -232,7 +233,7 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
||||
|
||||
-(int)getParameterCount
|
||||
{
|
||||
return 48;
|
||||
return 49;
|
||||
}
|
||||
|
||||
-(NSString *)getParameterNameWithIndex: (int)i
|
||||
@@ -242,7 +243,7 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
||||
|
||||
-(NSString *)getParameterLabelWithIndex: (int)i
|
||||
{
|
||||
NSString *parameter_labels[48] = {
|
||||
NSString *parameter_labels[49] = {
|
||||
@"Camera FOV",
|
||||
@"Shadow Quality (0 - 2)",
|
||||
@"Enable per-pixel lighting",
|
||||
@@ -290,13 +291,14 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
||||
@"Fog - Color G",
|
||||
@"Fog - Color B",
|
||||
@"Dust - Enable",
|
||||
@"Dust - Intensity"
|
||||
@"Dust - Intensity",
|
||||
@"Debug - Display"
|
||||
};
|
||||
return parameter_labels[i];
|
||||
}
|
||||
-(KREngineParameterType)getParameterTypeWithIndex: (int)i
|
||||
{
|
||||
KREngineParameterType types[48] = {
|
||||
KREngineParameterType types[49] = {
|
||||
|
||||
KRENGINE_PARAMETER_FLOAT,
|
||||
KRENGINE_PARAMETER_INT,
|
||||
@@ -345,13 +347,14 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
||||
KRENGINE_PARAMETER_FLOAT,
|
||||
KRENGINE_PARAMETER_FLOAT,
|
||||
KRENGINE_PARAMETER_BOOL,
|
||||
KRENGINE_PARAMETER_FLOAT
|
||||
KRENGINE_PARAMETER_FLOAT,
|
||||
KRENGINE_PARAMETER_INT
|
||||
};
|
||||
return types[i];
|
||||
}
|
||||
-(float)getParameterValueWithIndex: (int)i
|
||||
{
|
||||
float values[48] = {
|
||||
float values[49] = {
|
||||
_settings.perspective_fov,
|
||||
(float)_settings.m_cShadowBuffers,
|
||||
_settings.bEnablePerPixel ? 1.0f : 0.0f,
|
||||
@@ -399,7 +402,8 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
||||
_settings.fog_color.y,
|
||||
_settings.fog_color.z,
|
||||
_settings.dust_particle_enable,
|
||||
_settings.dust_particle_intensity
|
||||
_settings.dust_particle_intensity,
|
||||
_settings.debug_display
|
||||
};
|
||||
return values[i];
|
||||
}
|
||||
@@ -592,17 +596,20 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
||||
case 47:
|
||||
_settings.dust_particle_intensity = v;
|
||||
break;
|
||||
case 48:
|
||||
_settings.debug_display = v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
-(float)getParameterMinWithIndex: (int)i
|
||||
{
|
||||
float minValues[48] = {
|
||||
float minValues[49] = {
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.01f, 50.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
|
||||
};
|
||||
|
||||
return minValues[i];
|
||||
@@ -610,12 +617,12 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
||||
|
||||
-(float)getParameterMaxWithIndex: (int)i
|
||||
{
|
||||
float maxValues[48] = {
|
||||
float maxValues[49] = {
|
||||
PI, 3.0f, 1.0f, 1.0, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 10.0f,
|
||||
1.0f, 10.0f, 2.0f, 1.0f, 1.0f, 1.0f, 5.0f, 1.0f, 0.5f, 1.0f,
|
||||
2.0f, 2.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
|
||||
1.0f, 1.0f, 10.0f, 1000.0f, 1.0f, 5.0f, 1000.0f, 1.0f, 5.0f, 3.0f,
|
||||
1000.0f, 1000.0f, 0.01f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f
|
||||
1000.0f, 1000.0f, 0.01f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f
|
||||
};
|
||||
|
||||
return maxValues[i];
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
@@ -45,6 +45,7 @@ KRMeshManager::KRMeshManager(KRContext &context) : KRContextObject(context) {
|
||||
m_vboMemUsed = 0;
|
||||
m_randomParticleVertexData = NULL;
|
||||
m_volumetricLightingVertexData = NULL;
|
||||
m_memoryTransferredThisFrame = 0;
|
||||
|
||||
// addModel(new KRMeshCube(context)); // FINDME - HACK! This needs to be fixed, as it currently segfaults
|
||||
|
||||
@@ -200,6 +201,7 @@ void KRMeshManager::bindVBO(GLvoid *data, GLsizeiptr size, GLvoid *index_data, G
|
||||
|
||||
GLDEBUG(glBindBuffer(GL_ARRAY_BUFFER, m_currentVBO.vbo_handle));
|
||||
GLDEBUG(glBufferData(GL_ARRAY_BUFFER, size, data, static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
||||
m_memoryTransferredThisFrame += size;
|
||||
m_vboMemUsed += size;
|
||||
configureAttribs(enable_vertex, enable_normal, enable_tangent, enable_uva, enable_uvb, enable_bone_indexes, enable_bone_weights);
|
||||
|
||||
@@ -294,6 +296,15 @@ long KRMeshManager::getMemUsed()
|
||||
return m_vboMemUsed;
|
||||
}
|
||||
|
||||
long KRMeshManager::getMemActive()
|
||||
{
|
||||
long mem_active = 0;
|
||||
for(std::map<GLvoid *, vbo_info_type>::iterator itr = m_vbosActive.begin(); itr != m_vbosActive.end(); itr++) {
|
||||
mem_active += (*itr).second.size;
|
||||
}
|
||||
return mem_active;
|
||||
}
|
||||
|
||||
void KRMeshManager::rotateBuffers(bool new_frame)
|
||||
{
|
||||
m_vbosPool.insert(m_vbosActive.begin(), m_vbosActive.end());
|
||||
@@ -388,3 +399,24 @@ KRMeshManager::RandomParticleVertexData *KRMeshManager::getRandomParticles()
|
||||
}
|
||||
return m_randomParticleVertexData;
|
||||
}
|
||||
|
||||
void KRMeshManager::startFrame(float deltaTime)
|
||||
{
|
||||
m_memoryTransferredThisFrame = 0;
|
||||
}
|
||||
|
||||
long KRMeshManager::getMemoryTransferedThisFrame()
|
||||
{
|
||||
return m_memoryTransferredThisFrame;
|
||||
}
|
||||
|
||||
|
||||
int KRMeshManager::getActiveVBOCount()
|
||||
{
|
||||
return m_vbosActive.size();
|
||||
}
|
||||
|
||||
int KRMeshManager::getPoolVBOCount()
|
||||
{
|
||||
return m_vbosPool.size();
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
virtual ~KRMeshManager();
|
||||
|
||||
void rotateBuffers(bool new_frame);
|
||||
void startFrame(float deltaTime);
|
||||
|
||||
KRMesh *loadModel(const char *szName, KRDataBlock *pData);
|
||||
std::vector<KRMesh *> getModel(const char *szName);
|
||||
@@ -61,6 +62,7 @@ public:
|
||||
void releaseVBO(GLvoid *data);
|
||||
void unbindVBO();
|
||||
long getMemUsed();
|
||||
long getMemActive();
|
||||
|
||||
void configureAttribs(bool enable_vertex, bool enable_normal, bool enable_tangent, bool enable_uva, bool enable_uvb, bool enable_bone_indexes, bool enable_bone_weights);
|
||||
|
||||
@@ -85,9 +87,19 @@ public:
|
||||
KRVector3D vertex;
|
||||
} VolumetricLightingVertexData;
|
||||
|
||||
|
||||
|
||||
|
||||
RandomParticleVertexData *getRandomParticles();
|
||||
VolumetricLightingVertexData *getVolumetricLightingVertexes();
|
||||
|
||||
|
||||
long getMemoryTransferedThisFrame();
|
||||
|
||||
int getActiveVBOCount();
|
||||
int getPoolVBOCount();
|
||||
|
||||
|
||||
private:
|
||||
std::multimap<std::string, KRMesh *> m_models; // Multiple models with the same name/key may be inserted, representing multiple LOD levels of the model
|
||||
|
||||
@@ -108,6 +120,8 @@ private:
|
||||
RandomParticleVertexData *m_randomParticleVertexData;
|
||||
VolumetricLightingVertexData *m_volumetricLightingVertexData;
|
||||
|
||||
long m_memoryTransferredThisFrame;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -72,6 +72,8 @@ KRRenderSettings::KRRenderSettings()
|
||||
|
||||
dust_particle_intensity = 0.25f;
|
||||
dust_particle_enable = false;
|
||||
|
||||
debug_display = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -138,6 +140,7 @@ KRRenderSettings& KRRenderSettings::operator=(const KRRenderSettings &s)
|
||||
perspective_farz=s.perspective_farz;
|
||||
|
||||
m_skyBoxName=s.m_skyBoxName;
|
||||
debug_display = s.debug_display;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -84,6 +84,8 @@ public:
|
||||
float perspective_farz;
|
||||
|
||||
std::string m_skyBoxName;
|
||||
|
||||
int debug_display;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
|
||||
KRTextureManager::KRTextureManager(KRContext &context) : KRContextObject(context) {
|
||||
m_textureMemUsed = 0;
|
||||
|
||||
for(int iTexture=0; iTexture<KRENGINE_MAX_TEXTURE_UNITS; iTexture++) {
|
||||
m_boundTextures[iTexture] = NULL;
|
||||
}
|
||||
@@ -142,6 +143,16 @@ long KRTextureManager::getMemUsed() {
|
||||
return m_textureMemUsed;
|
||||
}
|
||||
|
||||
long KRTextureManager::getMemActive() {
|
||||
long mem_active = 0;
|
||||
for(std::set<KRTexture *>::iterator itr=m_activeTextures.begin(); itr != m_activeTextures.end(); itr++) {
|
||||
KRTexture *activeTexture = *itr;
|
||||
mem_active += activeTexture->getMemSize();
|
||||
}
|
||||
|
||||
return mem_active;
|
||||
}
|
||||
|
||||
void KRTextureManager::startFrame(float deltaTime)
|
||||
{
|
||||
m_memoryTransferredThisFrame = 0;
|
||||
@@ -307,3 +318,8 @@ std::set<KRTexture *> &KRTextureManager::getActiveTextures()
|
||||
{
|
||||
return m_activeTextures;
|
||||
}
|
||||
|
||||
std::set<KRTexture *> &KRTextureManager::getPoolTextures()
|
||||
{
|
||||
return m_poolTextures;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
KRTexture *getTexture(const char *szFile);
|
||||
|
||||
long getMemUsed();
|
||||
long getMemActive();
|
||||
|
||||
long getMemoryTransferedThisFrame();
|
||||
void addMemoryTransferredThisFrame(long memoryTransferred);
|
||||
@@ -66,6 +67,7 @@ public:
|
||||
void compress();
|
||||
|
||||
std::set<KRTexture *> &getActiveTextures();
|
||||
std::set<KRTexture *> &getPoolTextures();
|
||||
|
||||
private:
|
||||
long m_memoryTransferredThisFrame;
|
||||
@@ -77,7 +79,6 @@ private:
|
||||
std::set<KRTexture *> m_poolTextures;
|
||||
|
||||
long m_textureMemUsed;
|
||||
|
||||
|
||||
void rotateBuffers();
|
||||
void balanceTextureMemory();
|
||||
|
||||
Reference in New Issue
Block a user