Struct ProfilingScope
RAII scope that calls Begin(CommandBuffer) on construction and
End(CommandBuffer) on disposal, ensuring markers are always balanced.
Use in a using statement to guarantee Dispose() is called.
Implements
Inherited Members
Namespace: UnityEngine.Rendering
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
[IgnoredByDeepProfiler]
public struct ProfilingScope : IDisposable
Remarks
This struct is a no-op in non-development Players.
Constructors
ProfilingScope(BaseCommandBuffer, ProfilingSampler)
Creates a profiling scope that records markers into cmd as well as inline on the CPU.
Declaration
public ProfilingScope(BaseCommandBuffer cmd, ProfilingSampler sampler)
Parameters
| Type | Name | Description |
|---|---|---|
| BaseCommandBuffer | cmd | Command buffer to receive the GPU-visible begin/end markers. |
| ProfilingSampler | sampler | The sampler that provides the underlying marker.
May be |
Remarks
Do not use with a named CommandBuffer. A named command buffer inserts its own scope marker on execution, which orphans the markers added here: the begin and end appear inside different named-buffer execution brackets and will be mismatched in the Profiler timeline.
ProfilingScope(CommandBuffer, ProfilingSampler)
Creates a profiling scope that records markers into cmd as well as inline on the CPU.
Declaration
public ProfilingScope(CommandBuffer cmd, ProfilingSampler sampler)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | cmd | Command buffer to receive the GPU-visible begin/end markers. |
| ProfilingSampler | sampler | The sampler that provides the underlying marker.
May be |
Remarks
Do not use with a named CommandBuffer. A named command buffer inserts its own scope marker on execution, which orphans the markers added here: the begin and end appear inside different named-buffer execution brackets and will be mismatched in the Profiler timeline.
ProfilingScope(CommandBuffer, ProfilingSampler, Object)
Creates a profiling scope that records markers into cmd with a
Unity Object context associated with the sample.
Declaration
public ProfilingScope(CommandBuffer cmd, ProfilingSampler sampler, Object contextObject)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | cmd | Command buffer to receive the GPU-visible begin/end markers. |
| ProfilingSampler | sampler | The sampler that provides the underlying marker.
May be |
| Object | contextObject | Unity Object (e.g. Texture, Mesh, Material) to associate with this sample. The Profiler displays it in the sample hierarchy. |
Remarks
Do not use with a named CommandBuffer. A named command buffer inserts its own scope marker on execution, which orphans the markers added here.
ProfilingScope(ProfilingSampler)
Creates a profiling scope without a command buffer (inline CPU profiling only).
Declaration
public ProfilingScope(ProfilingSampler sampler)
Parameters
| Type | Name | Description |
|---|---|---|
| ProfilingSampler | sampler | The sampler that provides the underlying marker.
May be |
ProfilingScope(ProfilingSampler, Object)
Creates an inline CPU-only profiling scope with a Unity Object context associated with the sample. No command buffer is involved; the marker is emitted directly on the CPU timeline.
Declaration
public ProfilingScope(ProfilingSampler sampler, Object contextObject)
Parameters
| Type | Name | Description |
|---|---|---|
| ProfilingSampler | sampler | The sampler that provides the underlying marker.
May be |
| Object | contextObject | Unity Object (e.g. Texture, Mesh, Material) to associate with this sample. The Profiler displays it in the sample hierarchy. |
Methods
Dispose()
Ends the profiling scope by calling End(CommandBuffer). Safe to call multiple times.
Declaration
public void Dispose()