Use Formatter::Format for formatting hex numbers

This commit is contained in:
baldurk
2017-05-12 15:26:36 +01:00
parent 08fa2ec411
commit 5986f209e1
10 changed files with 48 additions and 58 deletions
@@ -1677,8 +1677,7 @@ void D3D11PipelineStateViewer::setState()
ui->alphaToCoverage->setPixmap(state.m_OM.m_BlendState.AlphaToCoverage ? tick : cross);
ui->independentBlend->setPixmap(state.m_OM.m_BlendState.IndependentBlend ? tick : cross);
ui->sampleMask->setText(
QFormatStr("%1").arg(state.m_OM.m_BlendState.SampleMask, 8, 16, QLatin1Char('0')).toUpper());
ui->sampleMask->setText(Formatter::Format(state.m_OM.m_BlendState.SampleMask, true));
ui->blendFactor->setText(QFormatStr("%1, %2, %3, %4")
.arg(state.m_OM.m_BlendState.BlendFactor[0], 0, 'f', 2)
@@ -1691,12 +1690,9 @@ void D3D11PipelineStateViewer::setState()
ui->depthWrite->setPixmap(state.m_OM.m_State.DepthWrites ? tick : cross);
ui->stencilEnabled->setPixmap(state.m_OM.m_State.StencilEnable ? tick : cross);
ui->stencilReadMask->setText(
QFormatStr("%1").arg(state.m_OM.m_State.StencilReadMask, 2, 16, QLatin1Char('0')).toUpper());
ui->stencilWriteMask->setText(
QFormatStr("%1").arg(state.m_OM.m_State.StencilWriteMask, 2, 16, QLatin1Char('0')).toUpper());
ui->stencilRef->setText(
QFormatStr("%1").arg(state.m_OM.m_State.StencilRef, 2, 16, QLatin1Char('0')).toUpper());
ui->stencilReadMask->setText(Formatter::Format(state.m_OM.m_State.StencilReadMask, true));
ui->stencilWriteMask->setText(Formatter::Format(state.m_OM.m_State.StencilWriteMask, true));
ui->stencilRef->setText(Formatter::Format(state.m_OM.m_State.StencilRef, true));
ui->stencils->setUpdatesEnabled(false);
ui->stencils->clear();
@@ -1653,12 +1653,9 @@ void D3D12PipelineStateViewer::setState()
ui->depthWrite->setPixmap(state.m_OM.m_State.DepthWrites ? tick : cross);
ui->stencilEnabled->setPixmap(state.m_OM.m_State.StencilEnable ? tick : cross);
ui->stencilReadMask->setText(
QFormatStr("%1").arg(state.m_OM.m_State.StencilReadMask, 2, 16, QLatin1Char('0')).toUpper());
ui->stencilWriteMask->setText(
QFormatStr("%1").arg(state.m_OM.m_State.StencilWriteMask, 2, 16, QLatin1Char('0')).toUpper());
ui->stencilRef->setText(
QFormatStr("%1").arg(state.m_OM.m_State.StencilRef, 2, 16, QLatin1Char('0')).toUpper());
ui->stencilReadMask->setText(Formatter::Format(state.m_OM.m_State.StencilReadMask, true));
ui->stencilWriteMask->setText(Formatter::Format(state.m_OM.m_State.StencilWriteMask, true));
ui->stencilRef->setText(Formatter::Format(state.m_OM.m_State.StencilRef, true));
ui->stencils->setUpdatesEnabled(false);
ui->stencils->clear();
@@ -1201,7 +1201,7 @@ void GLPipelineStateViewer::setState()
ui->primRestart->setVisible(true);
if(state.m_VtxIn.primitiveRestart)
ui->primRestart->setText(
tr("Restart Idx: 0x%1").arg(state.m_VtxIn.restartIndex, 8, 16, QLatin1Char('0')).toUpper());
tr("Restart Idx: 0x%1").arg(Formatter::Format(state.m_VtxIn.restartIndex, true)));
else
ui->primRestart->setText(tr("Restart Idx: Disabled"));
}
@@ -1634,10 +1634,7 @@ void GLPipelineStateViewer::setState()
if(state.m_Rasterizer.m_State.SampleMask)
{
ui->sampleMask->setText(
QFormatStr("%1")
.arg(state.m_Rasterizer.m_State.SampleMaskValue, 8, 16, QLatin1Char('0'))
.toUpper());
ui->sampleMask->setText(Formatter::Format(state.m_Rasterizer.m_State.SampleMaskValue, true));
ui->sampleMask->setPixmap(QPixmap());
}
else
@@ -1912,23 +1909,23 @@ void GLPipelineStateViewer::setState()
ui->stencils->clear();
if(state.m_StencilState.StencilEnable)
{
ui->stencils->addTopLevelItem(new RDTreeWidgetItem(
{tr("Front"), ToQStr(state.m_StencilState.m_FrontFace.Func),
ToQStr(state.m_StencilState.m_FrontFace.FailOp),
ToQStr(state.m_StencilState.m_FrontFace.DepthFailOp),
ToQStr(state.m_StencilState.m_FrontFace.PassOp),
QFormatStr("%1").arg(state.m_StencilState.m_FrontFace.WriteMask, 2, 16, QLatin1Char('0')).toUpper(),
QFormatStr("%1").arg(state.m_StencilState.m_FrontFace.ValueMask, 2, 16, QLatin1Char('0')).toUpper(),
QFormatStr("%1").arg(state.m_StencilState.m_FrontFace.Ref, 2, 16, QLatin1Char('0')).toUpper()}));
ui->stencils->addTopLevelItem(
new RDTreeWidgetItem({tr("Front"), ToQStr(state.m_StencilState.m_FrontFace.Func),
ToQStr(state.m_StencilState.m_FrontFace.FailOp),
ToQStr(state.m_StencilState.m_FrontFace.DepthFailOp),
ToQStr(state.m_StencilState.m_FrontFace.PassOp),
Formatter::Format(state.m_StencilState.m_FrontFace.WriteMask, true),
Formatter::Format(state.m_StencilState.m_FrontFace.ValueMask, true),
Formatter::Format(state.m_StencilState.m_FrontFace.Ref, true)}));
ui->stencils->addTopLevelItem(new RDTreeWidgetItem(
{tr("Back"), ToQStr(state.m_StencilState.m_BackFace.Func),
ToQStr(state.m_StencilState.m_BackFace.FailOp),
ToQStr(state.m_StencilState.m_BackFace.DepthFailOp),
ToQStr(state.m_StencilState.m_BackFace.PassOp),
QFormatStr("%1").arg(state.m_StencilState.m_BackFace.WriteMask, 2, 16, QLatin1Char('0')).toUpper(),
QFormatStr("%1").arg(state.m_StencilState.m_BackFace.ValueMask, 2, 16, QLatin1Char('0')).toUpper(),
QFormatStr("%1").arg(state.m_StencilState.m_BackFace.Ref, 2, 16, QLatin1Char('0')).toUpper()}));
ui->stencils->addTopLevelItem(
new RDTreeWidgetItem({tr("Back"), ToQStr(state.m_StencilState.m_BackFace.Func),
ToQStr(state.m_StencilState.m_BackFace.FailOp),
ToQStr(state.m_StencilState.m_BackFace.DepthFailOp),
ToQStr(state.m_StencilState.m_BackFace.PassOp),
Formatter::Format(state.m_StencilState.m_BackFace.WriteMask, true),
Formatter::Format(state.m_StencilState.m_BackFace.ValueMask, true),
Formatter::Format(state.m_StencilState.m_BackFace.Ref, true)}));
}
else
{
@@ -1748,8 +1748,7 @@ void VulkanPipelineStateViewer::setState()
ui->sampleCount->setText(QString::number(state.MSAA.rasterSamples));
ui->sampleShading->setPixmap(state.MSAA.sampleShadingEnable ? tick : cross);
ui->minSampleShading->setText(Formatter::Format(state.MSAA.minSampleShading));
ui->sampleMask->setText(
QFormatStr("%1").arg(state.MSAA.sampleMask, 8, 16, QLatin1Char('0')).toUpper());
ui->sampleMask->setText(Formatter::Format(state.MSAA.sampleMask, true));
////////////////////////////////////////////////
// Output Merger
@@ -1932,15 +1931,15 @@ void VulkanPipelineStateViewer::setState()
ui->stencils->addTopLevelItem(new RDTreeWidgetItem(
{tr("Front"), ToQStr(state.DS.front.Func), ToQStr(state.DS.front.FailOp),
ToQStr(state.DS.front.DepthFailOp), ToQStr(state.DS.front.PassOp),
QFormatStr("%1").arg(state.DS.front.writeMask, 2, 16, QLatin1Char('0')).toUpper(),
QFormatStr("%1").arg(state.DS.front.compareMask, 2, 16, QLatin1Char('0')).toUpper(),
QFormatStr("%1").arg(state.DS.front.ref, 2, 16, QLatin1Char('0')).toUpper()}));
ui->stencils->addTopLevelItem(new RDTreeWidgetItem(
{tr("Back"), ToQStr(state.DS.back.Func), ToQStr(state.DS.back.FailOp),
ToQStr(state.DS.back.DepthFailOp), ToQStr(state.DS.back.PassOp),
QFormatStr("%1").arg(state.DS.back.writeMask, 2, 16, QLatin1Char('0')).toUpper(),
QFormatStr("%1").arg(state.DS.back.compareMask, 2, 16, QLatin1Char('0')).toUpper(),
QFormatStr("%1").arg(state.DS.back.ref, 2, 16, QLatin1Char('0')).toUpper()}));
Formatter::Format(state.DS.front.writeMask, true),
Formatter::Format(state.DS.front.compareMask, true),
Formatter::Format(state.DS.front.ref, true)}));
ui->stencils->addTopLevelItem(
new RDTreeWidgetItem({tr("Back"), ToQStr(state.DS.back.Func), ToQStr(state.DS.back.FailOp),
ToQStr(state.DS.back.DepthFailOp), ToQStr(state.DS.back.PassOp),
Formatter::Format(state.DS.back.writeMask, true),
Formatter::Format(state.DS.back.compareMask, true),
Formatter::Format(state.DS.back.ref, true)}));
}
else
{
+1 -1
View File
@@ -521,7 +521,7 @@ private:
s += lit("\nD: -");
if(val.stencil >= 0)
s += lit("\nS: 0x") + QFormatStr("%1").arg(val.stencil, 2, 16, QLatin1Char('0')).toUpper();
s += lit("\nS: 0x") + Formatter::Format(uint8_t(val.stencil & 0xff), true);
else if(val.stencil == -2)
s += lit("\nS: ?");
else
+2 -1
View File
@@ -875,7 +875,8 @@ void TextureViewer::UI_UpdateStatusText()
int stencil = (int)(255.0f * val.value_f[1]);
statusText += tr(", Stencil %1 / 0x%2").arg(stencil).arg(stencil, 0, 16);
statusText +=
tr(", Stencil %1 / 0x%2").arg(stencil).arg(Formatter::Format(uint8_t(stencil & 0xff), true));
}
else
{
+3 -3
View File
@@ -414,11 +414,11 @@ struct StencilFace
DOCUMENT("The :class:`CompareFunc` to use for testing stencil values.");
CompareFunc Func = CompareFunc::AlwaysTrue;
DOCUMENT("The current stencil reference value.");
uint32_t Ref = 0;
uint8_t Ref = 0;
DOCUMENT("The mask for testing stencil values.");
uint32_t ValueMask = 0;
uint8_t ValueMask = 0;
DOCUMENT("The mask for writing stencil values.");
uint32_t WriteMask = 0;
uint8_t WriteMask = 0;
};
DOCUMENT("Describes the stencil state.");
+2 -2
View File
@@ -856,7 +856,7 @@ void Serialiser::Serialise(const char *name, GLPipe::StencilState &el)
Serialise("", el.m_BackFace.ValueMask);
Serialise("", el.m_BackFace.WriteMask);
SIZE_CHECK(60);
SIZE_CHECK(44);
}
template <>
@@ -953,7 +953,7 @@ void Serialiser::Serialise(const char *name, GLPipe::State &el)
Serialise("", el.m_Hints);
SIZE_CHECK(1896);
SIZE_CHECK(1880);
}
#pragma endregion OpenGL pipeline state
+2 -2
View File
@@ -1686,14 +1686,14 @@ void GLReplay::SavePipelineState()
pipe.m_StencilState.StencilEnable = rs.Enabled[GLRenderState::eEnabled_StencilTest];
pipe.m_StencilState.m_FrontFace.ValueMask = rs.StencilFront.valuemask;
pipe.m_StencilState.m_FrontFace.WriteMask = rs.StencilFront.writemask;
pipe.m_StencilState.m_FrontFace.Ref = rs.StencilFront.ref;
pipe.m_StencilState.m_FrontFace.Ref = uint8_t(rs.StencilFront.ref & 0xff);
pipe.m_StencilState.m_FrontFace.Func = MakeCompareFunc(rs.StencilFront.func);
pipe.m_StencilState.m_FrontFace.PassOp = MakeStencilOp(rs.StencilFront.pass);
pipe.m_StencilState.m_FrontFace.FailOp = MakeStencilOp(rs.StencilFront.stencilFail);
pipe.m_StencilState.m_FrontFace.DepthFailOp = MakeStencilOp(rs.StencilFront.depthFail);
pipe.m_StencilState.m_BackFace.ValueMask = rs.StencilBack.valuemask;
pipe.m_StencilState.m_BackFace.WriteMask = rs.StencilBack.writemask;
pipe.m_StencilState.m_BackFace.Ref = rs.StencilBack.ref;
pipe.m_StencilState.m_BackFace.Ref = uint8_t(rs.StencilBack.ref & 0xff);
pipe.m_StencilState.m_BackFace.Func = MakeCompareFunc(rs.StencilBack.func);
pipe.m_StencilState.m_BackFace.PassOp = MakeStencilOp(rs.StencilBack.pass);
pipe.m_StencilState.m_BackFace.FailOp = MakeStencilOp(rs.StencilBack.stencilFail);
+3 -3
View File
@@ -310,9 +310,9 @@ namespace renderdoc
public StencilOp DepthFailOp;
public StencilOp PassOp;
public CompareFunc Func;
public UInt32 Ref;
public UInt32 ValueMask;
public UInt32 WriteMask;
public byte Ref;
public byte ValueMask;
public byte WriteMask;
};
[CustomMarshalAs(CustomUnmanagedType.CustomClass)]
public StencilFace m_FrontFace, m_BackFace;