Skip to content

[HDRP] Fix GC allocs #3136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public override void Setup()
var hdrpAsset = HDRenderPipeline.defaultAsset;
if (hdrpAsset != null)
m_Material = CoreUtils.CreateEngineMaterial(hdrpAsset.renderPipelineResources.shaders.alphaInjectionPS);

name = "AlphaInjection"; // Needed to get a scope name in RenderDoc captures
}

public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public override void Setup()
var hdrpAsset = HDRenderPipeline.defaultAsset;
if (hdrpAsset != null)
m_Material = CoreUtils.CreateEngineMaterial(hdrpAsset.renderPipelineResources.shaders.chromaKeyingPS);

name = "ChromaKeying"; // Needed to get a scope name in RenderDoc captures
}

public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,10 @@ void OnDestroy()
CoreUtils.Destroy(volume);
}
}

// We don't need the custom passes anymore
var hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline;
UnRegisterCustomPasses(hdPipeline);
}

public void AddInputFilterAtLayer(CompositionFilter filter, int index)
Expand Down Expand Up @@ -929,14 +933,12 @@ static internal void RegisterCustomPasses(HDRenderPipeline hdPipeline)
}

// If custom post processes are not registered in the HDRP asset, they are never executed so we have to add them manually
int indx = hdPipeline.asset.beforePostProcessCustomPostProcesses.FindIndex(x => x == typeof(ChromaKeying).AssemblyQualifiedName);
if (indx < 0)
if (!hdPipeline.asset.beforePostProcessCustomPostProcesses.Contains(typeof(ChromaKeying).AssemblyQualifiedName))
{
hdPipeline.asset.beforePostProcessCustomPostProcesses.Add(typeof(ChromaKeying).AssemblyQualifiedName);
}

indx = hdPipeline.asset.beforePostProcessCustomPostProcesses.FindIndex(x => x == typeof(AlphaInjection).AssemblyQualifiedName);
if (indx < 0)
if (!hdPipeline.asset.beforePostProcessCustomPostProcesses.Contains(typeof(AlphaInjection).AssemblyQualifiedName))
{
hdPipeline.asset.beforePostProcessCustomPostProcesses.Add(typeof(AlphaInjection).AssemblyQualifiedName);
}
Expand All @@ -950,14 +952,12 @@ static internal void UnRegisterCustomPasses(HDRenderPipeline hdPipeline)
return;
}

int indx = hdPipeline.asset.beforePostProcessCustomPostProcesses.FindIndex(x => x == typeof(ChromaKeying).AssemblyQualifiedName);
if (indx >= 0)
if (hdPipeline.asset.beforePostProcessCustomPostProcesses.Contains(typeof(ChromaKeying).AssemblyQualifiedName))
{
hdPipeline.asset.beforePostProcessCustomPostProcesses.Remove(typeof(ChromaKeying).AssemblyQualifiedName);
}

indx = hdPipeline.asset.beforePostProcessCustomPostProcesses.FindIndex(x => x == typeof(AlphaInjection).AssemblyQualifiedName);
if (indx >= 0)
if (hdPipeline.asset.beforePostProcessCustomPostProcesses.Contains(typeof(AlphaInjection).AssemblyQualifiedName))
{
hdPipeline.asset.beforePostProcessCustomPostProcesses.Remove(typeof(AlphaInjection).AssemblyQualifiedName);
}
Expand Down