Version: 2023.2

CommandBuffer

class in UnityEngine.Rendering

切换到手册

描述

要执行的图形命令的列表。

命令缓冲区可保存渲染命令列表(“设置渲染目标、绘制网格等等”)。可将渲染命令设置为在摄像机渲染(请参阅 Camera.AddCommandBuffer)、光源渲染(请参阅 Light.AddCommandBuffer)期间的各个点执行,或者立即执行(请参阅 Graphics.ExecuteCommandBuffer)。

Typically they would be used to extend Unity's render pipelines in a custom way. For example, you could render some additional objects into deferred rendering G-buffer after all regular objects are done, or do custom processing of light shadow maps. See command buffers overview page for more details.

命令缓冲区创建后,可根据需要多次执行。

另请参阅:Camera.AddCommandBufferLight.AddCommandBufferCameraEventLightEventGraphics.ExecuteCommandBuffercommand buffers overview

静态变量

ThrowOnSetRenderTargetThrow an exception when SetRenderTarget is recorded on a command buffer. This is mainly usefull when using native renderpasses to avoid inadvertently recording SetRenderTarget commands on the command buffer.

变量

name此命令缓冲区的名称。
sizeInBytes此命令缓冲区的大小,以字节为单位(只读)。

构造函数

CommandBuffer创建新的空命令缓冲区。

公共函数

