From 6946d5fddddd5f94c405614cef8f39c627d89146 Mon Sep 17 00:00:00 2001 From: PeterLValve Date: Mon, 31 Mar 2014 17:08:31 -0700 Subject: [PATCH] UI: Improved support for shared contexts and viewing shared state objects * 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 | 149 ++++++++------ src/vogleditor/vogleditor.h | 3 + .../vogleditor_qframebufferexplorer.cpp | 193 ++++++++++-------- .../vogleditor_qframebufferexplorer.h | 12 +- .../vogleditor_qprogramexplorer.cpp | 22 +- src/vogleditor/vogleditor_qprogramexplorer.h | 5 +- src/vogleditor/vogleditor_qshaderexplorer.cpp | 22 +- src/vogleditor/vogleditor_qshaderexplorer.h | 5 +- .../vogleditor_qtextureexplorer.cpp | 58 +++++- src/vogleditor/vogleditor_qtextureexplorer.h | 9 +- 10 files changed, 324 insertions(+), 154 deletions(-) diff --git a/src/vogleditor/vogleditor.cpp b/src/vogleditor/vogleditor.cpp index c609a5f..c7e0ff9 100644 --- a/src/vogleditor/vogleditor.cpp +++ b/src/vogleditor/vogleditor.cpp @@ -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(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(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(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(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(*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 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(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(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(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(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(*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(index.internalPointer()); diff --git a/src/vogleditor/vogleditor.h b/src/vogleditor/vogleditor.h index 647877e..c4be73c 100644 --- a/src/vogleditor/vogleditor.h +++ b/src/vogleditor/vogleditor.h @@ -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); diff --git a/src/vogleditor/vogleditor_qframebufferexplorer.cpp b/src/vogleditor/vogleditor_qframebufferexplorer.cpp index d24dde7..d4d9b2c 100644 --- a/src/vogleditor/vogleditor_qframebufferexplorer.cpp +++ b/src/vogleditor/vogleditor_qframebufferexplorer.cpp @@ -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 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 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(*iter); - if (pState->get_snapshot_handle() == framebufferHandle) + vogl_framebuffer_container container = ui->framebufferObjectListbox->itemData(index).value(); + 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) { diff --git a/src/vogleditor/vogleditor_qframebufferexplorer.h b/src/vogleditor/vogleditor_qframebufferexplorer.h index b275a34..3ece145 100644 --- a/src/vogleditor/vogleditor_qframebufferexplorer.h +++ b/src/vogleditor/vogleditor_qframebufferexplorer.h @@ -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 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 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 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); diff --git a/src/vogleditor/vogleditor_qprogramexplorer.cpp b/src/vogleditor/vogleditor_qprogramexplorer.cpp index 1e7d610..c5dc70e 100644 --- a/src/vogleditor/vogleditor_qprogramexplorer.cpp +++ b/src/vogleditor/vogleditor_qprogramexplorer.cpp @@ -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 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) diff --git a/src/vogleditor/vogleditor_qprogramexplorer.h b/src/vogleditor/vogleditor_qprogramexplorer.h index 1a04f38..de871e9 100644 --- a/src/vogleditor/vogleditor_qprogramexplorer.h +++ b/src/vogleditor/vogleditor_qprogramexplorer.h @@ -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_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 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); diff --git a/src/vogleditor/vogleditor_qshaderexplorer.cpp b/src/vogleditor/vogleditor_qshaderexplorer.cpp index c1f267f..e80c5e0 100644 --- a/src/vogleditor/vogleditor_qshaderexplorer.cpp +++ b/src/vogleditor/vogleditor_qshaderexplorer.cpp @@ -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 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(); } diff --git a/src/vogleditor/vogleditor_qshaderexplorer.h b/src/vogleditor/vogleditor_qshaderexplorer.h index 00933d6..ceeb7a7 100644 --- a/src/vogleditor/vogleditor_qshaderexplorer.h +++ b/src/vogleditor/vogleditor_qshaderexplorer.h @@ -5,6 +5,7 @@ #include "vogl_core.h" +class vogl_context_snapshot; class vogl_gl_object_state; typedef vogl::vector 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 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 diff --git a/src/vogleditor/vogleditor_qtextureexplorer.cpp b/src/vogleditor/vogleditor_qtextureexplorer.cpp index 5a656d5..6249e02 100644 --- a/src/vogleditor/vogleditor_qtextureexplorer.cpp +++ b/src/vogleditor/vogleditor_qtextureexplorer.cpp @@ -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 @@ -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 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 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(*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) diff --git a/src/vogleditor/vogleditor_qtextureexplorer.h b/src/vogleditor/vogleditor_qtextureexplorer.h index 617871a..f9a2647 100644 --- a/src/vogleditor/vogleditor_qtextureexplorer.h +++ b/src/vogleditor/vogleditor_qtextureexplorer.h @@ -7,6 +7,7 @@ #include "vogleditor_qtextureviewer.h" class vogl_gl_object_state; +class vogl_context_snapshot; typedef vogl::vector 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 sharingContexts); + uint set_renderbuffer_objects(vogl::vector 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); -- 2.43.0