浏览代码
Merge pull request #230 from Unity-Technologies/Branch_Batching2
Merge pull request #230 from Unity-Technologies/Branch_Batching2
prepare HD shaders for new fast batcher compatibility/Branch_batcher
GitHub
8 年前
当前提交
7d8feec6
共有 8 个文件被更改,包括 198 次插入 和 37 次删除
-
6Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl
-
65Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderVariables.hlsl
-
9Assets/TestScenes/Common.meta
-
9Assets/TestScenes/Common/Scripts.meta
-
134Assets/TestScenes/Common/Scripts/MiniProfiler.cs
-
12Assets/TestScenes/Common/Scripts/MiniProfiler.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: e42cfeaf226ad624786ad5b39095906c |
|||
folderAsset: yes |
|||
timeCreated: 1493044341 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 711a9f1e8aa51844980a04a15d8c8f58 |
|||
folderAsset: yes |
|||
timeCreated: 1493044341 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
using UnityEngine.Profiling; |
|||
|
|||
public class MiniProfiler : MonoBehaviour { |
|||
|
|||
public bool m_Enable = false; |
|||
|
|||
private int frameCount = 0; |
|||
private const int kAverageFrameCount = 64; |
|||
private float m_AccDeltaTime; |
|||
private float m_AvgDeltaTime; |
|||
|
|||
internal class RecorderEntry |
|||
{ |
|||
public string name; |
|||
public float time; |
|||
public int count; |
|||
public float avgTime; |
|||
public float avgCount; |
|||
public float accTime; |
|||
public int accCount; |
|||
public Recorder recorder; |
|||
}; |
|||
|
|||
RecorderEntry[] recordersList = |
|||
{ |
|||
new RecorderEntry() { name="RenderLoop.Draw" }, |
|||
// new RecorderEntry() { name="BatchRenderer.Flush" },
|
|||
new RecorderEntry() { name="Shadows.Draw" }, |
|||
new RecorderEntry() { name="BatchRenderer.ApplyShaderPass" }, |
|||
|
|||
/* |
|||
new RecorderEntry() { name="gBatchGBufferObj" }, |
|||
new RecorderEntry() { name="gBatchGBufferBatch" }, |
|||
new RecorderEntry() { name="gBatchShadowObj" }, |
|||
new RecorderEntry() { name="gBatchShadowBatch" }, |
|||
*/ |
|||
|
|||
/* |
|||
new RecorderEntry() { name="Map_PerDraw_Buffer" }, |
|||
new RecorderEntry() { name="Unmap_PerDraw_Buffer" }, |
|||
new RecorderEntry() { name="DrawBuffersBatchMode" }, |
|||
new RecorderEntry() { name="DrawBatchIndexed" }, |
|||
new RecorderEntry() { name="BatchRenderer.ApplyShaderPass" }, |
|||
new RecorderEntry() { name="PerformFlushProperties" }, |
|||
*/ |
|||
|
|||
|
|||
/* |
|||
new RecorderEntry() { name="Camera.Render" }, |
|||
new RecorderEntry() { name="GUI.Repaint" }, |
|||
new RecorderEntry() { name="PrepareValues" }, |
|||
new RecorderEntry() { name="ApplyGpuProgram" }, |
|||
new RecorderEntry() { name="WriteParameters" }, |
|||
new RecorderEntry() { name="FlushBuffers" }, |
|||
new RecorderEntry() { name="BindBuffers" }, |
|||
new RecorderEntry() { name="Gfx.ProcessCommand" }, |
|||
*/ |
|||
}; |
|||
|
|||
void Awake() |
|||
{ |
|||
for (int i=0;i<recordersList.Length;i++) |
|||
{ |
|||
var sampler = Sampler.Get(recordersList[i].name); |
|||
if ( sampler != null ) |
|||
{ |
|||
recordersList[i].recorder = sampler.GetRecorder(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
void Update() |
|||
{ |
|||
|
|||
if (m_Enable) |
|||
{ |
|||
|
|||
// get timing & update average accumulators
|
|||
for (int i = 0; i < recordersList.Length; i++) |
|||
{ |
|||
recordersList[i].time = recordersList[i].recorder.elapsedNanoseconds / 1000000.0f; |
|||
recordersList[i].count = recordersList[i].recorder.sampleBlockCount; |
|||
recordersList[i].accTime += recordersList[i].time; |
|||
recordersList[i].accCount += recordersList[i].count; |
|||
} |
|||
|
|||
m_AccDeltaTime += Time.deltaTime; |
|||
|
|||
frameCount++; |
|||
// time to time, update average values & reset accumulators
|
|||
if (frameCount >= kAverageFrameCount) |
|||
{ |
|||
for (int i = 0; i < recordersList.Length; i++) |
|||
{ |
|||
recordersList[i].avgTime = recordersList[i].accTime * (1.0f / kAverageFrameCount); |
|||
recordersList[i].avgCount = recordersList[i].accCount * (1.0f / kAverageFrameCount); |
|||
recordersList[i].accTime = 0.0f; |
|||
recordersList[i].accCount = 0; |
|||
|
|||
} |
|||
|
|||
m_AvgDeltaTime = m_AccDeltaTime / kAverageFrameCount; |
|||
m_AccDeltaTime = 0.0f; |
|||
frameCount = 0; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
void OnGUI() |
|||
{ |
|||
|
|||
if (m_Enable) |
|||
{ |
|||
GUI.color = new Color(1, 1, 1, .75f); |
|||
float w = 500, h = 204; |
|||
|
|||
GUILayout.BeginArea(new Rect(10, 150, w, h), "Mini Profiler", GUI.skin.window); |
|||
string sLabel = System.String.Format("<b>{0:F2} FPS ({1:F2}ms)</b>\n", 1.0f / m_AvgDeltaTime, Time.deltaTime * 1000.0f); |
|||
for (int i = 0; i < recordersList.Length; i++) |
|||
{ |
|||
sLabel += string.Format("{0:F2}ms (*{1:F2})\t({2:F2}ms *{3:F2})\t<b>{4}</b>\n", recordersList[i].avgTime, recordersList[i].avgCount, recordersList[i].time, recordersList[i].count, recordersList[i].name); |
|||
} |
|||
GUILayout.Label(sLabel); |
|||
GUILayout.EndArea(); |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6dc6eb1c59f1c9745b732f87dafd16f2 |
|||
timeCreated: 1493044341 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue