summaryrefslogtreecommitdiff
path: root/retrace/glretrace_main.cpp
diff options
context:
space:
mode:
authorAlexander Trukhin <alxtry@gmail.com>2015-06-29 21:13:48 +0300
committerAlexander Trukhin <alxtry@gmail.com>2015-08-26 15:46:51 +0300
commit87a07779ecc48249046d000ec87a57fd15112ff4 (patch)
tree258edba3bfdf6d19e3626b33e36bc945ace6f163 /retrace/glretrace_main.cpp
parent019b38bf3dfde02cf5319122f6113c342d2e0620 (diff)
retrace,glretrace: Profiling options. Hook up the abstraction.
New options: "glretrace --pframes=SELECTION_STRING", "glretrace --pdrawcalls=SELECTION_STRING", "glretrace --pcalls=SELECTION_STRING". Each option is for profiling corresponding boundary (frames, draw calls or all calls). Profiling is done with the backends in glretrace::metricBackends and metrics selected in them (via enableMetric() backend interface call). Selection strings are parsed in enableMetricsFromCLI(). Backends are used in series. For each backend required number of passes is evaluated. It does not work with old profiling options. Format for SELECTION_STRING: --pdrawcalls="backend1:metric1,metric2,metric3;backend2:metric1,metric2" Where metric1 is either [groupId, metricId] or metricName Example: --pframes="GL_AMD_performance_monitor: [0,4], [1,5], VS_INVOCATION_COUNT; GL_INTEL_performance_query: [1,2]"
Diffstat (limited to 'retrace/glretrace_main.cpp')
-rwxr-xr-xretrace/glretrace_main.cpp80
1 files changed, 79 insertions, 1 deletions
diff --git a/retrace/glretrace_main.cpp b/retrace/glretrace_main.cpp
index f68b0791..d4aa14c8 100755
--- a/retrace/glretrace_main.cpp
+++ b/retrace/glretrace_main.cpp
@@ -218,6 +218,16 @@ flushQueries() {
void
beginProfile(trace::Call &call, bool isDraw) {
+ if (retrace::profilingWithBackends) {
+ if (profilingBoundaries[QUERY_BOUNDARY_CALL] ||
+ profilingBoundaries[QUERY_BOUNDARY_DRAWCALL]) {
+ if (curMetricBackend) {
+ curMetricBackend->beginQuery(isDraw ? QUERY_BOUNDARY_DRAWCALL : QUERY_BOUNDARY_CALL);
+ }
+ }
+ return;
+ }
+
glretrace::Context *currentContext = glretrace::getCurrentContext();
/* Create call query */
@@ -261,6 +271,15 @@ beginProfile(trace::Call &call, bool isDraw) {
void
endProfile(trace::Call &call, bool isDraw) {
+ if (retrace::profilingWithBackends) {
+ if (profilingBoundaries[QUERY_BOUNDARY_CALL] ||
+ profilingBoundaries[QUERY_BOUNDARY_DRAWCALL]) {
+ if (curMetricBackend) {
+ curMetricBackend->endQuery(isDraw ? QUERY_BOUNDARY_DRAWCALL : QUERY_BOUNDARY_CALL);
+ }
+ }
+ return;
+ }
/* CPU profiling for all calls */
if (retrace::profilingCpuTimes) {
@@ -418,11 +437,56 @@ initContext() {
getCurrentRss(currentRss);
retrace::profiler.setBaseRssUsage(currentRss);
}
+
+ if (retrace::profilingWithBackends) {
+ if (!metricBackendsSetup) {
+ if (retrace::profilingCallsMetricsString) {
+ enableMetricsFromCLI(retrace::profilingCallsMetricsString,
+ QUERY_BOUNDARY_CALL);
+ }
+ if (retrace::profilingFramesMetricsString) {
+ enableMetricsFromCLI(retrace::profilingFramesMetricsString,
+ QUERY_BOUNDARY_FRAME);
+ }
+ if (retrace::profilingDrawCallsMetricsString) {
+ enableMetricsFromCLI(retrace::profilingDrawCallsMetricsString,
+ QUERY_BOUNDARY_DRAWCALL);
+ }
+ unsigned numPasses = 0;
+ for (auto &b : metricBackends) {
+ b->generatePasses();
+ numPasses += b->getNumPasses();
+ }
+ retrace::numPasses = numPasses > 0 ? numPasses : 1;
+ metricBackendsSetup = 1;
+ }
+
+ unsigned numPasses = 0;
+ for (auto &b : metricBackends) {
+ numPasses += b->getNumPasses();
+ if (retrace::curPass < numPasses) {
+ curMetricBackend = b;
+ b->beginPass(); // begin pass
+ break;
+ }
+ }
+
+ if (profilingBoundaries[QUERY_BOUNDARY_FRAME]) {
+ if (curMetricBackend) {
+ curMetricBackend->beginQuery(QUERY_BOUNDARY_FRAME);
+ }
+ }
+ }
}
void
frame_complete(trace::Call &call) {
- if (retrace::profiling) {
+ if (retrace::profilingWithBackends) {
+ if (curMetricBackend) {
+ curMetricBackend->endQuery(QUERY_BOUNDARY_FRAME);
+ }
+ }
+ else if (retrace::profiling) {
/* Complete any remaining queries */
flushQueries();
@@ -444,6 +508,10 @@ frame_complete(trace::Call &call) {
!currentDrawable->visible) {
retrace::warning(call) << "could not infer drawable size (glViewport never called)\n";
}
+
+ if (curMetricBackend) {
+ curMetricBackend->beginQuery(QUERY_BOUNDARY_FRAME);
+ }
}
@@ -660,10 +728,20 @@ retrace::flushRendering(void) {
void
retrace::finishRendering(void) {
+ if (profilingWithBackends && glretrace::curMetricBackend) {
+ (glretrace::curMetricBackend)->endQuery(QUERY_BOUNDARY_FRAME);
+ }
+
glretrace::Context *currentContext = glretrace::getCurrentContext();
if (currentContext) {
glFinish();
}
+
+ if (retrace::profilingWithBackends) {
+ if (glretrace::curMetricBackend) {
+ (glretrace::curMetricBackend)->endPass();
+ }
+ }
}
void