浏览代码

Fixing tests. Also adding ScriptableRenderContext to OnBeginRendering and removing problematic objects from AnimatedCubeScene.unity

/main
Jon Hogins 4 年前
当前提交
67ab9579
共有 11 个文件被更改,包括 51 次插入158 次删除
  1. 99
      TestProjects/PerceptionURP/Packages/packages-lock.json
  2. 4
      com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBox3DLabeler.cs
  3. 4
      com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBoxLabeler.cs
  4. 8
      com.unity.perception/Runtime/GroundTruth/Labelers/CameraLabeler.cs
  5. 4
      com.unity.perception/Runtime/GroundTruth/Labelers/InstanceSegmentationLabeler.cs
  6. 4
      com.unity.perception/Runtime/GroundTruth/Labelers/ObjectCountLabeler.cs
  7. 4
      com.unity.perception/Runtime/GroundTruth/Labelers/RenderedObjectInfoLabeler.cs
  8. 1
      com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs
  9. 8
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
  10. 18
      com.unity.perception/Tests/Editor/PerceptionCameraEditorTests.cs
  11. 55
      com.unity.perception/Tests/Runtime/TestAssets/AnimatedCubeScene.unity

99
TestProjects/PerceptionURP/Packages/packages-lock.json


{
"dependencies": {
"com.unity.burst": {
"version": "1.3.9",
"version": "1.4.6",
"depth": 1,
"source": "registry",
"dependencies": {

"url": "https://packages.unity.com"
},
"com.unity.collections": {
"version": "0.7.0-preview.2",
"depth": 3,
"source": "registry",
"dependencies": {
"com.unity.test-framework.performance": "1.3.3-preview",
"com.unity.burst": "1.3.0-preview.5"
},
"url": "https://packages.unity.com"
},
"com.unity.entities": {
"version": "0.8.0-preview.8",
"version": "0.9.0-preview.6",
"com.unity.burst": "1.3.0-preview.5",
"com.unity.properties": "0.10.4-preview",
"com.unity.mathematics": "1.1.0",
"com.unity.serialization": "0.6.4-preview",
"com.unity.test-framework.performance": "1.3.3-preview",
"nuget.mono-cecil": "0.1.5-preview",
"com.unity.jobs": "0.2.7-preview.11",
"com.unity.scriptablebuildpipeline": "1.6.4-preview",
"com.unity.platforms": "0.2.1-preview.4"
"com.unity.test-framework.performance": "2.0.8-preview",
"com.unity.burst": "1.3.0-preview.12"
},
"url": "https://packages.unity.com"
},

"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.jobs": {
"version": "0.2.7-preview.11",
"depth": 2,
"source": "registry",
"dependencies": {
"com.unity.collections": "0.7.0-preview.2",
"com.unity.mathematics": "1.1.0"
},
"url": "https://packages.unity.com"
},
"com.unity.mathematics": {
"version": "1.2.1",
"depth": 2,

},
"com.unity.nuget.newtonsoft-json": {
"version": "1.1.2",
"depth": 1,
"version": "2.0.0-preview",
"depth": 3,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"

"depth": 0,
"source": "local",
"dependencies": {
"com.unity.burst": "1.4.6",
"com.unity.collections": "0.9.0-preview.6",
"com.unity.burst": "1.3.9",
"com.unity.entities": "0.8.0-preview.8",
"com.unity.simulation.capture": "0.0.10-preview.19",
"com.unity.simulation.capture": "0.0.10-preview.19",
"com.unity.platforms": {
"version": "0.2.1-preview.4",
"depth": 2,
"source": "registry",
"dependencies": {
"com.unity.nuget.newtonsoft-json": "1.1.2",
"com.unity.properties": "0.10.4-preview",
"com.unity.searcher": "4.0.9",
"com.unity.serialization": "0.6.4-preview"
},
"url": "https://packages.unity.com"
},
"com.unity.properties": {
"version": "0.10.4-preview",
"depth": 2,
"source": "registry",
"dependencies": {
"com.unity.collections": "0.1.1-preview",
"com.unity.test-framework.performance": "1.0.9-preview"
},
"url": "https://packages.unity.com"
},
"com.unity.render-pipelines.core": {
"version": "7.3.1",
"depth": 1,

},
"url": "https://packages.unity.com"
},
"com.unity.scriptablebuildpipeline": {
"version": "1.6.4-preview",
"depth": 2,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.searcher": {
"version": "4.0.9",
"depth": 3,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.serialization": {
"version": "0.6.4-preview",
"depth": 2,
"source": "registry",
"dependencies": {
"com.unity.burst": "1.1.2",
"com.unity.collections": "0.1.1-preview",
"com.unity.jobs": "0.1.1-preview",
"com.unity.mathematics": "1.1.0",
"com.unity.properties": "0.10.4-preview",
"com.unity.test-framework.performance": "1.0.9-preview"
},
"url": "https://packages.unity.com"
},
"com.unity.shadergraph": {
"version": "7.3.1",
"depth": 1,

"url": "https://packages.unity.com"
},
"com.unity.test-framework.performance": {
"version": "1.3.3-preview",
"version": "2.0.8-preview",
"com.unity.modules.jsonserialize": "1.0.0"
"com.unity.nuget.newtonsoft-json": "2.0.0-preview"
},
"url": "https://packages.unity.com"
},

4
com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBox3DLabeler.cs


using System.Diagnostics.CodeAnalysis;
using Unity.Collections;
using Unity.Profiling;
using UnityEngine.Rendering;
namespace UnityEngine.Perception.GroundTruth
{

return corners;
}
/// <param name="scriptableRenderContext"></param>
protected override void OnBeginRendering()
protected override void OnBeginRendering(ScriptableRenderContext scriptableRenderContext)
{
m_CurrentFrame = Time.frameCount;

4
com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBoxLabeler.cs


using Unity.Profiling;
using UnityEngine.Serialization;
using Unity.Simulation;
using UnityEngine.Rendering;
using UnityEngine.UI;
namespace UnityEngine.Perception.GroundTruth

m_Style.alignment = TextAnchor.MiddleLeft;
}
/// <param name="scriptableRenderContext"></param>
protected override void OnBeginRendering()
protected override void OnBeginRendering(ScriptableRenderContext scriptableRenderContext)
{
m_AsyncAnnotations[Time.frameCount] = perceptionCamera.SensorHandle.ReportAnnotationAsync(m_BoundingBoxAnnotationDefinition);
}

8
com.unity.perception/Runtime/GroundTruth/Labelers/CameraLabeler.cs


/// Called during the Update each frame the the labeler is enabled and <see cref="SensorHandle.ShouldCaptureThisFrame"/> is true.
/// </summary>
protected virtual void OnUpdate() {}
protected virtual void OnBeginRendering() {}
/// <param name="scriptableRenderContext">The current context from the Scriptable Render Pipeline.</param>
protected virtual void OnBeginRendering(ScriptableRenderContext scriptableRenderContext) {}
/// <param name="scriptableRenderContext"></param>
/// <param name="scriptableRenderContext">The current context from the Scriptable Render Pipeline.</param>
protected virtual void OnEndRendering(ScriptableRenderContext scriptableRenderContext) {}
/// <summary>
/// Labeling pass to display labeler's visualization components, if applicable. Important note, all labeler's visualizations need

set => visualizationEnabled = value;
}
internal void InternalOnUpdate() => OnUpdate();
internal void InternalOnBeginRendering() => OnBeginRendering();
internal void InternalOnBeginRendering(ScriptableRenderContext context) => OnBeginRendering(context);
internal void InternalOnEndRendering(ScriptableRenderContext context) => OnEndRendering(context);
internal void InternalCleanup() => Cleanup();
internal void InternalVisualize() => OnVisualize();

4
com.unity.perception/Runtime/GroundTruth/Labelers/InstanceSegmentationLabeler.cs


using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
namespace UnityEngine.Perception.GroundTruth
{

}
}
/// <param name="scriptableRenderContext"></param>
protected override void OnBeginRendering()
protected override void OnBeginRendering(ScriptableRenderContext scriptableRenderContext)
{
m_AsyncAnnotations[Time.frameCount] = perceptionCamera.SensorHandle.ReportAnnotationAsync(m_AnnotationDefinition);
}

