private InternalDrawRequest[] CreateASetOfDrawRequests(int numRequests, int numVerticesPerRequest, int numIndicesPerRequest) { var requests = new List <InternalDrawRequest>(); var verts = new Vertex2D[numVerticesPerRequest]; for (var n = 0; n < numVerticesPerRequest; n++) { verts[n] = new Vertex2D { Colour = Colour.White, Position = Vector2.Zero, TexCoord0 = Vector2.Zero, TexCoord1 = Vector2.Zero, TexWeighting = 0.0f }; } var indices = new int[numIndicesPerRequest]; for (var n = 0; n < numIndicesPerRequest; n++) { indices[n] = 0; } for (var n = 0; n < numRequests; n++) { var request = new InternalDrawRequest { Colour = Colour.White, CoordinateSpace = CoordinateSpace.Screen, Depth = 0.0f, FillType = FillType.Coloured, Layer = 0, Texture0 = 5UL, Texture1 = 6UL, TextureMode0 = TextureCoordinateMode.Mirror, TextureMode1 = TextureCoordinateMode.Mirror, Vertices = verts, Indices = indices }; requests.Add(request); } return(requests.ToArray()); }
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); }