1 /**************************************************************************
3 * Copyright 2013-2014 RAD Game Tools and Valve Software
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 **************************************************************************/
29 #include <QMainWindow>
32 #include <QModelIndexList>
34 #include "vogl_dynamic_string.h"
35 #include "vogl_hash_map.h"
36 #include "vogl_json.h"
37 #include "vogleditor_qframebufferexplorer.h"
38 #include "vogleditor_qprogramexplorer.h"
39 #include "vogleditor_qshaderexplorer.h"
40 #include "vogleditor_qtextureexplorer.h"
41 #include "vogleditor_qtimelineview.h"
42 #include "vogleditor_tracereplayer.h"
48 typedef uint64_t GLuint64;
50 class vogleditor_QTextureExplorer;
55 class QSortFilterProxyModel;
57 class vogl_context_snapshot;
58 class vogl_framebuffer_state;
59 class vogl_program_state;
60 class vogl_replay_window;
61 class vogl_shader_state;
62 class vogl_texture_state;
63 class vogl_trace_file_reader;
64 class vogl_trace_file_writer;
65 class vogl_trace_packet;
66 class vogl_gl_state_snapshot;
67 class vogleditor_apiCallTimelineModel;
68 class vogleditor_apiCallTreeItem;
69 class vogleditor_gl_state_snapshot;
70 class vogleditor_QApiCallTreeModel;
71 class vogleditor_QStateTreeModel;
73 class VoglEditor : public QMainWindow
78 explicit VoglEditor(QWidget* parent = 0);
81 bool open_trace_file(vogl::dynamic_string filename);
82 void close_trace_file();
85 void on_action_Open_triggered();
86 void on_action_Close_triggered();
87 void on_actionE_xit_triggered();
88 void on_actionExport_API_Calls_triggered();
90 void on_treeView_currentChanged(const QModelIndex & current, const QModelIndex & previous);
92 void on_treeView_clicked(const QModelIndex& index);
94 void playCurrentTraceFile();
95 void trimCurrentTraceFile();
97 bool trim_trace_file(QString filename, uint maxFrameIndex, uint maxAllowedTrimLen);
99 void on_stateTreeView_clicked(const QModelIndex &index);
101 void on_searchTextBox_textChanged(const QString &searchText);
102 void on_searchNextButton_clicked();
103 void on_searchPrevButton_clicked();
104 void on_prevSnapshotButton_clicked();
105 void on_nextSnapshotButton_clicked();
106 void on_prevDrawcallButton_clicked();
107 void on_nextDrawcallButton_clicked();
109 void on_program_edited(vogl_program_state* pNewProgramState);
111 void on_actionSave_Session_triggered();
113 void on_actionOpen_Session_triggered();
115 void on_searchTextBox_returnPressed();
120 void onApiCallSelected(const QModelIndex &index, bool bAllowStateSnapshot);
121 bool displayTexture(GLuint64 textureHandle, bool bBringTabToFront);
122 void displayFramebuffer(GLuint64 framebufferHandle, bool bBringTabToFront);
123 bool displayShader(GLuint64 shaderHandle, bool bBringTabToFront);
124 void displayProgram(GLuint64 programHandle, bool bBringTabToFront);
127 vogl_gl_state_snapshot *read_state_snapshot_from_trace(vogl_trace_file_reader* pTrace_reader);
129 void reset_tracefile_ui();
130 void reset_snapshot_ui();
132 void update_ui_for_snapshot(vogleditor_gl_state_snapshot *pStateSnapshot);
133 void displayMachineInfoHelper(QString prefix, const QString& sectionKeyStr, const vogl::json_value& value, QString& rMachineInfoStr);
134 void displayMachineInfo();
135 void recursive_update_snapshot_flags(vogleditor_apiCallTreeItem* pItem, bool& bFoundEditedSnapshot);
137 vogleditor_gl_state_snapshot* findMostRecentSnapshot_helper(vogleditor_apiCallTreeItem* pItem, vogleditor_gl_state_snapshot*& pMostRecentSnapshot, const vogleditor_gl_state_snapshot* pCurSnapshot);
138 vogleditor_gl_state_snapshot* findMostRecentSnapshot(vogleditor_apiCallTreeItem* pItem, const vogleditor_gl_state_snapshot* pCurSnapshot);
140 void selectApicallModelIndex(QModelIndex index, bool scrollTo, bool select);
142 void write_child_api_calls(vogleditor_apiCallTreeItem* pItem, FILE* pFile);
144 bool load_session_from_disk(QString sessionFile);
145 bool save_session_to_disk(QString sessionFile);
146 bool save_snapshot_to_disk(vogl_gl_state_snapshot* pSnapshot, dynamic_string filename, vogl_blob_manager *pBlob_manager);
148 QString m_openFilename;
149 QLabel* m_pStatusLabel;
150 vogleditor_QFramebufferExplorer* m_pFramebufferExplorer;
151 vogleditor_QTextureExplorer* m_pTextureExplorer;
152 vogleditor_QTextureExplorer* m_pRenderbufferExplorer;
153 vogleditor_QProgramExplorer* m_pProgramExplorer;
154 vogleditor_QShaderExplorer* m_pShaderExplorer;
155 vogleditor_QTimelineView* m_timeline;
157 QGridLayout* m_pFramebufferTab_layout;
158 QGridLayout* m_pTextureTab_layout;
159 QGridLayout* m_pRenderbufferTab_layout;
160 QGridLayout* m_pProgramTab_layout;
161 QGridLayout* m_pShaderTab_layout;
163 vogleditor_gl_state_snapshot* m_currentSnapshot;
164 vogleditor_apiCallTreeItem* m_pCurrentCallTreeItem;
166 QProcess* m_pVoglReplayProcess;
167 QToolButton* m_pPlayButton;
168 QToolButton* m_pTrimButton;
170 vogleditor_traceReplayer m_traceReplayer;
171 vogl_trace_file_reader* m_pTraceReader;
172 vogl::json_document m_backtraceDoc;
173 vogl::hash_map<vogl::uint32, vogl::json_node*> m_backtraceToJsonMap;
175 vogleditor_apiCallTimelineModel* m_pTimelineModel;
176 vogleditor_QApiCallTreeModel* m_pApiCallTreeModel;
177 vogleditor_QStateTreeModel* m_pStateTreeModel;
179 QColor m_searchTextboxBackgroundColor;
182 #endif // VOGLEDITOR_H