示例#1
0
        public override void Prepare(PrepareContext context)
        {
            BatchCombiner.CombineBatches(ref _DrawCalls, context.BatchesToRelease);

            _DrawCalls.Sort(Frame.BatchComparer);
            context.PrepareMany(_DrawCalls);

            OnPrepareDone();
        }
示例#2
0
        public override void Prepare()
        {
            BatchCombiner.CombineBatches(_DrawCalls);

#if PSM
            _DrawCalls.Timsort(Frame.BatchComparer);
#else
            _DrawCalls.Sort(Frame.BatchComparer);
#endif

            foreach (var batch in _DrawCalls)
            {
                if (batch != null)
                {
                    batch.Prepare();
                }
            }
        }
示例#3
0
        public void Prepare(bool parallel)
        {
            if (Interlocked.Exchange(ref State, State_Preparing) != State_Initialized)
            {
                throw new InvalidOperationException("Frame was not in initialized state when prepare operation began ");
            }

            if (false)
            {
                var totalBatches = Batch.LifetimeCount - InitialBatchCount;
                Console.WriteLine("Frame contains {0} batches", totalBatches);
            }

            BatchCombiner.CombineBatches(Batches);

#if PSM
            Batches.Timsort(BatchComparer);
#else
            Batches.Sort(BatchComparer);
#endif

            if (!Monitor.TryEnter(PrepareLock, 5000))
            {
                throw new InvalidOperationException("Spent more than five seconds waiting for a previous prepare operation.");
            }

            try {
                if (parallel)
                {
                    RenderManager.ParallelPrepare(this);
                }
                else
                {
                    PrepareSubset(0, Batches.Count);
                }
            } finally {
                Monitor.Exit(PrepareLock);
            }

            if (Interlocked.Exchange(ref State, State_Prepared) != State_Preparing)
            {
                throw new InvalidOperationException("Frame was not in preparing state when prepare operation completed");
            }
        }
示例#4
0
文件: Frame.cs 项目: jli94/Fracture
        public void Prepare(bool parallel)
        {
            if (Interlocked.Exchange(ref State, (int)States.Preparing) != (int)States.Initialized)
            {
                throw new InvalidOperationException("Frame was not in initialized state when prepare operation began ");
            }

            if (false)
            {
                var totalBatches = Batch.LifetimeCount - InitialBatchCount;
                Console.WriteLine("Frame contains {0} batches", totalBatches);
            }

            var numRemoved = BatchCombiner.CombineBatches(ref Batches, BatchesToRelease);

            // Batch combining shuffles the batches around to group by type. Once it's done,
            //  we need to do the final sort to preserve layer and material ordering.
            Batches.Sort(BatchComparer);

            if (!Monitor.TryEnter(PrepareLock, 5000))
            {
                throw new InvalidOperationException("Spent more than five seconds waiting for a previous prepare operation.");
            }

            try {
                if (parallel)
                {
                    RenderManager.ParallelPrepareBatches(this);
                }
                else
                {
                    RenderManager.SynchronousPrepareBatches(this);
                }
            } finally {
                Monitor.Exit(PrepareLock);
            }

            if (Interlocked.Exchange(ref State, (int)States.Prepared) != (int)States.Preparing)
            {
                throw new InvalidOperationException("Frame was not in preparing state when prepare operation completed");
            }
        }
示例#5
0
 void IBatchContainer.PrepareChildren(ref PrepareContext context)
 {
     BatchCombiner.CombineBatches(ref _DrawCalls, ref context.BatchesToRelease);
     _DrawCalls.Sort(Frame.BatchComparer);
     context.PrepareMany(ref _DrawCalls);
 }