Add toolbar button to switch between HLSL and assembly debugging

* This hopefully makes the HLSL debug mode more obvious to people.
This commit is contained in:
baldurk committed 2018-06-22 19:28:34 +01:00
1 parent c5689827a9
commit 04f214c768
3 files changed
+86 -20

No files matched your search

+47 -10
View File
@@ -209,6 +209,8 @@ void ShaderViewer::editShader(bool customShader, const QString &entryPoint, cons
ui->regFormatSep->hide();
ui->intView->hide();
ui->floatView->hide();
ui->debugToggleSep->hide();
ui->debugToggle->hide();
// hide signatures
ui->inputSig->hide();
@@ -407,6 +409,12 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR
ui->inputSig->hide();
ui->outputSig->hide();
if(shader->debugInfo.files.isEmpty())
{
ui->debugToggle->setEnabled(false);
ui->debugToggle->setText(tr("HLSL Unavailable"));
}
ui->registers->setColumns({tr("Name"), tr("Type"), tr("Value")});
ui->registers->header()->setSectionResizeMode(0, QHeaderView::Interactive);
ui->registers->header()->setSectionResizeMode(1, QHeaderView::Interactive);
@@ -571,6 +579,8 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR
ui->regFormatSep->hide();
ui->intView->hide();
ui->floatView->hide();
ui->debugToggleSep->hide();
ui->debugToggle->hide();
// show input and output signatures
ui->inputSig->setColumns(
@@ -706,6 +716,21 @@ void ShaderViewer::updateWindowTitle()
}
}
void ShaderViewer::gotoSourceDebugging()
{
if(m_CurInstructionScintilla)
{
ToolWindowManager::raiseToolWindow(m_CurInstructionScintilla);
m_CurInstructionScintilla->setFocus(Qt::MouseFocusReason);
}
}
void ShaderViewer::gotoDisassemblyDebugging()
{
ToolWindowManager::raiseToolWindow(m_DisassemblyFrame);
m_DisassemblyFrame->setFocus(Qt::MouseFocusReason);
}
ShaderViewer::~ShaderViewer()
{
// don't want to async invoke while using 'this', so save the trace separately
@@ -849,16 +874,10 @@ void ShaderViewer::debug_contextMenu(const QPoint &pos)
QAction gotoOther(isDisasm ? tr("Go to Source") : tr("Go to Disassembly"), this);
QObject::connect(&gotoOther, &QAction::triggered, [this, isDisasm]() {
if(isDisasm && m_CurInstructionScintilla)
{
ToolWindowManager::raiseToolWindow(m_CurInstructionScintilla);
m_CurInstructionScintilla->setFocus(Qt::MouseFocusReason);
}
else if(!isDisasm)
{
ToolWindowManager::raiseToolWindow(m_DisassemblyFrame);
m_DisassemblyFrame->setFocus(Qt::MouseFocusReason);
}
if(isDisasm)
gotoSourceDebugging();
else
gotoDisassemblyDebugging();
updateDebugging();
});
@@ -1529,6 +1548,14 @@ void ShaderViewer::updateDebugging()
if(!m_Trace || m_CurrentStep < 0 || m_CurrentStep >= m_Trace->states.count())
return;
if(ui->debugToggle->isEnabled())
{
if(isSourceDebugging())
ui->debugToggle->setText(tr("Debug in Assembly"));
else
ui->debugToggle->setText(tr("Debug in HLSL"));
}
const ShaderDebugState &state = m_Trace->states[m_CurrentStep];
uint32_t nextInst = state.nextInstruction;
@@ -3041,6 +3068,16 @@ void ShaderViewer::on_floatView_clicked()
updateDebugging();
}
void ShaderViewer::on_debugToggle_clicked()
{
if(isSourceDebugging())
gotoDisassemblyDebugging();
else
gotoSourceDebugging();
updateDebugging();
}
ScintillaEdit *ShaderViewer::currentScintilla()
{
ScintillaEdit *cur = qobject_cast<ScintillaEdit *>(QApplication::focusWidget());
+3
View File
@@ -112,6 +112,7 @@ private slots:
void on_refresh_clicked();
void on_intView_clicked();
void on_floatView_clicked();
void on_debugToggle_clicked();
void on_watch_itemChanged(QTableWidgetItem *item);
@@ -158,6 +159,8 @@ private:
void getRegisterFromWord(const QString &text, VariableCategory &varCat, int &varIdx, int &arrayIdx);
void updateWindowTitle();
void gotoSourceDebugging();
void gotoDisassemblyDebugging();
void showVariableTooltip(VariableCategory varCat, int varIdx, int arrayIdx);
void showVariableTooltip(QString name);
+36 -10
View File
@@ -205,7 +205,7 @@
</widget>
</item>
<item>
<widget class="Line" name="editSep">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@@ -255,7 +255,7 @@
</widget>
</item>
<item>
<widget class="Line" name="debugSep">
<widget class="Line" name="editSep">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@@ -321,6 +321,13 @@
</property>
</widget>
</item>
<item>
<widget class="Line" name="debugSep">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="run">
<property name="toolTip">
@@ -341,13 +348,6 @@
</property>
</widget>
</item>
<item>
<widget class="Line" name="regFormatSep">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="runToCursor">
<property name="minimumSize">
@@ -427,7 +427,7 @@
</widget>
</item>
<item>
<widget class="Line" name="line">
<widget class="Line" name="regFormatSep">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@@ -465,6 +465,32 @@
</property>
</widget>
</item>
<item>
<widget class="Line" name="debugToggleSep">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="debugToggle">
<property name="minimumSize">
<size>
<width>23</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Change the debugging view</string>
</property>
<property name="text">
<string notr="true">Debug Toggle</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">