示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GorgonBuffer" /> class.
        /// </summary>
        /// <param name="graphics">The <see cref="GorgonGraphics"/> object used to create and manipulate the buffer.</param>
        /// <param name="info">Information used to create the buffer.</param>
        /// <param name="initialData">[Optional] The initial data used to populate the buffer.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="info"/> parameter is <b>null</b>.</exception>
        /// <exception cref="ArgumentException">Thrown if the size of the buffer is less than 1 byte.</exception>
        /// <exception cref="GorgonException">Thrown if the buffer is created with a usage of <see cref="ResourceUsage.Immutable"/>, but the <paramref name="initialData"/> parameter is <b>null</b>.
        /// <para>-or-</para>
        /// <para>A value on the <paramref name="info"/> parameter is incorrect.</para>
        /// </exception>
        public GorgonBuffer(GorgonGraphics graphics, IGorgonBufferInfo info, GorgonNativeBuffer <byte> initialData = null)
            : base(graphics)
        {
            _info = new GorgonBufferInfo(info ?? throw new ArgumentNullException(nameof(info)));

            Initialize(initialData);
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GorgonBufferInfo"/> class.
        /// </summary>
        /// <param name="info">The buffer information to copy.</param>
        /// <param name="newName">[Optional] The new name for the buffer.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="info"/> parameter is <b>null</b>.</exception>
        public GorgonBufferInfo(IGorgonBufferInfo info, string newName = null)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }

            Name          = string.IsNullOrEmpty(newName) ? info.Name : newName;
            Usage         = info.Usage;
            SizeInBytes   = info.SizeInBytes;
            Binding       = info.Binding;
            AllowCpuRead  = info.AllowCpuRead;
            StructureSize = info.StructureSize;
            AllowRawView  = info.AllowRawView;
            IndirectArgs  = info.IndirectArgs;
        }