private void PopulateCommandListsForVisualDebugDrawing() { m_CommandList.CommandAllocator.Reset(); m_CommandList.CommandList.Reset(m_CommandList.CommandAllocator, m_PipelineState); // set viewport and scissors m_CommandList.CommandList.SetGraphicsRootSignature(m_RootSignature); // @TODO - redesign this section m_TransformationCBPointer = m_ConstantBuffer.Map(0); //Utilities.Write(m_TransformationCBPointer, ref m_TransformationCB); List <Matrix> dataToCopy = new List <Matrix>(); dataToCopy.Add(m_TransformationCB.viewProjectionMatrix); foreach (Matrix mtx in m_TransformationCB.BoneMatrices) { dataToCopy.Add(mtx); } Utilities.Write(m_TransformationCBPointer, dataToCopy.ToArray(), 0, dataToCopy.Count); m_ConstantBuffer.Unmap(0); m_CommandList.CommandList.SetDescriptorHeaps(1, new DescriptorHeap[] { m_ConstantBufferViewHeap }); //m_CommandList.SetDescriptorHeaps(2, new DescriptorHeap[] { m_ConstantBufferViewHeap, m_srvDescriptorHeap }); GpuDescriptorHandle hDescriptor = m_ConstantBufferViewHeap.GPUDescriptorHandleForHeapStart; m_CommandList.CommandList.SetGraphicsRootDescriptorTable(0, hDescriptor); hDescriptor += m_ConstantBufferDescriptorSize; //Int32 sizeInBytes = (Utilities.SizeOf<TransformationCB>() + 255) & ~255; //hDescriptor += sizeInBytes; m_CommandList.CommandList.SetGraphicsRootDescriptorTable(1, hDescriptor); m_CommandList.CommandList.SetViewport(m_Viewport); m_CommandList.CommandList.SetScissorRectangles(m_SissorRect); // use barrier to notify we are using the m_RenderTarget Resource rtvBackBuffer = m_SwapChainDX12.GetBackBuffer(m_FrameIndex); m_CommandList.CommandList.ResourceBarrierTransition(rtvBackBuffer, ResourceStates.Present, ResourceStates.RenderTarget); //CpuDescriptorHandle rtvHandle = m_RenderTargetViewHeap.CPUDescriptorHandleForHeapStart; //rtvHandle += m_FrameIndex * m_RTVDescriptorSize; //CpuDescriptorHandle dsvHandle = m_DepthStencilViewHeap.CPUDescriptorHandleForHeapStart; CpuDescriptorHandle rtvHandle = m_DeviceContext.Dx12Device.RenderTargetDescriptorCache.GetCpuAddressByOffset(m_FrameIndex); // @TODO - need to set the depth value consistent with frame counts! CpuDescriptorHandle dsvHandle = m_DeviceContext.Dx12Device.DepthStencilDescriptorCache.GetCpuAddressByOffset(0); m_CommandList.CommandList.SetRenderTargets(rtvHandle, dsvHandle); // clear the render target & depth stencil m_CommandList.CommandList.ClearRenderTargetView(rtvHandle, new Color4(0, 0.2f, 0.4f, 1), 0, null); m_CommandList.CommandList.ClearDepthStencilView(dsvHandle, ClearFlags.FlagsDepth, 1.0f, 0, 0, null); // record commands //m_CommandList.CommandList.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList; //m_CommandList.SetVertexBuffer(0, m_VertexBufferView); // @TODO - I need to wrap command list separately! //H1StaticMeshLODResource resource = m_TempStaticMesh.StaticMeshData.GetLODResource(0); //H1StaticMeshLODResource resource = H1Global<H1World>.Instance.PersistentLevel.GetActor(0).GetActorComponent<H1StaticMeshComponent>().StaticMesh.StaticMeshData.GetLODResource(1); //resource.LocalVertexFactory.setVertexBuffers(m_CommandList.CommandList); //m_CommandList.DrawInstanced(3, 1, 0, 0); //m_CommandList.SetIndexBuffer(m_IndexBufferView); //m_CommandList.CommandList.SetIndexBuffer(resource.IndexBuffer.View); //int instanceCount = Convert.ToInt32(resource.IndexBuffer.Count); //m_CommandList.CommandList.DrawIndexedInstanced(instanceCount, 1, 0, 0, 0); //H1RenderUtils.DrawBox(m_CommandList.CommandList, new H1Transform()); //H1RenderUtils.DrawPlane10x10(m_CommandList.CommandList, new Vector2(0, 0), new Vector2(1, 1)); //H1RenderUtils.DrawSphere(m_CommandList.CommandList, new Vector3(0, 0, 0), new Vector3(1), 8, 6); //AngleSingle angle1 = new AngleSingle(10.0f, AngleType.Degree); //H1RenderUtils.DrawCone(m_CommandList.CommandList, angle1.Radians, angle1.Radians, 24, false, new Vector4(1)); //H1RenderUtils.DrawCylinder(m_CommandList.CommandList, new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1), 1, 3, 10); //H1RenderUtils.DrawCapsule(m_CommandList.CommandList, new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1), 1, 3, 10); H1RenderUtils.DrawDisc(m_CommandList.CommandList, new Vector3(0), new Vector3(1, 0, 0), new Vector3(0, 1, 0), 1, 10); //H1RenderUtils.DrawFlatArrow(m_CommandList.CommandList, new Vector3(0), new Vector3(1, 0, 0), new Vector3(0, 1, 0), 10, 1, 0.1f); //H1RenderUtils.DrawWireBox(m_CommandList.CommandList, Matrix.Identity, new Vector3(-1, -1, -1), new Vector3(1), 1, 0, 0); //H1RenderUtils.DrawWireSphere(m_CommandList.CommandList, new Vector3(0), 2.0f, 24); //H1RenderUtils.DrawWireCylinder(m_CommandList.CommandList, new Vector3(0), new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1), 1.0f, 3, 10); //H1RenderUtils.DrawWireCapsule(m_CommandList.CommandList, new Vector3(0), new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1), 1.0f, 3, 10); //H1RenderUtils.DrawWireCone(m_CommandList.CommandList, Matrix.Identity, 1.0f, 15.0f, 10); //H1RenderUtils.DrawWireSphereCappedCone(m_CommandList.CommandList, Matrix.Identity, 1.0f, 15.0f, 16, 4, 10); //H1RenderUtils.DrawOrientedWireBox(m_CommandList.CommandList, new Vector3(0), new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1), new Vector3(2)); //H1RenderUtils.DrawCoordinateSystem(m_CommandList.CommandList, new Vector3(0), Matrix.Identity, 2.0f); //H1RenderUtils.DrawDirectionalArrow(m_CommandList.CommandList, Matrix.Identity, 2.0f, 0.2f); //H1RenderUtils.DrawWireStar(m_CommandList.CommandList, new Vector3(0), 1.0f); //H1RenderUtils.DrawDashedLine(m_CommandList.CommandList, new Vector3(-1), new Vector3(1), 0.2f); //H1RenderUtils.DrawWireDiamond(m_CommandList.CommandList, Matrix.Identity, 0.2f); //H1SkeletalMeshComponent skeletalMeshComponent = H1Global<H1World>.Instance.PersistentLevel.GetActor(0).GetActorComponent<H1SkeletalMeshComponent>(); //skeletalMeshComponent.SkeletalMesh.SkeletonDebugDrawing(m_CommandList.CommandList); // execute commands H1Global <Commands.H1CommandManager> .Instance.ExecuteCommands(); // use barrier to notify that we are going to present the render target m_CommandList.CommandList.ResourceBarrierTransition(rtvBackBuffer, ResourceStates.RenderTarget, ResourceStates.Present); // execute the command m_CommandList.CommandList.Close(); }