Exemple #1
0
    public static void EmitScalerDataToProfilerStream(string scalerName, bool enabled, int overrideLevel, int currentLevel, float scale, bool applied, int maxLevel)
    {
        if (!Profiler.enabled || scalerName.Length == 0)
        {
            return;
        }
        ScalerInfo scalerInfo;
        bool       existingInfo = scalerInfos.TryGetValue(scalerName, out scalerInfo);

        if (!existingInfo)
        {
            scalerInfo = new ScalerInfo();
        }

        byte[] scalerNameBytes = Encoding.ASCII.GetBytes(scalerName);
        scalerInfo.enabled       = (uint)(enabled ? 1 : 0);
        scalerInfo.overrideLevel = overrideLevel;
        scalerInfo.currentLevel  = currentLevel;
        scalerInfo.scale         = scale;
        scalerInfo.maxLevel      = maxLevel;
        scalerInfo.applied       = (uint)(applied ? 1 : 0);

        unsafe
        {
            fixed(byte *pSource = scalerNameBytes)
            {
                UnsafeUtility.MemCpy(scalerInfo.scalerName, pSource, scalerNameBytes.Length);
            }
        }

        if (!existingInfo)
        {
            scalerInfos.Add(scalerName, scalerInfo);
        }
        else
        {
            scalerInfos[scalerName] = scalerInfo;
        }
    }
Exemple #2
0
 /// <summary>
 /// Flushes the Adaptive Performance scaler data for this frame. Used in conjunction with <see cref="EmitScalerDataToProfilerStream"/>.
 /// </summary>
 public static void FlushScalerDataToProfilerStream()
 {
     ScalerInfo[] arr = new ScalerInfo[scalerInfos.Count];
     scalerInfos.Values.CopyTo(arr, 0);
     Profiler.EmitFrameMetaData(kAdaptivePerformanceProfilerModuleGuid, kScalerDataTag, arr);
 }