re-indent Qt code to match rest of C++ code

This commit is contained in:
baldurk
2015-07-10 16:38:41 +02:00
parent 9276cb875f
commit 97920b7b31
15 changed files with 676 additions and 669 deletions
+110 -110
View File
@@ -9,177 +9,177 @@
Core::Core(QString paramFilename, QString remoteHost, uint32_t remoteIdent, bool temp)
{
m_LogLoaded = false; m_LoadInProgress = false;
m_LogLoaded = false; m_LoadInProgress = false;
m_FrameID = 0; m_EventID = 0;
m_FrameID = 0; m_EventID = 0;
memset(&m_APIProps, 0, sizeof(m_APIProps));
memset(&m_APIProps, 0, sizeof(m_APIProps));
m_MainWindow = new MainWindow(this);
m_MainWindow->show();
m_MainWindow = new MainWindow(this);
m_MainWindow->show();
if(!paramFilename.isEmpty())
{
QFileInfo fi(paramFilename);
if(!paramFilename.isEmpty())
{
QFileInfo fi(paramFilename);
if(fi.suffix() == "rdc")
{
LoadLogfile(paramFilename, temp);
}
}
if(fi.suffix() == "rdc")
{
LoadLogfile(paramFilename, temp);
}
}
}
Core::~Core()
{
delete m_MainWindow;
delete m_MainWindow;
}
void Core::LoadLogfile(QString logFile, bool temporary)
{
LoadLogfile(-1, "", logFile, temporary);
LoadLogfile(-1, "", logFile, temporary);
}
void Core::LoadLogfile(int proxyRenderer, QString replayHost, QString logFile, bool temporary)
{
m_LogFile = logFile;
m_LogFile = logFile;
m_LoadInProgress = true;
m_LoadInProgress = true;
float loadProgress = 0.0f;
float postloadProgress = 0.0f;
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);
// 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 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));
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;
m_LoadInProgress = false;
return;
}
return;
}
m_FrameID = 0;
m_EventID = 0;
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);
// fetch initial data like drawcalls, textures and buffers
m_Renderer.BlockInvoke([this, &postloadProgress](IReplayRenderer *r) {
r->GetFrameInfo(&m_FrameInfo);
m_APIProps = r->GetAPIProperties();
m_APIProps = r->GetAPIProperties();
postloadProgress = 0.2f;
postloadProgress = 0.2f;
m_Drawcalls = new rdctype::array<FetchDrawcall>[m_FrameInfo.count];
m_Drawcalls = new rdctype::array<FetchDrawcall>[m_FrameInfo.count];
postloadProgress = 0.4f;
postloadProgress = 0.4f;
for (int i = 0; i < m_FrameInfo.count; i++)
r->GetDrawcalls((uint32_t)i, &m_Drawcalls[i]);
for(int i = 0; i < m_FrameInfo.count; i++)
r->GetDrawcalls((uint32_t)i, &m_Drawcalls[i]);
postloadProgress = 0.7f;
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];
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;
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];
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;
postloadProgress = 0.9f;
r->GetD3D11PipelineState(&CurD3D11PipelineState);
r->GetGLPipelineState(&CurGLPipelineState);
//CurPipelineState.SetStates(m_APIProps, CurD3D11PipelineState, CurGLPipelineState);
r->GetD3D11PipelineState(&CurD3D11PipelineState);
r->GetGLPipelineState(&CurGLPipelineState);
//CurPipelineState.SetStates(m_APIProps, CurD3D11PipelineState, CurGLPipelineState);
UnreadMessageCount = 0;
AddMessages(m_FrameInfo[0].debugMessages);
UnreadMessageCount = 0;
AddMessages(m_FrameInfo[0].debugMessages);
postloadProgress = 1.0f;
});
postloadProgress = 1.0f;
});
QThread::msleep(20);
QThread::msleep(20);
m_LogLoaded = true;
m_LogLoaded = true;
QList<ILogViewerForm*> logviewers(m_LogViewers);
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();
}
});
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;
m_LoadInProgress = false;
}
void Core::SetEventID(ILogViewerForm *exclude, uint32_t frameID, uint32_t eventID)
{
m_FrameID = frameID;
m_EventID = eventID;
m_FrameID = frameID;
m_EventID = eventID;
m_Renderer.BlockInvoke([frameID,eventID,this](IReplayRenderer *r) {
r->SetFrameEvent(frameID, eventID);
r->GetD3D11PipelineState(&CurD3D11PipelineState);
r->GetGLPipelineState(&CurGLPipelineState);
//CurPipelineState.SetStates(m_APIProps, CurD3D11PipelineState, CurGLPipelineState);
});
m_Renderer.BlockInvoke([frameID, eventID, this](IReplayRenderer *r) {
r->SetFrameEvent(frameID, eventID);
r->GetD3D11PipelineState(&CurD3D11PipelineState);
r->GetGLPipelineState(&CurGLPipelineState);
//CurPipelineState.SetStates(m_APIProps, CurD3D11PipelineState, CurGLPipelineState);
});
for(ILogViewerForm *logviewer : m_LogViewers)
{
if(logviewer == exclude)
continue;
for(ILogViewerForm *logviewer : m_LogViewers)
{
if(logviewer == exclude)
continue;
logviewer->OnEventSelected(frameID, eventID);
}
logviewer->OnEventSelected(frameID, eventID);
}
}
void GUIInvoke::call(const std::function<void()> &f)
{
if(qApp->thread() == QThread::currentThread())
{
f();
return;
}
if(qApp->thread() == QThread::currentThread())
{
f();
return;
}
// TODO: could maybe do away with string compare here via caching
// invoke->metaObject()->indexOfMethod("doInvoke"); ?
// 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);
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;
}
if(qApp->thread() == QThread::currentThread())
{
f();
return;
}
// TODO: could maybe do away with string compare here via caching
// invoke->metaObject()->indexOfMethod("doInvoke"); ?
// 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);
GUIInvoke *invoke = new GUIInvoke(f);
invoke->moveToThread(qApp->thread());
QMetaObject::invokeMethod(invoke, "doInvoke", Qt::BlockingQueuedConnection);
}
+142 -140
View File
@@ -9,158 +9,158 @@
struct ILogViewerForm
{
virtual void OnLogfileLoaded() = 0;
virtual void OnLogfileClosed() = 0;
virtual void OnEventSelected(uint32_t frameID, uint32_t eventID) = 0;
virtual void OnLogfileLoaded() = 0;
virtual void OnLogfileClosed() = 0;
virtual void OnEventSelected(uint32_t frameID, uint32_t eventID) = 0;
};
struct ILogLoadProgressListener
{
virtual void LogfileProgressBegin() = 0;
virtual void LogfileProgress(float progress) = 0;
virtual void LogfileProgressBegin() = 0;
virtual void LogfileProgress(float progress) = 0;
};
class MainWindow;
class Core
{
public:
Core(QString paramFilename, QString remoteHost, uint32_t remoteIdent, bool temp);
~Core();
public:
Core(QString paramFilename, QString remoteHost, uint32_t remoteIdent, bool temp);
~Core();
//////////////////////////////////////////////////////////////////////////////
// Control functions
//////////////////////////////////////////////////////////////////////////////
// Control functions
// loading a local log, no remote replay
void LoadLogfile(QString logFile, bool temporary);
// loading a local log, no remote replay
void LoadLogfile(QString logFile, bool temporary);
// when loading a log while replaying remotely, provide the proxy renderer that will be used
// as well as the hostname to replay on.
void LoadLogfile(int proxyRenderer, QString replayHost, QString logFile, bool temporary);
// when loading a log while replaying remotely, provide the proxy renderer that will be used
// as well as the hostname to replay on.
void LoadLogfile(int proxyRenderer, QString replayHost, QString logFile, bool temporary);
void CloseLogfile();
void CloseLogfile();
QString TempLogFilename(QString appname);
QString TempLogFilename(QString appname);
void SetEventID(ILogViewerForm *exclude, uint32_t frameID, uint32_t eventID);
void SetEventID(ILogViewerForm *exclude, uint32_t frameID, uint32_t eventID);
void AddLogProgressListener(ILogLoadProgressListener *p);
void AddLogProgressListener(ILogLoadProgressListener *p);
void AddLogViewer(ILogViewerForm *f)
{
m_LogViewers.push_back(f);
void AddLogViewer(ILogViewerForm *f)
{
m_LogViewers.push_back(f);
if(LogLoaded())
{
f->OnLogfileLoaded();
f->OnEventSelected(CurFrame(), CurEvent());
}
}
if(LogLoaded())
{
f->OnLogfileLoaded();
f->OnEventSelected(CurFrame(), CurEvent());
}
}
void RemoveLogViewer(ILogViewerForm *f)
{
m_LogViewers.removeAll(f);
}
void RemoveLogViewer(ILogViewerForm *f)
{
m_LogViewers.removeAll(f);
}
//////////////////////////////////////////////////////////////////////////////
// Singleton windows
//////////////////////////////////////////////////////////////////////////////
// Singleton windows
/*
private MainWindow m_MainWindow = null;
private EventBrowser m_EventBrowser = null;
private APIInspector m_APIInspector = null;
private DebugMessages m_DebugMessages = null;
private TimelineBar m_TimelineBar = null;
private TextureViewer m_TextureViewer = null;
private PipelineStateViewer m_PipelineStateViewer = null;
*/
/*
private MainWindow m_MainWindow = null;
private EventBrowser m_EventBrowser = null;
private APIInspector m_APIInspector = null;
private DebugMessages m_DebugMessages = null;
private TimelineBar m_TimelineBar = null;
private TextureViewer m_TextureViewer = null;
private PipelineStateViewer m_PipelineStateViewer = null;
*/
//////////////////////////////////////////////////////////////////////////////
// Accessors
//////////////////////////////////////////////////////////////////////////////
// Accessors
RenderManager *Renderer() { return &m_Renderer; }
RenderManager *Renderer() { return &m_Renderer; }
bool LogLoaded() { return m_LogLoaded; }
bool LogLoading() { return m_LoadInProgress; }
QString LogFilename() { return m_LogFile; }
bool LogLoaded() { return m_LogLoaded; }
bool LogLoading() { return m_LoadInProgress; }
QString LogFilename() { return m_LogFile; }
const rdctype::array<FetchFrameInfo> &FrameInfo() { return m_FrameInfo; }
const APIProperties &APIProps() { return m_APIProps; }
const rdctype::array<FetchFrameInfo> &FrameInfo() { return m_FrameInfo; }
const APIProperties &APIProps() { return m_APIProps; }
// TODO: support multiple frames
uint32_t CurFrame() { return m_FrameID; }
uint32_t CurEvent() { return m_EventID; }
// TODO: support multiple frames
uint32_t CurFrame() { return m_FrameID; }
uint32_t CurEvent() { return m_EventID; }
const FetchDrawcall *CurDrawcall() { return GetDrawcall(CurFrame(), CurEvent()); }
const rdctype::array<FetchDrawcall> &CurDrawcalls(uint32_t frame) { return m_Drawcalls[frame]; }
const FetchDrawcall *CurDrawcall() { return GetDrawcall(CurFrame(), CurEvent()); }
const rdctype::array<FetchDrawcall> &CurDrawcalls(uint32_t frame) { return m_Drawcalls[frame]; }
FetchTexture *GetTexture(ResourceId id) { return m_Textures[id]; }
const rdctype::array<FetchTexture> &GetTextures() { return m_TextureList; }
FetchTexture *GetTexture(ResourceId id) { return m_Textures[id]; }
const rdctype::array<FetchTexture> &GetTextures() { return m_TextureList; }
FetchBuffer *GetBuffer(ResourceId id) { return m_Buffers[id]; }
const rdctype::array<FetchBuffer> &GetBuffers() { return m_BufferList; }
FetchBuffer *GetBuffer(ResourceId id) { return m_Buffers[id]; }
const rdctype::array<FetchBuffer> &GetBuffers() { return m_BufferList; }
QList<DebugMessage> DebugMessages;
int UnreadMessageCount;
void AddMessages(rdctype::array<DebugMessage> &msgs)
{
UnreadMessageCount += msgs.count;
for(int i=0; i < msgs.count; i++)
DebugMessages.push_back(msgs[i]);
}
QList<DebugMessage> DebugMessages;
int UnreadMessageCount;
void AddMessages(rdctype::array<DebugMessage> &msgs)
{
UnreadMessageCount += msgs.count;
for(int i = 0; i < msgs.count; i++)
DebugMessages.push_back(msgs[i]);
}
D3D11PipelineState CurD3D11PipelineState;
GLPipelineState CurGLPipelineState;
//CommonPipelineState CurPipelineState;
D3D11PipelineState CurD3D11PipelineState;
GLPipelineState CurGLPipelineState;
//CommonPipelineState CurPipelineState;
private:
RenderManager m_Renderer;
private:
RenderManager m_Renderer;
QList<ILogViewerForm*> m_LogViewers;
QList<ILogLoadProgressListener*> m_ProgressListeners;
QList<ILogViewerForm*> m_LogViewers;
QList<ILogLoadProgressListener*> m_ProgressListeners;
bool m_LogLoaded, m_LoadInProgress;
QString m_LogFile;
bool m_LogLoaded, m_LoadInProgress;
QString m_LogFile;
uint32_t m_FrameID, m_EventID;
uint32_t m_FrameID, m_EventID;
const FetchDrawcall *GetDrawcall(const rdctype::array<FetchDrawcall> &draws, uint32_t eventID)
{
for(int i=0; i < draws.count; i++)
{
if (draws[i].children.count > 0)
{
const FetchDrawcall *draw = GetDrawcall(draws[i].children, eventID);
if (draw != NULL) return draw;
}
const FetchDrawcall *GetDrawcall(const rdctype::array<FetchDrawcall> &draws, uint32_t eventID)
{
for(int i = 0; i < draws.count; i++)
{
if(draws[i].children.count > 0)
{
const FetchDrawcall *draw = GetDrawcall(draws[i].children, eventID);
if(draw != NULL) return draw;
}
if (draws[i].eventID == eventID)
return &draws[i];
}
if(draws[i].eventID == eventID)
return &draws[i];
}
return NULL;
}
return NULL;
}
const FetchDrawcall *GetDrawcall(uint32_t frameID, uint32_t eventID)
{
if (m_Drawcalls == NULL || frameID >= (uint32_t)m_FrameInfo.count)
return NULL;
const FetchDrawcall *GetDrawcall(uint32_t frameID, uint32_t eventID)
{
if(m_Drawcalls == NULL || frameID >= (uint32_t)m_FrameInfo.count)
return NULL;
return GetDrawcall(m_Drawcalls[frameID], eventID);
}
return GetDrawcall(m_Drawcalls[frameID], eventID);
}
rdctype::array<FetchDrawcall> *m_Drawcalls;
rdctype::array<FetchDrawcall> *m_Drawcalls;
APIProperties m_APIProps;
rdctype::array<FetchFrameInfo> m_FrameInfo;
APIProperties m_APIProps;
rdctype::array<FetchFrameInfo> m_FrameInfo;
QMap<ResourceId, FetchTexture*> m_Textures;
rdctype::array<FetchTexture> m_TextureList;
QMap<ResourceId, FetchBuffer*> m_Buffers;
rdctype::array<FetchBuffer> m_BufferList;
QMap<ResourceId, FetchTexture*> m_Textures;
rdctype::array<FetchTexture> m_TextureList;
QMap<ResourceId, FetchBuffer*> m_Buffers;
rdctype::array<FetchBuffer> m_BufferList;
// Windows
MainWindow *m_MainWindow;
// Windows
MainWindow *m_MainWindow;
};
// Utility class for invoking a lambda on the GUI thread.
@@ -170,19 +170,20 @@ class Core
class GUIInvoke : public QObject
{
Q_OBJECT
GUIInvoke(const std::function<void()> &f) : func(f) {}
std::function<void()> func;
public:
static void call(const std::function<void()> &f);
static void blockcall(const std::function<void()> &f);
private:
Q_OBJECT
GUIInvoke(const std::function<void()> &f) : func(f) {}
std::function<void()> func;
public:
static void call(const std::function<void()> &f);
static void blockcall(const std::function<void()> &f);
protected slots:
void doInvoke()
{
func();
deleteLater();
}
protected slots:
void doInvoke()
{
func();
deleteLater();
}
};
// Utility class for calling a lambda on a new thread.
@@ -190,31 +191,32 @@ class GUIInvoke : public QObject
class LambdaThread : public QObject
{
Q_OBJECT
private:
Q_OBJECT
std::function<void()> m_func;
QThread *m_Thread;
std::function<void()> m_func;
QThread *m_Thread;
public slots:
void process()
{
m_func();
m_Thread->quit();
deleteLater();
m_Thread->deleteLater();
}
public slots:
void process()
{
m_func();
m_Thread->quit();
deleteLater();
m_Thread->deleteLater();
}
public:
explicit LambdaThread(std::function<void()> f)
{
m_Thread = new QThread();
m_func = f;
moveToThread(m_Thread);
connect(m_Thread, SIGNAL(started()), this, SLOT(process()));
}
public:
explicit LambdaThread(std::function<void()> f)
{
m_Thread = new QThread();
m_func = f;
moveToThread(m_Thread);
connect(m_Thread, SIGNAL(started()), this, SLOT(process()));
}
void start(QThread::Priority prio = QThread::InheritPriority) { m_Thread->start(prio); }
bool isRunning() { return m_Thread->isRunning(); }
void start(QThread::Priority prio = QThread::InheritPriority) { m_Thread->start(prio); }
bool isRunning() { return m_Thread->isRunning(); }
};
#endif // CORE_H
+100 -100
View File
@@ -6,8 +6,8 @@
RenderManager::RenderManager()
{
m_Running = false;
m_Thread = NULL;
m_Running = false;
m_Thread = NULL;
}
RenderManager::~RenderManager()
@@ -17,157 +17,157 @@ RenderManager::~RenderManager()
void RenderManager::Init(int proxyRenderer, QString replayHost, QString logfile, float *progress)
{
if(m_Running)
return;
if(m_Running)
return;
m_ProxyRenderer = proxyRenderer;
m_ReplayHost = replayHost;
m_Logfile = logfile;
m_Progress = progress;
m_ProxyRenderer = proxyRenderer;
m_ReplayHost = replayHost;
m_Logfile = logfile;
m_Progress = progress;
*progress = 0.0f;
*progress = 0.0f;
m_Thread = new LambdaThread([this]() { run(); });
m_Thread->start(QThread::HighestPriority);
m_Thread = new LambdaThread([this]() { run(); });
m_Thread->start(QThread::HighestPriority);
while (m_Thread->isRunning() && !m_Running) {}
while(m_Thread->isRunning() && !m_Running) {}
}
bool RenderManager::IsRunning()
{
return m_Thread->isRunning() && m_Running;
return m_Thread->isRunning() && m_Running;
}
void RenderManager::AsyncInvoke(RenderManager::InvokeMethod m)
{
InvokeHandle *cmd = new InvokeHandle(m);
cmd->selfdelete = true;
InvokeHandle *cmd = new InvokeHandle(m);
cmd->selfdelete = true;
PushInvoke(cmd);
PushInvoke(cmd);
}
void RenderManager::BlockInvoke(RenderManager::InvokeMethod m)
{
InvokeHandle *cmd = new InvokeHandle(m);
InvokeHandle *cmd = new InvokeHandle(m);
PushInvoke(cmd);
PushInvoke(cmd);
while(!cmd->processed) {}
while(!cmd->processed) {}
}
void RenderManager::CloseThread()
{
m_Running = false;
m_Running = false;
m_RenderCondition.wakeAll();
m_RenderCondition.wakeAll();
// wait for the thread to close and clean up
while(m_Thread->isRunning()) {}
// wait for the thread to close and clean up
while(m_Thread->isRunning()) {}
m_Thread->deleteLater();
m_Thread->deleteLater();
}
void RenderManager::PushInvoke(RenderManager::InvokeHandle *cmd)
{
if(m_Thread == NULL || !m_Thread->isRunning() || !m_Running)
{
cmd->processed = true;
if(cmd->selfdelete) delete cmd;
return;
}
if(m_Thread == NULL || !m_Thread->isRunning() || !m_Running)
{
cmd->processed = true;
if(cmd->selfdelete) delete cmd;
return;
}
m_RenderLock.lock();
m_RenderQueue.push_back(cmd);
m_RenderLock.unlock();
m_RenderLock.lock();
m_RenderQueue.push_back(cmd);
m_RenderLock.unlock();
m_RenderCondition.wakeAll();
m_RenderCondition.wakeAll();
}
void RenderManager::run()
{
IReplayRenderer *renderer = NULL;
IRemoteRenderer *remote = NULL;
IReplayRenderer *renderer = NULL;
IRemoteRenderer *remote = NULL;
if (m_ProxyRenderer < 0)
{
m_CreateStatus = RENDERDOC_CreateReplayRenderer(m_Logfile.toUtf8(), m_Progress, &renderer);
}
else
{
m_CreateStatus = RENDERDOC_CreateRemoteReplayConnection(m_ReplayHost.toUtf8(), &remote);
if(m_ProxyRenderer < 0)
{
m_CreateStatus = RENDERDOC_CreateReplayRenderer(m_Logfile.toUtf8(), m_Progress, &renderer);
}
else
{
m_CreateStatus = RENDERDOC_CreateRemoteReplayConnection(m_ReplayHost.toUtf8(), &remote);
if(remote == NULL)
{
return;
}
if(remote == NULL)
{
return;
}
m_CreateStatus = remote->CreateProxyRenderer(m_ProxyRenderer, m_Logfile.toUtf8(), m_Progress, &renderer);
m_CreateStatus = remote->CreateProxyRenderer(m_ProxyRenderer, m_Logfile.toUtf8(), m_Progress, &renderer);
if(renderer == NULL)
{
remote->Shutdown();
remote = NULL;
return;
}
}
if(renderer == NULL)
{
remote->Shutdown();
remote = NULL;
return;
}
}
if(renderer == NULL)
return;
if(renderer == NULL)
return;
RENDERDOC_LogText(QString("QRenderDoc - renderer created for %1").arg(m_Logfile).toUtf8());
RENDERDOC_LogText(QString("QRenderDoc - renderer created for %1").arg(m_Logfile).toUtf8());
m_Running = true;
m_Running = true;
// main render command loop
while(m_Running)
{
QQueue<InvokeHandle *> queue;
// main render command loop
while(m_Running)
{
QQueue<InvokeHandle *> queue;
// wait for the condition to be woken, grab current queue,
// unlock again.
{
m_RenderLock.lock();
m_RenderCondition.wait(&m_RenderLock);
m_RenderQueue.swap(queue);
m_RenderLock.unlock();
}
// wait for the condition to be woken, grab current queue,
// unlock again.
{
m_RenderLock.lock();
m_RenderCondition.wait(&m_RenderLock);
m_RenderQueue.swap(queue);
m_RenderLock.unlock();
}
// process all the commands
for(InvokeHandle *cmd : queue)
{
if(cmd == NULL) continue;
// process all the commands
for(InvokeHandle *cmd : queue)
{
if(cmd == NULL) continue;
if(cmd->method != NULL)
cmd->method(renderer);
if(cmd->method != NULL)
cmd->method(renderer);
cmd->processed = true;
cmd->processed = true;
// if it's a throwaway command, delete it
if(cmd->selfdelete)
delete cmd;
}
}
// if it's a throwaway command, delete it
if(cmd->selfdelete)
delete cmd;
}
}
// clean up anything left in the queue
{
QQueue<InvokeHandle *> queue;
// clean up anything left in the queue
{
QQueue<InvokeHandle *> queue;
m_RenderLock.lock();
m_RenderQueue.swap(queue);
m_RenderLock.unlock();
m_RenderLock.lock();
m_RenderQueue.swap(queue);
m_RenderLock.unlock();
for(InvokeHandle *cmd : queue)
{
if(cmd == NULL) continue;
for(InvokeHandle *cmd : queue)
{
if(cmd == NULL) continue;
cmd->processed = true;
cmd->processed = true;
if(cmd->selfdelete)
delete cmd;
}
}
if(cmd->selfdelete)
delete cmd;
}
}
// close the core renderer
renderer->Shutdown();
if(remote) remote->Shutdown();
// close the core renderer
renderer->Shutdown();
if(remote) remote->Shutdown();
}
+35 -35
View File
@@ -16,53 +16,53 @@ class LambdaThread;
class RenderManager
{
public:
typedef std::function<void(IReplayRenderer*)> InvokeMethod;
public:
typedef std::function<void(IReplayRenderer*)> InvokeMethod;
RenderManager();
~RenderManager();
RenderManager();
~RenderManager();
void Init(int proxyRenderer, QString replayHost, QString logfile, float *progress);
void Init(int proxyRenderer, QString replayHost, QString logfile, float *progress);
bool IsRunning();
ReplayCreateStatus GetCreateStatus() { return m_CreateStatus; }
bool IsRunning();
ReplayCreateStatus GetCreateStatus() { return m_CreateStatus; }
void AsyncInvoke(InvokeMethod m);
void BlockInvoke(InvokeMethod m);
void AsyncInvoke(InvokeMethod m);
void BlockInvoke(InvokeMethod m);
void CloseThread();
private:
void CloseThread();
private:
struct InvokeHandle
{
InvokeHandle(InvokeMethod m)
{
method = m;
processed = false;
selfdelete = true;
}
struct InvokeHandle
{
InvokeHandle(InvokeMethod m)
{
method = m;
processed = false;
selfdelete = true;
}
InvokeMethod method;
bool processed;
bool selfdelete;
};
InvokeMethod method;
bool processed;
bool selfdelete;
};
void run();
void run();
QMutex m_RenderLock;
QQueue<InvokeHandle *> m_RenderQueue;
QWaitCondition m_RenderCondition;
QMutex m_RenderLock;
QQueue<InvokeHandle *> m_RenderQueue;
QWaitCondition m_RenderCondition;
void PushInvoke(InvokeHandle *cmd);
void PushInvoke(InvokeHandle *cmd);
int m_ProxyRenderer;
QString m_ReplayHost;
QString m_Logfile;
float *m_Progress;
int m_ProxyRenderer;
QString m_ReplayHost;
QString m_Logfile;
float *m_Progress;
volatile bool m_Running;
LambdaThread *m_Thread;
ReplayCreateStatus m_CreateStatus;
volatile bool m_Running;
LambdaThread *m_Thread;
ReplayCreateStatus m_CreateStatus;
};
#endif // RENDERMANAGER_H
+41 -41
View File
@@ -8,58 +8,58 @@
int main(int argc, char *argv[])
{
RENDERDOC_LogText("QRenderDoc initialising.");
RENDERDOC_LogText("QRenderDoc initialising.");
QString filename = "";
bool temp = false;
QString filename = "";
bool temp = false;
for(int i=0; i < argc; i++)
{
if(!QString::compare(argv[i], "--tempfile", Qt::CaseInsensitive))
temp = true;
}
for(int i = 0; i < argc; i++)
{
if(!QString::compare(argv[i], "--tempfile", Qt::CaseInsensitive))
temp = true;
}
QString remoteHost = "";
uint remoteIdent = 0;
QString remoteHost = "";
uint remoteIdent = 0;
for (int i = 0; i+1 < argc; i++)
{
if (!QString::compare(argv[i], "--REMOTEACCESS", Qt::CaseInsensitive))
{
QRegularExpression regexp("^([a-zA-Z0-9_-]+:)?([0-9]+)$");
for(int i = 0; i + 1 < argc; i++)
{
if(!QString::compare(argv[i], "--REMOTEACCESS", Qt::CaseInsensitive))
{
QRegularExpression regexp("^([a-zA-Z0-9_-]+:)?([0-9]+)$");
QRegularExpressionMatch match = regexp.match(argv[i+1]);
QRegularExpressionMatch match = regexp.match(argv[i + 1]);
if (match.hasMatch())
{
QString host = match.captured(1);
if(match.hasMatch())
{
QString host = match.captured(1);
if (host.length() > 0 && host[host.length() - 1] == ':')
host.chop(1);
if(host.length() > 0 && host[host.length() - 1] == ':')
host.chop(1);
bool ok = false;
uint32_t ident = match.captured(2).toUInt(&ok);
bool ok = false;
uint32_t ident = match.captured(2).toUInt(&ok);
if(ok)
{
remoteHost = host;
remoteIdent = ident;
}
}
}
}
if(ok)
{
remoteHost = host;
remoteIdent = ident;
}
}
}
}
if (argc > 1)
{
filename = argv[argc - 1];
QFileInfo checkFile(filename);
if(!checkFile.exists() || !checkFile.isFile())
filename = "";
}
if(argc > 1)
{
filename = argv[argc - 1];
QFileInfo checkFile(filename);
if(!checkFile.exists() || !checkFile.isFile())
filename = "";
}
QApplication a(argc, argv);
QApplication a(argc, argv);
Core core(filename, remoteHost, remoteIdent, temp);
Core core(filename, remoteHost, remoteIdent, temp);
return a.exec();
return a.exec();
}
+3 -3
View File
@@ -5,8 +5,8 @@
CustomPaintWidget::CustomPaintWidget(QWidget *parent) : QWidget(parent)
{
m_Output = NULL;
setAttribute(Qt::WA_PaintOnScreen);
m_Output = NULL;
setAttribute(Qt::WA_PaintOnScreen);
}
CustomPaintWidget::~CustomPaintWidget()
@@ -16,6 +16,6 @@ CustomPaintWidget::~CustomPaintWidget()
void CustomPaintWidget::paintEvent(QPaintEvent *e)
{
if(m_Output) m_Output->Display();
if(m_Output) m_Output->Display();
}
+12 -11
View File
@@ -6,20 +6,21 @@ struct IReplayOutput;
class CustomPaintWidget : public QWidget
{
Q_OBJECT
public:
explicit CustomPaintWidget(QWidget *parent = 0);
~CustomPaintWidget();
private:
Q_OBJECT
public:
explicit CustomPaintWidget(QWidget *parent = 0);
~CustomPaintWidget();
void SetOutput(IReplayOutput *out) { m_Output = out; }
void SetOutput(IReplayOutput *out) { m_Output = out; }
signals:
signals:
public slots:
public slots:
protected:
void paintEvent(QPaintEvent *e);
QPaintEngine *paintEngine() const { return NULL; }
protected:
void paintEvent(QPaintEvent *e);
QPaintEngine *paintEngine() const { return NULL; }
IReplayOutput *m_Output;
IReplayOutput *m_Output;
};
+4 -4
View File
@@ -11,12 +11,12 @@ LineEditFocusWidget::~LineEditFocusWidget()
void LineEditFocusWidget::focusInEvent(QFocusEvent *e)
{
QLineEdit::focusInEvent(e);
emit(enter());
QLineEdit::focusInEvent(e);
emit(enter());
}
void LineEditFocusWidget::focusOutEvent(QFocusEvent *e)
{
QLineEdit::focusOutEvent(e);
emit(leave());
QLineEdit::focusOutEvent(e);
emit(leave());
}
+12 -11
View File
@@ -3,18 +3,19 @@
class LineEditFocusWidget : public QLineEdit
{
Q_OBJECT
public:
explicit LineEditFocusWidget(QWidget *parent = 0);
~LineEditFocusWidget();
private:
Q_OBJECT
public:
explicit LineEditFocusWidget(QWidget *parent = 0);
~LineEditFocusWidget();
signals:
void enter();
void leave();
signals:
void enter();
void leave();
public slots:
public slots:
protected:
void focusInEvent(QFocusEvent *e);
void focusOutEvent(QFocusEvent *e);
protected:
void focusInEvent(QFocusEvent *e);
void focusOutEvent(QFocusEvent *e);
};
+98 -98
View File
@@ -11,75 +11,75 @@ enum {
uint AddDrawcalls(QTreeWidgetItem *parent, const rdctype::array<FetchDrawcall> &draws)
{
uint lastEID = 0;
uint lastEID = 0;
for(int32_t i=0; i < draws.count; i++)
{
QTreeWidgetItem *child = new QTreeWidgetItem(parent, QStringList{QString(draws[i].name.elems), QString("%1").arg(draws[i].eventID), "0.0"});
lastEID = AddDrawcalls(child, draws[i].children);
if(lastEID == 0) lastEID = draws[i].eventID;
child->setData(COL_EID, Qt::UserRole, QVariant(lastEID));
}
for(int32_t i = 0; i < draws.count; i++)
{
QTreeWidgetItem *child = new QTreeWidgetItem(parent, QStringList{ QString(draws[i].name.elems), QString("%1").arg(draws[i].eventID), "0.0" });
lastEID = AddDrawcalls(child, draws[i].children);
if(lastEID == 0) lastEID = draws[i].eventID;
child->setData(COL_EID, Qt::UserRole, QVariant(lastEID));
}
return lastEID;
return lastEID;
}
EventBrowser::EventBrowser(Core *core, QWidget *parent) :
QFrame(parent),
ui(new Ui::EventBrowser),
m_Core(core)
QFrame(parent),
ui(new Ui::EventBrowser),
m_Core(core)
{
ui->setupUi(this);
ui->setupUi(this);
m_Core->AddLogViewer(this);
m_Core->AddLogViewer(this);
ui->events->header()->resizeSection(COL_EID, 80);
ui->events->header()->resizeSection(COL_EID, 80);
ui->events->header()->setSectionResizeMode(COL_NAME, QHeaderView::Stretch);
ui->events->header()->setSectionResizeMode(COL_EID, QHeaderView::Interactive);
ui->events->header()->setSectionResizeMode(COL_DURATION, QHeaderView::Interactive);
ui->events->header()->setSectionResizeMode(COL_NAME, QHeaderView::Stretch);
ui->events->header()->setSectionResizeMode(COL_EID, QHeaderView::Interactive);
ui->events->header()->setSectionResizeMode(COL_DURATION, QHeaderView::Interactive);
// we set up the name column first, EID second, so that the name column gets the
// expand/collapse widgets. Then we need to put them back in order
ui->events->header()->moveSection(COL_NAME, COL_EID);
// we set up the name column first, EID second, so that the name column gets the
// expand/collapse widgets. Then we need to put them back in order
ui->events->header()->moveSection(COL_NAME, COL_EID);
// Qt doesn't allow moving the column with the expand/collapse widgets, so this
// becomes quickly infuriating to rearrange, just disable until that can be fixed.
ui->events->header()->setSectionsMovable(false);
// Qt doesn't allow moving the column with the expand/collapse widgets, so this
// becomes quickly infuriating to rearrange, just disable until that can be fixed.
ui->events->header()->setSectionsMovable(false);
QObject::connect(ui->closeFind, &QToolButton::clicked, this, &EventBrowser::hideFindJump);
QObject::connect(ui->closeJump, &QToolButton::clicked, this, &EventBrowser::hideFindJump);
QObject::connect(ui->jumpToEID, &LineEditFocusWidget::leave, this, &EventBrowser::hideFindJump);
QObject::connect(ui->findEvent, &LineEditFocusWidget::leave, this, &EventBrowser::hideFindJump);
ui->jumpStrip->hide();
ui->findStrip->hide();
ui->bookmarkStrip->hide();
QObject::connect(ui->closeFind, &QToolButton::clicked, this, &EventBrowser::hideFindJump);
QObject::connect(ui->closeJump, &QToolButton::clicked, this, &EventBrowser::hideFindJump);
QObject::connect(ui->jumpToEID, &LineEditFocusWidget::leave, this, &EventBrowser::hideFindJump);
QObject::connect(ui->findEvent, &LineEditFocusWidget::leave, this, &EventBrowser::hideFindJump);
ui->jumpStrip->hide();
ui->findStrip->hide();
ui->bookmarkStrip->hide();
}
EventBrowser::~EventBrowser()
{
m_Core->RemoveLogViewer(this);
delete ui;
m_Core->RemoveLogViewer(this);
delete ui;
}
void EventBrowser::OnLogfileLoaded()
{
QTreeWidgetItem *frame = new QTreeWidgetItem((QTreeWidget *)NULL, QStringList{QString("Frame #%1").arg(m_Core->FrameInfo()[0].frameNumber), "", ""});
QTreeWidgetItem *frame = new QTreeWidgetItem((QTreeWidget *)NULL, QStringList{ QString("Frame #%1").arg(m_Core->FrameInfo()[0].frameNumber), "", "" });
QTreeWidgetItem *framestart = new QTreeWidgetItem(frame, QStringList{"Frame Start", "0", ""});
framestart->setData(COL_EID, Qt::UserRole, QVariant(0));
QTreeWidgetItem *framestart = new QTreeWidgetItem(frame, QStringList{ "Frame Start", "0", "" });
framestart->setData(COL_EID, Qt::UserRole, QVariant(0));
uint lastEID = AddDrawcalls(frame, m_Core->CurDrawcalls(0));
frame->setData(COL_EID, Qt::UserRole, QVariant(lastEID));
uint lastEID = AddDrawcalls(frame, m_Core->CurDrawcalls(0));
frame->setData(COL_EID, Qt::UserRole, QVariant(lastEID));
ui->events->insertTopLevelItem(0, frame);
ui->events->insertTopLevelItem(0, frame);
ui->events->expandItem(frame);
ui->events->expandItem(frame);
}
void EventBrowser::OnLogfileClosed()
{
ui->events->clear();
ui->events->clear();
}
void EventBrowser::OnEventSelected(uint32_t frameID, uint32_t eventID)
@@ -89,106 +89,106 @@ void EventBrowser::OnEventSelected(uint32_t frameID, uint32_t eventID)
void EventBrowser::on_find_clicked()
{
ui->jumpStrip->hide();
ui->findStrip->show();
ui->bookmarkStrip->hide();
ui->findEvent->setFocus();
ui->jumpStrip->hide();
ui->findStrip->show();
ui->bookmarkStrip->hide();
ui->findEvent->setFocus();
}
void EventBrowser::on_gotoEID_clicked()
{
ui->jumpStrip->show();
ui->findStrip->hide();
ui->bookmarkStrip->hide();
ui->jumpToEID->setFocus();
ui->jumpStrip->show();
ui->findStrip->hide();
ui->bookmarkStrip->hide();
ui->jumpToEID->setFocus();
}
void EventBrowser::on_toolButton_clicked()
{
ui->jumpStrip->hide();
ui->findStrip->hide();
ui->bookmarkStrip->show();
ui->jumpStrip->hide();
ui->findStrip->hide();
ui->bookmarkStrip->show();
}
static void SetDrawcallTimes(QTreeWidgetItem *node, const rdctype::array<CounterResult> &results)
{
if(node == NULL) return;
if(node == NULL) return;
// parent nodes take the value of the sum of their children
double duration = 0.0;
// parent nodes take the value of the sum of their children
double duration = 0.0;
// look up leaf nodes in the dictionary
if(node->childCount() == 0)
{
uint eid = node->data(COL_EID, Qt::UserRole).toUInt();
// look up leaf nodes in the dictionary
if(node->childCount() == 0)
{
uint eid = node->data(COL_EID, Qt::UserRole).toUInt();
duration = -1.0;
duration = -1.0;
for(int32_t i=0; i < results.count; i++)
{
if(results[i].eventID == eid)
duration = results[i].value.d;
}
for(int32_t i = 0; i < results.count; i++)
{
if(results[i].eventID == eid)
duration = results[i].value.d;
}
node->setText(COL_DURATION, duration < 0.0f ? "" : QString::number(duration*1000000.0));
node->setData(COL_DURATION, Qt::UserRole, QVariant(duration));
node->setText(COL_DURATION, duration < 0.0f ? "" : QString::number(duration*1000000.0));
node->setData(COL_DURATION, Qt::UserRole, QVariant(duration));
return;
}
return;
}
for(int i = 0; i < node->childCount(); i++)
{
SetDrawcallTimes(node->child(i), results);
for(int i = 0; i < node->childCount(); i++)
{
SetDrawcallTimes(node->child(i), results);
double nd = node->child(i)->data(COL_DURATION, Qt::UserRole).toDouble();
double nd = node->child(i)->data(COL_DURATION, Qt::UserRole).toDouble();
if(nd > 0.0)
duration += nd;
}
if(nd > 0.0)
duration += nd;
}
node->setText(COL_DURATION, duration < 0.0f ? "" : QString::number(duration*1000000.0));
node->setData(COL_DURATION, Qt::UserRole, QVariant(duration));
node->setText(COL_DURATION, duration < 0.0f ? "" : QString::number(duration*1000000.0));
node->setData(COL_DURATION, Qt::UserRole, QVariant(duration));
}
void EventBrowser::on_timeDraws_clicked()
{
m_Core->Renderer()->AsyncInvoke([this](IReplayRenderer *r) {
m_Core->Renderer()->AsyncInvoke([this](IReplayRenderer *r) {
uint32_t counters[] = { eCounter_EventGPUDuration };
uint32_t counters[] = { eCounter_EventGPUDuration };
rdctype::array<CounterResult> results;
r->FetchCounters(m_Core->CurFrame(), 0, ~0U, counters, 1, &results);
rdctype::array<CounterResult> results;
r->FetchCounters(m_Core->CurFrame(), 0, ~0U, counters, 1, &results);
GUIInvoke::blockcall([this,results]() {
SetDrawcallTimes(ui->events->topLevelItem(0), results);
_CrtCheckMemory();
});
});
GUIInvoke::blockcall([this, results]() {
SetDrawcallTimes(ui->events->topLevelItem(0), results);
_CrtCheckMemory();
});
});
}
void EventBrowser::on_events_itemSelectionChanged()
{
if(ui->events->selectedItems().empty()) return;
if(ui->events->selectedItems().empty()) return;
uint EID = ui->events->selectedItems()[0]->data(COL_EID, Qt::UserRole).toUInt();
uint EID = ui->events->selectedItems()[0]->data(COL_EID, Qt::UserRole).toUInt();
m_Core->SetEventID(this, 0, EID);
m_Core->SetEventID(this, 0, EID);
}
void EventBrowser::hideFindJump()
{
ui->jumpStrip->hide();
ui->findStrip->hide();
ui->jumpStrip->hide();
ui->findStrip->hide();
}
void EventBrowser::on_jumpToEID_returnPressed()
{
bool ok = false;
uint eid = ui->findEvent->text().toUInt(&ok);
if(ok)
{
//SelectEvent(0, eid);
}
bool ok = false;
uint eid = ui->findEvent->text().toUInt(&ok);
if(ok)
{
//SelectEvent(0, eid);
}
}
void EventBrowser::on_findEvent_returnPressed()
+21 -20
View File
@@ -6,41 +6,42 @@
#include "Code/Core.h"
namespace Ui {
class EventBrowser;
class EventBrowser;
}
class EventBrowser : public QFrame, public ILogViewerForm
{
Q_OBJECT
private:
Q_OBJECT
public:
explicit EventBrowser(Core *core, QWidget *parent = 0);
~EventBrowser();
public:
explicit EventBrowser(Core *core, QWidget *parent = 0);
~EventBrowser();
void OnLogfileLoaded();
void OnLogfileClosed();
void OnEventSelected(uint32_t frameID, uint32_t eventID);
void OnLogfileLoaded();
void OnLogfileClosed();
void OnEventSelected(uint32_t frameID, uint32_t eventID);
private slots:
void on_find_clicked();
private slots:
void on_find_clicked();
void on_gotoEID_clicked();
void on_gotoEID_clicked();
void on_events_itemSelectionChanged();
void on_events_itemSelectionChanged();
void on_timeDraws_clicked();
void on_timeDraws_clicked();
void on_toolButton_clicked();
void on_toolButton_clicked();
void hideFindJump();
void hideFindJump();
void on_jumpToEID_returnPressed();
void on_jumpToEID_returnPressed();
void on_findEvent_returnPressed();
void on_findEvent_returnPressed();
private:
Ui::EventBrowser *ui;
Core *m_Core;
private:
Ui::EventBrowser *ui;
Core *m_Core;
};
#endif // EVENTBROWSER_H
+23 -23
View File
@@ -9,46 +9,46 @@
#include "Code/Core.h"
MainWindow::MainWindow(Core *core) :
QMainWindow(NULL),
ui(new Ui::MainWindow),
m_Core(core)
QMainWindow(NULL),
ui(new Ui::MainWindow),
m_Core(core)
{
ui->setupUi(this);
ui->setupUi(this);
EventBrowser *eventbrowser = new EventBrowser(core);
EventBrowser *eventbrowser = new EventBrowser(core);
ui->toolWindowManager->addToolWindow(eventbrowser, ToolWindowManager::EmptySpace);
ui->toolWindowManager->addToolWindow(eventbrowser, ToolWindowManager::EmptySpace);
TextureViewer *textureviewer = new TextureViewer(core);
TextureViewer *textureviewer = new TextureViewer(core);
ui->toolWindowManager->addToolWindow(textureviewer, ToolWindowManager::AreaReference(ToolWindowManager::RightOf, ui->toolWindowManager->areaOf(eventbrowser)));
ui->toolWindowManager->addToolWindow(textureviewer, ToolWindowManager::AreaReference(ToolWindowManager::RightOf, ui->toolWindowManager->areaOf(eventbrowser)));
ui->toolWindowManager->setRubberBandLineWidth(50);
ui->toolWindowManager->setRubberBandLineWidth(50);
}
MainWindow::~MainWindow()
{
delete ui;
delete ui;
}
void MainWindow::on_action_Exit_triggered()
{
this->close();
this->close();
}
void MainWindow::on_action_Open_Log_triggered()
{
QString filename = QFileDialog::getOpenFileName(this,
"Select Logfile to open",
"",
"Log Files (*.rdc);;Image Files (*.dds *.hdr *.exr *.bmp *.jpg *.jpeg *.png *.tga *.gif *.psd;;All Files (*.*)");
QString filename = QFileDialog::getOpenFileName(this,
"Select Logfile to open",
"",
"Log Files (*.rdc);;Image Files (*.dds *.hdr *.exr *.bmp *.jpg *.jpeg *.png *.tga *.gif *.psd;;All Files (*.*)");
QFileInfo checkFile(filename);
if(filename != "" && checkFile.exists() && checkFile.isFile())
{
LambdaThread *thread = new LambdaThread([filename,this] () {
m_Core->LoadLogfile(filename, false);
});
thread->start();
}
QFileInfo checkFile(filename);
if(filename != "" && checkFile.exists() && checkFile.isFile())
{
LambdaThread *thread = new LambdaThread([filename, this]() {
m_Core->LoadLogfile(filename, false);
});
thread->start();
}
}
+12 -11
View File
@@ -5,27 +5,28 @@
#include <stdint.h>
namespace Ui {
class MainWindow;
class MainWindow;
}
class Core;
class MainWindow : public QMainWindow
{
Q_OBJECT
private:
Q_OBJECT
public:
explicit MainWindow(Core *core);
~MainWindow();
public:
explicit MainWindow(Core *core);
~MainWindow();
private slots:
void on_action_Exit_triggered();
private slots:
void on_action_Exit_triggered();
void on_action_Open_Log_triggered();
void on_action_Open_Log_triggered();
private:
Ui::MainWindow *ui;
Core *m_Core;
private:
Ui::MainWindow *ui;
Core *m_Core;
};
#endif // MAINWINDOW_H
+50 -50
View File
@@ -10,81 +10,81 @@
#endif
TextureViewer::TextureViewer(Core *core, QWidget *parent) :
QFrame(parent),
ui(new Ui::TextureViewer),
m_Core(core)
QFrame(parent),
ui(new Ui::TextureViewer),
m_Core(core)
{
ui->setupUi(this);
ui->setupUi(this);
m_Core->AddLogViewer(this);
m_Core->AddLogViewer(this);
ui->framerender->SetOutput(NULL);
m_Output = NULL;
ui->framerender->SetOutput(NULL);
m_Output = NULL;
}
TextureViewer::~TextureViewer()
{
m_Core->RemoveLogViewer(this);
delete ui;
m_Core->RemoveLogViewer(this);
delete ui;
}
void TextureViewer::OnLogfileLoaded()
{
#if defined(WIN32)
HWND wnd = (HWND)ui->framerender->winId();
HWND wnd = (HWND)ui->framerender->winId();
#elif defined(__linux__)
Display *display = QX11Info::display();
GLXDrawable drawable = (GLXDrawable)ui->framerender->winId();
Display *display = QX11Info::display();
GLXDrawable drawable = (GLXDrawable)ui->framerender->winId();
void *displayAndDrawable[2] = { (void *)display, (void *)drawable };
void *wnd = displayAndDrawable;
void *displayAndDrawable[2] = { (void *)display, (void *)drawable };
void *wnd = displayAndDrawable;
#else
#error "Unknown platform"
#error "Unknown platform"
#endif
m_Core->Renderer()->BlockInvoke([wnd,this](IReplayRenderer *r) {
m_Output = r->CreateOutput(wnd);
ui->framerender->SetOutput(m_Output);
m_Core->Renderer()->BlockInvoke([wnd, this](IReplayRenderer *r) {
m_Output = r->CreateOutput(wnd);
ui->framerender->SetOutput(m_Output);
OutputConfig c = { eOutputType_TexDisplay };
m_Output->SetOutputConfig(c);
});
OutputConfig c = { eOutputType_TexDisplay };
m_Output->SetOutputConfig(c);
});
}
void TextureViewer::OnLogfileClosed()
{
m_Output = NULL;
ui->framerender->SetOutput(NULL);
m_Output = NULL;
ui->framerender->SetOutput(NULL);
}
void TextureViewer::OnEventSelected(uint32_t frameID, uint32_t eventID)
{
m_Core->Renderer()->AsyncInvoke([this](IReplayRenderer *) {
TextureDisplay d;
if(m_Core->APIProps().pipelineType == ePipelineState_D3D11)
d.texid = m_Core->CurD3D11PipelineState.m_OM.RenderTargets[0].Resource;
else
d.texid = m_Core->CurGLPipelineState.m_FB.m_DrawFBO.Color[0];
d.mip = 0;
d.sampleIdx = ~0U;
d.overlay = eTexOverlay_None;
d.CustomShader = ResourceId();
d.HDRMul = -1.0f;
d.linearDisplayAsGamma = true;
d.FlipY = false;
d.rangemin = 0.0f;
d.rangemax = 1.0f;
d.scale = -1.0f;
d.offx = 0.0f;
d.offy = 0.0f;
d.sliceFace = 0;
d.rawoutput = false;
d.lightBackgroundColour = d.darkBackgroundColour =
FloatVector(0.0f, 0.0f, 0.0f, 0.0f);
d.Red = d.Green = d.Blue = true;
d.Alpha = false;
m_Output->SetTextureDisplay(d);
m_Core->Renderer()->AsyncInvoke([this](IReplayRenderer *) {
TextureDisplay d;
if(m_Core->APIProps().pipelineType == ePipelineState_D3D11)
d.texid = m_Core->CurD3D11PipelineState.m_OM.RenderTargets[0].Resource;
else
d.texid = m_Core->CurGLPipelineState.m_FB.m_DrawFBO.Color[0];
d.mip = 0;
d.sampleIdx = ~0U;
d.overlay = eTexOverlay_None;
d.CustomShader = ResourceId();
d.HDRMul = -1.0f;
d.linearDisplayAsGamma = true;
d.FlipY = false;
d.rangemin = 0.0f;
d.rangemax = 1.0f;
d.scale = -1.0f;
d.offx = 0.0f;
d.offy = 0.0f;
d.sliceFace = 0;
d.rawoutput = false;
d.lightBackgroundColour = d.darkBackgroundColour =
FloatVector(0.0f, 0.0f, 0.0f, 0.0f);
d.Red = d.Green = d.Blue = true;
d.Alpha = false;
m_Output->SetTextureDisplay(d);
GUIInvoke::call([this]() { ui->framerender->update(); });
});
GUIInvoke::call([this]() { ui->framerender->update(); });
});
}
+13 -12
View File
@@ -6,25 +6,26 @@
#include "Code/Core.h"
namespace Ui {
class TextureViewer;
class TextureViewer;
}
class TextureViewer : public QFrame, public ILogViewerForm
{
Q_OBJECT
private:
Q_OBJECT
public:
explicit TextureViewer(Core *core, QWidget *parent = 0);
~TextureViewer();
public:
explicit TextureViewer(Core *core, QWidget *parent = 0);
~TextureViewer();
void OnLogfileLoaded();
void OnLogfileClosed();
void OnEventSelected(uint32_t frameID, uint32_t eventID);
void OnLogfileLoaded();
void OnLogfileClosed();
void OnEventSelected(uint32_t frameID, uint32_t eventID);
private:
Ui::TextureViewer *ui;
Core *m_Core;
IReplayOutput *m_Output;
private:
Ui::TextureViewer *ui;
Core *m_Core;
IReplayOutput *m_Output;
};
#endif // TEXTUREVIEWER_H