4
com.unity.perception/Runtime/GroundTruth/Labelers/ObjectCountLabeler.cs


using System.Diagnostics.CodeAnalysis;
using Unity.Collections;
using Unity.Profiling;
using UnityEngine.Rendering;
using UnityEngine.UI;
namespace UnityEngine.Perception.GroundTruth

visualizationEnabled = supportsVisualization;
}
/// <param name="scriptableRenderContext"></param>
protected override void OnBeginRendering()
protected override void OnBeginRendering(ScriptableRenderContext scriptableRenderContext)
{
if (m_ObjectCountMetricDefinition.Equals(default))
{

4
com.unity.perception/Runtime/GroundTruth/Labelers/RenderedObjectInfoLabeler.cs


using JetBrains.Annotations;
using Unity.Collections;
using Unity.Profiling;
using UnityEngine.Rendering;
using UnityEngine.Serialization;
using UnityEngine.UI;

visualizationEnabled = supportsVisualization;
}
/// <param name="scriptableRenderContext"></param>
protected override void OnBeginRendering()
protected override void OnBeginRendering(ScriptableRenderContext scriptableRenderContext)
{
if (m_RenderedObjectInfoMetricDefinition.Equals(default))
{

1
com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs


using Unity.Simulation;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
#if HDRP_PRESENT
using UnityEngine.Rendering.HighDefinition;

8
com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs


RenderPipelineManager.endCameraRendering += CheckForRendererFeature;
}
void Update()
// LateUpdate is called once per frame. It is called after coroutines, ensuring it is called properly after
// creation when running tests, since the test runner uses coroutines to run test code.
void LateUpdate()
{
EnsureSensorRegistered();
if (!SensorHandle.IsValid)

m_LastFrameCaptured = Time.frameCount;
CaptureRgbData(cam);
CallOnLabelers(l => l.InternalOnBeginRendering());
CallOnLabelers(l => l.InternalOnBeginRendering(scriptableRenderContext));
}
void OnEndCameraRendering(ScriptableRenderContext scriptableRenderContext, Camera cam)

m_LastFrameEndRendering = Time.frameCount;
CaptureInstanceSegmentation(scriptableRenderContext);
CaptureInstanceSegmentation(scriptableRenderContext);
}
void CallOnLabelers(Action<CameraLabeler> action)

18
com.unity.perception/Tests/Editor/PerceptionCameraEditorTests.cs


#if MOQ_PRESENT
using Moq;
using Moq.Protected;
using UnityEngine.Rendering;
#endif
namespace EditorTests

mockLabeler.Protected().Verify("Setup", Times.Once());
mockLabeler.Protected().Verify("OnUpdate", Times.Once());
mockLabeler.Protected().Verify("OnBeginRendering", Times.Once());
mockLabeler.Protected().Verify("OnEndRendering", Times.Once());
mockLabeler.Protected().Verify("OnBeginRendering", Times.Once(), ItExpr.IsAny<ScriptableRenderContext>());
mockLabeler.Protected().Verify("OnEndRendering", Times.Once(), ItExpr.IsAny<ScriptableRenderContext>());
yield return new ExitPlayMode();
}
[UnityTest]

