]> git.cworth.org Git - vogl/commitdiff
UI: Improved support for shared contexts and viewing shared state objects master
authorPeterLValve <peterl@valvesoftware.com>
Tue, 1 Apr 2014 00:08:31 +0000 (17:08 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 1 Apr 2014 19:37:34 +0000 (12:37 -0700)
* GL state objects that belong to shared contexts can now be visualized if the parent context is current.
* Framebuffer Objects are NOT considered shared state by OpenGL because they reference textures and renderbuffers which ARE shared state objects.

src/vogleditor/vogleditor.cpp
src/vogleditor/vogleditor.h
src/vogleditor/vogleditor_qframebufferexplorer.cpp
src/vogleditor/vogleditor_qframebufferexplorer.h
src/vogleditor/vogleditor_qprogramexplorer.cpp
src/vogleditor/vogleditor_qprogramexplorer.h
src/vogleditor/vogleditor_qshaderexplorer.cpp
src/vogleditor/vogleditor_qshaderexplorer.h
src/vogleditor/vogleditor_qtextureexplorer.cpp
src/vogleditor/vogleditor_qtextureexplorer.h

index c609a5f4e474b9b83a1d67daf4f1d568bd0317ba..c7e0ff9508ead46a52a4e87e9e790bacc4f5c6ee 100644 (file)
@@ -1504,69 +1504,104 @@ void VoglEditor::update_ui_for_snapshot(vogleditor_gl_state_snapshot* pStateSnap
        if (curContextHandle != 0)
        {
            vogl_context_snapshot* pContext = pStateSnapshot->get_context(curContextHandle);
-
-           // textures
-           vogl_gl_object_state_ptr_vec textureObjects;
-           pContext->get_all_objects_of_category(cGLSTTexture, textureObjects);
-           m_pTextureExplorer->set_texture_objects(textureObjects);
-
-           GLuint curActiveTextureUnit = pContext->get_general_state().get_value<GLuint>(GL_ACTIVE_TEXTURE);
-           if (curActiveTextureUnit >= GL_TEXTURE0 && curActiveTextureUnit < (GL_TEXTURE0 + pContext->get_context_info().get_max_texture_image_units()))
-           {
-               GLuint cur2DBinding = pContext->get_general_state().get_value<GLuint>(GL_TEXTURE_2D_BINDING_EXT, curActiveTextureUnit - GL_TEXTURE0);
-               displayTexture(cur2DBinding, false);
-           }
-           if (textureObjects.size() > 0) { VOGLEDITOR_ENABLE_STATE_TAB(ui->textureTab); }
-
-           // renderbuffers
-           vogl_gl_object_state_ptr_vec renderbufferObjects;
-           pContext->get_all_objects_of_category(cGLSTRenderbuffer, renderbufferObjects);
-           m_pRenderbufferExplorer->set_texture_objects(renderbufferObjects);
-           if (renderbufferObjects.size() > 0) { VOGLEDITOR_ENABLE_STATE_TAB(ui->renderbufferTab); }
-
-           // framebuffer
-           vogl_gl_object_state_ptr_vec framebufferObjects;
-           pContext->get_all_objects_of_category(cGLSTFramebuffer, framebufferObjects);
-           m_pFramebufferExplorer->set_framebuffer_objects(framebufferObjects, *pContext, pStateSnapshot->get_default_framebuffer());
-           GLuint64 curDrawFramebuffer = pContext->get_general_state().get_value<GLuint64>(GL_DRAW_FRAMEBUFFER_BINDING);
-           displayFramebuffer(curDrawFramebuffer, false);
-           if (framebufferObjects.size() > 0) { VOGLEDITOR_ENABLE_STATE_TAB(ui->framebufferTab); }
-
-           // programs
-           vogl_gl_object_state_ptr_vec programObjects;
-           pContext->get_all_objects_of_category(cGLSTProgram, programObjects);
-           m_pProgramExplorer->set_program_objects(programObjects);
-           GLuint64 curProgram = pContext->get_general_state().get_value<GLuint64>(GL_CURRENT_PROGRAM);
-           m_pProgramExplorer->set_active_program(curProgram);
-           if (programObjects.size() > 0) { VOGLEDITOR_ENABLE_STATE_TAB(ui->programTab); }
-
-           // shaders
-           vogl_gl_object_state_ptr_vec shaderObjects;
-           pContext->get_all_objects_of_category(cGLSTShader, shaderObjects);
-           m_pShaderExplorer->set_shader_objects(shaderObjects);
-           if (curProgram != 0)
-           {
-               for (vogl_gl_object_state_ptr_vec::iterator iter = programObjects.begin(); iter != programObjects.end(); iter++)
-               {
-                   if ((*iter)->get_snapshot_handle() == curProgram)
-                   {
-                       vogl_program_state* pProgramState = static_cast<vogl_program_state*>(*iter);
-                       if (pProgramState->get_attached_shaders().size() > 0)
-                       {
-                           uint curShader = pProgramState->get_attached_shaders()[0];
-                           m_pShaderExplorer->set_active_shader(curShader);
-                       }
-                       break;
-                   }
-               }
-           }
-           if (shaderObjects.size() > 0) { VOGLEDITOR_ENABLE_STATE_TAB(ui->shaderTab); }
+           update_ui_for_context(pContext, pStateSnapshot);
        }
    }
 
    this->setCursor(origCursor);
 }
 
