From 988121ee652d7b4c5c21f28ad8d821aba8dbaae0 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 10 Nov 2017 15:55:56 +0000 Subject: [PATCH] Display generic mesh input attrs, and add ---s for out of bounds access --- .../Code/Interface/CommonPipelineState.cpp | 6 ++ .../Code/Interface/CommonPipelineState.h | 2 + qrenderdoc/Windows/BufferViewer.cpp | 58 ++++++++++++++++++- 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/qrenderdoc/Code/Interface/CommonPipelineState.cpp b/qrenderdoc/Code/Interface/CommonPipelineState.cpp index 127ee40c8..bd890cfd1 100644 --- a/qrenderdoc/Code/Interface/CommonPipelineState.cpp +++ b/qrenderdoc/Code/Interface/CommonPipelineState.cpp @@ -697,6 +697,7 @@ QVector CommonPipelineState::GetVertexInputs() ret[i].Format = layouts[i].Format; memset(&ret[i].GenericValue, 0, sizeof(PixelValue)); ret[i].Used = false; + ret[i].GenericEnabled = false; if(m_D3D11->m_IA.Bytecode != NULL) { @@ -754,6 +755,7 @@ QVector CommonPipelineState::GetVertexInputs() ret[i].Format = layouts[i].Format; memset(&ret[i].GenericValue, 0, sizeof(PixelValue)); ret[i].Used = false; + ret[i].GenericEnabled = false; if(m_D3D12->m_VS.ShaderDetails != NULL) { @@ -801,6 +803,7 @@ QVector CommonPipelineState::GetVertexInputs() ret[a].InstanceRate = (int)m_GL->m_VtxIn.vbuffers[attrs[i].BufferSlot].Divisor; ret[a].Format = attrs[i].Format; ret[a].Used = true; + ret[a].GenericEnabled = false; if(m_GL->m_VS.ShaderDetails != NULL) { @@ -831,6 +834,8 @@ QVector CommonPipelineState::GetVertexInputs() ret[a].GenericValue.value_f[c] = (float)attrs[i].GenericValue.value_i[c]; } + ret[a].GenericEnabled = true; + ret[a].PerInstance = false; ret[a].InstanceRate = 0; ret[a].Format.compByteWidth = 4; @@ -880,6 +885,7 @@ QVector CommonPipelineState::GetVertexInputs() ret[a].InstanceRate = 1; ret[a].Format = attrs[i].format; ret[a].Used = true; + ret[a].GenericEnabled = false; if(m_Vulkan->m_VS.ShaderDetails != NULL) { diff --git a/qrenderdoc/Code/Interface/CommonPipelineState.h b/qrenderdoc/Code/Interface/CommonPipelineState.h index d3fba1634..29be5ed27 100644 --- a/qrenderdoc/Code/Interface/CommonPipelineState.h +++ b/qrenderdoc/Code/Interface/CommonPipelineState.h @@ -105,6 +105,8 @@ from the vertex buffer before advancing to the next value. no VB bound. )"); PixelValue GenericValue; + DOCUMENT("``True`` if this attribute is using :data:`GenericValue` for its data."); + bool GenericEnabled; DOCUMENT("``True`` if this attribute is enabled and used by the vertex shader."); bool Used; }; diff --git a/qrenderdoc/Windows/BufferViewer.cpp b/qrenderdoc/Windows/BufferViewer.cpp index 3ab8cf52b..dfed72d0d 100644 --- a/qrenderdoc/Windows/BufferViewer.cpp +++ b/qrenderdoc/Windows/BufferViewer.cpp @@ -590,7 +590,7 @@ public: return col == 1 ? lit("--") : lit(" Restart"); if(idx == ~0U) - return QVariant(); + return outOfBounds(); } if(col == 1 && meshView) @@ -599,11 +599,17 @@ public: if(displayIndices && displayIndices->data) idx = CalcIndex(displayIndices, row, baseVertex); + if(idx == ~0U) + return outOfBounds(); + return idx; } const FormatElement &el = elementForColumn(col); + if(useGenerics(col)) + return interpretGeneric(col, el); + uint32_t instIdx = 0; if(el.instancerate > 0) instIdx = curInstance / el.instancerate; @@ -647,6 +653,8 @@ public: return ret; } } + + return outOfBounds(); } } } @@ -669,6 +677,8 @@ public: BufferData *indices = NULL; QList columns; + QVector generics; + QVector genericsEnabled; QList buffers; uint32_t primRestart = 0; @@ -741,6 +751,12 @@ public: return columns[columnLookup[col - reservedColumnCount()]]; } + bool useGenerics(int col) const + { + col = columnLookup[col - reservedColumnCount()]; + return col < genericsEnabled.size() && genericsEnabled[col]; + } + private: // maps from column number (0-based from data, so excluding VTX/IDX columns) // to the column element in the columns list, and lists its component. @@ -829,7 +845,33 @@ private: } } - QString interpretVariant(QVariant &v, const FormatElement &el) const + QString outOfBounds() const { return lit("---"); } + QString interpretGeneric(int col, const FormatElement &el) const + { + int comp = componentForIndex(col); + + col = columnLookup[col - reservedColumnCount()]; + + if(col < generics.size()) + { + if(el.format.compType == CompType::Float) + { + return interpretVariant(QVariant(generics[col].value_f[comp]), el); + } + else if(el.format.compType == CompType::SInt) + { + return interpretVariant(QVariant(generics[col].value_i[comp]), el); + } + else if(el.format.compType == CompType::UInt) + { + return interpretVariant(QVariant(generics[col].value_u[comp]), el); + } + } + + return outOfBounds(); + } + + QString interpretVariant(const QVariant &v, const FormatElement &el) const { QString ret; @@ -2180,6 +2222,8 @@ void BufferViewer::configureMeshColumns() QVector vinputs = m_Ctx.CurPipelineState().GetVertexInputs(); m_ModelVSIn->columns.reserve(vinputs.count()); + m_ModelVSIn->genericsEnabled.resize(vinputs.count()); + m_ModelVSIn->generics.resize(vinputs.count()); for(const VertexInputAttribute &a : vinputs) { @@ -2191,6 +2235,14 @@ void BufferViewer::configureMeshColumns() 1, // matrix dimension a.Format, false, false); + m_ModelVSIn->genericsEnabled[m_ModelVSIn->columns.size()] = false; + + if(a.GenericEnabled) + { + m_ModelVSIn->genericsEnabled[m_ModelVSIn->columns.size()] = true; + m_ModelVSIn->generics[m_ModelVSIn->columns.size()] = a.GenericValue; + } + m_ModelVSIn->columns.push_back(f); } @@ -2716,6 +2768,8 @@ void BufferViewer::ClearModels() m->buffers.clear(); m->columns.clear(); + m->generics.clear(); + m->genericsEnabled.clear(); m->numRows = 0; m->endReset();