Example #1
0
        public void Add(GLCmdEncodingInstruction inst)
        {
            var currentIndex = (uint)mInstructions.Count;

            mInstructions.Add(new GLCmdRecordInstruction
            {
                Index     = inst.Index,
                Operation = inst.Operation,
            });

            if (mCurrentContext == null)
            {
                InitializeNewContext(inst, currentIndex);
            }
            else
            {
                if (mCurrentContext.Category == inst.Category)
                {
                    mCurrentContext.Last = currentIndex;
                }
                else
                {
                    InitializeNewContext(inst, currentIndex);
                }
            }
        }
Example #2
0
 void InitializeNewContext(GLCmdEncodingInstruction inst, uint currentIndex)
 {
     mCurrentContext = new GLCmdEncoderContext
     {
         Category = inst.Category,
         First    = currentIndex,
         Last     = currentIndex,
     };
     mContexts.Add(mCurrentContext);
 }
Example #3
0
        public void CopyBuffer(IMgBuffer srcBuffer, IMgBuffer dstBuffer, MgBufferCopy[] pRegions)
        {
            if (srcBuffer == null)
            {
                throw new ArgumentNullException(nameof(srcBuffer));
            }

            if (dstBuffer == null)
            {
                throw new ArgumentNullException(nameof(dstBuffer));
            }

            var bSrcBuffer = (IGLBuffer)srcBuffer;

            Debug.Assert(bSrcBuffer.IsBufferType);

            var bDstBuffer = (IGLBuffer)dstBuffer;

            Debug.Assert(bDstBuffer.IsBufferType);

            var copyParams = new List <GLCmdCopyBufferRegionRecord>();

            for (var i = 0; i < pRegions.Length; i += 1)
            {
                var region = pRegions[i];
                if (region.SrcOffset > (ulong)long.MaxValue)
                {
                    throw new InvalidOperationException(nameof(pRegions) + "[" + i + "].SrcOffset is greater than long.MaxValue");
                }

                if (region.DstOffset > (ulong)long.MaxValue)
                {
                    throw new InvalidOperationException(nameof(pRegions) + "[" + i + "].DstOffset is greater than long.MaxValue");
                }

                if (region.Size > (ulong)int.MaxValue)
                {
                    throw new InvalidOperationException(nameof(pRegions) + "[" + i + "].Size is greater than int.MaxValue");
                }

                var bufferParam = new GLCmdCopyBufferRegionRecord
                {
                    ReadOffset  = new IntPtr((long)region.SrcOffset),
                    WriteOffset = new IntPtr((long)region.DstOffset),
                    Size        = (int)region.Size,
                };
                copyParams.Add(bufferParam);
            }

            var item = new GLCmdCopyBufferRecord
            {
                Source      = bSrcBuffer.BufferId,
                Destination = bDstBuffer.BufferId,
                Regions     = copyParams.ToArray(),
            };

            var nextIndex = mBag.CopyBuffers.Push(item);

            var instruction = new GLCmdEncodingInstruction
            {
                Category  = GLCmdEncoderCategory.Blit,
                Index     = nextIndex,
                Operation = CmdCopyBuffer,
            };

            mInstructions.Add(instruction);
        }