mockLabeler.Protected().Verify("Setup", Times.Once());
mockLabeler.Protected().Verify("OnUpdate", Times.Once());
mockLabeler.Protected().Verify("OnBeginRendering", Times.Once());
mockLabeler.Protected().Verify("OnEndRendering", Times.Once());
mockLabeler.Protected().Verify("OnBeginRendering", Times.Once(), ItExpr.IsAny<ScriptableRenderContext>());
mockLabeler.Protected().Verify("OnEndRendering", Times.Once(), ItExpr.IsAny<ScriptableRenderContext>());
yield return new ExitPlayMode();
}
[UnityTest]

yield return null;
mockLabeler.Protected().Verify("Setup", Times.Never());
mockLabeler.Protected().Verify("OnUpdate", Times.Never());
mockLabeler.Protected().Verify("OnBeginRendering", Times.Never());
mockLabeler.Protected().Verify("OnEndRendering", Times.Never());
mockLabeler.Protected().Verify("OnBeginRendering", Times.Never(), It.IsAny<ScriptableRenderContext>());
mockLabeler.Protected().Verify("OnEndRendering", Times.Never(), It.IsAny<ScriptableRenderContext>());
mockLabeler.Protected().Verify("Cleanup", Times.Never());
yield return new ExitPlayMode();
}

yield return null;
mockLabeler.Protected().Verify("Setup", Times.Once());
mockLabeler.Protected().Verify("OnUpdate", Times.Never());
mockLabeler.Protected().Verify("OnBeginRendering", Times.Never());
mockLabeler.Protected().Verify("OnEndRendering", Times.Never());
mockLabeler.Protected().Verify("OnBeginRendering", Times.Never(), It.IsAny<ScriptableRenderContext>());
mockLabeler.Protected().Verify("OnEndRendering", Times.Never(), It.IsAny<ScriptableRenderContext>());
Assert.IsFalse(labeler.enabled);
yield return new ExitPlayMode();
}

55
com.unity.perception/Tests/Runtime/TestAssets/AnimatedCubeScene.unity


m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_AmbientMode: 3
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5

LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 1
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1

m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
m_UseShadowmask: 0
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2

value: AnimatedCube
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 19412e53743b3814da68e59d98ab6794, type: 3}
--- !u!1 &2024690174
GameObject:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2024690176}
- component: {fileID: 2024690175}
m_Layer: 0
m_Name: StaticLightingSky
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &2024690175
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2024690174}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 441482e8936e35048a1dffac814e3ef8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Profile: {fileID: 0}
m_StaticLightingSkyUniqueID: 0
m_SkySettings: {fileID: 0}
m_SkySettingsFromProfile: {fileID: 0}
--- !u!4 &2024690176
Transform:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2024690174}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_SourcePrefab: {fileID: 100100000, guid: 19412e53743b3814da68e59d98ab6794, type: 3}
正在加载...
取消
保存