-
Notifications
You must be signed in to change notification settings - Fork 840
Correctly dealloc/realloc resources when switching RenderGraph on and off. #328
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
de72db5
Handle deallocation/reallocation of resources when switching rendergr…
JulienIgnace-Unity 4a82b6d
AO and Post Processes.
JulienIgnace-Unity 7e7697f
Prefixed all history buffers with camera name for readability in the …
JulienIgnace-Unity 90a92df
LIght volume debug and Volumetric (WIP)
JulienIgnace-Unity 3d68c4e
Fixed volumetric
JulienIgnace-Unity e6abb28
Fixed deallocation of SSS buffers
JulienIgnace-Unity 6eb35c9
Review feedback fixes.
JulienIgnace-Unity 53bbad2
Init order fix for post process
JulienIgnace-Unity 899d7a9
Reverted volumetric lighting changes and now render graph version use…
JulienIgnace-Unity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphDefaultResources.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using UnityEngine.Rendering; | ||
|
||
namespace UnityEngine.Experimental.Rendering.RenderGraphModule | ||
{ | ||
/// <summary> | ||
/// Helper class allowing access to default resources (black or white texture, etc.) during render passes. | ||
/// </summary> | ||
public class RenderGraphDefaultResources | ||
{ | ||
bool m_IsValid; | ||
|
||
// We need to keep around a RTHandle version of default regular 2D textures since RenderGraph API is all RTHandle. | ||
RTHandle m_BlackTexture2D; | ||
RTHandle m_WhiteTexture2D; | ||
|
||
/// <summary>Default black 2D texture.</summary> | ||
public TextureHandle blackTexture { get; private set; } | ||
/// <summary>Default white 2D texture.</summary> | ||
public TextureHandle whiteTexture { get; private set; } | ||
/// <summary>Default clear color XR 2D texture.</summary> | ||
public TextureHandle clearTextureXR { get; private set; } | ||
/// <summary>Default magenta XR 2D texture.</summary> | ||
public TextureHandle magentaTextureXR { get; private set; } | ||
/// <summary>Default black XR 2D texture.</summary> | ||
public TextureHandle blackTextureXR { get; private set; } | ||
/// <summary>Default black (UInt) XR 2D texture.</summary> | ||
public TextureHandle blackUIntTextureXR { get; private set; } | ||
/// <summary>Default black XR 3D texture.</summary> | ||
public TextureHandle blackTexture3DXR { get; private set; } | ||
/// <summary>Default white XR 2D texture.</summary> | ||
public TextureHandle whiteTextureXR { get; private set; } | ||
|
||
internal RenderGraphDefaultResources() | ||
{ | ||
m_BlackTexture2D = RTHandles.Alloc(Texture2D.blackTexture); | ||
m_WhiteTexture2D = RTHandles.Alloc(Texture2D.whiteTexture); | ||
} | ||
|
||
internal void Cleanup() | ||
{ | ||
m_BlackTexture2D.Release(); | ||
m_WhiteTexture2D.Release(); | ||
} | ||
|
||
internal void InitializeForRendering(RenderGraph renderGraph) | ||
{ | ||
if (!m_IsValid) | ||
{ | ||
blackTexture = renderGraph.ImportTexture(m_BlackTexture2D); | ||
whiteTexture = renderGraph.ImportTexture(m_WhiteTexture2D); | ||
|
||
clearTextureXR = renderGraph.ImportTexture(TextureXR.GetClearTexture()); | ||
magentaTextureXR = renderGraph.ImportTexture(TextureXR.GetMagentaTexture()); | ||
blackTextureXR = renderGraph.ImportTexture(TextureXR.GetBlackTexture()); | ||
blackUIntTextureXR = renderGraph.ImportTexture(TextureXR.GetBlackUIntTexture()); | ||
blackTexture3DXR = renderGraph.ImportTexture(TextureXR.GetBlackTexture3D()); | ||
whiteTextureXR = renderGraph.ImportTexture(TextureXR.GetWhiteTexture()); | ||
|
||
m_IsValid = true; | ||
} | ||
} | ||
|
||
// Imported resources are cleared everytime the Render Graph is executed, so we need to know if that happens | ||
// so that we can re-import all default resources if needed. | ||
internal void Clear() | ||
{ | ||
m_IsValid = false; | ||
} | ||
} | ||
} | ||
|
11 changes: 11 additions & 0 deletions
11
com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphDefaultResources.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.