+void VoglEditor::update_ui_for_context(vogl_context_snapshot* pContext, vogleditor_gl_state_snapshot* pStateSnapshot)
+{
+    // vogl stores all the created objects in the deepest context, so need to find that context to populate the UI
+    vogl::vector<vogl_context_snapshot*> sharingContexts;
+    sharingContexts.push_back(pContext);
+    vogl_context_snapshot* pRootContext = pContext;
+    vogl_context_snapshot* pTmpContext = NULL;
+    while (pRootContext->get_context_desc().get_trace_share_context() != 0)
+    {
+        pTmpContext = pStateSnapshot->get_context(pRootContext->get_context_desc().get_trace_share_context());
+        VOGL_ASSERT(pTmpContext != NULL);
+        if (pTmpContext == NULL)
+        {
+            // this is a bug
+            break;
+        }
+
+        // update the root context
+        pRootContext = pTmpContext;
+    }
+
+    // add the root context if it is new (ie, not equal the supplied context)
+    if (pRootContext != pContext)
+    {
+        sharingContexts.push_back(pRootContext);
+    }
+
+    // textures
+    m_pTextureExplorer->clear();
+    uint textureCount = m_pTextureExplorer->set_texture_objects(sharingContexts);
+
+    GLuint curActiveTextureUnit = pContext->get_general_state().get_value<GLuint>(GL_ACTIVE_TEXTURE);
+    if (curActiveTextureUnit >= GL_TEXTURE0 && curActiveTextureUnit < (GL_TEXTURE0 + pContext->get_context_info().get_max_texture_image_units()))
+    {
+        GLuint cur2DBinding = pContext->get_general_state().get_value<GLuint>(GL_TEXTURE_2D_BINDING_EXT, curActiveTextureUnit - GL_TEXTURE0);
+        displayTexture(cur2DBinding, false);
+    }
+    if (textureCount > 0) { VOGLEDITOR_ENABLE_STATE_TAB(ui->textureTab); }
+
+    // renderbuffers
+    m_pRenderbufferExplorer->clear();
+    int renderbufferCount = m_pRenderbufferExplorer->set_renderbuffer_objects(sharingContexts);
+    if (renderbufferCount > 0) { VOGLEDITOR_ENABLE_STATE_TAB(ui->renderbufferTab); }
+
+    // framebuffer
+    m_pFramebufferExplorer->clear();
+    uint framebufferCount = m_pFramebufferExplorer->set_framebuffer_objects(pContext, sharingContexts, &(pStateSnapshot->get_default_framebuffer()));
+    GLuint64 curDrawFramebuffer = pContext->get_general_state().get_value<GLuint64>(GL_DRAW_FRAMEBUFFER_BINDING);
+    displayFramebuffer(curDrawFramebuffer, false);
+    if (framebufferCount > 0) { VOGLEDITOR_ENABLE_STATE_TAB(ui->framebufferTab); }
+
+    // programs
+    m_pProgramExplorer->clear();
+    uint programCount = m_pProgramExplorer->set_program_objects(sharingContexts);
+    GLuint64 curProgram = pContext->get_general_state().get_value<GLuint64>(GL_CURRENT_PROGRAM);
+    m_pProgramExplorer->set_active_program(curProgram);
+    if (programCount > 0) { VOGLEDITOR_ENABLE_STATE_TAB(ui->programTab); }
+
+    // shaders
+    m_pShaderExplorer->clear();
+    uint shaderCount = m_pShaderExplorer->set_shader_objects(sharingContexts);
+    if (curProgram != 0)
+    {
+        bool bFound = false;
+        for (uint c = 0; c < sharingContexts.size(); c++)
+        {
+            vogl_gl_object_state_ptr_vec programObjects;
+            sharingContexts[c]->get_all_objects_of_category(cGLSTProgram, programObjects);
+            for (vogl_gl_object_state_ptr_vec::iterator iter = programObjects.begin(); iter != programObjects.end(); iter++)
+            {
+                if ((*iter)->get_snapshot_handle() == curProgram)
+                {
+                    vogl_program_state* pProgramState = static_cast<vogl_program_state*>(*iter);
+                    if (pProgramState->get_attached_shaders().size() > 0)
+                    {
+                        uint curShader = pProgramState->get_attached_shaders()[0];
+                        m_pShaderExplorer->set_active_shader(curShader);
+                    }
+
+                    bFound = true;
+                    break;
+                }
+            }
+
+            if (bFound)
+                break;
+        }
+    }
+    if (shaderCount > 0) { VOGLEDITOR_ENABLE_STATE_TAB(ui->shaderTab); }
+}
+
 void VoglEditor::on_stateTreeView_clicked(const QModelIndex &index)
 {
    vogleditor_stateTreeItem* pStateItem = static_cast<vogleditor_stateTreeItem*>(index.internalPointer());
index 647877eb9e539209732258850c131ca8d97c5ca3..c4be73cee078480143cbd2bfe5976698a9bf261a 100644 (file)
@@ -133,6 +133,9 @@ private:
    void reset_snapshot_ui();
 
    void update_ui_for_snapshot(vogleditor_gl_state_snapshot *pStateSnapshot);
+
+   void update_ui_for_context(vogl_context_snapshot* pContext, vogleditor_gl_state_snapshot *pStateSnapshot);
+
    void displayMachineInfoHelper(QString prefix, const QString& sectionKeyStr, const vogl::json_value& value, QString& rMachineInfoStr);
    void displayMachineInfo();
    void recursive_update_snapshot_flags(vogleditor_apiCallTreeItem* pItem, bool& bFoundEditedSnapshot);
index d24dde7c4dda4a4292b01335b7ac114490ee948a..d4d9b2cdb5c28fb23130f8806c2783d470d9c7f7 100644 (file)
@@ -42,6 +42,7 @@ vogleditor_QFramebufferExplorer::vogleditor_QFramebufferExplorer(QWidget *parent
 
 vogleditor_QFramebufferExplorer::~vogleditor_QFramebufferExplorer()
 {
+    clear();
     delete ui;
 
     delete m_colorExplorerLayout;
@@ -57,6 +58,8 @@ vogleditor_QFramebufferExplorer::~vogleditor_QFramebufferExplorer()
 
 void vogleditor_QFramebufferExplorer::clear()
 {
+    m_objects.clear();
+    m_sharing_contexts.clear();
     ui->framebufferObjectListbox->clear();
 
     clearViewers();
@@ -78,20 +81,46 @@ void vogleditor_QFramebufferExplorer::clearViewers()
     m_viewers.clear();
 }
 
-void vogleditor_QFramebufferExplorer::set_framebuffer_objects(vogl_gl_object_state_ptr_vec objects, vogl_context_snapshot& context, vogl_default_framebuffer_state& defaultFramebufferState)
+uint vogleditor_QFramebufferExplorer::set_framebuffer_objects(vogl_context_snapshot* pContext, vogl::vector<vogl_context_snapshot*> sharingContexts, vogl_default_framebuffer_state* pDefaultFramebufferState)
 {
     clear();
 
-    m_context = &context;
-    m_objects = objects;
-    m_pDefaultFramebufferState = &defaultFramebufferState;
+    m_sharing_contexts = sharingContexts;
+
+    uint framebufferCount = 0;
+
+    framebufferCount += set_default_framebuffer(pDefaultFramebufferState);
+
+    // framebuffers are not shared state objects, but they can reference shared objects,
+    // so only add the framebuffers from the main context
+    vogl_gl_object_state_ptr_vec framebufferObjects;
+    pContext->get_all_objects_of_category(cGLSTFramebuffer, framebufferObjects);
+    framebufferCount += add_framebuffer_objects(sharingContexts, framebufferObjects);
+
+    return framebufferCount;
+}
+
+uint vogleditor_QFramebufferExplorer::set_default_framebuffer(vogl_default_framebuffer_state* pDefaultFramebufferState)
+{
+    int numAdded = 0;
+    if (pDefaultFramebufferState != NULL)
+    {
+        m_pDefaultFramebufferState = pDefaultFramebufferState;
+
+        // add default framebuffer
+        vogl_framebuffer_container defaultContainer;
+        defaultContainer.index = 0;
+        defaultContainer.pFBOState = NULL;
+        defaultContainer.pDefaultFBState = m_pDefaultFramebufferState;
+        ui->framebufferObjectListbox->addItem("Framebuffer 0 - (default framebuffer)", QVariant::fromValue(defaultContainer));
+        numAdded = 1;
+    }
+    return numAdded;
+}
 
-    // add default framebuffer
-    vogl_framebuffer_container defaultContainer;
-    defaultContainer.index = 0;
-    defaultContainer.pFBOState = NULL;
-    defaultContainer.pDefaultFBState = m_pDefaultFramebufferState;
-    ui->framebufferObjectListbox->addItem("Framebuffer 0 - (default framebuffer)", QVariant::fromValue(defaultContainer));
+uint vogleditor_QFramebufferExplorer::add_framebuffer_objects(vogl::vector<vogl_context_snapshot*> sharingContexts, vogl_gl_object_state_ptr_vec objects)
+{
+    m_objects.append(objects);
 
     // add framebuffer objects
     QString valueStr;
@@ -106,20 +135,28 @@ void vogleditor_QFramebufferExplorer::set_framebuffer_objects(vogl_gl_object_sta
             const vogl_framebuffer_attachment* pAttachment = &(pState->get_attachments().begin()->second);
             if (pAttachment->get_type() == GL_TEXTURE)
             {
-                vogl_texture_state* pTexState = this->get_texture_attachment(NULL, pAttachment->get_handle());
-                if (pTexState != NULL)
+                for (uint c = 0; c < sharingContexts.size(); c++)
                 {
-                    width = pTexState->get_texture().get_width();
-                    height = pTexState->get_texture().get_height();
+                    vogl_texture_state* pTexState = this->get_texture_attachment(*(sharingContexts[c]), pAttachment->get_handle());
+                    if (pTexState != NULL)
+                    {
+                        width = pTexState->get_texture().get_width();
+                        height = pTexState->get_texture().get_height();
+                        break;
+                    }
                 }
             }
             else if (pAttachment->get_type() == GL_RENDERBUFFER)
             {
-                vogl_renderbuffer_state* pRbState = this->get_renderbuffer_attachment(NULL, pAttachment->get_handle());
-                if (pRbState != NULL)
+                for (uint c = 0; c < sharingContexts.size(); c++)
                 {
-                    width = pRbState->get_texture().get_texture().get_width();
-                    height = pRbState->get_texture().get_texture().get_height();
+                    vogl_renderbuffer_state* pRbState = this->get_renderbuffer_attachment(*(sharingContexts[c]), pAttachment->get_handle());
+                    if (pRbState != NULL)
+                    {
+                        width = pRbState->get_texture().get_texture().get_width();
+                        height = pRbState->get_texture().get_texture().get_height();
+                        break;
+                    }
                 }
             }
 
@@ -130,13 +167,15 @@ void vogleditor_QFramebufferExplorer::set_framebuffer_objects(vogl_gl_object_sta
             valueStr = valueStr.sprintf("Framebuffer %" PRIu64 " - %d attachments", pState->get_snapshot_handle(), pState->get_attachments().size());
         }
 
-        vogl_framebuffer_container defaultContainer;
-        defaultContainer.index = 0;
-        defaultContainer.pFBOState = pState;
-        defaultContainer.pDefaultFBState = NULL;
+        vogl_framebuffer_container container;
+        container.index = ui->framebufferObjectListbox->count();
+        container.pFBOState = pState;
+        container.pDefaultFBState = NULL;
 
-        ui->framebufferObjectListbox->addItem(valueStr, QVariant::fromValue(defaultContainer));
+        ui->framebufferObjectListbox->addItem(valueStr, QVariant::fromValue(container));
     }
+
+    return objects.size();
 }
 
 bool vogleditor_QFramebufferExplorer::set_active_framebuffer(unsigned long long framebufferHandle)
@@ -150,18 +189,16 @@ bool vogleditor_QFramebufferExplorer::set_active_framebuffer(unsigned long long
     }
     else
     {
-        int index = 1;
-        for (vogl_gl_object_state_ptr_vec::iterator iter = m_objects.begin(); iter != m_objects.end(); iter++)
+        for (int index = 0; index < ui->framebufferObjectListbox->count(); index++)
         {
-            vogl_framebuffer_state* pState = static_cast<vogl_framebuffer_state*>(*iter);
-            if (pState->get_snapshot_handle() == framebufferHandle)
+            vogl_framebuffer_container container = ui->framebufferObjectListbox->itemData(index).value<vogl_framebuffer_container>();
+            vogl_framebuffer_state* pState = container.pFBOState;
+            if (pState != NULL && pState->get_snapshot_handle() == framebufferHandle)
             {
                 ui->framebufferObjectListbox->setCurrentIndex(index);
                 bDisplayedFramebuffer = true;
                 break;
             }
-
-            ++index;
         }
     }
     return bDisplayedFramebuffer;
@@ -226,59 +263,61 @@ void vogleditor_QFramebufferExplorer::selectedFramebufferIndexChanged(int index)
         vogl_framebuffer_state* pState = container.pFBOState;
         if (pState != NULL)
         {
-            vogl_gl_object_state_ptr_vec textureVec;
-            m_context->get_all_objects_of_category(cGLSTTexture, textureVec);
-
-            vogl_gl_object_state_ptr_vec renderbufferVec;
-            m_context->get_all_objects_of_category(cGLSTRenderbuffer, renderbufferVec);
-
             const vogl_framebuffer_state::GLenum_to_attachment_map& rAttachments = pState->get_attachments();
             for (vogl_framebuffer_state::GLenum_to_attachment_map::const_iterator iter = rAttachments.begin(); iter != rAttachments.end(); iter++)
             {
                 const vogl_framebuffer_attachment* pAttachment = &(iter->second);
                 if (pAttachment->get_type() == GL_TEXTURE)
                 {
-                    vogl_texture_state* pTexState = this->get_texture_attachment(&textureVec, pAttachment->get_handle());
-                    if (pTexState != NULL)
+                    for (uint c = 0; c < m_sharing_contexts.size(); c++)
                     {
-                        if (iter->first == GL_DEPTH_ATTACHMENT ||
-                            iter->first == GL_DEPTH)
+                        vogl_texture_state* pTexState = this->get_texture_attachment(*(m_sharing_contexts[c]), pAttachment->get_handle());
+                        if (pTexState != NULL)
                         {
-                            depthVec.push_back(pTexState);
-                        }
-                        else if (iter->first == GL_STENCIL_ATTACHMENT ||
-                                 iter->first == GL_STENCIL)
-                        {
-                            stencilVec.push_back(pTexState);
-                        }
-                        else
-                        {
-                            colorVec.push_back(pTexState);
-
-                            ADD_COLOR_BUFFER_VIEWER
+                            if (iter->first == GL_DEPTH_ATTACHMENT ||
+                                iter->first == GL_DEPTH)
+                            {
+                                depthVec.push_back(pTexState);
+                            }
+                            else if (iter->first == GL_STENCIL_ATTACHMENT ||
+                                     iter->first == GL_STENCIL)
+                            {
+                                stencilVec.push_back(pTexState);
+                            }
+                            else
+                            {
+                                colorVec.push_back(pTexState);
+
+                                ADD_COLOR_BUFFER_VIEWER
+                            }
+                            break;
                         }
                     }
                 }
                 else if (pAttachment->get_type() == GL_RENDERBUFFER)
                 {
-                    vogl_renderbuffer_state* pRbState = this->get_renderbuffer_attachment(&renderbufferVec, pAttachment->get_handle());
-                    if (pRbState != NULL)
+                    for (uint c = 0; c < m_sharing_contexts.size(); c++)
                     {
-                        if (iter->first == GL_DEPTH_ATTACHMENT ||
-                            iter->first == GL_DEPTH)
-                        {
-                            depthVec.push_back(pRbState);
-                        }
-                        else if (iter->first == GL_STENCIL_ATTACHMENT ||
-                                 iter->first == GL_STENCIL)
-                        {
-                            stencilVec.push_back(pRbState);
-                        }
-                        else
+                        vogl_renderbuffer_state* pRbState = this->get_renderbuffer_attachment(*(m_sharing_contexts[c]), pAttachment->get_handle());
+                        if (pRbState != NULL)
                         {
-                            colorVec.push_back(pRbState);
-
-                            ADD_COLOR_BUFFER_VIEWER
+                            if (iter->first == GL_DEPTH_ATTACHMENT ||
+                                iter->first == GL_DEPTH)
+                            {
+                                depthVec.push_back(pRbState);
+                            }
+                            else if (iter->first == GL_STENCIL_ATTACHMENT ||
+                                     iter->first == GL_STENCIL)
+                            {
+                                stencilVec.push_back(pRbState);
+                            }
+                            else
+                            {
+                                colorVec.push_back(pRbState);
+
+                                ADD_COLOR_BUFFER_VIEWER
+                            }
+                            break;
                         }
                     }
                 }
@@ -359,17 +398,13 @@ void vogleditor_QFramebufferExplorer::selectedFramebufferIndexChanged(int index)
     }
 }
 
-vogl_texture_state* vogleditor_QFramebufferExplorer::get_texture_attachment(vogl_gl_object_state_ptr_vec* pObjectVec, unsigned int handle)
+vogl_texture_state* vogleditor_QFramebufferExplorer::get_texture_attachment(vogl_context_snapshot& context, unsigned int handle)
 {
     vogl_gl_object_state_ptr_vec textureVec;
-    if (pObjectVec == NULL)
-    {
-        m_context->get_all_objects_of_category(cGLSTTexture, textureVec);
-        pObjectVec = &textureVec;
-    }
+    context.get_all_objects_of_category(cGLSTTexture, textureVec);
 
     vogl_texture_state* pTexState = NULL;
-    for (vogl_gl_object_state_ptr_vec::iterator texIter = pObjectVec->begin(); texIter != pObjectVec->end(); texIter++)
+    for (vogl_gl_object_state_ptr_vec::iterator texIter = textureVec.begin(); texIter != textureVec.end(); texIter++)
     {
         if ((*texIter)->get_snapshot_handle() == handle)
         {
@@ -381,17 +416,13 @@ vogl_texture_state* vogleditor_QFramebufferExplorer::get_texture_attachment(vogl
     return pTexState;
 }
 
-vogl_renderbuffer_state* vogleditor_QFramebufferExplorer::get_renderbuffer_attachment(vogl_gl_object_state_ptr_vec* pObjectVec, unsigned int handle)
+vogl_renderbuffer_state* vogleditor_QFramebufferExplorer::get_renderbuffer_attachment(vogl_context_snapshot& context, unsigned int handle)
 {
     vogl_gl_object_state_ptr_vec renderbufferVec;
-    if (pObjectVec == NULL)
-    {
-        m_context->get_all_objects_of_category(cGLSTRenderbuffer, renderbufferVec);
-        pObjectVec = &renderbufferVec;
-    }
+    context.get_all_objects_of_category(cGLSTRenderbuffer, renderbufferVec);
 
     vogl_renderbuffer_state* pRenderbufferState = NULL;
-    for (vogl_gl_object_state_ptr_vec::iterator texIter = pObjectVec->begin(); texIter != pObjectVec->end(); texIter++)
+    for (vogl_gl_object_state_ptr_vec::iterator texIter = renderbufferVec.begin(); texIter != renderbufferVec.end(); texIter++)
     {
         if ((*texIter)->get_snapshot_handle() == handle)
         {
index b275a34efe9151a4d8c405d8e1d82e37a27ca44e..3ece145cf8f244ba4a3a59c64accfe5759c55a5a 100644 (file)
@@ -29,7 +29,7 @@ public:
     explicit vogleditor_QFramebufferExplorer(QWidget *parent = 0);
     ~vogleditor_QFramebufferExplorer();
 
-    void set_framebuffer_objects(vogl_gl_object_state_ptr_vec objects, vogl_context_snapshot& context, vogl_default_framebuffer_state& defaultFramebufferState);
+    uint set_framebuffer_objects(vogl_context_snapshot* pContext, vogl::vector<vogl_context_snapshot*> sharingContexts, vogl_default_framebuffer_state *pDefaultFramebufferState);
 
     bool set_active_framebuffer(unsigned long long framebufferHandle);
 
@@ -44,12 +44,16 @@ private:
     QVBoxLayout* m_stencilExplorerLayout;
     vogleditor_QTextureExplorer* m_depthExplorer;
     vogleditor_QTextureExplorer* m_stencilExplorer;
-    vogl_context_snapshot* m_context;
+    vogl::vector<vogl_context_snapshot*> m_sharing_contexts;
     vogl_default_framebuffer_state* m_pDefaultFramebufferState;
 
     void clearViewers();
-    vogl_texture_state* get_texture_attachment(vogl_gl_object_state_ptr_vec* pObjectVec, unsigned int handle);
-    vogl_renderbuffer_state* get_renderbuffer_attachment(vogl_gl_object_state_ptr_vec* pObjectVec, unsigned int handle);
+
+    uint set_default_framebuffer(vogl_default_framebuffer_state* pDefaultFramebufferState);
+    uint add_framebuffer_objects(vogl::vector<vogl_context_snapshot*> sharingContexts, vogl_gl_object_state_ptr_vec objects);
+
+    vogl_texture_state* get_texture_attachment(vogl_context_snapshot& context, unsigned int handle);
+    vogl_renderbuffer_state* get_renderbuffer_attachment(vogl_context_snapshot &context, unsigned int handle);
 
 private slots:
     void selectedFramebufferIndexChanged(int index);
index 1e7d6104c1e3349f3bd399bdbadca93d4a35116f..c5dc70e1debfefcda9c8793c28af92367c1f4136 100644 (file)
@@ -2,6 +2,7 @@
 #include "ui_vogleditor_qprogramexplorer.h"
 
 #include "vogl_gl_object.h"
+#include "vogl_gl_state_snapshot.h"
 #include "vogl_program_state.h"
 
 Q_DECLARE_METATYPE(vogl_program_state*);
@@ -29,10 +30,25 @@ void vogleditor_QProgramExplorer::clear()
     ui->shaderTextEdit->clear();
 }
 
-void vogleditor_QProgramExplorer::set_program_objects(vogl_gl_object_state_ptr_vec objects)
+uint vogleditor_QProgramExplorer::set_program_objects(vogl::vector<vogl_context_snapshot*> sharingContexts)
 {
     clear();
-    m_objects = objects;
+
+    uint programCount = 0;
+    for (uint c = 0; c < sharingContexts.size(); c++)
+    {
+        vogl_gl_object_state_ptr_vec programObjects;
+        sharingContexts[c]->get_all_objects_of_category(cGLSTProgram, programObjects);
+
+        programCount += add_program_objects(programObjects);
+    }
+
+    return programCount;
+}
+
+uint vogleditor_QProgramExplorer::add_program_objects(vogl_gl_object_state_ptr_vec objects)
+{
+    m_objects.append(objects);
 
     for (vogl_gl_object_state_ptr_vec::iterator iter = objects.begin(); iter != objects.end(); iter++)
     {
@@ -50,6 +66,8 @@ void vogleditor_QProgramExplorer::set_program_objects(vogl_gl_object_state_ptr_v
             VOGL_ASSERT(!"Unhandled object type in vogleditor_QProgramExplorer");
         }
     }
+
+    return objects.size();
 }
 
 bool vogleditor_QProgramExplorer::set_active_program(unsigned long long programHandle)
index 1a04f38360da3e54bd09a190219b9cbf680e9ffb..de871e9b3006b69a2660c928b6c9ab84e143abb9 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "vogl_core.h"
 
+class vogl_context_snapshot;
 class vogl_gl_object_state;
 class vogl_program_state;
 typedef vogl::vector<vogl_gl_object_state *> vogl_gl_object_state_ptr_vec;
@@ -23,7 +24,7 @@ public:
 
     void clear();
 
-    void set_program_objects(vogl_gl_object_state_ptr_vec objects);
+    uint set_program_objects(vogl::vector<vogl_context_snapshot*> sharingContexts);
 
     bool set_active_program(unsigned long long programHandle);
 
@@ -40,6 +41,8 @@ private:
     Ui::vogleditor_QProgramExplorer *ui;
     vogl_gl_object_state_ptr_vec m_objects;
 
+    uint add_program_objects(vogl_gl_object_state_ptr_vec objects);
+
 signals:
     void program_edited(vogl_program_state* pNewProgramState);
 
index c1f267f93c33146d94d91fca3334ea2c67da6970..e80c5e04d19572c4feaee193b41d22bd1f887012 100644 (file)
@@ -2,6 +2,7 @@
 #include "ui_vogleditor_qshaderexplorer.h"
 
 #include "vogl_gl_object.h"
+#include "vogl_gl_state_snapshot.h"
 #include "vogl_shader_state.h"
 
 Q_DECLARE_METATYPE(vogl_shader_state*);
@@ -24,10 +25,25 @@ void vogleditor_QShaderExplorer::clear()
     ui->shaderTextEdit->clear();
 }
 
-void vogleditor_QShaderExplorer::set_shader_objects(vogl_gl_object_state_ptr_vec objects)
+uint vogleditor_QShaderExplorer::set_shader_objects(vogl::vector<vogl_context_snapshot*> sharingContexts)
 {
     clear();
-    m_objects = objects;
+
+    uint shaderCount = 0;
+    for (uint c = 0; c < sharingContexts.size(); c++)
+    {
+        vogl_gl_object_state_ptr_vec shaderObjects;
+        sharingContexts[c]->get_all_objects_of_category(cGLSTShader, shaderObjects);
+
+        shaderCount += add_shader_objects(shaderObjects);
+    }
+
+    return shaderCount;
+}
+
+uint vogleditor_QShaderExplorer::add_shader_objects(vogl_gl_object_state_ptr_vec objects)
+{
+    m_objects.append(objects);
 
     for (vogl_gl_object_state_ptr_vec::iterator iter = objects.begin(); iter != objects.end(); iter++)
     {
@@ -45,6 +61,8 @@ void vogleditor_QShaderExplorer::set_shader_objects(vogl_gl_object_state_ptr_vec
             VOGL_ASSERT(!"Unhandled object type in vogleditor_QShaderExplorer");
         }
     }
+
+    return m_objects.size();
 }
 
 
index 00933d62dc1fd7cdf1ce7a462ca0f5d0f1c432eb..ceeb7a72baf3623d06461129608241d97b777a18 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "vogl_core.h"
 
+class vogl_context_snapshot;
 class vogl_gl_object_state;
 typedef vogl::vector<vogl_gl_object_state *> vogl_gl_object_state_ptr_vec;
 
@@ -22,7 +23,7 @@ public:
 
     void clear();
 
-    void set_shader_objects(vogl_gl_object_state_ptr_vec objects);
+    uint set_shader_objects(vogl::vector<vogl_context_snapshot*> sharingContexts);
 
     bool set_active_shader(unsigned long long shaderHandle);
 
@@ -32,6 +33,8 @@ private slots:
 private:
     Ui::vogleditor_QShaderExplorer *ui;
     vogl_gl_object_state_ptr_vec m_objects;
+
+    uint add_shader_objects(vogl_gl_object_state_ptr_vec objects);
 };
 
 #endif // VOGLEDITOR_QSHADEREXPLORER_H
index 5a656d59b425f5e5669e7adcc01490f87a2e388c..6249e02cf2cf424e8d7b556134367185c0929644 100644 (file)
@@ -2,6 +2,7 @@
 #include "ui_vogleditor_qtextureexplorer.h"
 
 #include "vogl_gl_object.h"
+#include "vogl_gl_state_snapshot.h"
 #include "vogl_texture_state.h"
 #include "vogl_renderbuffer_state.h"
 #include <QColorDialog>
@@ -49,11 +50,14 @@ vogleditor_QTextureExplorer::vogleditor_QTextureExplorer(QWidget *parent) :
 
 vogleditor_QTextureExplorer::~vogleditor_QTextureExplorer()
 {
+    clear();
     delete ui;
 }
 
 void vogleditor_QTextureExplorer::clear()
 {
+    m_objects.clear();
+
     ui->textureObjectListbox->clear();
 
     m_textureViewer.clear();
@@ -71,13 +75,56 @@ unsigned int vogleditor_QTextureExplorer::get_preferred_height() const
     return m_textureViewer.get_preferred_height() + ui->textureObjectListbox->height() * 2 + 50;
 }
 
-void vogleditor_QTextureExplorer::set_texture_objects(vogl_gl_object_state_ptr_vec objects)
+uint vogleditor_QTextureExplorer::set_texture_objects(vogl::vector<vogl_context_snapshot*> sharingContexts)
+{
+    clear();
+
+    uint textureCount = 0;
+
+    for (uint c = 0; c < sharingContexts.size(); c++)
+    {
+        vogl_gl_object_state_ptr_vec textureObjects;
+        sharingContexts[c]->get_all_objects_of_category(cGLSTTexture, textureObjects);
+
+        textureCount += add_texture_objects(textureObjects);
+    }
+
+    return textureCount;
+}
+
+uint vogleditor_QTextureExplorer::set_renderbuffer_objects(vogl::vector<vogl_context_snapshot*> sharingContexts)
+{
+    clear();
+
+    uint textureCount = 0;
+
+    for (uint c = 0; c < sharingContexts.size(); c++)
+    {
+        vogl_gl_object_state_ptr_vec renderbufferObjects;
+        sharingContexts[c]->get_all_objects_of_category(cGLSTRenderbuffer, renderbufferObjects);
+
+        textureCount += add_texture_objects(renderbufferObjects);
+    }
+
+    return textureCount;
+}
+
+uint vogleditor_QTextureExplorer::set_texture_objects(vogl_gl_object_state_ptr_vec textureObjects)
 {
     clear();
-    m_objects = objects;
 
-    for (vogl_gl_object_state_ptr_vec::iterator iter = objects.begin(); iter != objects.end(); iter++)
+    return add_texture_objects(textureObjects);
+}
+
+uint vogleditor_QTextureExplorer::add_texture_objects(vogl_gl_object_state_ptr_vec textureObjects)
+{
+    uint textureCount = 0;
+
+    for (vogl_gl_object_state_ptr_vec::iterator iter = textureObjects.begin(); iter != textureObjects.end(); iter++)
     {
+        ++textureCount;
+        m_objects.push_back(*iter);
+
         if ((*iter)->get_type() == cGLSTTexture)
         {
             vogl_texture_state* pTexState = static_cast<vogl_texture_state*>(*iter);
@@ -101,9 +148,11 @@ void vogleditor_QTextureExplorer::set_texture_objects(vogl_gl_object_state_ptr_v
             VOGL_ASSERT(!"Unhandled object type in TextureExplorer");
         }
     }
+
+    return textureCount;
 }
 
-void vogleditor_QTextureExplorer::add_texture_object(vogl_texture_state& textureState, vogl::dynamic_string bufferType)
+uint vogleditor_QTextureExplorer::add_texture_object(vogl_texture_state& textureState, vogl::dynamic_string bufferType)
 {
     m_objects.push_back(&textureState);
 
@@ -111,6 +160,7 @@ void vogleditor_QTextureExplorer::add_texture_object(vogl_texture_state& texture
     valueStr = valueStr.sprintf("%s (%u x %u) %s", bufferType.c_str(), textureState.get_texture().get_width(), textureState.get_texture().get_height(), g_gl_enums.find_name(textureState.get_texture().get_ogl_internal_fmt()));
 
     ui->textureObjectListbox->addItem(valueStr, QVariant::fromValue((vogl_gl_object_state*)&textureState));
+    return 1;
 }
 
 bool vogleditor_QTextureExplorer::set_active_texture(unsigned long long textureHandle)
index 617871aa2b1d027349ae1d6cd44e311fe1de4976..f9a26472dfaf673284d52ae0c5a5ade1e793f2d3 100644 (file)
@@ -7,6 +7,7 @@
 #include "vogleditor_qtextureviewer.h"
 
 class vogl_gl_object_state;
+class vogl_context_snapshot;
 typedef vogl::vector<vogl_gl_object_state *> vogl_gl_object_state_ptr_vec;
 
 class vogl_texture_state;
@@ -23,8 +24,10 @@ public:
     explicit vogleditor_QTextureExplorer(QWidget *parent = 0);
     ~vogleditor_QTextureExplorer();
 
-    void set_texture_objects(vogl_gl_object_state_ptr_vec objects);
-    void add_texture_object(vogl_texture_state& textureState, vogl::dynamic_string bufferType);
+    uint set_texture_objects(vogl::vector<vogl_context_snapshot*> sharingContexts);
+    uint set_renderbuffer_objects(vogl::vector<vogl_context_snapshot*> sharingContexts);
+    uint set_texture_objects(vogl_gl_object_state_ptr_vec objects);
+    uint add_texture_object(vogl_texture_state& textureState, vogl::dynamic_string bufferType);
 
     bool set_active_texture(unsigned long long textureHandle);
 
@@ -39,6 +42,8 @@ private:
     vogl_gl_object_state_ptr_vec m_objects;
     QTextureViewer m_textureViewer;
 
+    uint add_texture_objects(vogl_gl_object_state_ptr_vec objects);
+
 private slots:
     void selectedTextureIndexChanged(int index);
     void channelSelectionChanged(int index);