예제 #1
0
        private void AddToQueue(IDrawQueue queue,
                                ref CoordinateSpace target,
                                ref FillType type,
                                ref Colour colour,
                                ref Vertex2D[] vertices,
                                ref int[] indices,
                                ref ulong texture0,
                                ref ulong texture1,
                                ref TextureCoordinateMode texMode0,
                                ref TextureCoordinateMode texMode1,
                                ref float depth,
                                ref int layer,
                                ref bool validate)
        {
            if (validate)
            {
                var success = queue.AddIfValid(ref target,
                                               ref type,
                                               ref colour,
                                               ref vertices,
                                               ref indices,
                                               ref texture0,
                                               ref texture1,
                                               ref texMode0,
                                               ref texMode1,
                                               ref depth,
                                               ref layer);

                if (!success)
                {
                    throw new Yak2DException("Add draw request to dynamic draw queue queue failed. Request validation failed. Reason written to debug output");
                }
            }
            else
            {
                queue.Add(ref target,
                          ref type,
                          ref colour,
                          ref vertices,
                          ref indices,
                          ref texture0,
                          ref texture1,
                          ref texMode0,
                          ref texMode1,
                          ref depth,
                          ref layer);
            }

            _stageIsSortedAndProcessed = false;
        }
예제 #2
0
        /*
         * Batch boundaries are triggered by:
         *  - Change in layer
         *  - Change in Queue being used
         *  - Once one of the texture slots is attempted to be set more than once
         *  OR
         *  - When a texture wrap mode is changed on an active texture
         */

        //Helper adds request to queue
        private void Add(IDrawQueue queue,
                         FillType fill,
                         ulong texture0,
                         ulong texture1,
                         TextureCoordinateMode tmode0,
                         TextureCoordinateMode tmode1,
                         int layer,
                         float depth = 1.0f)
        {
            //Unsorted properties

            var verts = new Vertex2D[]
            {
                new Vertex2D {
                    Colour = Colour.White, Position = Vector2.Zero, TexCoord0 = Vector2.Zero, TexCoord1 = Vector2.Zero, TexWeighting = 1.0f
                },
                new Vertex2D {
                    Colour = Colour.White, Position = Vector2.Zero, TexCoord0 = Vector2.Zero, TexCoord1 = Vector2.Zero, TexWeighting = 1.0f
                },
                new Vertex2D {
                    Colour = Colour.White, Position = Vector2.Zero, TexCoord0 = Vector2.Zero, TexCoord1 = Vector2.Zero, TexWeighting = 1.0f
                },
            };

            var indices = new int[] { 0, 1, 2 };
            var target  = CoordinateSpace.Screen;
            var colour  = Colour.White;

            queue.Add(ref target,
                      ref fill,
                      ref colour,
                      ref verts,
                      ref indices,
                      ref texture0,
                      ref texture1,
                      ref tmode0,
                      ref tmode1,
                      ref depth,
                      ref layer);
        }
예제 #3
0
        private void AddItem(IDrawQueue queue,
                             TextureCoordinateMode texcoord0,
                             TextureCoordinateMode texcoord1,
                             FillType fill,
                             ulong t0,
                             ulong t1,
                             float depth,
                             int layer)
        {
            var space  = CoordinateSpace.Screen;
            var colour = Colour.White;

            var verts = new Vertex2D[]
            {
                new Vertex2D {
                    Colour = Colour.White, Position = Vector2.Zero, TexCoord0 = Vector2.Zero, TexCoord1 = Vector2.One, TexWeighting = 0.9f
                },
                new Vertex2D {
                    Colour = Colour.White, Position = Vector2.Zero, TexCoord0 = Vector2.Zero, TexCoord1 = Vector2.One, TexWeighting = 0.9f
                },
                new Vertex2D {
                    Colour = Colour.White, Position = Vector2.Zero, TexCoord0 = Vector2.Zero, TexCoord1 = Vector2.One, TexWeighting = 0.9f
                }
            };

            var indices = new int[] { 0, 1, 2 };

            queue.Add(ref space,
                      ref fill,
                      ref colour,
                      ref verts,
                      ref indices,
                      ref t0,
                      ref t1,
                      ref texcoord0,
                      ref texcoord1,
                      ref depth,
                      ref layer);
        }
예제 #4
0
        public bool GenerateTheNextBatch(DrawingBatch[] pool, int queue, int batchIndex, ref int numQueues, QueueWrap[] wraps, int[] nextRequestToConsume, int lowestLayer, bool[] activeInCurrentLayer, int[] indexCounter, bool[] activeOverAllLayers)
        {
            var lengthOfBatchInQueue = 0;

            //We Switch On:
            //    Change in Layer
            //    Change in Queue
            //    Once one of the textures is attempted to be set more than once each
            //OR  TextureWrapMode is changed on active texture
            //    When new texture is selected the batch's texture wrap mode is also set for that texture

            var rawQs = new IDrawQueue[numQueues];

            for (var n = 0; n < numQueues; n++)
            {
                rawQs[n] = wraps[n].Queue;
            }

            var queueStartIndex = indexCounter[queue];

            var nextQueueIndex = rawQs[queue].Data.Ordering[nextRequestToConsume[queue]];
            var layer          = lowestLayer;
            var tex0           = rawQs[queue].Data.Texture0[nextQueueIndex];
            var hasTexBeenSet0 = tex0 != 0UL;
            var tMode0         = rawQs[queue].Data.TextureMode0[nextQueueIndex];
            var tex1           = rawQs[queue].Data.Texture1[nextQueueIndex];
            var hasTexBeenSet1 = tex1 != 0UL;
            var tMode1         = rawQs[queue].Data.TextureMode1[nextQueueIndex];

            ConsumeNextRequest(queue,
                               rawQs,
                               nextRequestToConsume,
                               indexCounter,
                               ref tex0,
                               ref hasTexBeenSet0,
                               ref tMode0,
                               ref tex1,
                               ref hasTexBeenSet1,
                               ref tMode1,
                               activeOverAllLayers);
            lengthOfBatchInQueue++;

            while (true)
            {
                if (CheckIfNextInQueueShouldBeIncluded(queue,
                                                       numQueues,
                                                       rawQs,
                                                       nextRequestToConsume,
                                                       activeInCurrentLayer,
                                                       layer,
                                                       tex0,
                                                       tMode0,
                                                       hasTexBeenSet0,
                                                       tex1,
                                                       tMode1,
                                                       hasTexBeenSet1,
                                                       activeOverAllLayers))
                {
                    ConsumeNextRequest(queue,
                                       rawQs,
                                       nextRequestToConsume,
                                       indexCounter,
                                       ref tex0,
                                       ref hasTexBeenSet0,
                                       ref tMode0,
                                       ref tex1,
                                       ref hasTexBeenSet1,
                                       ref tMode1,
                                       activeOverAllLayers);
                    lengthOfBatchInQueue++;
                }
                else
                {
                    //End DrawingBatch
                    break;
                }
            }

            var length = indexCounter[queue] - queueStartIndex;

            if (length == 0)
            {
                return(false);
            }

            pool[batchIndex].StartIndex   = queueStartIndex + wraps[queue].BufferPositionOfFirstIndex;
            pool[batchIndex].NumIndices   = indexCounter[queue] - queueStartIndex;
            pool[batchIndex].Texture0     = tex0;
            pool[batchIndex].Texture1     = tex1;
            pool[batchIndex].TextureMode0 = tMode0;
            pool[batchIndex].TextureMode1 = tMode1;

            return(true);
        }