Esempio n. 1
0
        public void ActivateBind(int index)
        {
            Activate();
            BufferRangeTarget target = (BufferRangeTarget)BufferTarget;

            GL.BindBufferBase​(target, index, _bufferId);
        }
Esempio n. 2
0
        /// <summary>
        /// Activates the bind.
        /// </summary>
        /// <param name="index">The index.</param>
        public void ActivateBind(int index) //todo: more than one bound buffer is not working, but have different indices; test: glUniformBlockBinding
        {
            Activate();
            BufferRangeTarget target = (BufferRangeTarget)BufferTarget;

            GL.BindBufferBase​(target, index, bufferID);
        }
Esempio n. 3
0
        private void SetBuffer(int index, ShaderStage stage, BufferRange buffer, bool isStorage)
        {
            int bindingPoint = isStorage
                ? _program.GetStorageBufferBindingPoint(stage, index)
                : _program.GetUniformBufferBindingPoint(stage, index);

            if (bindingPoint == -1)
            {
                return;
            }

            BufferRangeTarget target = isStorage
                ? BufferRangeTarget.ShaderStorageBuffer
                : BufferRangeTarget.UniformBuffer;

            if (buffer.Buffer == null)
            {
                GL.BindBufferRange(target, bindingPoint, 0, IntPtr.Zero, 0);

                return;
            }

            int bufferHandle = ((Buffer)buffer.Buffer).Handle;

            IntPtr bufferOffset = (IntPtr)buffer.Offset;

            GL.BindBufferRange(target, bindingPoint, bufferHandle, bufferOffset, buffer.Size);
        }
Esempio n. 4
0
        public void bindBuffer(int index, string name, int uboIndex, BufferRangeTarget Target)
        {
            int uniformBlockIndex = GL.GetUniformBlockIndex(_program, name);

            GL.BindBufferBase(Target, index, uboIndex);
            GL.UniformBlockBinding(_program, uniformBlockIndex, index);
        }
Esempio n. 5
0
 /// <summary>
 /// Binds <see cref="GLObject.Id"/> to an indexed buffer target.
 /// </summary>
 /// <param name="target">The target for the bind</param>
 /// <param name="index">The index of the binding point</param>
 public void BindBase(BufferRangeTarget target, int index)
 {
     if (index != -1)
     {
         GL.BindBufferBase(target, index, Id);
     }
 }
Esempio n. 6
0
 public void BindBufferBase(BufferRangeTarget target, int index, int buffer)
 {
     AddCommand(new GLCommand
     {
         Command   = CommandEnum.BindBufferBase,
         Arguments = ValueTuple.Create(target, index, buffer)
     });
 }
Esempio n. 7
0
 /// <summary>
 /// Binds a range of this buffers data to an indexed buffer target.
 /// </summary>
 /// <param name="target">The target for the bind</param>
 /// <param name="index">The index of the binding point</param>
 /// <param name="offsetInBytes"></param>
 /// <param name="sizeInBytes"></param>
 public void BindRange(BufferRangeTarget target, int index, int offsetInBytes, int sizeInBytes)
 {
     // TODO: Check for out of bounds data ranges.
     if (index != -1)
     {
         GL.BindBufferRange(target, index, Id, new IntPtr(offsetInBytes), sizeInBytes);
     }
 }
Esempio n. 8
0
        public void BindBufferRange(BufferRangeTarget target, int bindingPoint, int buffer, IntPtr offset, IntPtr size)
        {
            if (!_bufferBindings.ContainsKey(target))
            {
                _bufferBindings[target] = new BufferBinding[BufferBindingPoints];
            }

            var binding = new BufferBinding(buffer, offset, size);

            if (IsBindingDifferent(target, bindingPoint, binding))
            {
                GL.BindBufferRange(target, bindingPoint, buffer, offset, size);
                _bufferBindings[target][bindingPoint] = binding;
            }
        }
Esempio n. 9
0
        public void SetTransformFeedbackBuffer(int index, BufferRange buffer)
        {
            const BufferRangeTarget target = BufferRangeTarget.TransformFeedbackBuffer;

            if (_tfEnabled)
            {
                GL.PauseTransformFeedback();
                GL.BindBufferRange(target, index, buffer.Handle.ToInt32(), (IntPtr)buffer.Offset, buffer.Size);
                GL.ResumeTransformFeedback();
            }
            else
            {
                GL.BindBufferRange(target, index, buffer.Handle.ToInt32(), (IntPtr)buffer.Offset, buffer.Size);
            }
        }
