Beispiel #1
0
 /// <summary>
 /// Copies data from CPU memory to the associated accelerator.
 /// </summary>
 /// <param name="stream">The stream to use.</param>
 public void CopyToAccelerator(AcceleratorStream stream)
 {
     if (stream == null)
     {
         throw new ArgumentNullException(nameof(stream));
     }
     CopyFromView(stream, CPUView.AsLinearView(), 0);
 }
Beispiel #2
0
        /// <summary>
        /// Copies data from the associated accelerator into CPU memory.
        /// </summary>
        /// <param name="stream">The stream to use.</param>
        /// <param name="acceleratorMemoryOffset">The source memory offset.</param>
        /// <param name="cpuMemoryOffset">the target memory offset.</param>
        /// <param name="extent">The extent (number of elements).</param>
        public void CopyFromAccelerator(
            AcceleratorStream stream,
            TIndex acceleratorMemoryOffset,
            TIndex cpuMemoryOffset,
            LongIndex1 extent)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (!cpuMemoryOffset.InBounds(CPUView.Extent))
            {
                throw new ArgumentOutOfRangeException(nameof(cpuMemoryOffset));
            }
            if (!acceleratorMemoryOffset.InBounds(Extent))
            {
                throw new ArgumentOutOfRangeException(nameof(acceleratorMemoryOffset));
            }
            if (extent < 1 || extent > Length)
            {
                throw new ArgumentOutOfRangeException(nameof(extent));
            }
            var linearSourceIndex =
                acceleratorMemoryOffset.ComputeLinearIndex(Extent);
            var linearTargetIndex =
                cpuMemoryOffset.ComputeLinearIndex(CPUView.Extent);

            if (linearSourceIndex + extent > Length ||
                linearTargetIndex + extent > CPUView.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(extent));
            }

            CopyToView(
                stream,
                CPUView.GetSubView(cpuMemoryOffset, extent),
                linearSourceIndex);
        }
Beispiel #3
0
        private void StartTimer()
        {
            Device.StartTimer(new TimeSpan(50000), () =>
            {
                if (!running || GPUView.CanvasSize.Width < 0)
                {
                    return(true);
                }

                if (lines.Count > 40)
                {
                    lines.Dequeue();
                }

                // Add new line
                lastLine = GetNextLine();
                lines.Enqueue(lastLine);

                CPUView.InvalidateSurface();
                GPUView.InvalidateSurface();

                return(true);
            });
        }
Beispiel #4
0
 private void OnChkBackgroundChanged(object sender, EventArgs args)
 {
     CPUView.InvalidateSurface();
     GPUView.InvalidateSurface();
 }