summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2016-05-04 23:53:46 +0100
committerJose Fonseca <jfonseca@vmware.com>2016-05-04 23:53:46 +0100
commit8e0a030ddc1257de3b1d2e602548383fcdbd0ce9 (patch)
treeae9175dea7320ecba5387346c31159b228021b41
parent701202aff05205b15b2fe91e43d39f70ec4b2d5d (diff)
glretrace: Cache current program/pipeline objects.
We were already using cached program on call lists. This changes generalizes to outside call lists and pipelines. This avoids glGetInteger calls on traces with lots of glUniform calls.
-rw-r--r--retrace/glretrace.hpp8
-rw-r--r--retrace/glretrace.py41
-rwxr-xr-xretrace/glretrace_main.cpp4
3 files changed, 24 insertions, 29 deletions
diff --git a/retrace/glretrace.hpp b/retrace/glretrace.hpp
index 7843c63c..c60a74db 100644
--- a/retrace/glretrace.hpp
+++ b/retrace/glretrace.hpp
@@ -67,7 +67,13 @@ public:
// Bound drawable
glws::Drawable *drawable = nullptr;
- GLuint activeProgram = 0;
+ // Active program (unswizzled) for profiling
+ GLuint currentUserProgram = 0;
+
+ // Current program (swizzled) for uniform swizzling
+ GLuint currentProgram = 0;
+ GLuint currentPipeline = 0;
+
bool insideBeginEnd = false;
bool insideList = false;
bool needsFlush = false;
diff --git a/retrace/glretrace.py b/retrace/glretrace.py
index 161ea8b3..fd6d6a8c 100644
--- a/retrace/glretrace.py
+++ b/retrace/glretrace.py
@@ -266,12 +266,6 @@ class GlRetracer(Retracer):
print r' retrace::warning(call) << "failed to get mapped pointer\n";'
print r' }'
- if function.name in ('glBindProgramPipeline', 'glBindProgramPipelineEXT'):
- # Note if glBindProgramPipeline has ever been called
- print r' if (pipeline) {'
- print r' _pipelineHasBeenBound = true;'
- print r' }'
-
if function.name.startswith('glCopyImageSubData'):
print r' if (srcTarget == GL_RENDERBUFFER || dstTarget == GL_RENDERBUFFER) {'
print r' retrace::warning(call) << " renderbuffer targets unsupported (https://github.com/apitrace/apitrace/issues/404)\n";'
@@ -289,10 +283,15 @@ class GlRetracer(Retracer):
function.name.startswith('glDispatchCompute')
)
- # Keep track of active program for call lists
+ # Keep track of current program/pipeline
if function.name in ('glUseProgram', 'glUseProgramObjectARB'):
print r' if (currentContext) {'
- print r' currentContext->activeProgram = call.arg(0).toUInt();'
+ print r' currentContext->currentUserProgram = call.arg(0).toUInt();'
+ print r' currentContext->currentProgram = %s;' % function.args[0].name
+ print r' }'
+ if function.name in ('glBindProgramPipeline', 'glBindProgramPipelineEXT'):
+ print r' if (currentContext) {'
+ print r' currentContext->currentPipeline = %s;' % function.args[0].name
print r' }'
# Only profile if not inside a list as the queries get inserted into list
@@ -574,9 +573,7 @@ if __name__ == '__main__':
#include "glproc.hpp"
#include "glretrace.hpp"
#include "glstate.hpp"
-
-
-static bool _pipelineHasBeenBound = false;
+#include "glsize.hpp"
static GLint
@@ -597,18 +594,13 @@ _getActiveProgram(void)
{
GLint program = -1;
glretrace::Context *currentContext = glretrace::getCurrentContext();
- if (currentContext && currentContext->insideList) {
- // glUseProgram & glUseProgramObjectARB are display-list-able
- program = _program_map[currentContext->activeProgram];
- } else {
- GLint pipeline = 0;
- if (_pipelineHasBeenBound) {
- glGetIntegerv(GL_PROGRAM_PIPELINE_BINDING, &pipeline);
- }
+ if (currentContext) {
+ GLint pipeline = currentContext->currentPipeline;
if (pipeline) {
glGetProgramPipelineiv(pipeline, GL_ACTIVE_PROGRAM, &program);
} else {
- glGetIntegerv(GL_CURRENT_PROGRAM, &program);
+ program = currentContext->currentProgram;
+ assert(program == _glGetInteger(GL_CURRENT_PROGRAM));
}
}
return program;
@@ -627,15 +619,12 @@ _validateActiveProgram(trace::Call &call)
return;
}
- GLint pipeline = 0;
- if (_pipelineHasBeenBound) {
- glGetIntegerv(GL_PROGRAM_PIPELINE_BINDING, &pipeline);
- }
+ GLint pipeline = currentContext->currentPipeline;
if (pipeline) {
// TODO
} else {
- GLint program = 0;
- glGetIntegerv(GL_CURRENT_PROGRAM, &program);
+ GLint program = currentContext->currentProgram;
+ assert(program == _glGetInteger(GL_CURRENT_PROGRAM));
if (!program) {
return;
}
diff --git a/retrace/glretrace_main.cpp b/retrace/glretrace_main.cpp
index 92c22750..a7688e8e 100755
--- a/retrace/glretrace_main.cpp
+++ b/retrace/glretrace_main.cpp
@@ -280,7 +280,7 @@ beginProfile(trace::Call &call, bool isDraw) {
}
if (isLastPass() && curMetricBackend) {
Context *currentContext = getCurrentContext();
- GLuint program = currentContext ? currentContext->activeProgram : 0;
+ GLuint program = currentContext ? currentContext->currentUserProgram : 0;
unsigned eventId = profilingBoundariesIndex[QUERY_BOUNDARY_CALL]++;
ProfilerCall::data callData = {false,
call.no,
@@ -305,7 +305,7 @@ beginProfile(trace::Call &call, bool isDraw) {
query.isDraw = isDraw;
query.call = call.no;
query.sig = call.sig;
- query.program = currentContext ? currentContext->activeProgram : 0;
+ query.program = currentContext ? currentContext->currentUserProgram : 0;
glGenQueries(NUM_QUERIES, query.ids);