diff --git a/qrenderdoc/Windows/BufferViewer.cpp b/qrenderdoc/Windows/BufferViewer.cpp index dfed72d0d..f68ff18ce 100644 --- a/qrenderdoc/Windows/BufferViewer.cpp +++ b/qrenderdoc/Windows/BufferViewer.cpp @@ -1453,6 +1453,9 @@ void BufferViewer::OnEventChanged(uint32_t eventID) guessSecondaryColumn(m_ModelGSOut); } + // needs to happen here so the mesh config is accurate when highlighting data is cached. + updatePreviewColumns(); + m_Ctx.Replay().AsyncInvoke([this, vsinHoriz, vsoutHoriz, gsoutHoriz](IReplayController *r) { BufferData *buf = NULL; @@ -1502,8 +1505,6 @@ void BufferViewer::OnEventChanged(uint32_t eventID) m_ModelVSIn->buffers.push_back(buf); } - updatePreviewColumns(); - INVOKE_MEMFN(RT_UpdateAndDisplay); m_ModelVSIn->endReset(); @@ -1566,6 +1567,12 @@ void BufferViewer::RT_FetchMeshData(IReplayController *r) m_ModelVSIn->indices->data = (byte *)indices; m_ModelVSIn->indices->end = (byte *)(indices + draw->numIndices); } + else if(draw && (draw->flags & DrawFlags::UseIBuffer)) + { + indices = new uint32_t[1]; + m_ModelVSIn->indices->data = (byte *)indices; + m_ModelVSIn->indices->end = (byte *)indices; + } uint32_t maxIndex = 0; if(draw) @@ -2103,6 +2110,9 @@ void BufferViewer::updatePreviewColumns() m_VSInPosition.idxbuf = ib.first; m_VSInPosition.idxoffs = ib.second + draw->indexOffset * draw->indexByteWidth; + if((draw->flags & DrawFlags::UseIBuffer) && m_VSInPosition.idxByteWidth == 0) + m_VSInPosition.idxByteWidth = 4U; + { const FormatElement &el = m_ModelVSIn->columns[elIdx]; diff --git a/renderdoc/driver/d3d11/d3d11_analyse.cpp b/renderdoc/driver/d3d11/d3d11_analyse.cpp index cbdee652e..64d90a517 100644 --- a/renderdoc/driver/d3d11/d3d11_analyse.cpp +++ b/renderdoc/driver/d3d11/d3d11_analyse.cpp @@ -2572,20 +2572,23 @@ uint32_t D3D11DebugManager::PickVertex(uint32_t eventID, const MeshDisplay &cfg, RDCASSERT(cfg.position.idxoffs < 0xffffffff); - D3D11_BUFFER_DESC ibdesc; - ib->GetDesc(&ibdesc); + if(ib) + { + D3D11_BUFFER_DESC ibdesc; + ib->GetDesc(&ibdesc); - D3D11_BOX box; - box.front = 0; - box.back = 1; - box.left = (uint32_t)cfg.position.idxoffs; - box.right = (uint32_t)cfg.position.idxoffs + cfg.position.numVerts * cfg.position.idxByteWidth; - box.top = 0; - box.bottom = 1; + D3D11_BOX box; + box.front = 0; + box.back = 1; + box.left = (uint32_t)cfg.position.idxoffs; + box.right = (uint32_t)cfg.position.idxoffs + cfg.position.numVerts * cfg.position.idxByteWidth; + box.top = 0; + box.bottom = 1; - box.right = RDCMIN(box.right, ibdesc.ByteWidth - (uint32_t)cfg.position.idxoffs); + box.right = RDCMIN(box.right, ibdesc.ByteWidth - (uint32_t)cfg.position.idxoffs); - m_pImmediateContext->CopySubresourceRegion(m_DebugRender.PickIBBuf, 0, 0, 0, 0, ib, 0, &box); + m_pImmediateContext->CopySubresourceRegion(m_DebugRender.PickIBBuf, 0, 0, 0, 0, ib, 0, &box); + } } if(m_DebugRender.PickVBBuf == NULL || @@ -2629,6 +2632,7 @@ uint32_t D3D11DebugManager::PickVertex(uint32_t eventID, const MeshDisplay &cfg, } // unpack and linearise the data + if(vb) { FloatVector *vbData = new FloatVector[cfg.position.numVerts]; diff --git a/renderdoc/driver/d3d11/d3d11_debug.cpp b/renderdoc/driver/d3d11/d3d11_debug.cpp index c18a05a8c..ad31371cb 100644 --- a/renderdoc/driver/d3d11/d3d11_debug.cpp +++ b/renderdoc/driver/d3d11/d3d11_debug.cpp @@ -4982,7 +4982,7 @@ void D3D11DebugManager::RenderMesh(uint32_t eventID, const vector &s } m_pImmediateContext->IASetVertexBuffers(0, 2, vbs, str, offs); - if(ibuf) + if(cfg.position.idxByteWidth) m_pImmediateContext->IASetIndexBuffer(ibuf, ifmt, ioffs); else m_pImmediateContext->IASetIndexBuffer(NULL, DXGI_FORMAT_UNKNOWN, NULL); diff --git a/renderdoc/driver/d3d12/d3d12_debug.cpp b/renderdoc/driver/d3d12/d3d12_debug.cpp index df54597ce..0e74e2418 100644 --- a/renderdoc/driver/d3d12/d3d12_debug.cpp +++ b/renderdoc/driver/d3d12/d3d12_debug.cpp @@ -5519,18 +5519,21 @@ void D3D12DebugManager::RenderMesh(uint32_t eventID, const vector &s if(PatchList_Count(fmt.topo) > 0) list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_POINTLIST); - if(fmt.idxByteWidth && fmt.idxbuf != ResourceId()) + if(fmt.idxByteWidth) { - ID3D12Resource *ib = - m_WrappedDevice->GetResourceManager()->GetCurrentAs(fmt.idxbuf); + if(fmt.idxbuf != ResourceId()) + { + ID3D12Resource *ib = + m_WrappedDevice->GetResourceManager()->GetCurrentAs(fmt.idxbuf); - D3D12_INDEX_BUFFER_VIEW iview; - iview.BufferLocation = ib->GetGPUVirtualAddress() + fmt.idxoffs; - iview.SizeInBytes = UINT(ib->GetDesc().Width - fmt.idxoffs); - iview.Format = fmt.idxByteWidth == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT; - list->IASetIndexBuffer(&iview); + D3D12_INDEX_BUFFER_VIEW iview; + iview.BufferLocation = ib->GetGPUVirtualAddress() + fmt.idxoffs; + iview.SizeInBytes = UINT(ib->GetDesc().Width - fmt.idxoffs); + iview.Format = fmt.idxByteWidth == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT; + list->IASetIndexBuffer(&iview); - list->DrawIndexedInstanced(fmt.numVerts, 1, 0, fmt.baseVertex, 0); + list->DrawIndexedInstanced(fmt.numVerts, 1, 0, fmt.baseVertex, 0); + } } else { @@ -5620,18 +5623,21 @@ void D3D12DebugManager::RenderMesh(uint32_t eventID, const vector &s Vec4f colour(0.8f, 0.8f, 0.0f, 1.0f); list->SetGraphicsRoot32BitConstants(3, 4, &colour.x, 0); - if(cfg.position.idxByteWidth && cfg.position.idxbuf != ResourceId()) + if(cfg.position.idxByteWidth) { - ID3D12Resource *ib = - m_WrappedDevice->GetResourceManager()->GetCurrentAs(cfg.position.idxbuf); + if(cfg.position.idxbuf != ResourceId()) + { + ID3D12Resource *ib = + m_WrappedDevice->GetResourceManager()->GetCurrentAs(cfg.position.idxbuf); - D3D12_INDEX_BUFFER_VIEW view; - view.BufferLocation = ib->GetGPUVirtualAddress() + cfg.position.idxoffs; - view.SizeInBytes = UINT(ib->GetDesc().Width - cfg.position.idxoffs); - view.Format = cfg.position.idxByteWidth == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT; - list->IASetIndexBuffer(&view); + D3D12_INDEX_BUFFER_VIEW view; + view.BufferLocation = ib->GetGPUVirtualAddress() + cfg.position.idxoffs; + view.SizeInBytes = UINT(ib->GetDesc().Width - cfg.position.idxoffs); + view.Format = cfg.position.idxByteWidth == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT; + list->IASetIndexBuffer(&view); - list->DrawIndexedInstanced(cfg.position.numVerts, 1, 0, cfg.position.baseVertex, 0); + list->DrawIndexedInstanced(cfg.position.numVerts, 1, 0, cfg.position.baseVertex, 0); + } } else { diff --git a/renderdoc/driver/gl/gl_debug.cpp b/renderdoc/driver/gl/gl_debug.cpp index b15dfb2b2..240358513 100644 --- a/renderdoc/driver/gl/gl_debug.cpp +++ b/renderdoc/driver/gl/gl_debug.cpp @@ -2978,7 +2978,7 @@ ResourceId GLReplay::RenderOverlay(ResourceId texid, CompType typeHint, DebugOve gl.glEnableVertexAttribArray(0); gl.glDisableVertexAttribArray(1); - if(postvs.idxbuf != ResourceId()) + if(postvs.idxByteWidth) { GLenum idxtype = eGL_UNSIGNED_BYTE; if(postvs.idxByteWidth == 2) @@ -4811,7 +4811,7 @@ void GLReplay::RenderMesh(uint32_t eventID, const vector &secondaryD GLenum secondarytopo = MakeGLPrimitiveTopology(fmt.topo); - if(fmt.idxbuf != ResourceId()) + if(fmt.idxByteWidth) { GLuint ib = m_pDriver->GetResourceManager()->GetCurrentResource(fmt.idxbuf).name; gl.glBindBuffer(eGL_ELEMENT_ARRAY_BUFFER, ib);