From 3773dd6d029d7fa804e782f4a7d5c5722b635af9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 13 Apr 2011 10:54:19 +0100 Subject: [PATCH] Linearize the shaders source in JSON. GL shaders appear with all sort of topologies, which makes very hard for the gui to handle. Instead simply provide a linearized view of the shaders source. The shader parameters will be passed separately. PS: May be do this for textures too. --- glstate.py | 63 ++++++++++++++++++++------------------------ gui/apitracecall.cpp | 4 +-- 2 files changed, 30 insertions(+), 37 deletions(-) diff --git a/glstate.py b/glstate.py index e142f6b..7bd658b 100644 --- a/glstate.py +++ b/glstate.py @@ -3080,36 +3080,31 @@ writeShader(JSONWriter &json, GLuint shader) delete [] source; } -''' - # programs - print 'static inline void' - print 'writeProgram(JSONWriter &json, GLuint program)' - print '{' - print ' if (!program) {' - print ' json.writeNull();' - print ' return;' - print ' }' - print - print ' json.beginObject();' - print ' json.beginMember("attached_shaders");' - print ' GLint attached_shaders = 0;' - print ' glGetProgramiv(program, GL_ATTACHED_SHADERS, &attached_shaders);' - print ' json.beginObject();' - print ' if (attached_shaders) {' - print ' GLuint *shaders = new GLuint[attached_shaders];' - print ' GLsizei count = 0;' - print ' glGetAttachedShaders(program, attached_shaders, &count, shaders);' - print ' for (GLsizei i = 0; i < count; ++ i) {' - print ' writeShader(json, shaders[i]);' - print ' }' - print ' delete [] shaders;' - print ' }' - print ' json.endObject();' - print ' json.endMember();' - print ' json.endObject();' - print '}' - print +static inline void +writeCurrentProgram(JSONWriter &json) +{ + GLint program = 0; + glGetIntegerv(GL_CURRENT_PROGRAM, &program); + if (!program) { + return; + } + + GLint attached_shaders = 0; + glGetProgramiv(program, GL_ATTACHED_SHADERS, &attached_shaders); + if (!attached_shaders) { + return; + } + + GLuint *shaders = new GLuint[attached_shaders]; + GLsizei count = 0; + glGetAttachedShaders(program, attached_shaders, &count, shaders); + for (GLsizei i = 0; i < count; ++ i) { + writeShader(json, shaders[i]); + } + delete [] shaders; +} +''' # texture image print ''' @@ -3316,11 +3311,11 @@ writeDrawBufferImage(JSONWriter &json, GLenum format) print def dump_current_program(self): - print ' GLint current_program = 0;' - print ' glGetIntegerv(GL_CURRENT_PROGRAM, ¤t_program);' - print ' json.beginMember("current_program");' - print ' writeProgram(json, current_program);' - print ' json.endMember();' + print ' json.beginMember("shaders");' + print ' json.beginObject();' + print ' writeCurrentProgram(json);' + print ' json.endObject();' + print ' json.endMember(); //shaders' print def dump_textures(self): diff --git a/gui/apitracecall.cpp b/gui/apitracecall.cpp index 871dfde..2d28e16 100644 --- a/gui/apitracecall.cpp +++ b/gui/apitracecall.cpp @@ -430,10 +430,8 @@ ApiTraceState::ApiTraceState() ApiTraceState::ApiTraceState(const QVariantMap &parsedJson) { m_parameters = parsedJson[QLatin1String("parameters")].toMap(); - QVariantMap currentProgram = - parsedJson[QLatin1String("current_program")].toMap(); QVariantMap attachedShaders = - currentProgram[QLatin1String("attached_shaders")].toMap(); + parsedJson[QLatin1String("shaders")].toMap(); QVariantMap::const_iterator itr; -- 2.43.0