using System.Collections.Generic; using UnityEngine.Events; namespace UnityEngine.Rendering { /// /// Command Buffer Pool /// public static class CommandBufferPool { static ObjectPool s_BufferPool = new ObjectPool(null, x => x.Clear()); /// /// Get a new Command Buffer. /// /// Returns a new Command Buffer obtained from the buffer pool. public static CommandBuffer Get() { var cmd = s_BufferPool.Get(); // Set to empty on purpose, does not create profiling markers. cmd.name = ""; return cmd; } /// /// Get a new Command Buffer and assign a name to it. /// Named Command Buffers will add profiling makers implicitly for the buffer execution. /// /// The name to be assigned to the new Command Buffer. /// Returns a new Command Buffer with the assigned name. public static CommandBuffer Get(string name) { var cmd = s_BufferPool.Get(); cmd.name = name; return cmd; } /// /// Release a Command Buffer. /// /// The Command Buffer to be released back into the buffer pool. public static void Release(CommandBuffer buffer) { s_BufferPool.Release(buffer); } } }