Fix crash if no drawcall is selected when exporting pipeline state

This commit is contained in:
baldurk
2020-03-05 11:15:48 +00:00
parent 6579dfc666
commit a18716e63d
5 changed files with 52 additions and 22 deletions
@@ -2435,6 +2435,8 @@ QVariantList D3D11PipelineStateViewer::exportViewHTML(const D3D11Pipe::View &vie
void D3D11PipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const D3D11Pipe::InputAssembly &ia)
{
const DrawcallDescription *draw = m_Ctx.CurDrawcall();
{
xml.writeStartElement(lit("h3"));
xml.writeCharacters(tr("Input Layouts"));
@@ -2510,10 +2512,13 @@ void D3D11PipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const D3D11Pipe
}
QString ifmt = lit("UNKNOWN");
if(m_Ctx.CurDrawcall()->indexByteWidth == 2)
ifmt = lit("R16_UINT");
if(m_Ctx.CurDrawcall()->indexByteWidth == 4)
ifmt = lit("R32_UINT");
if(draw)
{
if(draw->indexByteWidth == 2)
ifmt = lit("R16_UINT");
if(draw->indexByteWidth == 4)
ifmt = lit("R32_UINT");
}
m_Common.exportHTMLTable(xml, {tr("Buffer"), tr("Format"), tr("Offset"), tr("Byte Length")},
{name, ifmt, ia.indexBuffer.byteOffset, (qulonglong)length});
@@ -2522,7 +2527,8 @@ void D3D11PipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const D3D11Pipe
xml.writeStartElement(lit("p"));
xml.writeEndElement();
m_Common.exportHTMLTable(xml, {tr("Primitive Topology")}, {ToQStr(m_Ctx.CurDrawcall()->topology)});
m_Common.exportHTMLTable(xml, {tr("Primitive Topology")},
{ToQStr(draw ? draw->topology : Topology::Unknown)});
}
void D3D11PipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const D3D11Pipe::Shader &sh)
@@ -2323,6 +2323,8 @@ QVariantList D3D12PipelineStateViewer::exportViewHTML(const D3D12Pipe::View &vie
void D3D12PipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const D3D12Pipe::InputAssembly &ia)
{
const DrawcallDescription *draw = m_Ctx.CurDrawcall();
{
xml.writeStartElement(lit("h3"));
xml.writeCharacters(tr("Input Layouts"));
@@ -2402,10 +2404,13 @@ void D3D12PipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const D3D12Pipe
length = qMin(length, (uint64_t)ia.indexBuffer.byteSize);
QString ifmt = lit("UNKNOWN");
if(m_Ctx.CurDrawcall()->indexByteWidth == 2)
ifmt = lit("R16_UINT");
if(m_Ctx.CurDrawcall()->indexByteWidth == 4)
ifmt = lit("R32_UINT");
if(draw)
{
if(draw->indexByteWidth == 2)
ifmt = lit("R16_UINT");
if(draw->indexByteWidth == 4)
ifmt = lit("R32_UINT");
}
m_Common.exportHTMLTable(xml, {tr("Buffer"), tr("Format"), tr("Offset"), tr("Byte Length")},
{name, ifmt, (qulonglong)ia.indexBuffer.byteOffset, (qulonglong)length});
@@ -2414,7 +2419,8 @@ void D3D12PipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const D3D12Pipe
xml.writeStartElement(lit("p"));
xml.writeEndElement();
m_Common.exportHTMLTable(xml, {tr("Primitive Topology")}, {ToQStr(m_Ctx.CurDrawcall()->topology)});
m_Common.exportHTMLTable(xml, {tr("Primitive Topology")},
{ToQStr(draw ? draw->topology : Topology::Unknown)});
}
void D3D12PipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const D3D12Pipe::Shader &sh)
@@ -2376,6 +2376,8 @@ void GLPipelineStateViewer::shaderSave_clicked()
void GLPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const GLPipe::VertexInput &vtx)
{
const DrawcallDescription *draw = m_Ctx.CurDrawcall();
const GLPipe::State &pipe = *m_Ctx.CurGLPipelineState();
{
xml.writeStartElement(tr("h3"));
@@ -2454,10 +2456,15 @@ void GLPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const GLPipe::Vert
}
QString ifmt = lit("UNKNOWN");
if(m_Ctx.CurDrawcall()->indexByteWidth == 2)
ifmt = lit("R16_UINT");
if(m_Ctx.CurDrawcall()->indexByteWidth == 4)
ifmt = lit("R32_UINT");
if(draw)
{
if(draw->indexByteWidth == 1)
ifmt = lit("UNSIGNED_BYTE");
else if(draw->indexByteWidth == 2)
ifmt = lit("UNSIGNED_SHORT");
else if(draw->indexByteWidth == 4)
ifmt = lit("UNSIGNED_INT");
}
m_Common.exportHTMLTable(xml, {tr("Buffer"), tr("Format"), tr("Byte Length")},
{name, ifmt, (qulonglong)length});
@@ -2466,7 +2473,8 @@ void GLPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const GLPipe::Vert
xml.writeStartElement(tr("p"));
xml.writeEndElement();
m_Common.exportHTMLTable(xml, {tr("Primitive Topology")}, {ToQStr(m_Ctx.CurDrawcall()->topology)});
m_Common.exportHTMLTable(xml, {tr("Primitive Topology")},
{ToQStr(draw ? draw->topology : Topology::Unknown)});
{
xml.writeStartElement(tr("h3"));
@@ -350,7 +350,7 @@ div.stage table tr td { border-right: 1px solid #AAAAAA; background-color: #EEEE
const DrawcallDescription *draw = m_Ctx.CurDrawcall();
QList<const DrawcallDescription *> drawstack;
const DrawcallDescription *parent = draw->parent;
const DrawcallDescription *parent = draw ? draw->parent : NULL;
while(parent)
{
drawstack.push_front(parent);
@@ -362,7 +362,10 @@ div.stage table tr td { border-right: 1px solid #AAAAAA; background-color: #EEEE
context += QFormatStr(" > %1").arg(d->name);
}
context += QFormatStr(" => %1").arg(draw->name);
if(draw)
context += QFormatStr(" => %1").arg(draw->name);
else
context += tr(" => Capture Start");
xml.writeCharacters(context);
}
@@ -2891,6 +2891,8 @@ void VulkanPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const VKPipe::
void VulkanPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const VKPipe::InputAssembly &ia)
{
const DrawcallDescription *draw = m_Ctx.CurDrawcall();
{
xml.writeStartElement(lit("h3"));
xml.writeCharacters(tr("Index Buffer"));
@@ -2908,10 +2910,15 @@ void VulkanPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const VKPipe::
}
QString ifmt = lit("UNKNOWN");
if(m_Ctx.CurDrawcall()->indexByteWidth == 2)
ifmt = lit("UINT16");
if(m_Ctx.CurDrawcall()->indexByteWidth == 4)
ifmt = lit("UINT32");
if(draw)
{
if(draw->indexByteWidth == 1)
ifmt = lit("UINT8");
else if(draw->indexByteWidth == 2)
ifmt = lit("UINT16");
else if(draw->indexByteWidth == 4)
ifmt = lit("UINT32");
}
m_Common.exportHTMLTable(
xml, {tr("Buffer"), tr("Format"), tr("Offset"), tr("Byte Length"), tr("Primitive Restart")},
@@ -2923,7 +2930,7 @@ void VulkanPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const VKPipe::
xml.writeEndElement();
m_Common.exportHTMLTable(xml, {tr("Primitive Topology"), tr("Tessellation Control Points")},
{ToQStr(m_Ctx.CurDrawcall()->topology),
{ToQStr(draw ? draw->topology : Topology::Unknown),
m_Ctx.CurVulkanPipelineState()->tessellation.numControlPoints});
}