From 76a3a0a0f0e6c4c8cb69e8bfd4e83993b7e9b578 Mon Sep 17 00:00:00 2001 From: Andrew Haydn Grant Date: Thu, 13 Oct 2022 14:14:30 -0400 Subject: [PATCH 1/2] Fixed bug where the render texture cache would yield disposed textures --- .../SemanticSegmentationLabeler.cs | 2 +- .../Runtime/GroundTruth/RenderTextureReader.cs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentation/SemanticSegmentationLabeler.cs b/com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentation/SemanticSegmentationLabeler.cs index 57c43b0bd..6e5afa6d3 100644 --- a/com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentation/SemanticSegmentationLabeler.cs +++ b/com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentation/SemanticSegmentationLabeler.cs @@ -227,7 +227,7 @@ protected override void OnEndRendering(ScriptableRenderContext scriptableRenderC /// protected override void Cleanup() { - + Debug.Log("Cleaning UP"); if (m_TargetTextureOverride != null) m_TargetTextureOverride.Release(); diff --git a/com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs b/com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs index 2a83264e9..2ea271638 100644 --- a/com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs +++ b/com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs @@ -37,6 +37,11 @@ public static void Capture(ScriptableRenderContext context, RenderTexture sou else { var cpuTexture = GetTextureFromCache(sourceTex.width, sourceTex.height, sourceTex.graphicsFormat); + if (!cpuTexture) + { + Debug.LogWarning("No texture from cache found!"); + return; + } RenderTexture.active = sourceTex; cpuTexture.ReadPixels(new Rect(0, 0, sourceTex.width, sourceTex.height), 0, 0); cpuTexture.Apply(); @@ -73,7 +78,10 @@ static void OnGpuReadback(AsyncGPUReadbackRequest request, int frameCount, Re static Texture2D GetTextureFromCache(int width, int height, GraphicsFormat graphicsFormat) { if (s_CachedCpuTextures.TryGetValue((width, height, graphicsFormat), out var texture)) - return texture; + { + if (null != texture) return texture; + Debug.LogWarning("Found disposed or null texture in cache"); + } var newTexture = new Texture2D(width, height, graphicsFormat, TextureCreationFlags.None); s_CachedCpuTextures[(width, height, graphicsFormat)] = newTexture; return newTexture; From 4092b3dd2dcb4eb2b8e0b013f579491171e6280c Mon Sep 17 00:00:00 2001 From: Andrew Haydn Grant Date: Tue, 8 Nov 2022 09:51:33 -0500 Subject: [PATCH 2/2] Version upgrades --- .../PerceptionURP/Packages/packages-lock.json | 33 +++++++------------ .../ProjectSettings/ProjectVersion.txt | 4 +-- .../UserSettings/EditorUserSettings.asset | 6 ++-- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/TestProjects/PerceptionURP/Packages/packages-lock.json b/TestProjects/PerceptionURP/Packages/packages-lock.json index 8957ba5ac..5174496e5 100644 --- a/TestProjects/PerceptionURP/Packages/packages-lock.json +++ b/TestProjects/PerceptionURP/Packages/packages-lock.json @@ -1,7 +1,7 @@ { "dependencies": { "com.unity.burst": { - "version": "1.4.6", + "version": "1.5.6", "depth": 1, "source": "registry", "dependencies": { @@ -19,12 +19,12 @@ "url": "https://packages.unity.com" }, "com.unity.collections": { - "version": "0.9.0-preview.6", + "version": "1.1.0", "depth": 1, "source": "registry", "dependencies": { - "com.unity.test-framework.performance": "2.0.8-preview", - "com.unity.burst": "1.3.0-preview.12" + "com.unity.burst": "1.5.4", + "com.unity.test-framework": "1.1.29" }, "url": "https://packages.unity.com" }, @@ -97,12 +97,10 @@ "depth": 0, "source": "local", "dependencies": { - "com.unity.burst": "1.4.6", - "com.unity.collections": "0.9.0-preview.6", + "com.unity.burst": "1.5.6", + "com.unity.collections": "1.1.0", "com.unity.nuget.newtonsoft-json": "1.1.2", - "com.unity.render-pipelines.core": "7.1.6", - "com.unity.simulation.client": "0.0.10-preview.10", - "com.unity.simulation.core": "0.0.10-preview.25" + "com.unity.render-pipelines.core": "7.1.6" } }, "com.unity.render-pipelines.core": { @@ -153,13 +151,6 @@ }, "url": "https://packages.unity.com" }, - "com.unity.simulation.client": { - "version": "0.0.10-preview.10", - "depth": 1, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, "com.unity.simulation.core": { "version": "0.0.10-preview.26", "depth": 0, @@ -186,8 +177,8 @@ "url": "https://packages.unity.com" }, "com.unity.test-framework": { - "version": "1.1.27", - "depth": 0, + "version": "1.1.29", + "depth": 2, "source": "registry", "dependencies": { "com.unity.ext.nunit": "1.0.6", @@ -197,12 +188,12 @@ "url": "https://packages.unity.com" }, "com.unity.test-framework.performance": { - "version": "2.0.8-preview", - "depth": 2, + "version": "2.8.0-preview", + "depth": 0, "source": "registry", "dependencies": { "com.unity.test-framework": "1.1.0", - "com.unity.nuget.newtonsoft-json": "2.0.0-preview" + "com.unity.modules.jsonserialize": "1.0.0" }, "url": "https://packages.unity.com" }, diff --git a/TestProjects/PerceptionURP/ProjectSettings/ProjectVersion.txt b/TestProjects/PerceptionURP/ProjectSettings/ProjectVersion.txt index 39e912552..e610e2826 100644 --- a/TestProjects/PerceptionURP/ProjectSettings/ProjectVersion.txt +++ b/TestProjects/PerceptionURP/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2020.3.19f1 -m_EditorVersionWithRevision: 2020.3.19f1 (68f137dc9bbe) +m_EditorVersion: 2020.3.11f1 +m_EditorVersionWithRevision: 2020.3.11f1 (99c7afb366b3) diff --git a/TestProjects/PerceptionURP/UserSettings/EditorUserSettings.asset b/TestProjects/PerceptionURP/UserSettings/EditorUserSettings.asset index d865d5230..2d4d51d36 100644 --- a/TestProjects/PerceptionURP/UserSettings/EditorUserSettings.asset +++ b/TestProjects/PerceptionURP/UserSettings/EditorUserSettings.asset @@ -6,13 +6,13 @@ EditorUserSettings: serializedVersion: 4 m_ConfigSettings: RecentlyUsedScenePath-0: - value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2805183df1c43d2bf6e824fdee3531722c0ce6281d + value: 22424703114646680e0b0227036c6f1f05122b2b21382a35633c133af6f9 flags: 0 RecentlyUsedScenePath-1: - value: 22424703114646680e0b0227036c6f1f05122b2b21382a35633c133af6f9 + value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d flags: 0 RecentlyUsedScenePath-2: - value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d + value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2805183df1c43d2bf6e824fdee3531722c0ce6281d flags: 0 vcSharedLogLevel: value: 0d5e400f0650