forked from baldurk/renderdoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore.cpp
More file actions
187 lines (140 loc) · 4.67 KB
/
Core.cpp
File metadata and controls
187 lines (140 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include "Core.h"
#include "Windows/MainWindow.h"
#include <QApplication>
#include <QTimer>
#include <QMessageBox>
#include <QMetaObject>
#include <QFileInfo>
Core::Core(QString paramFilename, QString remoteHost, uint32_t remoteIdent, bool temp)
{
m_LogLoaded = false; m_LoadInProgress = false;
m_FrameID = 0; m_EventID = 0;
memset(&m_APIProps, 0, sizeof(m_APIProps));
m_MainWindow = new MainWindow(this);
m_MainWindow->show();
if(!paramFilename.isEmpty())
{
QFileInfo fi(paramFilename);
if(fi.suffix() == "rdc")
{
LoadLogfile(paramFilename, temp);
}
}
}
Core::~Core()
{
delete m_MainWindow;
}
void Core::LoadLogfile(QString logFile, bool temporary)
{
LoadLogfile(-1, "", logFile, temporary);
}
void Core::LoadLogfile(int proxyRenderer, QString replayHost, QString logFile, bool temporary)
{
m_LogFile = logFile;
m_LoadInProgress = true;
float loadProgress = 0.0f;
float postloadProgress = 0.0f;
// this function call will block until the log is either loaded, or there's some failure
m_Renderer.Init(proxyRenderer, replayHost, logFile, &loadProgress);
// if the renderer isn't running, we hit a failure case so display an error message
if(!m_Renderer.IsRunning())
{
QString errmsg = "Unknown error message";
ReplayCreateStatus status = m_Renderer.GetCreateStatus();
errmsg = status;
if(proxyRenderer >= 0)
QMessageBox::critical(NULL, "Error opening log",
QString("%1\nFailed to transfer and replay on remote host %2: %3.\n\n" \
"Check diagnostic log in Help menu for more details.").arg(logFile, replayHost, errmsg));
else
QMessageBox::critical(NULL, "Error opening log",
QString("%1\nFailed to open logfile for replay: %1.\n\n" \
"Check diagnostic log in Help menu for more details.").arg(logFile, errmsg));
m_LoadInProgress = false;
return;
}
m_FrameID = 0;
m_EventID = 0;
// fetch initial data like drawcalls, textures and buffers
m_Renderer.BlockInvoke([this, &postloadProgress](IReplayRenderer *r) {
r->GetFrameInfo(&m_FrameInfo);
m_APIProps = r->GetAPIProperties();
postloadProgress = 0.2f;
m_Drawcalls = new rdctype::array<FetchDrawcall>[m_FrameInfo.count];
postloadProgress = 0.4f;
for(int i = 0; i < m_FrameInfo.count; i++)
r->GetDrawcalls((uint32_t)i, &m_Drawcalls[i]);
postloadProgress = 0.7f;
r->GetBuffers(&m_BufferList);
for(int i = 0; i < m_BufferList.count; i++)
m_Buffers[m_BufferList[i].ID] = &m_BufferList[i];
postloadProgress = 0.8f;
r->GetTextures(&m_TextureList);
for(int i = 0; i < m_TextureList.count; i++)
m_Textures[m_TextureList[i].ID] = &m_TextureList[i];
postloadProgress = 0.9f;
r->GetD3D11PipelineState(&CurD3D11PipelineState);
r->GetGLPipelineState(&CurGLPipelineState);
r->GetVulkanPipelineState(&CurVulkanPipelineState);
//CurPipelineState.SetStates(m_APIProps, CurD3D11PipelineState, CurGLPipelineState);
UnreadMessageCount = 0;
AddMessages(m_FrameInfo[0].debugMessages);
postloadProgress = 1.0f;
});
QThread::msleep(20);
m_LogLoaded = true;
QList<ILogViewerForm*> logviewers(m_LogViewers);
GUIInvoke::blockcall([&logviewers]() {
// notify all the registers log viewers that a log has been loaded
for(ILogViewerForm *logviewer : logviewers)
{
if(logviewer) logviewer->OnLogfileLoaded();
}
});
m_LoadInProgress = false;
}
void Core::SetEventID(ILogViewerForm *exclude, uint32_t frameID, uint32_t eventID)
{
m_FrameID = frameID;
m_EventID = eventID;
m_Renderer.BlockInvoke([frameID, eventID, this](IReplayRenderer *r) {
r->SetFrameEvent(frameID, eventID, false);
r->GetD3D11PipelineState(&CurD3D11PipelineState);
r->GetGLPipelineState(&CurGLPipelineState);
r->GetVulkanPipelineState(&CurVulkanPipelineState);
//CurPipelineState.SetStates(m_APIProps, CurD3D11PipelineState, CurGLPipelineState);
});
for(ILogViewerForm *logviewer : m_LogViewers)
{
if(logviewer == exclude)
continue;
logviewer->OnEventSelected(frameID, eventID);
}
}
void GUIInvoke::call(const std::function<void()> &f)
{
if(qApp->thread() == QThread::currentThread())
{
f();
return;
}
// TODO: could maybe do away with string compare here via caching
// invoke->metaObject()->indexOfMethod("doInvoke"); ?
GUIInvoke *invoke = new GUIInvoke(f);
invoke->moveToThread(qApp->thread());
QMetaObject::invokeMethod(invoke, "doInvoke", Qt::QueuedConnection);
}
void GUIInvoke::blockcall(const std::function<void()> &f)
{
if(qApp->thread() == QThread::currentThread())
{
f();
return;
}
// TODO: could maybe do away with string compare here via caching
// invoke->metaObject()->indexOfMethod("doInvoke"); ?
GUIInvoke *invoke = new GUIInvoke(f);
invoke->moveToThread(qApp->thread());
QMetaObject::invokeMethod(invoke, "doInvoke", Qt::BlockingQueuedConnection);
}