<commit_before>﻿namespace CSharpGL
{
    /// <summary>
    /// Buffer object that not work as input variable in shader.
    /// </summary>
    /// <typeparam name="T">此buffer存储的是哪种struct的数据？<para>type of index value.</para></typeparam>
    public class IndependentBuffer<T> : Buffer where T : struct
    {
        /// <summary>
        /// </summary>
        /// <param name="target"></param>
        /// <param name="usage"></param>
        /// <param name="noDataCopyed"></param>
        public IndependentBuffer(BufferTarget target, BufferUsage usage, bool noDataCopyed)
            : base(usage)
        {
            this.Target = target;
            this.NoDataCopyed = noDataCopyed;
        }

        /// <summary>
        ///
        /// </summary>
        public bool NoDataCopyed { get; private set; }

        /// <summary>
        ///
        /// </summary>
        public BufferTarget Target { get; private set; }

        /// <summary>
        /// 申请指定长度的非托管数组。
        /// <para>create an unmanaged array to store data for this buffer.</para>
        /// </summary>
        /// <param name="elementCount">数组元素的数目。<para>How many elements?</para></param>
        public override void Create(int elementCount)
        {
            this.array = new UnmanagedArray<T>(elementCount, !this.NoDataCopyed);
        }

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return string.Format("{0}, ByteLength: {1}, Header: {2}", this.Target, this.ByteLength, this.Header);
        }

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override BufferPtr Upload2GPU()
        {
            uint[] buffers = new uint[1];
            glGenBuffers(1, buffers);
            var target = (uint)this.Target;
            glBindBuffer(target, buffers[0]);
            glBufferData(target, this.ByteLength, this.Header, (uint)this.Usage);
            glBindBuffer(target, 0);

            var bufferPtr = new IndependentBufferPtr(this.Target,
                buffers[0], this.Length, this.ByteLength);

            return bufferPtr;
        }
    }
}<commit_msg>clean<commit_after>﻿namespace CSharpGL
{
    /// <summary>
    /// Buffer object that not work as input variable in shader.
    /// </summary>
    /// <typeparam name="T">此buffer存储的是哪种struct的数据？<para>type of index value.</para></typeparam>
    public class IndependentBuffer<T> : Buffer where T : struct
    {
        /// <summary>
        /// No data copyed from CPU memory to GPU memory.
        /// </summary>
        private bool noDataCopyed;

        /// <summary>
        /// </summary>
        /// <param name="target"></param>
        /// <param name="usage"></param>
        /// <param name="noDataCopyed">No data copyed from CPU memory to GPU memory.</param>
        public IndependentBuffer(BufferTarget target, BufferUsage usage, bool noDataCopyed)
            : base(usage)
        {
            this.Target = target;
            this.noDataCopyed = noDataCopyed;
        }

        /// <summary>
        ///
        /// </summary>
        public BufferTarget Target { get; private set; }

        /// <summary>
        /// 申请指定长度的非托管数组。
        /// <para>create an unmanaged array to store data for this buffer.</para>
        /// </summary>
        /// <param name="elementCount">数组元素的数目。<para>How many elements?</para></param>
        public override void Create(int elementCount)
        {
            this.array = new UnmanagedArray<T>(elementCount, !this.noDataCopyed);
        }

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return string.Format("{0}, ByteLength: {1}, Header: {2}", this.Target, this.ByteLength, this.Header);
        }

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override BufferPtr Upload2GPU()
        {
            uint[] buffers = new uint[1];
            glGenBuffers(1, buffers);
            var target = (uint)this.Target;
            glBindBuffer(target, buffers[0]);
            glBufferData(target, this.ByteLength, this.Header, (uint)this.Usage);
            glBindBuffer(target, 0);

            var bufferPtr = new IndependentBufferPtr(this.Target, buffers[0], this.Length, this.ByteLength);

            return bufferPtr;
        }
    }
}
{'fraction_non_alphanumeric': 0.1422192453672695, 'fraction_numerical': 0.004018754186202277, 'mean_word_length': 1.7367135003054368, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6719818', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1238, 'n_words': 288}