Skip to content

[9.x.x] Fix allocation caused when sorting cameras in URP. #268

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 4 commits into from
Apr 27, 2020
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
1 change: 1 addition & 0 deletions com.unity.render-pipelines.universal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed an issue where the emission value in particle shaders would not update in the editor without entering playmode.
- Fixed issues with performance when importing fbx files
- Fixed issues with NullReferenceException happening with URP shaders
- Fixed an issue that caused memory allocations when sorting cameras. [case 1226448](https://issuetracker.unity3d.com/issues/2d-renderer-using-more-than-one-camera-that-renders-out-to-a-render-texture-creates-gc-alloc-every-frame)

## [7.1.1] - 2019-09-05
### Upgrade Guide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,6 @@ public struct PostProcessingData
public int lutSize;
}

class CameraDataComparer : IComparer<Camera>
{
public int Compare(Camera lhs, Camera rhs)
{
return (int)lhs.depth - (int)rhs.depth;
}
}

public static class ShaderKeywordStrings
{
public static readonly string MainLightShadows = "_MAIN_LIGHT_SHADOWS";
Expand Down Expand Up @@ -303,11 +295,11 @@ static bool IsMultiPassStereoEnabled(Camera camera)
#endif
}

Comparison<Camera> cameraComparison = (camera1, camera2) => { return (int) camera1.depth - (int) camera2.depth; };
void SortCameras(Camera[] cameras)
{
if (cameras.Length <= 1)
return;
Array.Sort(cameras, new CameraDataComparer());
if (cameras.Length > 1)
Array.Sort(cameras, cameraComparison);
}

static RenderTextureDescriptor CreateRenderTextureDescriptor(Camera camera, float renderScale,
Expand Down