Exemplo n.º 1
0
        /// <summary>
        /// Function to copy the contents of the specified buffer to this buffer.
        /// </summary>
        /// <param name="buffer">Buffer to copy.</param>
        /// <param name="sourceOffset">Starting byte index to start copying from.</param>
        /// <param name="byteCount">The number of bytes to copy.</param>
        /// <param name="destOffset">The offset within the destination buffer.</param>
        /// <remarks>This is used to copy data from one GPU buffer to another.</remarks>
        /// <exception cref="System.ArgumentOutOfRangeException">Thrown when the <paramref name="sourceOffset"/> is less than 0 or larger than the size of the source <paramref name="buffer"/>.
        /// <para>-or-</para>
        /// <para>Thrown when the <paramref name="byteCount"/> + sourceStartIndex is greater than the size of the source buffer, or less than 0.</para>
        /// <para>-or-</para>
        /// <para>Thrown when the <paramref name="destOffset"/> + byteCount is greater than the size of this buffer, or less than 0.</para>
        /// </exception>
        /// <exception cref="GorgonLibrary.GorgonException">Thrown when this buffer has a usage of Immutable.</exception>
        public void Copy(GorgonBaseBuffer buffer, int sourceOffset, int byteCount, int destOffset)
        {
            int sourceByteIndex = sourceOffset + byteCount;
            int destByteIndex   = destOffset + byteCount;

            GorgonDebug.AssertNull(buffer, "buffer");
            GorgonDebug.AssertParamRange(sourceOffset, 0, buffer.SizeInBytes, "sourceOffset");
            GorgonDebug.AssertParamRange(sourceByteIndex, 0, buffer.SizeInBytes, "sourceOffset");
            GorgonDebug.AssertParamRange(destOffset, 0, SizeInBytes, "destOffset");
            GorgonDebug.AssertParamRange(destByteIndex, 0, buffer.SizeInBytes, "destOffset");

#if DEBUG
            if (Settings.Usage == BufferUsage.Immutable)
            {
                throw new GorgonException(GorgonResult.AccessDenied, Resources.GORGFX_BUFFER_IMMUTABLE);
            }
#endif
            Graphics.Context.CopySubresourceRegion(buffer.D3DResource, 0, new D3D.ResourceRegion
            {
                Top    = 0,
                Bottom = 1,
                Left   = sourceOffset,
                Right  = sourceByteIndex,
                Front  = 0,
                Back   = 1
            }, D3DResource, 0, destOffset);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GorgonOutputBufferBinding"/> struct.
        /// </summary>
        /// <param name="buffer">The buffer to bind.</param>
        /// <param name="offset">The offset within the buffer to start at, in bytes.</param>
        /// <remarks>If the <paramref name="offset"/> parameter is set to -1, then data will be appended to the buffer from the last write.  Otherwise,
        /// writing will occur at the offset provided.</remarks>
        public GorgonOutputBufferBinding(GorgonBaseBuffer buffer, int offset = -1)
        {
            if ((buffer != null) && (!buffer.Settings.IsOutput))
            {
                throw new GorgonException(GorgonResult.CannotCreate, string.Format(Resources.GORGFX_BUFFER_NOT_OUTPUT, buffer.Name));
            }

            OutputBuffer = buffer;
            Offset       = offset;
        }
        /// <summary>
        /// Function to copy data from this view into a buffer.
        /// </summary>
        /// <param name="buffer">Buffer that will receive the data.</param>
        /// <param name="offset">DWORD aligned offset within the buffer to start writing at.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="buffer"/> parameter is NULL (Nothing in VB.Net).</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">Thrown when the <paramref name="offset"/> parameter is less than 0, or larger than the size of the buffer minus 4 bytes.</exception>
        /// <remarks>This will copy the contents of a structured buffer into any other type of buffer.  The view must have been created using a ViewType of Counter or Append, otherwise an exception will be thrown.</remarks>
        public void CopyTo(GorgonBaseBuffer buffer, int offset)
        {
            GorgonDebug.AssertNull(buffer, "buffer");
            GorgonDebug.AssertParamRange(offset, 0, buffer.SizeInBytes - 4, "index");

#if DEBUG
            if (ViewType == UnorderedAccessViewType.Standard)
            {
                throw new GorgonException(GorgonResult.CannotRead, Resources.GORGFX_VIEW_UNORDERED_TYPE_NOT_VALID_FOR_COPY);
            }
#endif
            Resource.Graphics.Context.CopyStructureCount(buffer.D3DBuffer, offset, D3DView);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Function to copy the contents of the specified buffer to this buffer.
        /// </summary>
        /// <param name="buffer">Buffer to copy.</param>
        /// <remarks>This is used to copy data from one GPU buffer to another.  The size of the buffers must be the same.</remarks>
        /// <exception cref="System.ArgumentException">Thrown when the <paramref name="buffer"/> size is not equal to the size of this buffer.</exception>
        /// <exception cref="GorgonLibrary.GorgonException">Thrown when this buffer has a usage of Immutable.</exception>
        public void Copy(GorgonBaseBuffer buffer)
        {
#if DEBUG
            if (buffer.SizeInBytes != SizeInBytes)
            {
                throw new ArgumentException(Resources.GORGFX_BUFFER_SIZE_MISMATCH, "buffer");
            }

            if (Settings.Usage == BufferUsage.Immutable)
            {
                throw new GorgonException(GorgonResult.AccessDenied, Resources.GORGFX_BUFFER_IMMUTABLE);
            }
#endif
            Graphics.Context.CopyResource(buffer.D3DResource, D3DResource);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Function to copy the contents of the specified buffer to this buffer.
 /// </summary>
 /// <param name="buffer">Buffer to copy.</param>
 /// <param name="sourceStartingIndex">Starting byte index to start copying from.</param>
 /// <param name="byteCount">The number of bytes to copy.</param>
 /// <remarks>This is used to copy data from one GPU buffer to another.</remarks>
 /// <exception cref="System.ArgumentOutOfRangeException">Thrown when the <paramref name="sourceStartingIndex"/> is less than 0 or larger than the size of the source <paramref name="buffer"/>.
 /// <para>-or-</para>
 /// <para>Thrown when the <paramref name="byteCount"/> + sourceStartIndex is greater than the size of the source buffer, or less than 0.</para>
 /// </exception>
 /// <exception cref="System.InvalidOperationException">Thrown when this buffer has a usage of Immutable.</exception>
 public void Copy(GorgonBaseBuffer buffer, int sourceStartingIndex, int byteCount)
 {
     Copy(buffer, sourceStartingIndex, byteCount, 0);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Function to return the default shader view for a buffer.
 /// </summary>
 /// <param name="buffer">Buffer to evaluate.</param>
 /// <returns>The default shader view for the buffer.</returns>
 public static GorgonShaderView ToShaderView(GorgonBaseBuffer buffer)
 {
     return(buffer == null ? null : buffer.DefaultShaderView);
 }