From ef65ad65f14130a4677b4bade764df7e55a71a61 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 13 Nov 2014 18:24:08 +0000 Subject: [PATCH] Fix highlighting VS output verts with index buffers --- renderdoc/driver/d3d11/d3d11_debug.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/renderdoc/driver/d3d11/d3d11_debug.cpp b/renderdoc/driver/d3d11/d3d11_debug.cpp index 311a45814..3efbf67dc 100644 --- a/renderdoc/driver/d3d11/d3d11_debug.cpp +++ b/renderdoc/driver/d3d11/d3d11_debug.cpp @@ -4900,11 +4900,18 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve m_HighlightCache.EID = events.back(); m_HighlightCache.buf = cfg.positionBuf; m_HighlightCache.stage = stage; + + ID3D11Buffer *idxBuf = curRS->IA.IndexBuffer; + DXGI_FORMAT idxFmt = curRS->IA.IndexFormat; + UINT idxOffs = curRS->IA.IndexOffset; + bool index16 = (idxFmt == DXGI_FORMAT_R16_UINT); + UINT bytesize = index16 ? 2 : 4; if(cfg.type == eMeshDataStage_VSIn) { m_HighlightCache.data = GetBufferData(cfg.positionBuf, 0, 0); m_HighlightCache.topo = curRS->IA.Topo; + idxOffs += drawcall->indexOffset*bytesize; } else { @@ -4912,7 +4919,14 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve m_HighlightCache.data.resize(postvs.buf.count); memcpy(&m_HighlightCache.data[0], postvs.buf.elems, postvs.buf.count); - m_HighlightCache.topo = GetPostVSBuffers(frameID, events.back()).GetStage(stage).topo; + const PostVSData::StageData &stagedata = GetPostVSBuffers(frameID, events.back()).GetStage(stage); + + m_HighlightCache.topo = stagedata.topo; + idxBuf = stagedata.idxBuf; + idxFmt = stagedata.idxFmt; + idxOffs = 0; + index16 = (idxFmt == DXGI_FORMAT_R16_UINT); + bytesize = index16 ? 2 : 4; } if((drawcall->flags & eDraw_UseIBuffer) == 0) @@ -4924,14 +4938,7 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve { m_HighlightCache.useidx = true; - ID3D11Buffer *idxBuf = curRS->IA.IndexBuffer; - DXGI_FORMAT idxFmt = curRS->IA.IndexFormat; - UINT idxOffs = curRS->IA.IndexOffset; - - bool index16 = (idxFmt == DXGI_FORMAT_R16_UINT); - UINT bytesize = index16 ? 2 : 4; - - vector idxdata = GetBufferData(idxBuf, idxOffs + drawcall->indexOffset*bytesize, drawcall->numIndices*bytesize); + vector idxdata = GetBufferData(idxBuf, idxOffs, drawcall->numIndices*bytesize); uint16_t *idx16 = (uint16_t *)&idxdata[0]; uint32_t *idx32 = (uint32_t *)&idxdata[0];