Display stencil values in binary and decimal in tooltips. Closes #2052

This commit is contained in:
baldurk
2020-10-01 15:56:52 +01:00
parent 7541b49c95
commit 55c57f7e89
9 changed files with 110 additions and 42 deletions
+2 -1
View File
@@ -358,7 +358,8 @@ QVariant RDTreeWidgetItem::data(int column, int role) const
}
else if(role == Qt::ToolTipRole && !m_widget->m_instantTooltips)
{
return m_tooltip;
if(!m_tooltip.isEmpty())
return m_tooltip;
}
else if(role == Qt::FontRole)
{
+7 -2
View File
@@ -115,14 +115,19 @@ public:
m_tooltip = value;
dataChanged(0, Qt::ToolTipRole);
}
inline void setToolTip(int column, const QString &value)
{
setData(column, Qt::ToolTipRole, value);
dataChanged(0, Qt::ToolTipRole);
}
inline Qt::CheckState checkState(int column) const
{
return static_cast<Qt::CheckState>(data(column, Qt::CheckStateRole).toInt());
return (Qt::CheckState)data(column, Qt::CheckStateRole).toInt();
}
inline void setCheckState(int column, Qt::CheckState state)
{
setData(column, Qt::CheckStateRole, static_cast<int>(state));
setData(column, Qt::CheckStateRole, int(state));
dataChanged(column, Qt::CheckStateRole);
}
@@ -1823,12 +1823,12 @@ void D3D11PipelineStateViewer::setState()
ui->depthWrite->setPixmap(state.outputMerger.depthStencilState.depthWrites ? tick : cross);
ui->stencilEnabled->setPixmap(state.outputMerger.depthStencilState.stencilEnable ? tick : cross);
ui->stencilReadMask->setText(
Formatter::Format((uint8_t)state.outputMerger.depthStencilState.frontFace.compareMask, true));
ui->stencilWriteMask->setText(
Formatter::Format((uint8_t)state.outputMerger.depthStencilState.frontFace.writeMask, true));
ui->stencilRef->setText(
Formatter::Format((uint8_t)state.outputMerger.depthStencilState.frontFace.reference, true));
m_Common.SetStencilLabelValue(
ui->stencilReadMask, (uint8_t)state.outputMerger.depthStencilState.frontFace.compareMask);
m_Common.SetStencilLabelValue(ui->stencilWriteMask,
(uint8_t)state.outputMerger.depthStencilState.frontFace.writeMask);
m_Common.SetStencilLabelValue(ui->stencilRef,
(uint8_t)state.outputMerger.depthStencilState.frontFace.reference);
ui->stencils->beginUpdate();
ui->stencils->clear();
@@ -1800,12 +1800,12 @@ void D3D12PipelineStateViewer::setState()
}
ui->stencilEnabled->setPixmap(state.outputMerger.depthStencilState.stencilEnable ? tick : cross);
ui->stencilReadMask->setText(
Formatter::Format((uint8_t)state.outputMerger.depthStencilState.frontFace.compareMask, true));
ui->stencilWriteMask->setText(
Formatter::Format((uint8_t)state.outputMerger.depthStencilState.frontFace.writeMask, true));
ui->stencilRef->setText(
Formatter::Format((uint8_t)state.outputMerger.depthStencilState.frontFace.reference, true));
m_Common.SetStencilLabelValue(
ui->stencilReadMask, (uint8_t)state.outputMerger.depthStencilState.frontFace.compareMask);
m_Common.SetStencilLabelValue(ui->stencilWriteMask,
(uint8_t)state.outputMerger.depthStencilState.frontFace.writeMask);
m_Common.SetStencilLabelValue(ui->stencilRef,
(uint8_t)state.outputMerger.depthStencilState.frontFace.reference);
ui->stencils->beginUpdate();
ui->stencils->clear();
@@ -2102,14 +2102,19 @@ void GLPipelineStateViewer::setState()
ui->stencils->clear();
if(state.stencilState.stencilEnable)
{
ui->stencils->addTopLevelItem(new RDTreeWidgetItem(
{tr("Front"), ToQStr(state.stencilState.frontFace.function),
ToQStr(state.stencilState.frontFace.failOperation),
ToQStr(state.stencilState.frontFace.depthFailOperation),
ToQStr(state.stencilState.frontFace.passOperation),
Formatter::Format((uint8_t)state.stencilState.frontFace.writeMask, true),
Formatter::Format((uint8_t)state.stencilState.frontFace.compareMask, true),
Formatter::Format((uint8_t)state.stencilState.frontFace.reference, true)}));
ui->stencils->addTopLevelItem(new RDTreeWidgetItem({
tr("Front"), ToQStr(state.stencilState.frontFace.function),
ToQStr(state.stencilState.frontFace.failOperation),
ToQStr(state.stencilState.frontFace.depthFailOperation),
ToQStr(state.stencilState.frontFace.passOperation), QVariant(), QVariant(), QVariant(),
}));
m_Common.SetStencilTreeItemValue(ui->stencils->topLevelItem(0), 5,
state.stencilState.frontFace.writeMask);
m_Common.SetStencilTreeItemValue(ui->stencils->topLevelItem(0), 6,
state.stencilState.frontFace.compareMask);
m_Common.SetStencilTreeItemValue(ui->stencils->topLevelItem(0), 7,
state.stencilState.frontFace.reference);
ui->stencils->addTopLevelItem(new RDTreeWidgetItem(
{tr("Back"), ToQStr(state.stencilState.backFace.function),
@@ -2119,6 +2124,13 @@ void GLPipelineStateViewer::setState()
Formatter::Format((uint8_t)state.stencilState.backFace.writeMask, true),
Formatter::Format((uint8_t)state.stencilState.backFace.compareMask, true),
Formatter::Format((uint8_t)state.stencilState.backFace.reference, true)}));
m_Common.SetStencilTreeItemValue(ui->stencils->topLevelItem(1), 5,
state.stencilState.backFace.writeMask);
m_Common.SetStencilTreeItemValue(ui->stencils->topLevelItem(1), 6,
state.stencilState.backFace.compareMask);
m_Common.SetStencilTreeItemValue(ui->stencils->topLevelItem(1), 7,
state.stencilState.backFace.reference);
}
else
{
@@ -32,6 +32,7 @@
#include "Code/QRDUtils.h"
#include "Code/Resources.h"
#include "Widgets/Extended/RDLabel.h"
#include "Widgets/Extended/RDTreeWidget.h"
#include "toolwindowmanager/ToolWindowManager.h"
#include "D3D11PipelineStateViewer.h"
#include "D3D12PipelineStateViewer.h"
@@ -656,6 +657,24 @@ void PipelineStateViewer::showEvent(QShowEvent *event)
}
}
void PipelineStateViewer::SetStencilLabelValue(QLabel *label, uint8_t value)
{
label->setText(Formatter::Format(value, true));
label->setToolTip(tr("%1 / 0x%2 / 0b%3")
.arg(value, 3, 10, QLatin1Char(' '))
.arg(Formatter::Format(value, true))
.arg(value, 8, 2, QLatin1Char('0')));
}
void PipelineStateViewer::SetStencilTreeItemValue(RDTreeWidgetItem *item, int column, uint8_t value)
{
item->setText(column, Formatter::Format(value, true));
item->setToolTip(column, tr("%1 / 0x%2 / 0b%3")
.arg(value, 3, 10, QLatin1Char(' '))
.arg(Formatter::Format(value, true))
.arg(value, 8, 2, QLatin1Char('0')));
}
QString PipelineStateViewer::GenerateHLSLStub(const ShaderBindpointMapping &bindpointMapping,
const ShaderReflection *shaderDetails,
const QString &entryFunc)
@@ -38,6 +38,7 @@ class QXmlStreamWriter;
class QToolButton;
class QMenu;
class RDLabel;
class RDTreeWidgetItem;
class D3D11PipelineStateViewer;
class D3D12PipelineStateViewer;
@@ -67,6 +68,9 @@ public:
QVariant persistData();
void setPersistData(const QVariant &persistData);
void SetStencilLabelValue(QLabel *label, uint8_t value);
void SetStencilTreeItemValue(RDTreeWidgetItem *item, int column, uint8_t value);
void SetupShaderEditButton(QToolButton *button, ResourceId pipelineId, ResourceId shaderId,
const ShaderBindpointMapping &bindpointMapping,
const ShaderReflection *shaderDetails);
@@ -2574,22 +2574,33 @@ void VulkanPipelineStateViewer::setState()
ui->stencils->clear();
if(state.depthStencil.stencilTestEnable)
{
ui->stencils->addTopLevelItem(new RDTreeWidgetItem(
{tr("Front"), ToQStr(state.depthStencil.frontFace.function),
ToQStr(state.depthStencil.frontFace.failOperation),
ToQStr(state.depthStencil.frontFace.depthFailOperation),
ToQStr(state.depthStencil.frontFace.passOperation),
Formatter::Format((uint8_t)state.depthStencil.frontFace.writeMask, true),
Formatter::Format((uint8_t)state.depthStencil.frontFace.compareMask, true),
Formatter::Format((uint8_t)state.depthStencil.frontFace.reference, true)}));
ui->stencils->addTopLevelItem(new RDTreeWidgetItem(
{tr("Back"), ToQStr(state.depthStencil.backFace.function),
ToQStr(state.depthStencil.backFace.failOperation),
ToQStr(state.depthStencil.backFace.depthFailOperation),
ToQStr(state.depthStencil.backFace.passOperation),
Formatter::Format((uint8_t)state.depthStencil.backFace.writeMask, true),
Formatter::Format((uint8_t)state.depthStencil.backFace.compareMask, true),
Formatter::Format((uint8_t)state.depthStencil.backFace.reference, true)}));
ui->stencils->addTopLevelItem(new RDTreeWidgetItem({
tr("Front"), ToQStr(state.depthStencil.frontFace.function),
ToQStr(state.depthStencil.frontFace.failOperation),
ToQStr(state.depthStencil.frontFace.depthFailOperation),
ToQStr(state.depthStencil.frontFace.passOperation), QVariant(), QVariant(), QVariant(),
}));
m_Common.SetStencilTreeItemValue(ui->stencils->topLevelItem(0), 5,
state.depthStencil.frontFace.writeMask);
m_Common.SetStencilTreeItemValue(ui->stencils->topLevelItem(0), 6,
state.depthStencil.frontFace.compareMask);
m_Common.SetStencilTreeItemValue(ui->stencils->topLevelItem(0), 7,
state.depthStencil.frontFace.reference);
ui->stencils->addTopLevelItem(new RDTreeWidgetItem({
tr("Back"), ToQStr(state.depthStencil.backFace.function),
ToQStr(state.depthStencil.backFace.failOperation),
ToQStr(state.depthStencil.backFace.depthFailOperation),
ToQStr(state.depthStencil.backFace.passOperation), QVariant(), QVariant(), QVariant(),
}));
m_Common.SetStencilTreeItemValue(ui->stencils->topLevelItem(1), 5,
state.depthStencil.backFace.writeMask);
m_Common.SetStencilTreeItemValue(ui->stencils->topLevelItem(1), 6,
state.depthStencil.backFace.compareMask);
m_Common.SetStencilTreeItemValue(ui->stencils->topLevelItem(1), 7,
state.depthStencil.backFace.reference);
}
else
{
+19 -3
View File
@@ -1082,6 +1082,7 @@ void TextureViewer::UI_UpdateStatusText()
ui->hoverText->setText(hoverText);
QString pickedText;
QString pickedTooltip;
if(m_PickedPoint.x() >= 0)
{
@@ -1126,10 +1127,24 @@ void TextureViewer::UI_UpdateStatusText()
pickedText += Formatter::Format(val.floatValue[0]);
}
int stencil = (int)(255.0f * val.floatValue[1]);
if(tex.format.type == ResourceFormatType::D16S8 ||
tex.format.type == ResourceFormatType::D24S8 ||
tex.format.type == ResourceFormatType::D32S8 || tex.format.type == ResourceFormatType::S8)
{
int stencil = (int)(255.0f * val.floatValue[1]);
pickedText +=
tr(", Stencil %1 / 0x%2").arg(stencil).arg(Formatter::Format(uint8_t(stencil & 0xff), true));
if(tex.format.type == ResourceFormatType::S8)
pickedText.clear();
else
pickedText += lit(", ");
pickedText += tr("Stencil 0x%1").arg(Formatter::Format(uint8_t(stencil & 0xff), true));
pickedTooltip = tr("Stencil: %1 / 0x%2 / 0b%3")
.arg(stencil, 3, 10, QLatin1Char(' '))
.arg(Formatter::Format(uint8_t(stencil & 0xff), true))
.arg(stencil, 8, 2, QLatin1Char('0'));
}
}
else
{
@@ -1185,6 +1200,7 @@ void TextureViewer::UI_UpdateStatusText()
pickedText += QString(m_HighWaterStatusLength - pickedText.length(), QLatin1Char(' '));
ui->pickedText->setText(pickedText);
ui->pickedText->setToolTip(pickedTooltip);
}
void TextureViewer::UI_UpdateTextureDetails()