]> git.cworth.org Git - vogl/commitdiff
Merge branch 'master' of https://github.com/ValveSoftware/vogl
authorPeterLValve <peterl@valvesoftware.com>
Thu, 27 Mar 2014 00:57:53 +0000 (17:57 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 1 Apr 2014 19:37:33 +0000 (12:37 -0700)
src/vogleditor/vogleditor.cpp
src/vogleditor/vogleditor_output.cpp
src/vogleditor/vogleditor_output.h
src/vogleditor/vogleditor_statetreecontextgeneralitem.cpp
src/vogleditor/vogleditor_tracereplayer.cpp
src/vogleditor/vogleditor_tracereplayer.h

index 14da0b21bb299dfc72045a939d0257c173001c9f..c609a5f4e474b9b83a1d67daf4f1d568bd0317ba 100644 (file)
@@ -323,16 +323,10 @@ void VoglEditor::playCurrentTraceFile()
     m_pPlayButton->setEnabled(false);
     m_pTrimButton->setEnabled(false);
 
-    if (m_traceReplayer.replay(m_pTraceReader, m_pApiCallTreeModel->root(), NULL, 0, true))
-    {
-        // replay was successful
-        m_pPlayButton->setEnabled(true);
-        m_pTrimButton->setEnabled(true);
-    }
-    else
-    {
-        vogleditor_output_error("Failed to replay the trace.");
-    }
+    m_traceReplayer.replay(m_pTraceReader, m_pApiCallTreeModel->root(), NULL, 0, true);
+
+    m_pPlayButton->setEnabled(true);
+    m_pTrimButton->setEnabled(true);
 
     setCursor(origCursor);
 }
@@ -1522,6 +1516,7 @@ void VoglEditor::update_ui_for_snapshot(vogleditor_gl_state_snapshot* pStateSnap
                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;
@@ -1535,6 +1530,7 @@ void VoglEditor::update_ui_for_snapshot(vogleditor_gl_state_snapshot* pStateSnap
            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;
index c96a06dc8420cab88ca414f3518409863d5b35f0..0c08f18f8864934daa1f7345719f98f4999e0f33 100644 (file)
@@ -1,6 +1,8 @@
 #include "vogleditor_output.h"
 #include <QTextEdit>
 
+vogleditor_output gs_OUTPUT;
+
 vogleditor_output::vogleditor_output()
 {
 }
@@ -21,17 +23,16 @@ void vogleditor_output::warning(const char* pWarning)
 {
     if (m_pTextEdit != NULL)
     {
-        m_pTextEdit->append("Warning: ");
-        m_pTextEdit->append(pWarning);
+        QString msg = QString("Warning: %1").arg(pWarning);
+        m_pTextEdit->append(msg);
     }
 }
 
-
 void vogleditor_output::error(const char* pError)
 {
     if (m_pTextEdit != NULL)
     {
-        m_pTextEdit->append("ERROR: ");
-        m_pTextEdit->append(pError);
+        QString msg = QString("ERROR: %1").arg(pError);
+        m_pTextEdit->append(msg);
     }
 }
index bbeec1c5425b7be8163ca0fcf5cb50caf2a9a5e7..e3c13e077db9195b4f85e9e54b68289a5a3aae03 100644 (file)
@@ -19,7 +19,7 @@ private:
     QTextEdit* m_pTextEdit;
 };
 
-static vogleditor_output gs_OUTPUT;
+extern vogleditor_output gs_OUTPUT;
 
 static void vogleditor_output_init(QTextEdit* pTextEdit) { gs_OUTPUT.init(pTextEdit); }
 static void vogleditor_output_message(const char* pMessage) { gs_OUTPUT.message(pMessage); }
index 06622bb703b299cc9e17b71588293919ca60997d..d891a023e4669b8914b2bd11fd863e6e4a17e4bf 100644 (file)
@@ -71,6 +71,11 @@ vogleditor_stateTreeContextGeneralItem::vogleditor_stateTreeContextGeneralItem(Q
     float fVals[16];
     int iVals[16];
     bool bVals[4];
+
+    memset(fVals, 0, sizeof(fVals));
+    memset(iVals, 0, sizeof(iVals));
+    memset(bVals, 0, sizeof(bVals));
+
     QString tmp;
 
 #define GET_PTR(name, num) if (generalState.get<int>(name, 0, iVals, num)) { vogleditor_stateTreeStateVecPtrItem* pPtrItem = new vogleditor_stateTreeStateVecPtrItem(#name, name, 0, generalState, iVals, num, false, this); this->m_diffableItems.push_back(pPtrItem); this->appendChild(pPtrItem); }
@@ -95,6 +100,14 @@ vogleditor_stateTreeContextGeneralItem::vogleditor_stateTreeContextGeneralItem(Q
             pNode->appendChild(pIntItem); }\
     } pNode->setValue(tmp.sprintf("[%d]", pNode->childCount())); this->appendChild(pNode);}
 
