Fix pipeline state highlighting of disabled input attributes

* Using the row index is not accurate when some input attributes are disabled,
  because they won't match up to the original index in the attributes list.
This commit is contained in:
baldurk
2018-10-11 11:09:36 +01:00
parent b91d19e316
commit 0282c9a685
4 changed files with 28 additions and 32 deletions
@@ -1296,6 +1296,8 @@ void D3D11PipelineStateViewer::setState()
byteOffs, l.perInstance ? lit("PER_INSTANCE") : lit("PER_VERTEX"),
l.instanceDataStepRate, QString()});
node->setTag(i);
if(usedSlot)
usedVBuffers[l.inputSlot] = true;
@@ -2239,7 +2241,7 @@ void D3D11PipelineStateViewer::highlightIABind(int slot)
{
RDTreeWidgetItem *item = ui->iaLayouts->topLevelItem(i);
if((int)IA.layouts[i].inputSlot != slot)
if((int)IA.layouts[item->tag().toUInt()].inputSlot != slot)
{
item->setBackground(QBrush());
item->setForeground(QBrush());
@@ -2260,20 +2262,17 @@ void D3D11PipelineStateViewer::on_iaLayouts_mouseMove(QMouseEvent *e)
if(!m_Ctx.IsCaptureLoaded())
return;
QModelIndex idx = ui->iaLayouts->indexAt(e->pos());
RDTreeWidgetItem *item = ui->iaLayouts->itemAt(e->pos());
vertex_leave(NULL);
const D3D11Pipe::InputAssembly &IA = m_Ctx.CurD3D11PipelineState()->inputAssembly;
if(idx.isValid())
if(item)
{
if(idx.row() >= 0 && idx.row() < IA.layouts.count())
{
uint32_t buffer = IA.layouts[idx.row()].inputSlot;
uint32_t buffer = IA.layouts[item->tag().toUInt()].inputSlot;
highlightIABind((int)buffer);
}
highlightIABind((int)buffer);
}
}
@@ -1314,6 +1314,8 @@ void D3D12PipelineStateViewer::setState()
byteOffs, l.perInstance ? lit("PER_INSTANCE") : lit("PER_VERTEX"),
l.instanceDataStepRate, QString()});
node->setTag(i);
if(usedSlot)
usedVBuffers[l.inputSlot] = true;
@@ -2096,7 +2098,7 @@ void D3D12PipelineStateViewer::highlightIABind(int slot)
{
RDTreeWidgetItem *item = ui->iaLayouts->topLevelItem(i);
if((int)IA.layouts[i].inputSlot != slot)
if((int)IA.layouts[item->tag().toUInt()].inputSlot != slot)
{
item->setBackground(QBrush());
item->setForeground(QBrush());
@@ -2117,20 +2119,17 @@ void D3D12PipelineStateViewer::on_iaLayouts_mouseMove(QMouseEvent *e)
if(!m_Ctx.IsCaptureLoaded())
return;
QModelIndex idx = ui->iaLayouts->indexAt(e->pos());
RDTreeWidgetItem *item = ui->iaLayouts->itemAt(e->pos());
vertex_leave(NULL);
const D3D12Pipe::InputAssembly &IA = m_Ctx.CurD3D12PipelineState()->inputAssembly;
if(idx.isValid())
if(item)
{
if(idx.row() >= 0 && idx.row() < IA.layouts.count())
{
uint32_t buffer = IA.layouts[idx.row()].inputSlot;
uint32_t buffer = IA.layouts[item->tag().toUInt()].inputSlot;
highlightIABind((int)buffer);
}
highlightIABind((int)buffer);
}
}
@@ -1222,6 +1222,8 @@ void GLPipelineStateViewer::setState()
a.enabled ? QString(a.format.Name()) : genericVal,
a.vertexBufferSlot, a.byteOffset, QString()});
node->setTag(i);
if(a.enabled)
usedBindings[a.vertexBufferSlot] = true;
@@ -2248,7 +2250,7 @@ void GLPipelineStateViewer::highlightIABind(int slot)
{
RDTreeWidgetItem *item = ui->viAttrs->topLevelItem(i);
if((int)VI.attributes[i].vertexBufferSlot != slot)
if((int)VI.attributes[item->tag().toUInt()].vertexBufferSlot != slot)
{
item->setBackground(QBrush());
item->setForeground(QBrush());
@@ -2269,20 +2271,17 @@ void GLPipelineStateViewer::on_viAttrs_mouseMove(QMouseEvent *e)
if(!m_Ctx.IsCaptureLoaded())
return;
QModelIndex idx = ui->viAttrs->indexAt(e->pos());
RDTreeWidgetItem *item = ui->viAttrs->itemAt(e->pos());
vertex_leave(NULL);
const GLPipe::VertexInput &VI = m_Ctx.CurGLPipelineState()->vertexInput;
if(idx.isValid())
if(item)
{
if(idx.row() >= 0 && idx.row() < VI.attributes.count())
{
uint32_t buffer = VI.attributes[idx.row()].vertexBufferSlot;
uint32_t buffer = VI.attributes[item->tag().toUInt()].vertexBufferSlot;
highlightIABind((int)buffer);
}
highlightIABind((int)buffer);
}
}
@@ -1557,6 +1557,8 @@ void VulkanPipelineStateViewer::setState()
RDTreeWidgetItem *node = new RDTreeWidgetItem(
{i, name, a.location, a.binding, a.format.Name(), a.byteOffset, QString()});
node->setTag(i);
usedBindings[a.binding] = true;
if(!usedSlot)
@@ -2350,7 +2352,7 @@ void VulkanPipelineStateViewer::highlightIABind(int slot)
{
RDTreeWidgetItem *item = ui->viAttrs->topLevelItem(i);
if((int)VI.attributes[i].binding != slot)
if((int)VI.attributes[item->tag().toUInt()].binding != slot)
{
item->setBackground(QBrush());
item->setForeground(QBrush());
@@ -2371,20 +2373,17 @@ void VulkanPipelineStateViewer::on_viAttrs_mouseMove(QMouseEvent *e)
if(!m_Ctx.IsCaptureLoaded())
return;
QModelIndex idx = ui->viAttrs->indexAt(e->pos());
RDTreeWidgetItem *item = ui->viAttrs->itemAt(e->pos());
vertex_leave(NULL);
const VKPipe::VertexInput &VI = m_Ctx.CurVulkanPipelineState()->vertexInput;
if(idx.isValid())
if(item)
{
if(idx.row() >= 0 && idx.row() < VI.attributes.count())
{
uint32_t binding = VI.attributes[idx.row()].binding;
uint32_t binding = VI.attributes[item->tag().toUInt()].binding;
highlightIABind((int)binding);
}
highlightIABind((int)binding);
}
}