Esempio n. 1
0
        /// <summary>
        /// Writes the contents of a given <see cref="HlslBuffer{T}"/> to the current <see cref="HlslBuffer{T}"/> instance, using a temporary CPU buffer
        /// </summary>
        /// <param name="buffer">The input <see cref="HlslBuffer{T}"/> to read data from</param>
        protected void SetDataWithCpuBuffer(HlslBuffer <T> buffer)
        {
            // Create a temporary array
            T[] array = ArrayPool <T> .Shared.Rent(buffer.Size);

            Span <T> span = array.AsSpan(0, buffer.Size);

            // Get the unpadded data from the read write buffer
            buffer.GetData(span);

            // Set the data, adding the padding if needed
            SetData(span);

            ArrayPool <T> .Shared.Return(array);
        }
        /// <inheritdoc/>
        public override void SetData(HlslBuffer <T> buffer)
        {
            if (!buffer.IsPaddingPresent)
            {
                // Directly copy the input buffer
                using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy);

                copyCommandList.CopyBufferRegion(buffer, 0, this, 0, SizeInBytes);
                copyCommandList.ExecuteAndWaitForCompletion();
            }
            else
            {
                SetDataWithCpuBuffer(buffer);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Writes the contents of a given <see cref="HlslBuffer{T}"/> to the current <see cref="HlslBuffer{T}"/> instance
 /// </summary>
 /// <param name="buffer">The input <see cref="HlslBuffer{T}"/> to read data from</param>
 public abstract void SetData(HlslBuffer <T> buffer);