浏览代码

prepare HD shaders for new fast batcher compatibility

/Branch_batcher
Arnaud Carre 7 年前
当前提交
f9bee4e4
共有 8 个文件被更改,包括 198 次插入37 次删除
  1. 6
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl
  2. 65
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderVariables.hlsl
  3. 9
      Assets/TestScenes/Common.meta
  4. 9
      Assets/TestScenes/Common/Scripts.meta
  5. 134
      Assets/TestScenes/Common/Scripts/MiniProfiler.cs
  6. 12
      Assets/TestScenes/Common/Scripts/MiniProfiler.cs.meta

6
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl


CBUFFER_START(_PerMaterial)
// shared constant between lit and layered lit
float _AlphaCutoff;
float4 _DoubleSidedConstants;

float3 _EmissionColor;
// Wind
float _InitialBend;
float _InitialBend;
float _Stiffness;
float _Drag;
float _ShiverDrag;

float _TessellationObjectScale;
float _TessellationTilingScale;
#endif
CBUFFER_END

65
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderVariables.hlsl


// ----------------------------------------------------------------------------
CBUFFER_START(UnityPerDraw)
CBUFFER_START(UnityPerDraw : register(b0))
float4x4 glstate_matrix_mvp;
float4x4 glstate_matrix_modelview0;
float4x4 glstate_matrix_invtrans_modelview0;
float4x4 glstate_matrix_mvp;
float4x4 glstate_matrix_modelview0;
float4x4 glstate_matrix_invtrans_modelview0;
float4x4 unity_ObjectToWorld;
float4x4 unity_WorldToObject;
float4 unity_LODFade; // x is the fade value ranging within [0,1]. y is x quantized into 16 levels
float4 unity_WorldTransformParams; // w is usually 1.0, or -1.0 for odd-negative scale transforms
float4x4 unity_ObjectToWorld;
float4x4 unity_WorldToObject;
float4 unity_LODFade; // x is the fade value ranging within [0,1]. y is x quantized into 16 levels
float4 unity_WorldTransformParams; // w is usually 1.0, or -1.0 for odd-negative scale transforms
float4 unity_LightmapST;
float4 unity_DynamicLightmapST;
// SH lighting environment
float4 unity_SHAr;
float4 unity_SHAg;
float4 unity_SHAb;
float4 unity_SHBr;
float4 unity_SHBg;
float4 unity_SHBb;
float4 unity_SHC;
// x = Disabled(0)/Enabled(1)
// y = Computation are done in global space(0) or local space(1)
// z = Texel size on U texture coordinate
float4 unity_ProbeVolumeParams;
float4x4 unity_ProbeVolumeWorldToObject;
float3 unity_ProbeVolumeSizeInv;
float3 unity_ProbeVolumeMin;
CBUFFER_END
#if defined(USING_STEREO_MATRICES)

CBUFFER_END
CBUFFER_START(UnityLighting)
// SH lighting environment
float4 unity_SHAr;
float4 unity_SHAg;
float4 unity_SHAb;
float4 unity_SHBr;
float4 unity_SHBg;
float4 unity_SHBb;
float4 unity_SHC;
CBUFFER_END
TEXTURE2D_FLOAT(_MainDepthTexture);
SAMPLER2D(sampler_MainDepthTexture);

TEXTURE2D(unity_DynamicDirectionality);
CBUFFER_START(UnityLightmaps)
float4 unity_LightmapST;
float4 unity_DynamicLightmapST;
CBUFFER_END
CBUFFER_START(UnityProbeVolume)
// x = Disabled(0)/Enabled(1)
// y = Computation are done in global space(0) or local space(1)
// z = Texel size on U texture coordinate
float4 unity_ProbeVolumeParams;
float4x4 unity_ProbeVolumeWorldToObject;
float3 unity_ProbeVolumeSizeInv;
float3 unity_ProbeVolumeMin;
CBUFFER_END
CBUFFER_START(UnityVelocityPass)
float4x4 _NonJitteredVP;

9
Assets/TestScenes/Common.meta


fileFormatVersion: 2
guid: e42cfeaf226ad624786ad5b39095906c
folderAsset: yes
timeCreated: 1493044341
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/TestScenes/Common/Scripts.meta


fileFormatVersion: 2
guid: 711a9f1e8aa51844980a04a15d8c8f58
folderAsset: yes
timeCreated: 1493044341
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

134
Assets/TestScenes/Common/Scripts/MiniProfiler.cs


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();
}
}
}

12
Assets/TestScenes/Common/Scripts/MiniProfiler.cs.meta


fileFormatVersion: 2
guid: 6dc6eb1c59f1c9745b732f87dafd16f2
timeCreated: 1493044341
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存