Beispiel #1
0
        public void BindPipeline(IMgPipeline pipeline)
        {
            if (pipeline == null)
            {
                throw new ArgumentNullException(nameof(pipeline));
            }
            mCurrentPipeline = (AmtComputePipeline)pipeline;

            var nextIndex = mBag.Pipelines.Push(mCurrentPipeline);

            mInstructions.Add(new AmtEncodingInstruction
            {
                Category  = AmtEncoderCategory.Compute,
                Index     = nextIndex,
                Operation = CmdBindPipeline,
            });
        }
Beispiel #2
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));
            }

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

            var bSrcBuffer = (AmtBuffer)srcBuffer;
            var bDstBuffer = (AmtBuffer)dstBuffer;

            var regions = new List <AmtBlitCopyBufferRegionRecord>();

            for (var i = 0; i < pRegions.Length; ++i)
            {
                if (pRegions[i].SrcOffset > nuint.MaxValue)
                {
                    throw new ArgumentOutOfRangeException(nameof(pRegions) + "[" + i + "].SrcOffset must be less than " + nuint.MaxValue);
                }

                if (pRegions[i].DstOffset > nuint.MaxValue)
                {
                    throw new ArgumentOutOfRangeException(nameof(pRegions) + "[" + i + "].DstOffset must be less than " + nuint.MaxValue);
                }

                if (pRegions[i].Size > nuint.MaxValue)
                {
                    throw new ArgumentOutOfRangeException(nameof(pRegions) + "[" + i + "].Size must be less than " + nuint.MaxValue);
                }

                regions.Add(new AmtBlitCopyBufferRegionRecord
                {
                    Size = (nuint)pRegions[i].Size,
                    DestinationOffset = (nuint)pRegions[i].DstOffset,
                    SourceOffset      = (nuint)pRegions[i].SrcOffset,
                });
            }

            var item = new AmtBlitCopyBufferRecord
            {
                Src     = bSrcBuffer.VertexBuffer,
                Dst     = bDstBuffer.VertexBuffer,
                Regions = regions.ToArray(),
            };
            var nextIndex = mBag.CopyBuffers.Push(item);

            mInstructions.Add(
                new AmtEncodingInstruction
            {
                Category  = AmtEncoderCategory.Blit,
                Index     = nextIndex,
                Operation = CmdCopyBuffer,
            }
                );
        }