+#define GET_INDEXED_BOOL(name, num, totalIndices) if (totalIndices > 0) {vogleditor_stateTreeItem* pNode = new vogleditor_stateTreeItem(#name, "", this);\
+    for (int i = 0; i < totalIndices; i++) {\
+        if (generalState.get<bool>(name, i, bVals, num, true)) {\
+            vogleditor_stateTreeStateVecBoolItem* pBoolItem = new vogleditor_stateTreeStateVecBoolItem(STR_INT(i), name, i, generalState, &(bVals[i]), num, true, pNode);\
+            this->m_diffableItems.push_back(pBoolItem);\
+            pNode->appendChild(pBoolItem); }\
+    } pNode->setValue(tmp.sprintf("[%d]", pNode->childCount())); this->appendChild(pNode);}
+
     // Start of version 1.0 - 2.1
     GET_INT(GL_ACCUM_ALPHA_BITS, 1);
     GET_INT(GL_ACCUM_BLUE_BITS, 1);
@@ -117,6 +130,8 @@ vogleditor_stateTreeContextGeneralItem::vogleditor_stateTreeContextGeneralItem(Q
     GET_INT(GL_AUX_BUFFERS, 1);
 
     GET_BOOL(GL_BLEND, 1);
+    int maxDrawBuffers = info.get_max_draw_buffers();
+    GET_INDEXED_BOOL(GL_BLEND, 1, maxDrawBuffers);
     GET_FLOAT(GL_BLEND_COLOR, 4);
     GET_ENUM(GL_BLEND_DST, 1);
     GET_ENUM(GL_BLEND_DST_ALPHA, 1);
@@ -698,4 +713,5 @@ vogleditor_stateTreeContextGeneralItem::vogleditor_stateTreeContextGeneralItem(Q
 #undef GET_FLOAT
 #undef GET_MATRIX
 #undef GET_INDEXED_INT
+#undef GET_INDEXED_BOOL
 }
index c7d826bd4cc65661c5f6d7c0c03dc501bd6cc8f0..bb3ba4329f6b0fb4d47e7649c7e097fedccd8f05 100644 (file)
@@ -6,7 +6,7 @@
 #include "vogl_find_files.h"
 #include "vogl_file_utils.h"
 #include "vogl_gl_replayer.h"
-
+#include "vogleditor_output.h"
 
 vogleditor_traceReplayer::vogleditor_traceReplayer()
     : m_pTraceReplayer(vogl_new(vogl_gl_replayer))
@@ -107,7 +107,7 @@ bool vogleditor_traceReplayer::applying_snapshot_and_process_resize(const vogl_g
     bool bStatus = true;
     while (status == vogl_gl_replayer::cStatusResizeWindow)
     {
-        vogl_warning_printf("%s: Waiting for window to resize\n", VOGL_METHOD_NAME);
+        vogleditor_output_message("Waiting for replay window to resize.");
 
         // Pump X events in case the window is resizing
         if (process_x_events())
@@ -123,17 +123,16 @@ bool vogleditor_traceReplayer::applying_snapshot_and_process_resize(const vogl_g
 
     if (bStatus && status != vogl_gl_replayer::cStatusOK)
     {
-        vogl_error_printf("%s: Replay unable to apply snapshot\n", VOGL_FUNCTION_NAME);
+        vogleditor_output_error("Replay unable to apply snapshot");
         bStatus = false;
     }
 
     return bStatus;
 }
 
-bool vogleditor_traceReplayer::recursive_replay_apicallTreeItem(vogleditor_apiCallTreeItem* pItem, vogleditor_gl_state_snapshot** ppNewSnapshot, uint64_t apiCallNumber)
+vogleditor_tracereplayer_result vogleditor_traceReplayer::recursive_replay_apicallTreeItem(vogleditor_apiCallTreeItem* pItem, vogleditor_gl_state_snapshot** ppNewSnapshot, uint64_t apiCallNumber)
 {
-    bool bStatus = true;
-
+    vogleditor_tracereplayer_result result = VOGLEDITOR_TRR_SUCCESS;
     vogleditor_apiCallItem* pApiCall = pItem->apiCallItem();
     if (pApiCall != NULL)
     {
@@ -145,8 +144,7 @@ bool vogleditor_traceReplayer::recursive_replay_apicallTreeItem(vogleditor_apiCa
         while (m_pTraceReplayer->get_has_pending_window_resize() || m_pTraceReplayer->get_pending_apply_snapshot())
         {
             // Pump X events in case the window is resizing
-            bStatus = process_x_events();
-            if (bStatus)
+            if (process_x_events())
             {
                 status = m_pTraceReplayer->process_pending_window_resize();
                 if (status != vogl_gl_replayer::cStatusResizeWindow)
@@ -155,7 +153,7 @@ bool vogleditor_traceReplayer::recursive_replay_apicallTreeItem(vogleditor_apiCa
             else
             {
                 // most likely the window wants to close, so let's return
-                return false;
+                return VOGLEDITOR_TRR_USER_EXIT;
             }
         }
 
@@ -171,56 +169,69 @@ bool vogleditor_traceReplayer::recursive_replay_apicallTreeItem(vogleditor_apiCa
                // get the snapshot after the selected api call
                if ((!*ppNewSnapshot) && (m_pTraceReplayer->get_last_processed_call_counter() == static_cast<int64_t>(apiCallNumber)))
                {
-                  vogl_printf("Taking snapshot on API call # %" PRIu64 "\n", apiCallNumber);
+                  dynamic_string info;
+                  vogleditor_output_message(info.format("Taking snapshot on API call # %" PRIu64 "...", apiCallNumber).c_str());
 
                   vogl_gl_state_snapshot* pNewSnapshot = m_pTraceReplayer->snapshot_state();
                   if (pNewSnapshot == NULL)
                   {
-                      vogl_error_printf("Taking new snapshot failed!\n");
+                      result = VOGLEDITOR_TRR_ERROR;
+                      vogleditor_output_error("... snapshot failed!");
                   }
                   else
                   {
-                      vogl_printf("Taking snapshot succeeded\n");
+                      result = VOGLEDITOR_TRR_SNAPSHOT_SUCCESS;
+                      vogleditor_output_message("... snapshot succeeded!\n");
                       *ppNewSnapshot = vogl_new(vogleditor_gl_state_snapshot, pNewSnapshot);
                       if (*ppNewSnapshot == NULL)
                       {
-                         vogl_error_printf("Allocating memory for snapshot container failed!\n");
+                         result = VOGLEDITOR_TRR_ERROR;
+                         vogleditor_output_error("Allocating memory for snapshot container failed!");
                          vogl_delete(pNewSnapshot);
                       }
                   }
-
-                  bStatus = false;
                }
             }
         }
         else
         {
             // replaying the trace packet failed, set as error
-            vogl_error_printf("%s: unable to replay gl entrypoint at call %" PRIu64 "\n", VOGL_FUNCTION_NAME, pTrace_packet->get_call_counter());
-            bStatus = false;
+            result = VOGLEDITOR_TRR_ERROR;
+            dynamic_string info;
+            vogleditor_output_error(info.format("Unable to replay gl entrypoint at call %" PRIu64, pTrace_packet->get_call_counter()).c_str());
         }
     }
 
-    if (bStatus && pItem->has_snapshot() && pItem->get_snapshot()->is_edited() && pItem->get_snapshot()->is_valid())
+    if (result == VOGLEDITOR_TRR_SUCCESS && pItem->has_snapshot() && pItem->get_snapshot()->is_edited() && pItem->get_snapshot()->is_valid())
     {
-        bStatus = applying_snapshot_and_process_resize(pItem->get_snapshot()->get_snapshot());
+        if(applying_snapshot_and_process_resize(pItem->get_snapshot()->get_snapshot()))
+        {
+            result = VOGLEDITOR_TRR_SUCCESS;
+        }
     }
 
-    if (bStatus)
+    if (result == VOGLEDITOR_TRR_SUCCESS)
     {
         for (int i = 0; i < pItem->childCount(); i++)
         {
-            bStatus = recursive_replay_apicallTreeItem(pItem->child(i), ppNewSnapshot, apiCallNumber);
+            result = recursive_replay_apicallTreeItem(pItem->child(i), ppNewSnapshot, apiCallNumber);
 
-            if (!bStatus)
+            if (result != VOGLEDITOR_TRR_SUCCESS)
                 break;
+
+            // Pump X events in case the window is resizing
+            if (process_x_events() == false)
+            {
+                // most likely the window wants to close, so let's return
+                return VOGLEDITOR_TRR_USER_EXIT;
+            }
         }
     }
 
-    return bStatus;
+    return result;
 }
 
-bool vogleditor_traceReplayer::replay(vogl_trace_file_reader* m_pTraceReader, vogleditor_apiCallTreeItem* pRootItem, vogleditor_gl_state_snapshot** ppNewSnapshot, uint64_t apiCallNumber, bool endlessMode)
+vogleditor_tracereplayer_result vogleditor_traceReplayer::replay(vogl_trace_file_reader* m_pTraceReader, vogleditor_apiCallTreeItem* pRootItem, vogleditor_gl_state_snapshot** ppNewSnapshot, uint64_t apiCallNumber, bool endlessMode)
 {
    // reset to beginnning of trace file.
    m_pTraceReader->seek_to_frame(0);
@@ -230,16 +241,16 @@ bool vogleditor_traceReplayer::replay(vogl_trace_file_reader* m_pTraceReader, vo
 
    if (!m_window.open(initial_window_width, initial_window_height))
    {
-      vogl_error_printf("%s: Failed opening GL replayer window!\n", VOGL_FUNCTION_NAME);
-      return false;
+      vogleditor_output_error("Failed opening GL replayer window!");
+      return VOGLEDITOR_TRR_ERROR;
    }
 
    uint replayer_flags = cGLReplayerForceDebugContexts;
    if (!m_pTraceReplayer->init(replayer_flags, &m_window, m_pTraceReader->get_sof_packet(), m_pTraceReader->get_multi_blob_manager()))
    {
-      vogl_error_printf("%s: Failed initializing GL replayer\n", VOGL_FUNCTION_NAME);
+      vogleditor_output_error("Failed initializing GL replayer!");
       m_window.close();
-      return false;
+      return VOGLEDITOR_TRR_ERROR;
    }
 
    XSelectInput(m_window.get_display(), m_window.get_xwindow(),
@@ -251,12 +262,13 @@ bool vogleditor_traceReplayer::replay(vogl_trace_file_reader* m_pTraceReader, vo
    timer tm;
    tm.start();
 
-   bool bStatus = true;
+   vogleditor_tracereplayer_result result = VOGLEDITOR_TRR_SUCCESS;
 
    for ( ; ; )
    {
       if (process_x_events() == false)
       {
+          result = VOGLEDITOR_TRR_USER_EXIT;
           break;
       }
 
@@ -264,6 +276,7 @@ bool vogleditor_traceReplayer::replay(vogl_trace_file_reader* m_pTraceReader, vo
       {
           vogleditor_apiCallTreeItem* pFirstFrame = pRootItem->child(0);
 
+          bool bStatus = true;
           // if the first snapshot has not been edited, then restore it here, otherwise it will get restored in the recursive call below.
           if (pFirstFrame->has_snapshot() && !pFirstFrame->get_snapshot()->is_edited())
           {
@@ -273,20 +286,31 @@ bool vogleditor_traceReplayer::replay(vogl_trace_file_reader* m_pTraceReader, vo
           if (bStatus)
           {
               // replay each API call.
-              bStatus = recursive_replay_apicallTreeItem(pRootItem, ppNewSnapshot, apiCallNumber);
+              result = recursive_replay_apicallTreeItem(pRootItem, ppNewSnapshot, apiCallNumber);
 
-              if (bStatus == false)
+              if (result == VOGLEDITOR_TRR_ERROR)
+              {
+                  QString msg = QString("Replay ending abruptly at frame index %1, global api call %2").arg(m_pTraceReplayer->get_frame_index()).arg(m_pTraceReplayer->get_last_processed_call_counter());
+                  vogleditor_output_error(msg.toStdString().c_str());
+                  break;
+              }
+              else if (result == VOGLEDITOR_TRR_SNAPSHOT_SUCCESS)
+              {
+                  break;
+              }
+              else if (result == VOGLEDITOR_TRR_USER_EXIT)
               {
-                 vogl_error_printf("%s: Replay ending abruptly at frame index %u, global api call %" PRIu64 "\n", VOGL_FUNCTION_NAME, m_pTraceReplayer->get_frame_index(), m_pTraceReplayer->get_last_processed_call_counter());
-                 break;
+                  vogleditor_output_message("Replay stopped");
+                  break;
               }
               else
               {
-                 vogl_message_printf("%s: At trace EOF, frame index %u\n", VOGL_FUNCTION_NAME, m_pTraceReplayer->get_frame_index());
-                 if (!endlessMode)
-                 {
-                     break;
-                 }
+                  QString msg = QString("At trace EOF, frame index %1").arg(m_pTraceReplayer->get_frame_index());
+                  vogleditor_output_message(msg.toStdString().c_str());
+                  if (!endlessMode)
+                  {
+                      break;
+                  }
               }
           }
           else
@@ -298,7 +322,7 @@ bool vogleditor_traceReplayer::replay(vogl_trace_file_reader* m_pTraceReader, vo
 
    m_pTraceReplayer->deinit();
    m_window.close();
-   return bStatus;
+   return result;
 }
 
 bool vogleditor_traceReplayer::pause()
index 176b22a41d8f26e01da47d168818bcf1e4bb5eb9..129011040997b146dba9421a407d6778923e11aa 100644 (file)
@@ -10,13 +10,21 @@ class vogl_gl_state_snapshot;
 class vogleditor_apiCallTreeItem;
 class vogl_trace_file_reader;
 
+enum vogleditor_tracereplayer_result
+{
+    VOGLEDITOR_TRR_SUCCESS = 0,
+    VOGLEDITOR_TRR_SNAPSHOT_SUCCESS,
+    VOGLEDITOR_TRR_USER_EXIT,
+    VOGLEDITOR_TRR_ERROR
+};
+
 class vogleditor_traceReplayer
 {
 public:
     vogleditor_traceReplayer();
     virtual ~vogleditor_traceReplayer();
 
-    bool replay(vogl_trace_file_reader* m_pTraceReader, vogleditor_apiCallTreeItem* pRootItem, vogleditor_gl_state_snapshot** ppNewSnapshot, uint64_t apiCallNumber, bool endlessMode);
+    vogleditor_tracereplayer_result replay(vogl_trace_file_reader* m_pTraceReader, vogleditor_apiCallTreeItem* pRootItem, vogleditor_gl_state_snapshot** ppNewSnapshot, uint64_t apiCallNumber, bool endlessMode);
     bool pause();
     bool restart();
     bool trim();
@@ -26,7 +34,7 @@ private:
 
     bool applying_snapshot_and_process_resize(const vogl_gl_state_snapshot* pSnapshot);
 
-    bool recursive_replay_apicallTreeItem(vogleditor_apiCallTreeItem* pItem, vogleditor_gl_state_snapshot** ppNewSnapshot, uint64_t apiCallNumber);
+    vogleditor_tracereplayer_result recursive_replay_apicallTreeItem(vogleditor_apiCallTreeItem* pItem, vogleditor_gl_state_snapshot** ppNewSnapshot, uint64_t apiCallNumber);
     bool process_x_events();
     vogl_gl_replayer* m_pTraceReplayer;
     vogl_replay_window m_window;