public void DrawBatcherTools_CombineList_DoesSoInCorrectOrder() { IDrawStageBatcherTools tools = new DrawStageBatcherTools(); var messenger = Substitute.For <IFrameworkMessenger>(); var q0 = new DrawQueue(messenger, new ComparerCollection(), 12, 4, false); Add(q0, FillType.Coloured, 0UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.Mirror, 0); var w0 = new QueueWrap { Id = 0, BufferPositionOfFirstIndex = 0, BufferPositionOfFirstVertex = 0, Queue = q0 }; var q1 = new DrawQueue(messenger, new ComparerCollection(), 12, 4, false); Add(q1, FillType.Coloured, 1UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.Mirror, 0); var w1 = new QueueWrap { Id = 0, BufferPositionOfFirstIndex = 0, BufferPositionOfFirstVertex = 0, Queue = q1 }; var q2 = new DrawQueue(messenger, new ComparerCollection(), 12, 4, false); Add(q2, FillType.Coloured, 2UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.Mirror, 0); var w2 = new QueueWrap { Id = 0, BufferPositionOfFirstIndex = 0, BufferPositionOfFirstVertex = 0, Queue = q2 }; var others = new List <QueueWrap> { w1, w2 }; var combined = tools.CombinedList(w0, others); Assert.Equal(2UL, combined[2].Queue.Data.Texture0[0]); }
public void DrawBatcherTools_AreAlLQueuesInactive_False() { IDrawStageBatcherTools tools = new DrawStageBatcherTools(); var num = 3; var active = new bool[] { false, true, false }; Assert.False(tools.AreAllQueuesInactive(ref num, active)); }
public void DrawBatcher_TestBatchCreation_TextureChangePersistence_TwoBatchForSingleDualSingleTexAndColourInterleaveAsWrapChanges() { 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(Substitute.For <IFrameworkMessenger>()), new DrawQueueFactory(messenger, properties, new ComparerCollection()), Substitute.For <IDrawStageBuffers>(), Substitute.For <IQueueToBufferBlitter>(), false); Add(queues.DynamicQueue.Queue, FillType.Coloured, 0UL, 0UL, TextureCoordinateMode.None, TextureCoordinateMode.None, 0, 1.0f); Add(queues.DynamicQueue.Queue, FillType.Textured, 5UL, 0UL, TextureCoordinateMode.Wrap, TextureCoordinateMode.Wrap, 0, 0.95f); Add(queues.DynamicQueue.Queue, FillType.DualTextured, 5UL, 10UL, TextureCoordinateMode.Wrap, TextureCoordinateMode.Wrap, 0, 0.9f); Add(queues.DynamicQueue.Queue, FillType.Textured, 5UL, 0UL, TextureCoordinateMode.Wrap, TextureCoordinateMode.Wrap, 0, 0.8f); Add(queues.DynamicQueue.Queue, FillType.DualTextured, 5UL, 10UL, TextureCoordinateMode.Wrap, TextureCoordinateMode.Mirror, 0, 0.7f); Add(queues.DynamicQueue.Queue, FillType.Coloured, 0UL, 0UL, TextureCoordinateMode.None, TextureCoordinateMode.None, 0, 0.6f); queues.ProcessDynamicQueue(); batcher.Process(queues.DynamicQueue, queues.PersistentQueues); Assert.Equal(2, batcher.NumberOfBatches); var batch = batcher.Pool[0]; Assert.Equal(5UL, batch.Texture0); Assert.Equal(10UL, batch.Texture1); Assert.Equal(TextureCoordinateMode.Wrap, batch.TextureMode0); Assert.Equal(TextureCoordinateMode.Wrap, batch.TextureMode1); Assert.Equal(0, batch.StartIndex); Assert.Equal(12, batch.NumIndices); batch = batcher.Pool[1]; Assert.Equal(5UL, batch.Texture0); Assert.Equal(10UL, batch.Texture1); Assert.Equal(TextureCoordinateMode.Wrap, batch.TextureMode0); Assert.Equal(TextureCoordinateMode.Mirror, batch.TextureMode1); Assert.Equal(12, batch.StartIndex); Assert.Equal(6, batch.NumIndices); }
public void DrawBatcherTools_GenerateTheNextBatch_ConsumesOneRequestButSkipsQueueDueToInactive() { IDrawStageBatcherTools tools = new DrawStageBatcherTools(); var messenger = Substitute.For <IFrameworkMessenger>(); var q0 = new DrawQueue(messenger, new ComparerCollection(), 12, 4, false); Add(q0, FillType.Coloured, 12UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.Mirror, 3); Add(q0, FillType.Coloured, 12UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.Mirror, 3); Add(q0, FillType.Coloured, 12UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.Mirror, 11); var w0 = new QueueWrap { Id = 0, BufferPositionOfFirstIndex = 0, BufferPositionOfFirstVertex = 0, Queue = q0 }; var q1 = new DrawQueue(messenger, new ComparerCollection(), 12, 4, false); Add(q1, FillType.Coloured, 1UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.Mirror, 9, 1.0f); var w1 = new QueueWrap { Id = 0, BufferPositionOfFirstIndex = 0, BufferPositionOfFirstVertex = 0, Queue = q1 }; var q2 = new DrawQueue(messenger, new ComparerCollection(), 12, 4, false); Add(q2, FillType.Coloured, 2UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.Mirror, 10, 0.5f); var w2 = new QueueWrap { Id = 0, BufferPositionOfFirstIndex = 0, BufferPositionOfFirstVertex = 0, Queue = q2 }; var others = new List <QueueWrap> { w1, w2 }; var combined = tools.CombinedList(w0, others).ToArray(); var num = 3; var pool = new DrawingBatch[] { new DrawingBatch() }; tools.GenerateTheNextBatch(pool, 1, 0, ref num, combined, new int[] { 0, 0, 0 }, 3, new bool[] { true, false, true }, new int[] { 0, 0, 0 }, new bool[] { true, false, true }); var batch = pool[0]; Assert.Equal(1UL, batch.Texture0); Assert.Equal(3, batch.NumIndices); }
public void DrawBatcherTools_IdentifyActiveInLayer_SimpleTest() { IDrawStageBatcherTools tools = new DrawStageBatcherTools(); var messenger = Substitute.For <IFrameworkMessenger>(); var q0 = new DrawQueue(messenger, new ComparerCollection(), 12, 4, false); Add(q0, FillType.Coloured, 0UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.Mirror, 3); var w0 = new QueueWrap { Id = 0, BufferPositionOfFirstIndex = 0, BufferPositionOfFirstVertex = 0, Queue = q0 }; var q1 = new DrawQueue(messenger, new ComparerCollection(), 12, 4, false); Add(q1, FillType.Coloured, 1UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.Mirror, 10); var w1 = new QueueWrap { Id = 0, BufferPositionOfFirstIndex = 0, BufferPositionOfFirstVertex = 0, Queue = q1 }; var q2 = new DrawQueue(messenger, new ComparerCollection(), 12, 4, false); Add(q2, FillType.Coloured, 2UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.Mirror, 10); var w2 = new QueueWrap { Id = 0, BufferPositionOfFirstIndex = 0, BufferPositionOfFirstVertex = 0, Queue = q2 }; var others = new List <QueueWrap> { w1, w2 }; var combined = tools.CombinedList(w0, others).ToArray(); var num = 3; var activeInLayer = new bool[3]; tools.IdentifyWhichQueuesAreActiveInTheCurrentLayer(ref num, combined, new int[] { 0, 0, 0 }, 10, activeInLayer, new bool[] { true, false, true }); Assert.False(activeInLayer[0]); Assert.False(activeInLayer[1]); Assert.True(activeInLayer[2]); }
public void DrawBatcherTools_CreatePoolSize_ExistingDataPersists() { IDrawStageBatcherTools tools = new DrawStageBatcherTools(); var pool = new DrawingBatch[] { new DrawingBatch { NumIndices = 5, StartIndex = 7, Texture0 = 0UL, Texture1 = 8UL, TextureMode0 = TextureCoordinateMode.None, TextureMode1 = TextureCoordinateMode.Wrap }, new DrawingBatch { NumIndices = 9, StartIndex = 3, Texture0 = 4UL, Texture1 = 9UL, TextureMode0 = TextureCoordinateMode.Mirror, TextureMode1 = TextureCoordinateMode.Wrap }, new DrawingBatch { NumIndices = 9, StartIndex = 2, Texture0 = 2UL, Texture1 = 12UL, TextureMode0 = TextureCoordinateMode.Wrap, TextureMode1 = TextureCoordinateMode.None } }; var result = tools.CreatePoolOfSize(6, true, pool); Assert.Equal(8UL, result[0].Texture1); Assert.Equal(TextureCoordinateMode.Mirror, result[1].TextureMode0); Assert.Equal(2, result[2].StartIndex); }
public void DrawBatcher_TestBatchCreation_TestSuccessfulWithOnlyDynamicQueueAndOneRequest() { 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); Add(queues.DynamicQueue.Queue, FillType.Coloured, 0UL, 0UL, TextureCoordinateMode.None, TextureCoordinateMode.None, 0); queues.ProcessDynamicQueue(); batcher.Process(queues.DynamicQueue, queues.PersistentQueues); Assert.Equal(1, batcher.NumberOfBatches); var batch = batcher.Pool[0]; 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); }
public void DrawBatcherTools_FindDeepestAtLowestLayer_SimpleTest() { IDrawStageBatcherTools tools = new DrawStageBatcherTools(); var messenger = Substitute.For <IFrameworkMessenger>(); var q0 = new DrawQueue(messenger, new ComparerCollection(), 12, 4, false); Add(q0, FillType.Coloured, 0UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.Mirror, 3); var w0 = new QueueWrap { Id = 0, BufferPositionOfFirstIndex = 0, BufferPositionOfFirstVertex = 0, Queue = q0 }; var q1 = new DrawQueue(messenger, new ComparerCollection(), 12, 4, false); Add(q1, FillType.Coloured, 1UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.Mirror, 10, 1.0f); var w1 = new QueueWrap { Id = 0, BufferPositionOfFirstIndex = 0, BufferPositionOfFirstVertex = 0, Queue = q1 }; var q2 = new DrawQueue(messenger, new ComparerCollection(), 12, 4, false); Add(q2, FillType.Coloured, 2UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.Mirror, 10, 0.5f); var w2 = new QueueWrap { Id = 0, BufferPositionOfFirstIndex = 0, BufferPositionOfFirstVertex = 0, Queue = q2 }; var others = new List <QueueWrap> { w1, w2 }; var combined = tools.CombinedList(w0, others).ToArray(); var num = 3; var index = tools.FindDeepestQueueAtLowestLayer(ref num, combined, new int[] { 0, 0, 0 }, 10, new bool[] { true, false, true }); Assert.Equal(2, index); }
public void DrawBatcher_TestBatchCreation_ReplicatingTextureModeIssues_HappensWhenModeNoneProvidedToEarlyTexCall() { 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(Substitute.For <IFrameworkMessenger>()), new DrawQueueFactory(messenger, properties, new ComparerCollection()), Substitute.For <IDrawStageBuffers>(), Substitute.For <IQueueToBufferBlitter>(), false); Add(queues.DynamicQueue.Queue, FillType.Coloured, 0UL, 0UL, TextureCoordinateMode.None, TextureCoordinateMode.None, 0, 1.0f); Add(queues.DynamicQueue.Queue, FillType.Coloured, 0UL, 0UL, TextureCoordinateMode.None, TextureCoordinateMode.None, 0, 1.0f); Add(queues.DynamicQueue.Queue, FillType.Textured, 5UL, 0UL, TextureCoordinateMode.Wrap, TextureCoordinateMode.None, 1, 0.5f); Add(queues.DynamicQueue.Queue, FillType.Textured, 5UL, 0UL, TextureCoordinateMode.Wrap, TextureCoordinateMode.None, 1, 0.5f); Add(queues.DynamicQueue.Queue, FillType.Textured, 6UL, 0UL, TextureCoordinateMode.Mirror, TextureCoordinateMode.None, 1, 0.3f); Add(queues.DynamicQueue.Queue, FillType.Textured, 7UL, 8UL, TextureCoordinateMode.Wrap, TextureCoordinateMode.Mirror, 1, 0.3f); queues.ProcessDynamicQueue(); batcher.Process(queues.DynamicQueue, queues.PersistentQueues); Assert.Equal(4, batcher.NumberOfBatches); var batch = batcher.Pool[0]; Assert.Equal(0UL, batch.Texture0); Assert.Equal(0UL, batch.Texture1); Assert.Equal(TextureCoordinateMode.None, batch.TextureMode0); Assert.Equal(TextureCoordinateMode.None, batch.TextureMode1); batch = batcher.Pool[1]; Assert.Equal(5UL, batch.Texture0); Assert.Equal(0UL, batch.Texture1); Assert.Equal(TextureCoordinateMode.Wrap, batch.TextureMode0); Assert.Equal(TextureCoordinateMode.None, batch.TextureMode1); batch = batcher.Pool[2]; Assert.Equal(6UL, batch.Texture0); Assert.Equal(0UL, batch.Texture1); Assert.Equal(TextureCoordinateMode.Mirror, batch.TextureMode0); Assert.Equal(TextureCoordinateMode.None, batch.TextureMode1); batch = batcher.Pool[3]; Assert.Equal(7UL, batch.Texture0); Assert.Equal(8UL, batch.Texture1); Assert.Equal(TextureCoordinateMode.Wrap, batch.TextureMode0); Assert.Equal(TextureCoordinateMode.Mirror, batch.TextureMode1); }
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); }
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); }