From 84ce12907199d0a7eb581b06de1d47e716fbd68b Mon Sep 17 00:00:00 2001 From: Mark Janes Date: Mon, 30 Oct 2017 15:00:04 -0700 Subject: State: track glGetProgramResourceName Used by gfxbench5 aztec benchmark to identify uniform locations. --- retrace/daemon/gldispatch/glframe_glhelper.cpp | 18 ++++++++++++++++++ retrace/daemon/gldispatch/glframe_glhelper.hpp | 3 +++ retrace/daemon/glframe_state.cpp | 21 +++++++++++++++++++++ retrace/daemon/glframe_state.hpp | 1 + 4 files changed, 43 insertions(+) (limited to 'retrace') diff --git a/retrace/daemon/gldispatch/glframe_glhelper.cpp b/retrace/daemon/gldispatch/glframe_glhelper.cpp index 09b5c01b..74b728b8 100644 --- a/retrace/daemon/gldispatch/glframe_glhelper.cpp +++ b/retrace/daemon/gldispatch/glframe_glhelper.cpp @@ -81,6 +81,7 @@ static void *pEndPerfQueryINTEL = NULL; static void *pGetPerfQueryDataINTEL = NULL; static void *pGetProgramiv = NULL; static void *pGetProgramInfoLog = NULL; +static void *pGetProgramResourceName = NULL; static void *pGetBooleanv = NULL; static void *pGetFloatv = NULL; static void *pBlendColor = NULL; @@ -251,6 +252,8 @@ GlFunctions::Init(void *lookup_fn) { assert(pGetProgramiv); pGetProgramInfoLog = _GetProcAddress("glGetProgramInfoLog"); assert(pGetProgramInfoLog); + pGetProgramResourceName = _GetProcAddress("glGetProgramResourceName"); + assert(pGetProgramResourceName); pGetBooleanv = _GetProcAddress("glGetBooleanv"); assert(pGetBooleanv); pGetFloatv = _GetProcAddress("glGetFloatv"); @@ -645,6 +648,21 @@ GlFunctions::GetProgramInfoLog(GLuint program, GLsizei bufSize, length, infoLog); } +void +GlFunctions::GetProgramResourceName(GLuint program, GLenum programInterface, + GLuint index, GLsizei bufSize, + GLsizei *length, GLchar *name) { + typedef void (*GETPROGRAMRESOURCENAME)(GLuint program, + GLenum programInterface, + GLuint index, GLsizei bufSize, + GLsizei *length, GLchar *name); + ((GETPROGRAMRESOURCENAME) pGetProgramResourceName)(program, + programInterface, + index, bufSize, + length, name); +} + + void GlFunctions::GetBooleanv(GLenum pname, GLboolean *params) { typedef void (*GETBOOLEANV)(GLenum pname, GLboolean *params); diff --git a/retrace/daemon/gldispatch/glframe_glhelper.hpp b/retrace/daemon/gldispatch/glframe_glhelper.hpp index ad9d2aa8..ec441266 100644 --- a/retrace/daemon/gldispatch/glframe_glhelper.hpp +++ b/retrace/daemon/gldispatch/glframe_glhelper.hpp @@ -112,6 +112,9 @@ class GlFunctions { static void GetProgramiv(GLuint program, GLenum pname, GLint *params); static void GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + static void GetProgramResourceName(GLuint program, GLenum programInterface, + GLuint index, GLsizei bufSize, + GLsizei *length, GLchar *name); static void GetBooleanv(GLenum pname, GLboolean *params); static void GetFloatv(GLenum pname, GLfloat *params); diff --git a/retrace/daemon/glframe_state.cpp b/retrace/daemon/glframe_state.cpp index 93d5c5b9..3176a2ee 100644 --- a/retrace/daemon/glframe_state.cpp +++ b/retrace/daemon/glframe_state.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include "GL/gl.h" #include "GL/glext.h" @@ -74,6 +75,7 @@ StateTrack::TrackMap::TrackMap() { lookup["glBindAttribLocation"] = &StateTrack::trackBindAttribLocation; lookup["glGetAttribLocation"] = &StateTrack::trackGetAttribLocation; lookup["glGetUniformLocation"] = &StateTrack::trackGetUniformLocation; + lookup["glGetProgramResourceName"] = &StateTrack::trackGetProgramResourceName; lookup["glGetUniformBlockIndex"] = &StateTrack::trackGetUniformBlockIndex; lookup["glUniformBlockBinding"] = &StateTrack::trackUniformBlockBinding; lookup["glBindFragDataLocation"] = &StateTrack::trackBindFragDataLocation; @@ -773,6 +775,25 @@ StateTrack::trackGetUniformLocation(const Call &call) { m_program_to_uniform_name[program][location] = name; } +void +StateTrack::trackGetProgramResourceName(const Call &call) { + const int call_program = call.args[0].value->toDouble(); + const int program = glretrace::getRetracedProgram(call_program); + const int programInterface = call.args[1].value->toDouble(); + const int index = call.args[2].value->toDouble(); + const int bufSize = call.args[3].value->toDouble(); + + GLsizei length; + std::vector name(bufSize); + GlFunctions::GetProgramResourceName(program, + programInterface, + index, + bufSize, + &length, + name.data()); + m_program_to_uniform_name[program][index] = name.data(); +} + void StateTrack::trackGetUniformBlockIndex(const trace::Call &call) { const int call_index = call.ret->toDouble(); diff --git a/retrace/daemon/glframe_state.hpp b/retrace/daemon/glframe_state.hpp index 993b897a..456723d0 100644 --- a/retrace/daemon/glframe_state.hpp +++ b/retrace/daemon/glframe_state.hpp @@ -145,6 +145,7 @@ class StateTrack { void trackBindAttribLocation(const trace::Call &); void trackGetAttribLocation(const trace::Call &); void trackGetUniformLocation(const trace::Call &); + void trackGetProgramResourceName(const trace::Call &); void trackGetUniformBlockIndex(const trace::Call &); void trackUniformBlockBinding(const trace::Call &); void trackBindFragDataLocation(const trace::Call &); -- cgit v1.2.3