Skip to content

Various fixes for Graphics tests with Render Graph #725

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 27 commits into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1df359c
WIP for enabling valid graphics tests with Render Graph.
JulienIgnace-Unity May 27, 2020
64ef0ca
Fixed more GCAlloc and added an option for a test to not be run if re…
JulienIgnace-Unity May 28, 2020
505924b
First batch of disabled tests.
JulienIgnace-Unity May 28, 2020
a6c1f8e
Fixed decal rendering
JulienIgnace-Unity May 28, 2020
04d0d20
Implemented ColorGrading and Uber Post (fixes a lot of small diff due…
JulienIgnace-Unity May 28, 2020
4934ab9
Revert "First batch of disabled tests."
JulienIgnace-Unity May 28, 2020
0dd42d8
Temp "texture not bound" error fix until bloom is implemented.
JulienIgnace-Unity May 28, 2020
027a5c5
Fixed an error when using a stale invalid renderer list handle.
JulienIgnace-Unity Jun 2, 2020
349a273
Add some debug info to compiled passes and removed wrong refCount++ o…
JulienIgnace-Unity Jun 2, 2020
a98f454
Merge branch 'HDRP/staging' of https://github.com/Unity-Technologies/…
JulienIgnace-Unity Jun 2, 2020
3eb0eb6
Added possibility to disallow pass pruning
JulienIgnace-Unity Jun 3, 2020
e1f9e08
Small fixes
JulienIgnace-Unity Jun 3, 2020
1213511
temporarily removed pruning of passes without product
JulienIgnace-Unity Jun 3, 2020
95952b0
Fixed HDRP asset for test 5009
JulienIgnace-Unity Jun 3, 2020
1d97a44
Implement alpha copy for post processes
JulienIgnace-Unity Jun 3, 2020
0c62ef7
Small render graph error fix for motion vector pass.
JulienIgnace-Unity Jun 3, 2020
84467f6
Disabled for render graph tests that are currently broken.
JulienIgnace-Unity Jun 4, 2020
7b8acc0
Updated yamato with new render graph configurations
JulienIgnace-Unity Jun 4, 2020
46a64a3
Fixed lens distortion
JulienIgnace-Unity Jun 4, 2020
76a7c00
Reenabled 4021
JulienIgnace-Unity Jun 4, 2020
68fb303
Revert "Reenabled 4021"
JulienIgnace-Unity Jun 4, 2020
fb085d0
Revert "Updated yamato with new render graph configurations"
JulienIgnace-Unity Jun 4, 2020
b3ac299
Revert "Disabled for render graph tests that are currently broken."
JulienIgnace-Unity Jun 4, 2020
d0bb7fa
Reverted HDRP test framework files (will go to another PR)
JulienIgnace-Unity Jun 4, 2020
4ac6aa2
Revert "Fixed HDRP asset for test 5009"
JulienIgnace-Unity Jun 4, 2020
ddd259e
Merge branch 'HDRP/staging' into HDRP/rendergraph-graphicstests
sebastienlagarde Jun 4, 2020
e7a4a08
Merge branch 'HDRP/staging' into HDRP/rendergraph-graphicstests
sebastienlagarde Jun 6, 2020
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
251 changes: 183 additions & 68 deletions com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ public void EnableAsyncCompute(bool value)
m_RenderPass.EnableAsyncCompute(value);
}

/// <summary>
/// Allow or not pass pruning
/// By default all passes can be pruned out if the render graph detects it's not actually used.
/// In some cases, a pass may not write or read any texture but rather do something with side effects (like setting a global texture parameter for example).
/// This function can be used to tell the system that it should not prune this pass.
/// </summary>
/// <param name="value"></param>
public void AllowPassPruning(bool value)
{
m_RenderPass.AllowPassPruning(value);
}

/// <summary>
/// Dispose the RenderGraphBuilder instance.
/// </summary>
Expand Down Expand Up @@ -175,7 +187,7 @@ void Dispose(bool disposing)

