diff --git a/renderdoc/api/replay/control_types.h b/renderdoc/api/replay/control_types.h index 91036da5c..38e078d94 100644 --- a/renderdoc/api/replay/control_types.h +++ b/renderdoc/api/replay/control_types.h @@ -57,6 +57,7 @@ struct MeshDisplay uint32_t highlightVert; MeshFormat position; MeshFormat second; + bool32 unproject; FloatVector prevMeshColour; FloatVector currentMeshColour; diff --git a/renderdoc/driver/d3d11/d3d11_debug.cpp b/renderdoc/driver/d3d11/d3d11_debug.cpp index d7cb03925..a8f00b8d6 100644 --- a/renderdoc/driver/d3d11/d3d11_debug.cpp +++ b/renderdoc/driver/d3d11/d3d11_debug.cpp @@ -4630,8 +4630,6 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve RDCERR("Failed to create m_MeshDisplayLayout %08x", hr); m_MeshDisplayLayout = NULL; } - - layoutdesc[0].Format = DXGI_FORMAT_R32G32B32A32_FLOAT; hr = m_pDevice->CreateInputLayout(layoutdesc, 2, m_DebugRender.MeshHomogVSBytecode, m_DebugRender.MeshHomogVSBytelen, &m_PostMeshDisplayLayout); @@ -4645,8 +4643,7 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve m_PrevMeshFmt = resFmt; m_PrevMeshFmt2 = resFmt2; - if((cfg.type != eMeshDataStage_VSIn && pipeState.m_HS.Shader == ResourceId()) || - (cfg.type == eMeshDataStage_GSOut && pipeState.m_HS.Shader != ResourceId())) + if(cfg.unproject || events.size() > 1) { float nearp = 0.1f; float farp = 1000.0f; @@ -4832,16 +4829,28 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve UINT str[] = { cfg.position.stride, cfg.second.stride }; UINT offs[] = { cfg.position.offset, cfg.second.offset }; - auto it = WrappedID3D11Buffer::m_BufferList.find(cfg.position.buf); + if(cfg.type == eMeshDataStage_VSIn) + { + auto it = WrappedID3D11Buffer::m_BufferList.find(cfg.position.buf); - if(it != WrappedID3D11Buffer::m_BufferList.end()) - vbs[0] = UNWRAP(WrappedID3D11Buffer, it->second.m_Buffer); + if(it != WrappedID3D11Buffer::m_BufferList.end()) + vbs[0] = UNWRAP(WrappedID3D11Buffer, it->second.m_Buffer); - it = WrappedID3D11Buffer::m_BufferList.find(cfg.second.buf); + it = WrappedID3D11Buffer::m_BufferList.find(cfg.second.buf); - if(it != WrappedID3D11Buffer::m_BufferList.end()) - vbs[1] = UNWRAP(WrappedID3D11Buffer, it->second.m_Buffer); + if(it != WrappedID3D11Buffer::m_BufferList.end()) + vbs[1] = UNWRAP(WrappedID3D11Buffer, it->second.m_Buffer); + } + else + { + PostVSData data = GetPostVSBuffers(frameID, events[0]); + if(cfg.type == eMeshDataStage_VSOut) + vbs[0] = vbs[1] = UNWRAP(WrappedID3D11Buffer, data.vsout.buf); + if(cfg.type == eMeshDataStage_GSOut) + vbs[0] = vbs[1] = UNWRAP(WrappedID3D11Buffer, data.gsout.buf); + } + m_pImmediateContext->IASetVertexBuffers(0, 2, vbs, str, offs); m_pImmediateContext->IASetInputLayout(m_MeshDisplayLayout); @@ -4914,8 +4923,7 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve } // axis markers - if(cfg.type == eMeshDataStage_VSIn || - (cfg.type == eMeshDataStage_VSOut && pipeState.m_HS.Shader != ResourceId())) + if(!cfg.unproject) { m_pImmediateContext->PSSetConstantBuffers(0, 1, &m_DebugRender.GenericPSCBuffer); @@ -5440,8 +5448,7 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve } // 'fake' helper frustum - if((cfg.type != eMeshDataStage_VSIn && pipeState.m_HS.Shader == ResourceId()) || - (cfg.type == eMeshDataStage_GSOut && pipeState.m_HS.Shader != ResourceId())) + if(cfg.unproject) { UINT strides[] = { sizeof(Vec3f) }; UINT offsets[] = { 0 }; diff --git a/renderdocui/Interop/FetchInfo.cs b/renderdocui/Interop/FetchInfo.cs index 4b040fced..e39282e78 100644 --- a/renderdocui/Interop/FetchInfo.cs +++ b/renderdocui/Interop/FetchInfo.cs @@ -383,6 +383,7 @@ namespace renderdoc public UInt32 highlightVert; public MeshFormat position; public MeshFormat secondary; + public bool unproject; public FloatVector prevMeshColour = new FloatVector(); public FloatVector currentMeshColour = new FloatVector(); diff --git a/renderdocui/Windows/BufferViewer.cs b/renderdocui/Windows/BufferViewer.cs index f62118bcf..5d01e978c 100644 --- a/renderdocui/Windows/BufferViewer.cs +++ b/renderdocui/Windows/BufferViewer.cs @@ -2208,6 +2208,13 @@ namespace renderdocui.Windows m_MeshDisplay.position.compType = pos.format.compType; m_MeshDisplay.position.specialFormat = pos.format.special ? pos.format.specialFormat : SpecialFormat.Unknown; m_MeshDisplay.position.showAlpha = false; + + m_MeshDisplay.unproject = false; + + if ((ui.m_Stage == MeshDataStage.VSOut && !m_Core.CurPipelineState.IsTessellationEnabled) || ui.m_Stage == MeshDataStage.GSOut) + { + m_MeshDisplay.unproject = pos.name.ToUpperInvariant() == "SV_POSITION"; + } } if (ui.m_Input == null || ui.m_Input.BufferFormats == null || @@ -2408,13 +2415,12 @@ namespace renderdocui.Windows if (m_Core.LogLoaded && MeshView) { m_ContextUIState = GetUIState(sender); - bool input = (m_ContextUIState == m_VSIn); if (e.Button == MouseButtons.Right && m_ContextUIState.m_Input != null && m_ContextUIState.m_Input.BufferFormats != null) { - selectColumnAsPositionToolStripMenuItem.Visible = input; + selectColumnAsPositionToolStripMenuItem.Visible = true; selectAlphaAsSecondaryToolStripMenuItem.Visible = true; m_ContextColumn = 0;