您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

41 行
1.1 KiB

using System;
using UnityEngine.Rendering;
namespace UnityEngine.Experimental.Rendering
{
public struct ProfilingSample : IDisposable
{
public readonly CommandBuffer cmd;
public readonly string name;
bool m_Disposed;
public ProfilingSample(string name, CommandBuffer cmd)
{
this.cmd = cmd;
this.name = name;
m_Disposed = false;
cmd.BeginSample(name);
}
public void Dispose()
{
Dispose(true);
}
// Protected implementation of Dispose pattern.
void Dispose(bool disposing)
{
if (m_Disposed)
return;
// As this is a struct, it could have been initialized using an empty constructor so we
// need to make sure `cmd` isn't null to avoid a crash. Switching to a class would fix
// this but will generate garbage on every frame (and this struct is used quite a lot).
if (disposing && cmd != null)
cmd.EndSample(name);
m_Disposed = true;
}
}
}