TurnBasedStrategyCourse/Library/PackageCache/com.unity.render-pipelines..../Runtime/Passes/CapturePass.cs

37 lines
1.5 KiB
C#

namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Let customizable actions inject commands to capture the camera output.
///
/// You can use this pass to inject capture commands into a command buffer
/// with the goal of having camera capture happening in external code.
/// </summary>
internal class CapturePass : ScriptableRenderPass
{
RTHandle m_CameraColorHandle;
const string m_ProfilerTag = "Capture Pass";
private static readonly ProfilingSampler m_ProfilingSampler = new ProfilingSampler(m_ProfilerTag);
public CapturePass(RenderPassEvent evt)
{
base.profilingSampler = new ProfilingSampler(nameof(CapturePass));
renderPassEvent = evt;
}
/// <inheritdoc/>
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
CommandBuffer cmdBuf = renderingData.commandBuffer;
m_CameraColorHandle = renderingData.cameraData.renderer.GetCameraColorBackBuffer(cmdBuf);
using (new ProfilingScope(cmdBuf, m_ProfilingSampler))
{
var colorAttachmentIdentifier = m_CameraColorHandle.nameID;
var captureActions = renderingData.cameraData.captureActions;
for (captureActions.Reset(); captureActions.MoveNext();)
captureActions.Current(colorAttachmentIdentifier, renderingData.commandBuffer);
}
}
}
}