Skip to content

Commit 86ee9f3

Browse files
committed
Updated project to use new RenderPipeline lifecycle.
1 parent 1d0abba commit 86ee9f3

File tree

5 files changed

+23
-54
lines changed

5 files changed

+23
-54
lines changed

Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ static void CreateBasicRenderLoop()
2424

2525
private ShaderPassName shaderPassBasic;
2626

27-
public void OnEnable()
27+
public override void Build()
2828
{
29-
Rebuild();
3029
}
3130

32-
public override void Initialize()
31+
public override void Cleanup()
3332
{
34-
shaderPassBasic = new ShaderPassName("BasicPass");
3533
}
3634

3735
// Main entry point for our scriptable render loop
@@ -59,7 +57,7 @@ public override void Render(Camera[] cameras, RenderLoop loop)
5957
SetupLightShaderVariables (cull.visibleLights, loop);
6058

6159
// Draw opaque objects using BasicPass shader pass
62-
var settings = new DrawRendererSettings (cull, camera, shaderPassBasic);
60+
var settings = new DrawRendererSettings (cull, camera, new ShaderPassName("BasicPass"));
6361
settings.sorting.flags = SortFlags.CommonOpaque;
6462
settings.inputFilter.SetQueuesOpaque ();
6563
loop.DrawRenderers (ref settings);

Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ public override void Render(Camera[] cameras, RenderLoop renderLoop)
3232
renderLoop.Submit();
3333
}
3434

35+
public override void Build()
36+
{
37+
38+
}
39+
40+
public override void Cleanup()
41+
{
42+
43+
}
44+
3545
public static void Run(TestDelegate renderCallback)
3646
{
3747
if (m_Instance == null)

Assets/ScriptableRenderLoop/HDRenderLoop/Editor/HDRenderLoopInspector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ public override void OnInspectorGUI()
280280
{
281281
EditorUtility.SetDirty(renderLoop); // Repaint
282282

283-
// If something is chanage regarding tile/cluster rendering we need to force a OnValidate() OnHDRenderLoop, else change Rebuild() will not be call
284-
renderLoop.OnValidate();
283+
// SetAssetDirty will tell renderloop to rebuild
284+
renderLoop.SetAssetDirty();
285285
}
286286

287287
EditorGUI.BeginChangeCheck();

Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ public TextureSettings textureSettings
145145
int m_VelocityBuffer;
146146
int m_DistortionBuffer;
147147

148-
public bool m_Dirty = false;
149-
150148
RenderTargetIdentifier m_CameraColorBufferRT;
151149
RenderTargetIdentifier m_CameraDepthBufferRT;
152150
RenderTargetIdentifier m_VelocityBufferRT;
@@ -168,19 +166,14 @@ public BaseLightLoop lightLoop
168166
// TODO TO CHECK: SebL I move allocation from Rebuild() to here, but there was a comment "// Our object can be garbage collected, so need to be allocate here", it is still true ?
169167
Lit.RenderLoop m_LitRenderLoop = new Lit.RenderLoop();
170168

171-
public void OnValidate()
172-
{
173-
// Calling direction Rebuild() here cause this warning:
174-
// "SendMessage cannot be called during Awake, CheckConsistency, or OnValidate UnityEngine.Experimental.ScriptableRenderLoop.HDRenderLoop:OnValidate()"
175-
// Workaround is to declare this dirty flag and call REbuild in Render()
176-
m_Dirty = true;
177-
}
178-
179-
public override void Rebuild()
169+
public override void Build()
180170
{
181-
// We call Cleanup() here because Rebuild() can be call by OnValidate(), i.e when inspector is touch
182-
// Note that module don't need to do the same as the call here is propagated correctly
183-
Cleanup();
171+
#if UNITY_EDITOR
172+
UnityEditor.SupportedRenderingFeatures.active = new UnityEditor.SupportedRenderingFeatures
173+
{
174+
reflectionProbe = UnityEditor.SupportedRenderingFeatures.ReflectionProbe.Rotation
175+
};
176+
#endif
184177

185178
m_CameraColorBuffer = Shader.PropertyToID("_CameraColorTexture");
186179
m_CameraDepthBuffer = Shader.PropertyToID("_CameraDepthTexture");
@@ -223,20 +216,6 @@ public override void Rebuild()
223216

224217
m_LitRenderLoop.Rebuild();
225218
m_lightLoop.Rebuild(m_TextureSettings);
226-
227-
m_Dirty = false;
228-
}
229-
230-
public override void Initialize()
231-
{
232-
#if UNITY_EDITOR
233-
UnityEditor.SupportedRenderingFeatures.active = new UnityEditor.SupportedRenderingFeatures
234-
{
235-
reflectionProbe = UnityEditor.SupportedRenderingFeatures.ReflectionProbe.Rotation
236-
};
237-
#endif
238-
239-
Rebuild();
240219
}
241220

242221
public override void Cleanup()
@@ -614,11 +593,6 @@ public void PushGlobalParams(Camera camera, RenderLoop renderLoop)
614593

615594
public override void Render(Camera[] cameras, RenderLoop renderLoop)
616595
{
617-
if (m_Dirty)
618-
{
619-
Rebuild();
620-
}
621-
622596
if (!m_LitRenderLoop.isInit)
623597
{
624598
m_LitRenderLoop.RenderInit(renderLoop);

Assets/ScriptableRenderLoop/fptl/FptlLighting.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,8 @@ static void CreateRenderLoopFPTL()
113113
private Texture2D m_LightAttentuationTexture;
114114
private int m_shadowBufferID;
115115

116-
private void OnValidate()
117-
{
118-
Rebuild();
119-
}
120-
121-
public override void Initialize()
122-
{
123-
Rebuild();
124-
}
125-
126116
public override void Cleanup()
127117
{
128-
// RenderLoop.renderLoopDelegate -= ExecuteRenderLoop;
129118
if (m_DeferredMaterial) DestroyImmediate(m_DeferredMaterial);
130119
if (m_DeferredReflectionMaterial) DestroyImmediate(m_DeferredReflectionMaterial);
131120
if (m_BlitMaterial) DestroyImmediate(m_BlitMaterial);
@@ -174,10 +163,8 @@ void ClearComputeBuffers()
174163
}
175164
}
176165

177-
public override void Rebuild()
166+
public override void Build()
178167
{
179-
ClearComputeBuffers();
180-
181168
s_GBufferAlbedo = Shader.PropertyToID("_CameraGBufferTexture0");
182169
s_GBufferSpecRough = Shader.PropertyToID("_CameraGBufferTexture1");
183170
s_GBufferNormal = Shader.PropertyToID("_CameraGBufferTexture2");

0 commit comments

Comments
 (0)