Exemple #1
0
        public void DrawBatcher_TestBatchCreation_FiveBatchesDueToTwoQueueChangesPlusADualBatchSingleQueueInThere()
        {
            var messenger = Substitute.For <IFrameworkMessenger>();
            var tools     = new DrawStageBatcherTools();

            IDrawStageBatcher batcher = new DrawStageBatcher(12, tools);

            var properties = Substitute.For <IStartupPropertiesCache>();

            properties.Internal.Returns(new InternalStartUpProperties
            {
                DrawQueueInitialSizeNumberOfRequests         = 32,
                DrawQueueInitialSizeElementsPerRequestScalar = 4
            });

            var queues = new DrawQueueGroup(new IdGenerator(messenger),
                                            new DrawQueueFactory(messenger, properties, new ComparerCollection()),
                                            Substitute.For <IDrawStageBuffers>(),
                                            Substitute.For <IQueueToBufferBlitter>(),
                                            false);

            //Dynamic

            Add(queues.DynamicQueue.Queue, FillType.Coloured, 0UL, 0UL, TextureCoordinateMode.None, TextureCoordinateMode.None, 0, 0.5f);
            Add(queues.DynamicQueue.Queue, FillType.Textured, 20UL, 0UL, TextureCoordinateMode.Wrap, TextureCoordinateMode.None, 1);

            queues.ProcessDynamicQueue();

            //Persistent

            var requests0 = new InternalDrawRequest[]
            {
                Create(FillType.Coloured, 0UL, 0UL, TextureCoordinateMode.None, TextureCoordinateMode.None, 0, 0.2f)
            };

            queues.CreateNewPersistentQueue(requests0, false);

            var requests1 = new InternalDrawRequest[]
            {
                //Depth 1.0f puts it at the beginning
                Create(FillType.Textured, 5UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.None, 0, 1.0f),
                Create(FillType.Textured, 10UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.None, 0, 1.0f)
            };

            queues.CreateNewPersistentQueue(requests1, false);

            batcher.Process(queues.DynamicQueue, queues.PersistentQueues);

            Assert.Equal(5, batcher.NumberOfBatches);

            var batch = batcher.Pool[0]; //In second persistent queue

            Assert.Equal(5UL, batch.Texture0);
            Assert.Equal(0UL, batch.Texture1);
            Assert.Equal(TextureCoordinateMode.Mirror, batch.TextureMode0);
            Assert.Equal(TextureCoordinateMode.None, batch.TextureMode1);
            Assert.Equal(3, batch.StartIndex);
            Assert.Equal(3, batch.NumIndices);

            batch = batcher.Pool[1]; //In second persistent queue

            Assert.Equal(10UL, batch.Texture0);
            Assert.Equal(0UL, batch.Texture1);
            Assert.Equal(TextureCoordinateMode.Mirror, batch.TextureMode0);
            Assert.Equal(TextureCoordinateMode.None, batch.TextureMode1);
            Assert.Equal(6, batch.StartIndex);
            Assert.Equal(3, batch.NumIndices);

            batch = batcher.Pool[2]; //In dynamic queue

            Assert.Equal(0UL, batch.Texture0);
            Assert.Equal(0UL, batch.Texture1);
            Assert.Equal(TextureCoordinateMode.None, batch.TextureMode0);
            Assert.Equal(TextureCoordinateMode.None, batch.TextureMode1);
            Assert.Equal(9, batch.StartIndex);
            Assert.Equal(3, batch.NumIndices);

            batch = batcher.Pool[3]; //In first persistent queue

            Assert.Equal(0UL, batch.Texture0);
            Assert.Equal(0UL, batch.Texture1);
            Assert.Equal(TextureCoordinateMode.None, batch.TextureMode0);
            Assert.Equal(TextureCoordinateMode.None, batch.TextureMode1);
            Assert.Equal(0, batch.StartIndex);
            Assert.Equal(3, batch.NumIndices);

            batch = batcher.Pool[4]; //Back to dynamic queue

            Assert.Equal(20UL, batch.Texture0);
            Assert.Equal(0UL, batch.Texture1);
            Assert.Equal(TextureCoordinateMode.Wrap, batch.TextureMode0);
            Assert.Equal(TextureCoordinateMode.None, batch.TextureMode1);
            Assert.Equal(12, batch.StartIndex);
            Assert.Equal(3, batch.NumIndices);
        }
Exemple #2
0
        public void DrawBatcher_TestBatchCreation_ThreeBatchesDueToQueueChange()
        {
            var messenger = Substitute.For <IFrameworkMessenger>();
            var tools     = new DrawStageBatcherTools();

            IDrawStageBatcher batcher = new DrawStageBatcher(12, tools);

            var properties = Substitute.For <IStartupPropertiesCache>();

            properties.Internal.Returns(new InternalStartUpProperties
            {
                DrawQueueInitialSizeNumberOfRequests         = 32,
                DrawQueueInitialSizeElementsPerRequestScalar = 4
            });

            var queues = new DrawQueueGroup(new IdGenerator(messenger),
                                            new DrawQueueFactory(messenger, properties, new ComparerCollection()),
                                            Substitute.For <IDrawStageBuffers>(),
                                            Substitute.For <IQueueToBufferBlitter>(),
                                            false);

            //Dynamic

            Add(queues.DynamicQueue.Queue, FillType.Coloured, 0UL, 0UL, TextureCoordinateMode.None, TextureCoordinateMode.None, 0);
            Add(queues.DynamicQueue.Queue, FillType.Coloured, 0UL, 0UL, TextureCoordinateMode.None, TextureCoordinateMode.None, 1);

            queues.ProcessDynamicQueue();

            //Persistent

            var requests = new InternalDrawRequest[]
            {
                Create(FillType.Coloured, 0UL, 0UL, TextureCoordinateMode.None, TextureCoordinateMode.None, 0)
            };

            queues.CreateNewPersistentQueue(requests, false);

            batcher.Process(queues.DynamicQueue, queues.PersistentQueues);

            Assert.Equal(3, batcher.NumberOfBatches);

            var batch = batcher.Pool[0]; //In dynamic queue

            Assert.Equal(0UL, batch.Texture0);
            Assert.Equal(0UL, batch.Texture1);
            Assert.Equal(TextureCoordinateMode.None, batch.TextureMode0);
            Assert.Equal(TextureCoordinateMode.None, batch.TextureMode1);
            Assert.Equal(3, batch.StartIndex);
            Assert.Equal(3, batch.NumIndices);

            batch = batcher.Pool[1]; //In persistent queue so at start of buffer

            Assert.Equal(0UL, batch.Texture0);
            Assert.Equal(0UL, batch.Texture1);
            Assert.Equal(TextureCoordinateMode.None, batch.TextureMode0);
            Assert.Equal(TextureCoordinateMode.None, batch.TextureMode1);
            Assert.Equal(0, batch.StartIndex);
            Assert.Equal(3, batch.NumIndices);

            batch = batcher.Pool[2]; //Back to dynamic queue

            Assert.Equal(0UL, batch.Texture0);
            Assert.Equal(0UL, batch.Texture1);
            Assert.Equal(TextureCoordinateMode.None, batch.TextureMode0);
            Assert.Equal(TextureCoordinateMode.None, batch.TextureMode1);
            Assert.Equal(6, batch.StartIndex);
            Assert.Equal(3, batch.NumIndices);
        }