Skip to content

Commit fadd67a

Browse files
YohannVaastUnityEvergreen
authored andcommitted
[Port] [6000.0] Manual backport: fix the FD issue by avoiding pooling of textures
1 parent fc24951 commit fadd67a

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public class InternalRenderGraphContext
6161
internal RenderGraphDefaultResources defaultResources;
6262
internal RenderGraphPass executingPass;
6363
internal bool contextlessTesting;
64+
internal bool forceResourceCreation;
6465
}
6566

6667
// This whole thing is a bit of a mess InternalRenderGraphContext is public (but all members are internal)
@@ -1186,6 +1187,15 @@ public void BeginRecording(in RenderGraphParameters parameters)
11861187
m_RenderGraphContext.renderGraphPool = m_RenderGraphPool;
11871188
m_RenderGraphContext.defaultResources = m_DefaultResources;
11881189

1190+
// With the actual implementation of the Frame Debugger, we cannot re-use resources during the same frame
1191+
// or it breaks the rendering of the pass preview, since the FD copies the texture after the execution of the RG.
1192+
m_RenderGraphContext.forceResourceCreation =
1193+
#if UNITY_EDITOR || DEVELOPMENT_BUILD
1194+
FrameDebugger.enabled;
1195+
#else
1196+
false;
1197+
#endif
1198+
11891199
if (m_DebugParameters.immediateMode)
11901200
{
11911201
UpdateCurrentCompiledGraph(graphHash: -1, forceNoCaching: true);

Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ internal bool CreatePooledResource(InternalRenderGraphContext rgContext, int typ
10341034
var resource = m_RenderGraphResources[type].resourceArray[index];
10351035
if (!resource.imported)
10361036
{
1037-
resource.CreatePooledGraphicsResource();
1037+
resource.CreatePooledGraphicsResource(rgContext.forceResourceCreation);
10381038

10391039
if (m_RenderGraphDebug.enableLogging)
10401040
resource.LogCreation(m_FrameInformationLogger);

Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public virtual bool NeedsFallBack()
188188
return requestFallBack && writeCount == 0;
189189
}
190190

191-
public virtual void CreatePooledGraphicsResource() { }
191+
public virtual void CreatePooledGraphicsResource(bool forceResourceCreation) { }
192192
public virtual void CreateGraphicsResource() { }
193193
public virtual void UpdateGraphicsResource() { }
194194
public virtual void ReleasePooledGraphicsResource(int frameIndex) { }
@@ -236,7 +236,7 @@ public override void ReleaseGraphicsResource()
236236
graphicsResource = null;
237237
}
238238

239-
public override void CreatePooledGraphicsResource()
239+
public override void CreatePooledGraphicsResource(bool forceResourceCreation)
240240
{
241241
Debug.Assert(m_Pool != null, "RenderGraphResource: CreatePooledGraphicsResource should only be called for regular pooled resources");
242242

@@ -247,7 +247,7 @@ public override void CreatePooledGraphicsResource()
247247

248248
// If the pool doesn't have any available resource that we can use, we will create one
249249
// In any case, we will update the graphicsResource name based on the RenderGraph resource name
250-
if (!m_Pool.TryGetResource(hashCode, out graphicsResource))
250+
if (forceResourceCreation || !m_Pool.TryGetResource(hashCode, out graphicsResource))
251251
{
252252
CreateGraphicsResource();
253253
}

0 commit comments

Comments
 (0)