BeginRenderPassBegin a new native render pass.
BeginSample添加命令,以开始对配置文件进行采样。
BlitAdds a command to use a shader to copy the pixel data from a texture into a render texture.
BuildRayTracingAccelerationStructureAdds a command to build the RayTracingAccelerationStructure to be used in a ray tracing dispatch or when using inline ray tracing (ray queries).
Clear清除缓冲区中的所有命令。
ClearRandomWriteTargets为 Shader Model 4.5 级别的像素着色器清除随机写入目标。
ClearRenderTarget添加“清除渲染目标”命令。
ConfigureFoveatedRenderingAdds a command to configure foveated rendering.
ConvertTextureAdds a command to copy the pixel data from one texture, convert the data into a different format, and copy it into another texture.
CopyBufferAdds a command to copy the contents of one GraphicsBuffer into another.
CopyCounterValueAdds a command to copy ComputeBuffer or GraphicsBuffer counter value.
CopyTextureAdds a command to copy pixel data from one texture to another.
CreateAsyncGraphicsFenceShortcut for calling CommandBuffer.CreateGraphicsFence with GraphicsFenceType.AsyncQueueSynchronisation as the first parameter.
CreateGraphicsFenceCreates a GraphicsFence.
DisableKeywordAdds a command to disable a global or local shader keyword.
DisableScissorRect添加用于禁用硬件剪辑矩形的命令。
DisableShaderKeywordAdds a command to disable a global shader keyword with a given name.
DispatchCompute添加用于执行 ComputeShader 的命令。
DispatchRaysAdds a command to execute a RayTracingShader.
DrawMesh添加“绘制网格”命令。
DrawMeshInstancedAdds a "draw mesh with instancing" command.The mesh will be just drawn once, it won't be per-pixel lit and will not cast or receive realtime shadows.如果 Material.enableInstancing 为 false,该命令不会立即失败并抛出异常,但如果检测到此类情况,则会记录错误并在每次执行命令时跳过渲染。如果当前平台不支持此 API(即,如果 GPU 实例化不可用),则会抛出 InvalidOperationException。请参阅 SystemInfo.supportsInstancing。
DrawMeshInstancedIndirect添加“通过间接实例化绘制网格”命令。
DrawMeshInstancedProcedural添加“通过实例化绘制网格”命令。Draw a mesh using Procedural Instancing. This is similar to Graphics.DrawMeshInstancedIndirect, except that when the instance count is known from script, it can be supplied directly using this method, rather than via a ComputeBuffer. If Material.enableInstancing is false, the command logs an error and skips rendering each time the command is executed; the command does not immediately fail and throw an exception.InvalidOperationException will be thrown if the current platform doesn't support this API (for example, if GPU instancing is not available). See SystemInfo.supportsInstancing.
DrawOcclusionMesh向 commandbuffer 添加命令以向当前渲染目标绘制 VR 设备的遮挡网格。
DrawProcedural添加“绘制程序化几何体”命令。
DrawProceduralIndirect添加“绘制程序化几何体”命令。
DrawRenderer添加“绘制渲染器”命令。
DrawRendererListAdds a "draw renderer list" command.
EnableKeywordAdds a command to enable a global or local shader keyword.
EnableScissorRect添加用于启用硬件剪辑矩形的命令。
EnableShaderKeywordAdds a command to enable a global keyword with a given name.
EndRenderPassTerminate the active native renderpass.
EndSampleAdds a command to end profile sampling.
GenerateMips生成渲染纹理的多级渐进纹理级别。
GetTemporaryRT添加“获取临时渲染纹理”命令。
GetTemporaryRTArray添加“获取临时渲染纹理阵列”命令。
IncrementUpdateCount递增纹理的 updateCount 属性。
InvokeOnRenderObjectCallbacks为 MonoBehaviour 脚本调度 OnRenderObject 回调的调用。
IssuePluginCustomBlit向本机代码插件发送用户定义的 blit 事件。
IssuePluginCustomTextureUpdateV2向本机代码插件发送纹理更新事件。
IssuePluginEvent向本机代码插件发送用户定义的事件。
IssuePluginEventAndData向本机代码插件发送具有自定义数据的用户定义的事件。
IssuePluginEventAndDataWithFlagsSend a user-defined event to a native code plugin with custom data and callback flags.
MarkLateLatchMatrixShaderPropertyIDMark a global shader property id to be late latched. Possible shader properties include view, inverseView, viewProjection, and inverseViewProjection matrices. The Universal Render Pipeline (URP) uses this function to support late latching of shader properties. If you call this function when using built-in Unity rendering or the High-Definition Rendering Pipeline (HDRP), the results are ignored.
NextSubPassStart the next native subpass as discribed by CommandBuffer.BeginRenderPass.
ReleaseTemporaryRT添加“释放临时渲染纹理”命令。
RequestAsyncReadback向命令缓冲区添加异步 GPU 回读请求命令。
RequestAsyncReadbackIntoNativeArray向命令缓冲区添加异步 GPU 回读请求命令。
RequestAsyncReadbackIntoNativeSlice向命令缓冲区添加异步 GPU 回读请求命令。
ResolveAntiAliasedSurface强制解析抗锯齿渲染纹理。
SetBufferCounterValueAdds a command to set the counter value of append/consume buffer.
SetBufferDataAdds a command to set the buffer with values from an array.
SetComputeBufferParam添加用于在 ComputeShader 中设置输入或输出缓冲区参数的命令。
SetComputeConstantBufferParamAdds a command to set a constant buffer on a ComputeShader.
SetComputeFloatParam添加用于在 ComputeShader 中设置浮点参数的命令。
SetComputeFloatParams添加用于在 ComputeShader 中设置多个连续浮点参数的命令。
SetComputeIntParam添加用于在 ComputeShader 中设置整数参数的命令。
SetComputeIntParams添加用于在 ComputeShader 中设置多个连续整数参数的命令。
SetComputeMatrixArrayParam添加用于在 ComputeShader 中设置矩阵数组参数的命令。
SetComputeMatrixParam添加用于在 ComputeShader 中设置矩阵参数的命令。
SetComputeParamsFromMaterialSets the parameters for a compute shader kernel from a Material.
SetComputeTextureParam添加用于在 ComputeShader 中设置纹理参数的命令。
SetComputeVectorArrayParam添加用于在 ComputeShader 中设置向量数组参数的命令。
SetComputeVectorParam添加用于在 ComputeShader 中设置向量参数的命令。
SetExecutionFlags设置标志,描述有关如何执行命令缓冲区的意图。
SetFoveatedRenderingModeAdds a command to set the mode to use for foveated rendering.
SetGlobalBuffer添加“设置全局着色器缓冲区属性”命令。
SetGlobalColor添加“设置全局着色器颜色属性”命令。
SetGlobalConstantBuffer添加用于绑定全局常量缓冲区的命令。
SetGlobalDepthBiasAdds a command to set the global depth bias.
SetGlobalFloat添加“设置全局着色器浮点属性”命令。
SetGlobalFloatArray添加“设置全局着色器浮点数组属性”命令。
SetGlobalIntAdds a command to set the value of a given property for all Shaders, where the property has a type of Int in ShaderLab code.
SetGlobalIntegerAdds a command to set the value of a given property for all Shaders, where the property is an integer.
SetGlobalMatrix添加“设置全局着色器矩阵属性”命令。
SetGlobalMatrixArray添加“设置全局着色器矩阵数组属性”命令。
SetGlobalRayTracingAccelerationStructureAdds a command to bind the RayTracingAccelerationStructure object to all shader stages.
SetGlobalTexture添加“设置全局着色器纹理属性”命令(引用 RenderTexture)。
SetGlobalVector添加“设置全局着色器向量属性”命令。
SetGlobalVectorArray添加“设置全局着色器向量数组属性”命令。
SetInstanceMultiplier添加用于将每个绘制调用的实例数乘以特定乘数的命令。
SetInvertCulling向缓冲区添加“设置反转剔除”命令。
SetKeywordAdds a command to set the state of a global or local shader keyword.
SetLateLatchProjectionMatricesSet the current stereo projection matrices for late latching. Stereo matrices is passed in as an array of two matrices.
SetProjectionMatrix添加用于设置投影矩阵的命令。
SetRandomWriteTarget为 Shader Model 4.5 级别的像素着色器设置随机写入目标。
SetRayTracingAccelerationStructureAdds a command to set the RayTracingAccelerationStructure to be used in a RayTracingShader or a ComputeShader.
SetRayTracingBufferParamAdds a command to set an input or output buffer parameter on a RayTracingShader.
SetRayTracingConstantBufferParamAdds a command to set a constant buffer on a RayTracingShader.
SetRayTracingFloatParam添加用于在 RayTracingShader 中设置浮点参数的命令。
SetRayTracingFloatParams添加用于在 RayTracingShader 中设置多个连续浮点参数的命令。
SetRayTracingIntParam添加用于在 RayTracingShader 中设置整数参数的命令。
SetRayTracingIntParams添加用于在 RayTracingShader 中设置多个连续整数参数的命令。
SetRayTracingMatrixArrayParam添加用于在 RayTracingShader 中设置矩阵数组参数的命令。
SetRayTracingMatrixParam添加用于在 RayTracingShader 中设置矩阵参数的命令。
SetRayTracingShaderPassAdds a command to select which Shader Pass to use when executing ray/geometry intersection shaders.
SetRayTracingTextureParam添加用于在 RayTracingShader 中设置纹理参数的命令。
SetRayTracingVectorArrayParam添加用于在 RayTracingShader 中设置矢量数组参数的命令。
SetRayTracingVectorParam添加用于在 RayTracingShader 中设置矢量参数的命令。
SetRenderTarget添加“设置活动的渲染目标”命令。
SetShadowSamplingMode添加“设置阴影采样模式”命令。
SetSinglePassStereo添加用于为摄像机设置单通道立体模式的命令。
SetupCameraProperties调度特定于摄像机的全局着色器变量的设置。
SetViewMatrix添加用于设置视图矩阵的命令。
SetViewport添加用于设置渲染视口的命令。
SetViewProjectionMatrices添加用于设置视图和投影矩阵的命令。
SetWireframeAdd a "set wireframe" command to the buffer.
UnmarkLateLatchMatrixUnmark a global shader property for late latching. After unmarking, the shader property will no longer be late latched. This function is intended for the Universal Render Pipeline (URP) to specify late latched shader properties.
WaitAllAsyncReadbackRequests向 CommandBuffer 添加“AsyncGPUReadback.WaitAllRequests”命令。
WaitOnAsyncGraphicsFenceInstructs the GPU to pause processing of the queue until it passes through the GraphicsFence fence.