public static DrawBat GetBatch(Shader shader, Texture2D texture) { if (curBatch != null) { if (curBatch.shader == shader && curBatch.texture == texture) { return(curBatch); } curBatch.Close(); } curQueue += 1; // if there is a prevBatch that matches for (var node = prevBatches.First; node != null; node = node.Next) { curBatch = node.Value; if (curBatch.shader == shader && curBatch.texture == texture) { prevBatches.Remove(node); curBatch.Open(curQueue); activeBatches.AddLast(curBatch); return(curBatch); } } // if there is an inactiveBatch that matches for (var node = inactiveBatches.First; node != null; node = node.Next) { curBatch = node.Value; if (curBatch.shader == shader && curBatch.texture == texture) { inactiveBatches.Remove(node); curBatch.Activate(); curBatch.Open(curQueue); activeBatches.AddLast(curBatch); return(curBatch); } } // create a new batch curBatch = new DrawBat(shader, texture); curBatch.Open(curQueue); activeBatches.AddLast(curBatch); return(curBatch); }
public static void Finish() { for (var node = prevBatches.First; prevBatches.Count > 0; node = prevBatches.First) { node.Value.Deactivate(); inactiveBatches.AddLast(node.Value); prevBatches.RemoveFirst(); } // Same as prevBatches.AddRange(activeBatches); activeBatches.Clear(); var swap = prevBatches; prevBatches = activeBatches; activeBatches = swap; if (curBatch != null) { curBatch.Close(); curBatch = null; } }
public static void Start() { curQueue = TransparentQueue + 1; curBatch = null; }