Esempio n. 10
0
        private void SetBuffer(int bindingPoint, BufferRange buffer, bool isStorage)
        {
            BufferRangeTarget target = isStorage
                ? BufferRangeTarget.ShaderStorageBuffer
                : BufferRangeTarget.UniformBuffer;

            if (buffer.Buffer == null)
            {
                GL.BindBufferRange(target, bindingPoint, 0, IntPtr.Zero, 0);

                return;
            }

            int bufferHandle = ((Buffer)buffer.Buffer).Handle;

            IntPtr bufferOffset = (IntPtr)buffer.Offset;

            GL.BindBufferRange(target, bindingPoint, bufferHandle, bufferOffset, buffer.Size);
        }
Esempio n. 11
0
        bool IsBindingDifferent(BufferRangeTarget target, int bindingPoint, BufferBinding binding)
        {
            if (_bufferBindings[target][bindingPoint] == null)
            {
                return(true);
            }

            var old = _bufferBindings[target][bindingPoint];

            if (old.Buffer != binding.Buffer)
            {
                return(true);
            }
            if (old.Offset != binding.Offset)
            {
                return(true);
            }
            if (old.Size != binding.Size)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 12
0
 public static void glBindBufferRange(
     BufferRangeTarget target,
     uint index,
     uint buffer,
     IntPtr offset,
     UIntPtr size) => p_glBindBufferRange(target, index, buffer, offset, size);
Esempio n. 13
0
 /// <summary>
 /// Binds a buffer to a binding point. Equivalent to glBindBufferBase with a check for redundant state changes.
 /// </summary>
 public void BindBufferBase(BufferRangeTarget target, int bindingPoint, int buffer)
 {
     _bufferBindingManager.BindBufferBase(target, bindingPoint, buffer);
 }
Esempio n. 14
0
 /// <summary>
 /// Binds a buffer range to a binding point. Equivalent to glBindBufferRange with a check for redundant state changes.
 /// </summary>
 public void BindBufferRange(BufferRangeTarget target, int bindingPoint, int buffer, IntPtr offset, IntPtr size)
 {
     _bufferBindingManager.BindBufferRange(target, bindingPoint, buffer, offset, size);
 }
Esempio n. 15
0
 /// <summary> Construct and bind to binding index on target</summary>
 public GLDataBlock(int bindingindex, bool std430, BufferRangeTarget tgr) : base(std430)
 {
     BindingIndex = bindingindex;
     Bind(BindingIndex, tgr);
 }
Esempio n. 16
0
 ///<summary> Bing to buffer range target at this binding index</summary>
 public void Bind(int bindingindex, BufferRangeTarget tgr)
 {
     System.Diagnostics.Debug.Assert(context == GLStatics.GetContext(), "Context incorrect"); // safety
     GL.BindBufferBase(tgr, bindingindex, Id);                                                // binding point set to tgr
 }
Esempio n. 17
0
 public unsafe static void BindBuffersRange(BufferRangeTarget target, uint first, int count, ref uint buffers, ref int offsets, ref int sizes)
 => glBindBuffersRange(target, first, count, ref buffers, ref offsets, ref sizes);
Esempio n. 18
0
 internal BufferBinding(BufferRangeTarget bindingTarget, ProgramInterface programInterface)
 {
     BindingTarget     = bindingTarget;
     _programInterface = programInterface;
 }
Esempio n. 19
0
 public unsafe static void BindBufferBase(BufferRangeTarget target, uint index, uint buffer)
 => glBindBufferBase(target, index, buffer);
Esempio n. 20
0
 public void BindBase(BufferRangeTarget target, int index)
 {
     GL.BindBufferBase(target, index, _id);
 }
 public void BindBufferBase(BufferRangeTarget target, int index, int buffer)
 {
     device.BindBufferBase(target, index, buffer);
 }
Esempio n. 22
0
 public unsafe static void BindBufferRange(BufferRangeTarget target, uint index, uint buffer, int offset, int size)
 => glBindBufferRange(target, index, buffer, offset, size);
Esempio n. 23
0
 public unsafe static void BindBuffersBase(BufferRangeTarget target, uint first, int count, ref uint buffers)
 => glBindBuffersBase(target, first, count, ref buffers);