Tim Cooper
8 年前
当前提交
8b0f6d4c
共有 18 个文件被更改,包括 191 次插入 和 112 次删除
-
1Assets/Editor/Tests/RenderloopTests/RenderPipelineTestFixture.cs
-
6Assets/ScriptableRenderPipeline/BasicRenderPipeline/BasicRenderPipeline.cs
-
18Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs
-
41Assets/ScriptableRenderPipeline/Fptl/FptlLighting.cs
-
4Assets/ScriptableRenderPipeline/Fptl/SkyboxHelper.cs
-
49Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
-
3Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/AmbientOcclusion/ScreenSpaceAmbientOcclusion.cs
-
20Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
-
4Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs
-
4Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkyRenderer.cs
-
4Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyRenderer.cs
-
12Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/RuntimeFilterIBL.cs
-
8Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs
-
24Assets/ScriptableRenderPipeline/HDRenderPipeline/Utilities.cs
-
21Assets/ScriptableRenderPipeline/LightweightPipeline/LightweightPipeline.cs
-
72Assets/ScriptableRenderPipeline/core/CommandBufferPool.cs
-
12Assets/ScriptableRenderPipeline/core/CommandBufferPool.cs.meta
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Events; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering |
|||
{ |
|||
class ObjectPool<T> where T : new() |
|||
{ |
|||
private readonly Stack<T> m_Stack = new Stack<T>(); |
|||
private readonly List<T> m_Loaned = new List<T>(); |
|||
private readonly UnityAction<T> m_ActionOnGet; |
|||
private readonly UnityAction<T> m_ActionOnRelease; |
|||
|
|||
public ObjectPool(UnityAction<T> actionOnGet, UnityAction<T> actionOnRelease) |
|||
{ |
|||
m_ActionOnGet = actionOnGet; |
|||
m_ActionOnRelease = actionOnRelease; |
|||
} |
|||
|
|||
public T Get() |
|||
{ |
|||
T element; |
|||
if (m_Stack.Count == 0) |
|||
{ |
|||
element = new T(); |
|||
} |
|||
else |
|||
{ |
|||
element = m_Stack.Pop(); |
|||
} |
|||
m_Loaned.Add(element); |
|||
if (m_ActionOnGet != null) |
|||
m_ActionOnGet(element); |
|||
return element; |
|||
} |
|||
|
|||
public void ReleaseAll() |
|||
{ |
|||
foreach (var element in m_Loaned) |
|||
{ |
|||
if (m_ActionOnRelease != null) |
|||
m_ActionOnRelease(element); |
|||
m_Stack.Push(element); |
|||
} |
|||
m_Loaned.Clear(); |
|||
} |
|||
} |
|||
|
|||
public class CommandBufferPool |
|||
{ |
|||
private static ObjectPool<CommandBuffer> m_BufferPool = new ObjectPool<CommandBuffer>(null, x => x.Clear()); |
|||
|
|||
public static CommandBuffer Get() |
|||
{ |
|||
var cmd = m_BufferPool.Get(); |
|||
cmd.name = "Unnamed Command Buffer"; |
|||
return cmd; |
|||
} |
|||
public static CommandBuffer Get(string name) |
|||
{ |
|||
var cmd = m_BufferPool.Get(); |
|||
cmd.name = name; |
|||
return cmd; |
|||
} |
|||
|
|||
public static void EndOfFrame() |
|||
{ |
|||
m_BufferPool.ReleaseAll(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: bc85748f0cef607499e03b46e3846ebd |
|||
timeCreated: 1497364325 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue