using System;
using UnityEngine.VFX;
namespace UnityEngine.Rendering
{
///
/// This struct contains some static helper functions that can be used when you want to convert between Commandbuffer and RasterCommandBuffer/ComputeCommandBuffer/UnsafeCommandBuffer
///
public struct CommandBufferHelpers
{
internal static RasterCommandBuffer rasterCmd = new RasterCommandBuffer(null, null, false);
internal static ComputeCommandBuffer computeCmd = new ComputeCommandBuffer(null, null, false);
internal static UnsafeCommandBuffer unsafeCmd = new UnsafeCommandBuffer(null, null, false);
///
/// Get a RasterCommandBuffer given an standard CommandBuffer.
///
/// The CommandBuffer the RasterCommandBuffer should record it's commands to.
/// A RasterCommandBuffer that will record its commands to the given buffer.
public static RasterCommandBuffer GetRasterCommandBuffer(CommandBuffer baseBuffer)
{
rasterCmd.m_WrappedCommandBuffer = baseBuffer;
return rasterCmd;
}
///
/// Get a ComputeCommandBuffer given an standard CommandBuffer.
///
/// The CommandBuffer the RasterCommandBuffer should record it's commands to.
/// A ComputeCommandBuffer that will record its commands to the given buffer.
public static ComputeCommandBuffer GetComputeCommandBuffer(CommandBuffer baseBuffer)
{
computeCmd.m_WrappedCommandBuffer = baseBuffer;
return computeCmd;
}
///
/// Get an UnsafeCommandBuffer given an standard CommandBuffer.
///
/// The CommandBuffer the UnsafeCommandBuffer should record its commands to.
/// A UnsafeCommandBuffer that will record its commands to the given buffer.
public static UnsafeCommandBuffer GetUnsafeCommandBuffer(CommandBuffer baseBuffer)
{
unsafeCmd.m_WrappedCommandBuffer = baseBuffer;
return unsafeCmd;
}
///
/// Get the actual unity engine CommandBuffer backing a UnsafeCommandBuffer. This strips the last remnants of render graph safety from the UnsafeCommandBuffer
/// you are fully on your own now to ensure any and all render graph safety. Please carefully consider if you really need this.
///
/// The UnsafeCommandBuffer you want to get the engine commandbuffer from.
/// A CommandBuffer that will record its commands to the given buffer.
public static CommandBuffer GetNativeCommandBuffer(UnsafeCommandBuffer baseBuffer)
{
return baseBuffer.m_WrappedCommandBuffer;
}
///
/// Wrapper for VFXManager.ProcessCameraCommand that works with UnsafeCommandBuffer.
///
/// The Camera to process the VFX commands for.
/// The CommandBuffer to push commands to (can be null).
/// The XR settings that the Visual Effect Graph uses to process the Camera commands.
/// The culling results to use.
public static void VFXManager_ProcessCameraCommand(Camera cam, UnsafeCommandBuffer cmd,
VFXCameraXRSettings camXRSettings, CullingResults results)
{
VFXManager.ProcessCameraCommand(cam, cmd.m_WrappedCommandBuffer, camXRSettings, results);
}
}
}