Version: 2023.2

Graphics.DrawProceduralIndirectNow

切换到手册
public static void DrawProceduralIndirectNow (MeshTopology topology, ComputeBuffer bufferWithArgs, int argsOffset);
public static void DrawProceduralIndirectNow (MeshTopology topology, GraphicsBuffer bufferWithArgs, int argsOffset);

参数

topology 程序化几何体的拓扑。
bufferWithArgs 具有绘制参数的缓冲区。
argsOffset 缓冲区中的字节偏移,绘制参数所在位置。

描述

在 GPU 上绘制程序化的几何形状。

DrawProceduralIndirectNow does a draw call on the GPU, without any vertex or index buffers. If the shader requires vertex buffers, one of the following occurs depending on platform: - If the vertex buffer is declared but the compiler can optimize it away, the normal DrawProcedural call occurs. - If the compiler is not able to optimize the vertex buffer declaration away, the draw call will be converted into a normal mesh drawing call with emulated vertex buffers injected. The latter option has performance overhead so it is recommended not to declare vertex inputs in shaders when using DrawProceduralIndirectNow.

This function only works on platforms that support compute shaders.

The amount of geometry to draw is read from a ComputeBuffer. Typical use case is generating an arbitrary amount of data from a ComputeShader and then rendering that, without requiring a readback to the CPU.

这主要在 Shader Model 4.5 级别的硬件中有用,其中着色器可以从 ComputeBuffer 缓冲区读取任意数据。

带参数的缓冲区 bufferWithArgs 必须在给定的 argsOffset 偏移处具有四个整数: 每个实例的顶点数、实例数、起始顶点位置和起始实例位置。 这会映射到 Direct3D11 DrawInstancedIndirect 和其他图形 API 中的等效函数。在 OpenGL 4.2 之前的版本和支持间接绘制的所有 OpenGL ES 版本中,最后一个参数保留,因此必须是零。

注意,该调用立即执行,类似于 Graphics.DrawMeshNow。它使用当前设置的渲染目标、变换矩阵和着色器通道。

CommandBuffers 中也有类似的功能,请参阅 CommandBuffer.DrawProceduralIndirect

另请参阅:Graphics.DrawProceduralNowComputeBuffer.CopyCountSystemInfo.supportsComputeShaders


public static void DrawProceduralIndirectNow (MeshTopology topology, GraphicsBuffer indexBuffer, ComputeBuffer bufferWithArgs, int argsOffset);
public static void DrawProceduralIndirectNow (MeshTopology topology, GraphicsBuffer indexBuffer, GraphicsBuffer bufferWithArgs, int argsOffset);

参数

topology 程序化几何体的拓扑。
indexBuffer 用于将顶点提交到 GPU 的索引缓冲区。
bufferWithArgs 具有绘制参数的缓冲区。
argsOffset 缓冲区中的字节偏移,绘制参数所在位置。

描述

在 GPU 上绘制程序化的几何形状。

DrawProceduralIndirectNow does a draw call on the GPU, without a vertex buffer. If the shader requires vertex buffers, one of the following occurs depending on platform: - If the vertex buffer is declared but the compiler can optimize it away, the normal DrawProcedural call occurs. - If the compiler is not able to optimize the vertex buffer declaration away, the draw call will be converted into a normal mesh drawing call with emulated vertex buffers injected. The latter option has performance overhead so it is recommended not to declare vertex inputs in shaders when using DrawProceduralIndirectNow. The amount of geometry to draw is read from a ComputeBuffer. Typical use case is generating an arbitrary amount of data from a ComputeShader and then rendering that, without requiring a readback to the CPU.

这主要在 Shader Model 4.5 级别的硬件中有用,其中着色器可以从 ComputeBuffer 缓冲区读取任意数据。

带参数的缓冲区 bufferWithArgs 必须在给定的 argsOffset 偏移处具有五个整数: 每个实例的索引数、实例数、起始索引位置、基顶点位置和起始实例位置。 这会映射到 Direct3D11 DrawIndexedInstancedIndirect 和其他图形 API 中的等效函数。在 OpenGL 4.2 之前的版本和支持间接绘制的所有 OpenGL ES 版本中,最后一个参数保留,因此必须是零。

注意,该调用立即执行,类似于 Graphics.DrawMeshNow。它使用当前设置的渲染目标、变换矩阵和着色器通道。

CommandBuffers 中也有类似的功能,请参阅 CommandBuffer.DrawProceduralIndirect

另请参阅:Graphics.DrawProceduralNowComputeBuffer.CopyCountSystemInfo.supportsComputeShaders