mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-21 22:16:38 +00:00
Wait for shader viewer background debugging, add cancel button
* Until we properly support background debugging we need to wait for it to complete, otherwise the user could close the window and we'd crash.
This commit is contained in:
@@ -1953,6 +1953,7 @@ public:
|
||||
setLabel(&m_Label);
|
||||
}
|
||||
|
||||
void enableCancel() { setCancelButtonText(tr("Cancel")); }
|
||||
void setPercentage(float percent) { setValue(int(maxProgress * percent)); }
|
||||
void setInfinite(bool infinite)
|
||||
{
|
||||
@@ -2299,13 +2300,16 @@ QStringList ParseArgsList(const QString &args)
|
||||
}
|
||||
|
||||
void ShowProgressDialog(QWidget *window, const QString &labelText, ProgressFinishedMethod finished,
|
||||
ProgressUpdateMethod update)
|
||||
ProgressUpdateMethod update, ProgressCancelMethod cancel)
|
||||
{
|
||||
if(finished())
|
||||
return;
|
||||
|
||||
RDProgressDialog dialog(labelText, window);
|
||||
|
||||
if(cancel)
|
||||
dialog.enableCancel();
|
||||
|
||||
// if we don't have an update function, set the progress display to be 'infinite spinner'
|
||||
dialog.setInfinite(!update);
|
||||
|
||||
@@ -2338,6 +2342,9 @@ void ShowProgressDialog(QWidget *window, const QString &labelText, ProgressFinis
|
||||
// to clean itself up
|
||||
tickerSemaphore.tryAcquire();
|
||||
progressTickerThread.wait();
|
||||
|
||||
if(cancel && dialog.wasCanceled())
|
||||
cancel();
|
||||
}
|
||||
|
||||
void UpdateTransferProgress(qint64 xfer, qint64 total, QElapsedTimer *timer,
|
||||
|
||||
@@ -666,6 +666,7 @@ class QElapsedTimer;
|
||||
|
||||
typedef std::function<float()> ProgressUpdateMethod;
|
||||
typedef std::function<bool()> ProgressFinishedMethod;
|
||||
typedef std::function<void()> ProgressCancelMethod;
|
||||
|
||||
QStringList ParseArgsList(const QString &args);
|
||||
bool IsRunningAsAdmin();
|
||||
@@ -676,7 +677,8 @@ bool RunProcessAsAdmin(const QString &fullExecutablePath, const QStringList &par
|
||||
void RevealFilenameInExternalFileBrowser(const QString &filePath);
|
||||
|
||||
void ShowProgressDialog(QWidget *window, const QString &labelText, ProgressFinishedMethod finished,
|
||||
ProgressUpdateMethod update = ProgressUpdateMethod());
|
||||
ProgressUpdateMethod update = ProgressUpdateMethod(),
|
||||
ProgressCancelMethod cancel = ProgressCancelMethod());
|
||||
|
||||
void UpdateTransferProgress(qint64 xfer, qint64 total, QElapsedTimer *timer,
|
||||
QProgressBar *progressBar, QLabel *progressLabel, QString progressText);
|
||||
|
||||
@@ -663,19 +663,43 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR
|
||||
|
||||
cacheResources();
|
||||
|
||||
m_Ctx.Replay().AsyncInvoke([this](IReplayController *r) {
|
||||
m_BackgroundRunning.release();
|
||||
|
||||
QPointer<ShaderViewer> me(this);
|
||||
|
||||
m_Ctx.Replay().AsyncInvoke([this, me](IReplayController *r) {
|
||||
if(!me)
|
||||
return;
|
||||
|
||||
rdcarray<ShaderDebugState> states = r->ContinueDebug(m_Trace->debugger);
|
||||
|
||||
bool finished = false;
|
||||
do
|
||||
{
|
||||
if(!me)
|
||||
return;
|
||||
|
||||
rdcarray<ShaderDebugState> nextStates = r->ContinueDebug(m_Trace->debugger);
|
||||
|
||||
QThread::msleep(5000);
|
||||
|
||||
if(!me)
|
||||
return;
|
||||
|
||||
states.append(nextStates);
|
||||
finished = nextStates.empty();
|
||||
} while(!finished);
|
||||
} while(!finished && m_BackgroundRunning.available() == 1);
|
||||
|
||||
if(!me || m_BackgroundRunning.available() != 1)
|
||||
return;
|
||||
|
||||
m_BackgroundRunning.tryAcquire(1);
|
||||
|
||||
r->SetFrameEvent(m_Ctx.CurEvent(), true);
|
||||
|
||||
if(!me)
|
||||
return;
|
||||
|
||||
GUIInvoke::call(this, [this, states]() {
|
||||
m_States = states;
|
||||
|
||||
@@ -708,6 +732,18 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR
|
||||
});
|
||||
});
|
||||
|
||||
GUIInvoke::defer(this, [this, debugContext]() {
|
||||
// wait a short while before displaying the progress dialog (which won't show if we're already
|
||||
// done by the time we reach it)
|
||||
for(int i = 0; m_BackgroundRunning.available() == 1 && i < 100; i++)
|
||||
QThread::msleep(5);
|
||||
|
||||
ShowProgressDialog(this, tr("Debugging %1").arg(debugContext),
|
||||
[this]() { return m_BackgroundRunning.available() == 0; }, NULL,
|
||||
[this]() { m_BackgroundRunning.acquire(); });
|
||||
|
||||
});
|
||||
|
||||
m_CurrentStateIdx = 0;
|
||||
|
||||
QObject::connect(ui->watch, &RDTableWidget::keyPress, this, &ShaderViewer::watch_keyPress);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
#include <QSemaphore>
|
||||
#include "Code/Interface/QRDInterface.h"
|
||||
|
||||
namespace Ui
|
||||
@@ -254,6 +255,8 @@ private:
|
||||
size_t m_CurrentStateIdx = 0;
|
||||
rdcarray<ShaderVariable> m_Variables;
|
||||
|
||||
QSemaphore m_BackgroundRunning;
|
||||
|
||||
rdcarray<AccessedResourceData> m_AccessedResources;
|
||||
AccessedResourceView m_AccessedResourceView = AccessedResourceView::SortByResource;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user