// Helper function to read atomic UAV counters back onto the CPU. This will cause a stall so only use in debug #if DEBUG private static int ReadCounter(IUnorderedAccessBindable uav) { int count = 0; // Copy the UAV counter to a staging resource /*RC.DeviceContext.CopyStructureCount(m_debugCounterBuffer.m_resource as SharpDX.Direct3D11.Buffer, 0, uav.UAV); * * var mapping = MyMapping.MapRead(m_debugCounterBuffer.m_resource); * mapping.ReadAndPosition(ref count); * mapping.Unmap();*/ return(count); }
// Helper function to read atomic UAV counters back onto the CPU. This will cause a stall so only use in debug #if DEBUG private static int ReadCounter(IUnorderedAccessBindable uav) { int count = 0; if (VRage.MyCompilationSymbols.DX11Debug) { // Copy the UAV counter to a staging resource RC.DeviceContext.CopyStructureCount(m_debugCounterBuffer.m_resource as SharpDX.Direct3D11.Buffer, 0, uav.UAV); var mapping = MyMapping.MapRead(m_debugCounterBuffer.m_resource); mapping.ReadAndPosition(ref count); mapping.Unmap(); } return(count); }
// IMPORTANT: This method can be called only once per frame. If it is not, it will stall CPU for quite long time // Helper function to read atomic UAV counters back onto the CPU. // The method reads in the current frame the value from the previous frame private static int ReadCounter(IUnorderedAccessBindable uav) { int count = 0; if (VRage.MyCompilationSymbols.DX11Debug) { // Copy the UAV counter to a staging resource RC.CopyStructureCount(m_debugCounterBuffers[m_debugCounterBuffersIndex].m_resource as SharpDX.Direct3D11.Buffer, 0, uav.Uav); m_debugCounterBuffersIndex = m_debugCounterBuffersIndex == 1 ? 0 : 1; var mapping = MyMapping.MapRead(m_debugCounterBuffers[m_debugCounterBuffersIndex].m_resource); mapping.ReadAndPosition(ref count); mapping.Unmap(); } return count; }