From 8e1782d1f442a3cf4d48a0d9e1d460a1fc666eff Mon Sep 17 00:00:00 2001 From: Pyrolistical Date: Mon, 29 Apr 2024 01:22:47 -0700 Subject: [PATCH] fix crash when axes are rendered but m_bShowCubes is toggled off --- samples/hellovr_dx12/hellovr_dx12_main.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/samples/hellovr_dx12/hellovr_dx12_main.cpp b/samples/hellovr_dx12/hellovr_dx12_main.cpp index 64dc99e8..c2581a43 100644 --- a/samples/hellovr_dx12/hellovr_dx12_main.cpp +++ b/samples/hellovr_dx12/hellovr_dx12_main.cpp @@ -1718,6 +1718,16 @@ void CMainApplication::RenderScene( vr::Hmd_Eye nEye ) // draw the controller axis lines m_pCommandList->SetPipelineState( m_pAxesPipelineState.Get() ); + // Select the CBV (left or right eye) + CD3DX12_GPU_DESCRIPTOR_HANDLE cbvHandle(m_pCBVSRVHeap->GetGPUDescriptorHandleForHeapStart()); + cbvHandle.Offset(nEye, m_nCBVSRVDescriptorSize); + m_pCommandList->SetGraphicsRootDescriptorTable(0, cbvHandle); + + // SRV is just after the left eye + CD3DX12_GPU_DESCRIPTOR_HANDLE srvHandle(m_pCBVSRVHeap->GetGPUDescriptorHandleForHeapStart()); + srvHandle.Offset(SRV_TEXTURE_MAP, m_nCBVSRVDescriptorSize); + m_pCommandList->SetGraphicsRootDescriptorTable(1, srvHandle); + m_pCommandList->IASetPrimitiveTopology( D3D_PRIMITIVE_TOPOLOGY_LINELIST ); m_pCommandList->IASetVertexBuffers( 0, 1, &m_controllerAxisVertexBufferView ); m_pCommandList->DrawInstanced( m_uiControllerVertcount, 1, 0, 0 );