void CheckTransientTexture(TextureHandle input)
{
if (input.transientPassIndex != -1 && input.transientPassIndex != m_RenderPass.index)
if (input.IsValid() && input.transientPassIndex != -1 && input.transientPassIndex != m_RenderPass.index)
{
throw new ArgumentException($"Trying to use a transient texture (pass index {input.transientPassIndex}) in a different pass (pass index {m_RenderPass.index}.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,40 @@ public RenderFunc<PassData> GetExecuteDelegate<PassData>()
where PassData : class, new() => ((RenderGraphPass<PassData>)this).renderFunc;

public abstract void Execute(RenderGraphContext renderGraphContext);
public abstract void Release(RenderGraphContext renderGraphContext);
public abstract void Release(RenderGraphObjectPool pool);
public abstract bool HasRenderFunc();

public string name { get; protected set; }
public int index { get; protected set; }
public ProfilingSampler customSampler { get; protected set; }
public bool enableAsyncCompute { get; protected set; }
public bool allowPassPruning { get; protected set; }

public TextureHandle depthBuffer { get; protected set; }
public TextureHandle[] colorBuffers { get; protected set; } = new TextureHandle[RenderGraph.kMaxMRTCount];
public int colorBufferMaxIndex { get; protected set; } = -1;
public int refCount { get; protected set; }

List<TextureHandle> m_TextureReadList = new List<TextureHandle>();
List<TextureHandle> m_TextureWriteList = new List<TextureHandle>();
List<TextureHandle> m_TransientTextureList = new List<TextureHandle>();
List<ComputeBufferHandle> m_BufferReadList = new List<ComputeBufferHandle>();
List<ComputeBufferHandle> m_BufferWriteList = new List<ComputeBufferHandle>();
List<RendererListHandle> m_UsedRendererListList = new List<RendererListHandle>();

public IReadOnlyCollection<TextureHandle> textureReadList { get { return m_TextureReadList; } }
public IReadOnlyCollection<TextureHandle> textureWriteList { get { return m_TextureWriteList; } }
public IReadOnlyCollection<TextureHandle> transientTextureList { get { return m_TransientTextureList; } }
public IReadOnlyCollection<ComputeBufferHandle> bufferReadList { get { return m_BufferReadList; } }
public IReadOnlyCollection<ComputeBufferHandle> bufferWriteList { get { return m_BufferWriteList; } }
public IReadOnlyCollection<RendererListHandle> usedRendererListList { get { return m_UsedRendererListList; } }
public List<TextureHandle> textureReadList = new List<TextureHandle>();
public List<TextureHandle> textureWriteList = new List<TextureHandle>();
public List<TextureHandle> transientTextureList = new List<TextureHandle>();
public List<ComputeBufferHandle> bufferReadList = new List<ComputeBufferHandle>();
public List<ComputeBufferHandle> bufferWriteList = new List<ComputeBufferHandle>();
public List<RendererListHandle> usedRendererListList = new List<RendererListHandle>();

public void Clear()
{
name = "";
index = -1;
customSampler = null;
m_TextureReadList.Clear();
m_TextureWriteList.Clear();
m_BufferReadList.Clear();
m_BufferWriteList.Clear();
m_TransientTextureList.Clear();
m_UsedRendererListList.Clear();
textureReadList.Clear();
textureWriteList.Clear();
bufferReadList.Clear();
bufferWriteList.Clear();
transientTextureList.Clear();
usedRendererListList.Clear();
enableAsyncCompute = false;
allowPassPruning = true;
refCount = 0;

// Invalidate everything
Expand All @@ -64,41 +59,46 @@ public void Clear()

public void AddTextureWrite(TextureHandle texture)
{
m_TextureWriteList.Add(texture);
textureWriteList.Add(texture);
refCount++;
}

public void AddTextureRead(TextureHandle texture)
{
m_TextureReadList.Add(texture);
textureReadList.Add(texture);
}

public void AddBufferWrite(ComputeBufferHandle buffer)
{
m_BufferWriteList.Add(buffer);
bufferWriteList.Add(buffer);
refCount++;
}

public void AddTransientTexture(TextureHandle texture)
{
m_TransientTextureList.Add(texture);
transientTextureList.Add(texture);
}

public void AddBufferRead(ComputeBufferHandle buffer)
{
m_BufferReadList.Add(buffer);
bufferReadList.Add(buffer);
}

public void UseRendererList(RendererListHandle rendererList)
{
m_UsedRendererListList.Add(rendererList);
usedRendererListList.Add(rendererList);
}

public void EnableAsyncCompute(bool value)
{
enableAsyncCompute = value;
}

public void AllowPassPruning(bool value)
{
allowPassPruning = value;
}

public void SetColorBuffer(TextureHandle resource, int index)
{
Debug.Assert(index < RenderGraph.kMaxMRTCount && index >= 0);
Expand All @@ -110,9 +110,9 @@ public void SetColorBuffer(TextureHandle resource, int index)
public void SetDepthBuffer(TextureHandle resource, DepthAccess flags)
{
depthBuffer = resource;
if ((flags | DepthAccess.Read) != 0)
if ((flags & DepthAccess.Read) != 0)
AddTextureRead(resource);
if ((flags | DepthAccess.Write) != 0)
if ((flags & DepthAccess.Write) != 0)
AddTextureWrite(resource);
}
}
Expand All @@ -138,13 +138,15 @@ public void Initialize(int passIndex, PassData passData, string passName, Profil
customSampler = sampler;
}

public override void Release(RenderGraphContext renderGraphContext)
public override void Release(RenderGraphObjectPool pool)
{
Clear();
renderGraphContext.renderGraphPool.Release(data);
pool.Release(data);
data = null;
renderFunc = null;
renderGraphContext.renderGraphPool.Release(this);

// We need to do the release from here because we need the final type.
pool.Release(this);
}

public override bool HasRenderFunc()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ public RTHandle GetTexture(in TextureHandle handle)
/// <returns>The Renderer List associated with the provided resource handle or an invalid renderer list if the handle is invalid.</returns>
public RendererList GetRendererList(in RendererListHandle handle)
{
if (!handle.IsValid())
if (!handle.IsValid() || handle >= m_RendererListResources.size)
return RendererList.nullRendererList;

return m_RendererListResources[handle].rendererList;
Expand Down Expand Up @@ -476,9 +476,9 @@ internal bool IsTextureImported(TextureHandle handle)
internal TextureHandle ImportBackbuffer(RenderTargetIdentifier rt)
{
if (m_CurrentBackbuffer != null)
m_RTHandleSystem.Release(m_CurrentBackbuffer);

m_CurrentBackbuffer = m_RTHandleSystem.Alloc(rt);
m_CurrentBackbuffer.SetTexture(rt);
else
m_CurrentBackbuffer = m_RTHandleSystem.Alloc(rt);

int newHandle = m_TextureResources.Add(new TextureResource(m_CurrentBackbuffer, 0));
return new TextureHandle(newHandle);
Expand Down Expand Up @@ -603,7 +603,7 @@ void CreateTextureForPass(ref TextureResource resource)
resource.cachedHash = hashCode;
}

void SetGlobalTextures(RenderGraphContext rgContext, IReadOnlyCollection<TextureHandle> textures, bool bindDummyTexture)
void SetGlobalTextures(RenderGraphContext rgContext, List<TextureHandle> textures, bool bindDummyTexture)
{
foreach (var resource in textures)
{
Expand All @@ -620,12 +620,12 @@ void SetGlobalTextures(RenderGraphContext rgContext, IReadOnlyCollection<Texture
}


internal void PreRenderPassSetGlobalTextures(RenderGraphContext rgContext, IReadOnlyCollection<TextureHandle> textures)
internal void PreRenderPassSetGlobalTextures(RenderGraphContext rgContext, List<TextureHandle> textures)
{
SetGlobalTextures(rgContext, textures, false);
}

internal void PostRenderPassUnbindGlobalTextures(RenderGraphContext rgContext, IReadOnlyCollection<TextureHandle> textures)
internal void PostRenderPassUnbindGlobalTextures(RenderGraphContext rgContext, List<TextureHandle> textures)
{
SetGlobalTextures(rgContext, textures, true);
}
Expand Down Expand Up @@ -748,7 +748,7 @@ internal void CreateRendererLists(List<RendererListHandle> rendererLists)
}
}

internal void Clear()
internal void Clear(bool onException)
{
LogResources();

Expand All @@ -757,7 +757,7 @@ internal void Clear()
m_ComputeBufferResources.Clear();

#if DEVELOPMENT_BUILD || UNITY_EDITOR
if (m_AllocatedTextures.Count != 0)
if (m_AllocatedTextures.Count != 0 && !onException)
{
string logMessage = "RenderGraph: Not all textures were released.";

Expand All @@ -770,6 +770,10 @@ internal void Clear()

Debug.LogWarning(logMessage);
}

// If an error occurred during execution, it's expected that textures are not all release so we clear the trakcing list.
if (onException)
m_AllocatedTextures.Clear();
#endif
}

Expand Down
Loading