Allow to save current GPU query string to apitrace
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "modes/profile_world.hpp"
|
||||
#include "graphics/sp/sp_base.hpp"
|
||||
#include "graphics/gl_headers.hpp"
|
||||
#include "graphics/glwrap.hpp"
|
||||
#include "graphics/graphics_restrictions.hpp"
|
||||
@@ -254,6 +255,19 @@ void CentralVideoSettings::init()
|
||||
UserConfigParams::m_max_texture_size = 256;
|
||||
}
|
||||
}
|
||||
#ifndef ANDROID
|
||||
if (SP::sp_apitrace && hasGLExtension("GL_KHR_debug"))
|
||||
{
|
||||
Log::info("IrrDriver", "Writing GPU query strings to apitrace and"
|
||||
" disable buffer storage");
|
||||
hasBufferStorage = false;
|
||||
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
SP::sp_apitrace = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,9 @@ extern "C" {
|
||||
#elif defined(USE_GLES2)
|
||||
# define __gl2_h_
|
||||
# include <GLES3/gl3.h>
|
||||
#ifndef ANDROID
|
||||
# include <GLES3/gl32.h>
|
||||
#endif
|
||||
# include <GLES3/gl3ext.h>
|
||||
# include <GLES2/gl2ext.h>
|
||||
# define glVertexAttribDivisorARB glVertexAttribDivisor
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "graphics/central_settings.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/shaders.hpp"
|
||||
#include "graphics/sp/sp_base.hpp"
|
||||
#include "utils/profiler.hpp"
|
||||
#include "utils/cpp2011.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
@@ -191,6 +192,15 @@ void initGL()
|
||||
|
||||
ScopedGPUTimer::ScopedGPUTimer(GPUTimer &t) : timer(t)
|
||||
{
|
||||
#ifndef ANDROID
|
||||
if (SP::sp_apitrace)
|
||||
{
|
||||
std::string msg = timer.getName();
|
||||
msg += " begin";
|
||||
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 100,
|
||||
GL_DEBUG_SEVERITY_NOTIFICATION, -1, msg.c_str());
|
||||
}
|
||||
#endif
|
||||
if (!UserConfigParams::m_profiler_enabled) return;
|
||||
if (profiler.isFrozen()) return;
|
||||
if (!timer.canSubmitQuery) return;
|
||||
@@ -205,6 +215,15 @@ ScopedGPUTimer::ScopedGPUTimer(GPUTimer &t) : timer(t)
|
||||
}
|
||||
ScopedGPUTimer::~ScopedGPUTimer()
|
||||
{
|
||||
#ifndef ANDROID
|
||||
if (SP::sp_apitrace)
|
||||
{
|
||||
std::string msg = timer.getName();
|
||||
msg += " end";
|
||||
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 100,
|
||||
GL_DEBUG_SEVERITY_NOTIFICATION, -1, msg.c_str());
|
||||
}
|
||||
#endif
|
||||
if (!UserConfigParams::m_profiler_enabled) return;
|
||||
if (profiler.isFrozen()) return;
|
||||
if (!timer.canSubmitQuery) return;
|
||||
@@ -214,7 +233,8 @@ ScopedGPUTimer::~ScopedGPUTimer()
|
||||
#endif
|
||||
}
|
||||
|
||||
GPUTimer::GPUTimer() : initialised(false), lastResult(0), canSubmitQuery(true)
|
||||
GPUTimer::GPUTimer(const char* name)
|
||||
: initialised(false), lastResult(0), canSubmitQuery(true), m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -56,9 +56,11 @@ class GPUTimer
|
||||
bool initialised;
|
||||
unsigned lastResult;
|
||||
bool canSubmitQuery;
|
||||
const char* m_name;
|
||||
public:
|
||||
GPUTimer();
|
||||
GPUTimer(const char* name);
|
||||
unsigned elapsedTimeus();
|
||||
const char* getName() const { return m_name; }
|
||||
};
|
||||
|
||||
class VertexUtils
|
||||
|
||||
@@ -98,7 +98,33 @@ using namespace irr;
|
||||
IrrDriver *irr_driver = NULL;
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
GPUTimer m_perf_query[Q_LAST];
|
||||
GPUTimer* m_perf_query[Q_LAST];
|
||||
static const char* m_perf_query_phase[Q_LAST] =
|
||||
{
|
||||
"Shadows Cascade 0",
|
||||
"Shadows Cascade 1",
|
||||
"Shadows Cascade 2",
|
||||
"Shadows Cascade 3",
|
||||
"Solid Pass",
|
||||
"Env Map",
|
||||
"SunLight",
|
||||
"PointLights",
|
||||
"SSAO",
|
||||
"Light Scatter",
|
||||
"Glow",
|
||||
"Combine Diffuse Color",
|
||||
"Skybox",
|
||||
"Transparent",
|
||||
"Particles",
|
||||
"Depth of Field",
|
||||
"Godrays",
|
||||
"Bloom",
|
||||
"Tonemap",
|
||||
"Motion Blur",
|
||||
"Lightning",
|
||||
"MLAA",
|
||||
"GUI",
|
||||
};
|
||||
#endif
|
||||
|
||||
const int MIN_SUPPORTED_HEIGHT = 768;
|
||||
@@ -143,6 +169,12 @@ IrrDriver::IrrDriver()
|
||||
m_recording = false;
|
||||
m_sun_interposer = NULL;
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
for (unsigned i = 0; i < Q_LAST; i++)
|
||||
{
|
||||
m_perf_query[i] = new GPUTimer(m_perf_query_phase[i]);
|
||||
}
|
||||
#endif
|
||||
} // IrrDriver
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -156,12 +188,25 @@ IrrDriver::~IrrDriver()
|
||||
STKTexManager::getInstance()->kill();
|
||||
delete m_wind;
|
||||
delete m_renderer;
|
||||
#ifndef SERVER_ONLY
|
||||
for (unsigned i = 0; i < Q_LAST; i++)
|
||||
{
|
||||
delete m_perf_query[i];
|
||||
}
|
||||
#endif
|
||||
assert(m_device != NULL);
|
||||
m_device->drop();
|
||||
m_device = NULL;
|
||||
m_modes.clear();
|
||||
} // ~IrrDriver
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
const char* IrrDriver::getGPUQueryPhaseName(unsigned q)
|
||||
{
|
||||
assert(q < Q_LAST);
|
||||
return m_perf_query_phase[q];
|
||||
} // getGPUQueryPhaseName
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Called before a race is started, after all cameras are set up.
|
||||
*/
|
||||
@@ -184,7 +229,7 @@ core::array<video::IRenderTarget> &IrrDriver::getMainSetup()
|
||||
|
||||
GPUTimer &IrrDriver::getGPUTimer(unsigned i)
|
||||
{
|
||||
return m_perf_query[i];
|
||||
return *m_perf_query[i];
|
||||
} // getGPUTimer
|
||||
#endif
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -281,6 +281,7 @@ public:
|
||||
void printRenderStats();
|
||||
void requestScreenshot();
|
||||
class GPUTimer &getGPUTimer(unsigned);
|
||||
const char* getGPUQueryPhaseName(unsigned);
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
std::unique_ptr<RenderTarget> createRenderTarget(const irr::core::dimension2du &dimension,
|
||||
|
||||
@@ -67,6 +67,8 @@ std::array<float, 16>* g_joint_ptr = NULL;
|
||||
// ----------------------------------------------------------------------------
|
||||
bool sp_culling = true;
|
||||
// ----------------------------------------------------------------------------
|
||||
bool sp_apitrace = false;
|
||||
// ----------------------------------------------------------------------------
|
||||
bool sp_debug_view = false;
|
||||
// ----------------------------------------------------------------------------
|
||||
bool g_handle_shadow = false;
|
||||
|
||||
@@ -93,6 +93,7 @@ extern unsigned sp_shadow_poly_count;
|
||||
extern int sp_cur_shadow_cascade;
|
||||
extern bool sp_culling;
|
||||
extern bool sp_debug_view;
|
||||
extern bool sp_apitrace;
|
||||
extern unsigned sp_cur_player;
|
||||
extern unsigned sp_cur_buf_id[MAX_PLAYER_COUNT];
|
||||
extern irr::core::vector3df sp_wind_dir;
|
||||
|
||||
10
src/main.cpp
10
src/main.cpp
@@ -189,6 +189,7 @@
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "graphics/particle_kind_manager.hpp"
|
||||
#include "graphics/referee.hpp"
|
||||
#include "graphics/sp/sp_base.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/event_handler.hpp"
|
||||
#include "guiengine/dialog_queue.hpp"
|
||||
@@ -630,6 +631,9 @@ void cmdLineHelp()
|
||||
" Takes precedence over trilinear or bilinear\n"
|
||||
" texture filtering.\n"
|
||||
" --shadows=n Set resolution of shadows (0 to disable).\n"
|
||||
" --apitrace This will disable buffer storage and\n"
|
||||
" writing gpu query strings to opengl, which\n"
|
||||
" can be seen later in apitrace.\n"
|
||||
"\n"
|
||||
"You can visit SuperTuxKart's homepage at "
|
||||
"https://supertuxkart.net\n\n",
|
||||
@@ -708,6 +712,12 @@ int handleCmdLinePreliminary()
|
||||
UserConfigParams::m_verbosity |= UserConfigParams::LOG_ALL;
|
||||
if(CommandLine::has("--online"))
|
||||
MainMenuScreen::m_enable_online=true;
|
||||
#ifndef ANDROID
|
||||
if(CommandLine::has("--apitrace"))
|
||||
{
|
||||
SP::sp_apitrace = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string s;
|
||||
if(CommandLine::has("--stk-config", &s))
|
||||
|
||||
@@ -35,33 +35,6 @@
|
||||
#include <stack>
|
||||
#include <sstream>
|
||||
|
||||
static const char* GPU_Phase[Q_LAST] =
|
||||
{
|
||||
"Shadows Cascade 0",
|
||||
"Shadows Cascade 1",
|
||||
"Shadows Cascade 2",
|
||||
"Shadows Cascade 3",
|
||||
"Solid Pass",
|
||||
"Env Map",
|
||||
"SunLight",
|
||||
"PointLights",
|
||||
"SSAO",
|
||||
"Light Scatter",
|
||||
"Glow",
|
||||
"Combine Diffuse Color",
|
||||
"Skybox",
|
||||
"Transparent",
|
||||
"Particles",
|
||||
"Depth of Field",
|
||||
"Godrays",
|
||||
"Bloom",
|
||||
"Tonemap",
|
||||
"Motion Blur",
|
||||
"Lightning",
|
||||
"MLAA",
|
||||
"GUI",
|
||||
};
|
||||
|
||||
Profiler profiler;
|
||||
|
||||
// Unit is in pencentage of the screen dimensions
|
||||
@@ -486,7 +459,7 @@ void Profiler::draw()
|
||||
if (hovered_gpu_marker != Q_LAST)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << GPU_Phase[hovered_gpu_marker] << " : "
|
||||
oss << irr_driver->getGPUQueryPhaseName(hovered_gpu_marker) << " : "
|
||||
<< hovered_gpu_marker_elapsed << " us";
|
||||
font->draw(oss.str().c_str(), GPU_MARKERS_NAMES_POS,
|
||||
video::SColor(0xFF, 0xFF, 0x00, 0x00));
|
||||
@@ -590,7 +563,7 @@ void Profiler::writeToFile()
|
||||
|
||||
for (unsigned i = 0; i < Q_LAST; i++)
|
||||
{
|
||||
f_gpu << "\"" << GPU_Phase[i] << "(" << i+1 << ")\" ";
|
||||
f_gpu << "\"" << irr_driver->getGPUQueryPhaseName(i) << "(" << i+1 << ")\" ";
|
||||
} // for i < Q_LAST
|
||||
f_gpu << std::endl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user