Skip to content

Commit dfbe0ae

Browse files
authored
Merge pull request #37 from Unity-Technologies/scriptablerenderloop-graphicssettings
Scriptablerenderloop graphicssettings
2 parents 4f8819b + 86ee9f3 commit dfbe0ae

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
@@ -287,8 +287,8 @@ private void TilePassUI(HDRenderLoop renderLoop)
287287
{
288288
EditorUtility.SetDirty(renderLoop); // Repaint
289289

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

294294
EditorGUI.BeginChangeCheck();

Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs

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

149-
public bool m_Dirty = false;
150-
151149
RenderTargetIdentifier m_CameraColorBufferRT;
152150
RenderTargetIdentifier m_CameraDepthBufferRT;
153151
RenderTargetIdentifier m_VelocityBufferRT;
@@ -169,19 +167,14 @@ public BaseLightLoop lightLoop
169167
// 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 ?
170168
Lit.RenderLoop m_LitRenderLoop = new Lit.RenderLoop();
171169

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

186179
m_CameraColorBuffer = Shader.PropertyToID("_CameraColorTexture");
187180
m_CameraDepthBuffer = Shader.PropertyToID("_CameraDepthTexture");
@@ -224,20 +217,6 @@ public override void Rebuild()
224217

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

243222
public override void Cleanup()
@@ -615,11 +594,6 @@ public void PushGlobalParams(Camera camera, RenderLoop renderLoop)
615594

616595
public override void Render(Camera[] cameras, RenderLoop renderLoop)
617596
{
618-
if (m_Dirty)
619-
{
620-
Rebuild();
621-
}
622-
623597
if (!m_LitRenderLoop.isInit)
624598
{
625599
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)