浏览代码

Cleanup rider warnings.

/main
Jon Hogins 5 年前
当前提交
0fe2ab98
共有 16 个文件被更改,包括 83 次插入125 次删除
  1. 4
      TestProjects/PerceptionHDRP/Assets/Rotator.cs
  2. 4
      TestProjects/PerceptionURP/Assets/Rotator.cs
  3. 1
      com.unity.perception/Editor/GroundTruth/InstanceSegmentationPassEditor.cs
  4. 2
      com.unity.perception/Editor/GroundTruth/ObjectCountPassEditor.cs
  5. 2
      com.unity.perception/Editor/GroundTruth/SemanticSegmentationPassEditor.cs
  6. 1
      com.unity.perception/Runtime/GroundTruth/GroundTruthPass.cs
  7. 82
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
  8. 3
      com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs
  9. 1
      com.unity.perception/Runtime/GroundTruth/RenderedObjectInfo.cs
  10. 2
      com.unity.perception/Runtime/GroundTruth/RenderedObjectInfoGenerator.cs
  11. 59
      com.unity.perception/Tests/Editor/BuildPerceptionPlayer.cs
  12. 10
      com.unity.perception/Tests/Runtime/GroundTruthTests/GroundTruthTestBase.cs
  13. 28
      com.unity.perception/Tests/Runtime/GroundTruthTests/ObjectCountTests.cs
  14. 9
      com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerSensorSchedulingTests.cs
  15. 0
      /com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerSensorSchedulingTests.cs.meta
  16. 0
      /com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerSensorSchedulingTests.cs

4
TestProjects/PerceptionHDRP/Assets/Rotator.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
public class Rotator : MonoBehaviour
{

4
TestProjects/PerceptionURP/Assets/Rotator.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
public class Rotator : MonoBehaviour
{

1
com.unity.perception/Editor/GroundTruth/InstanceSegmentationPassEditor.cs


#if HDRP_PRESENT
using UnityEditor;
using UnityEditor.Rendering.HighDefinition;
using UnityEngine.Perception.GroundTruth;

2
com.unity.perception/Editor/GroundTruth/ObjectCountPassEditor.cs


#if HDRP_PRESENT
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Rendering.HighDefinition;
using UnityEngine.Perception.GroundTruth;

2
com.unity.perception/Editor/GroundTruth/SemanticSegmentationPassEditor.cs


#if HDRP_PRESENT
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Rendering.HighDefinition;
using UnityEngine.Perception.GroundTruth;

1
com.unity.perception/Runtime/GroundTruth/GroundTruthPass.cs


using System;
using Unity.Entities;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;

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


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

/// <summary>
/// The ID to use for object count annotations in the resulting dataset
/// </summary>
public string m_ObjectCountID = "51DA3C27-369D-4929-AEA6-D01614635CE2";
[FormerlySerializedAs("m_ObjectCountID")]
public string objectCountId = "51DA3C27-369D-4929-AEA6-D01614635CE2";
/// <summary>
/// Whether object bounding boxes should be computed
/// </summary>

/// </summary>
public string m_BoundingBoxID = "F9F22E05-443F-4602-A422-EBE4EA9B55CB";
[FormerlySerializedAs("m_BoundingBoxID")]
public string boundingBoxId = "F9F22E05-443F-4602-A422-EBE4EA9B55CB";
/// <summary>
/// Whether visible pixels should be computed for each labeled object
/// </summary>

/// </summary>
public string m_VisiblePixelsID = "5BA92024-B3B7-41A7-9D3F-C03A6A8DDD01";
[FormerlySerializedAs("m_VisiblePixelsID")]
public string visiblePixelsId = "5BA92024-B3B7-41A7-9D3F-C03A6A8DDD01";
/// <summary>
/// The corner of the image to use as the origin for bounding boxs.
/// </summary>

internal event Action<NativeSlice<uint>, IReadOnlyList<LabelingConfigurationEntry>, int> classCountsReceived;
[NonSerialized]
internal RenderTexture m_LabelingTexture;
internal RenderTexture labelingTexture;
internal RenderTexture m_SegmentationTexture;
internal RenderTexture segmentationTexture;
RenderTextureReader<short> m_ClassLabelingTextureReader;
RenderTextureReader<uint> m_SegmentationReader;

produceBoundingBoxAnnotations = false;
}
m_SegmentationTexture = new RenderTexture(new RenderTextureDescriptor(width, height, GraphicsFormat.R8G8B8A8_UNorm, 8));
m_SegmentationTexture.name = "Segmentation";
m_LabelingTexture = new RenderTexture(new RenderTextureDescriptor(width, height, GraphicsFormat.R8G8B8A8_UNorm, 8));
m_LabelingTexture.name = "Labeling";
segmentationTexture = new RenderTexture(new RenderTextureDescriptor(width, height, GraphicsFormat.R8G8B8A8_UNorm, 8));
segmentationTexture.name = "Segmentation";
labelingTexture = new RenderTexture(new RenderTextureDescriptor(width, height, GraphicsFormat.R8G8B8A8_UNorm, 8));
labelingTexture.name = "Labeling";
#if HDRP_PRESENT
var customPassVolume = this.GetComponent<CustomPassVolume>() ?? gameObject.AddComponent<CustomPassVolume>();

{
name = "Segmentation Pass",
targetCamera = myCamera,
targetTexture = m_SegmentationTexture
targetTexture = segmentationTexture
m_SemanticSegmentationPass = new SemanticSegmentationPass(myCamera, m_LabelingTexture, LabelingConfiguration)
m_SemanticSegmentationPass = new SemanticSegmentationPass(myCamera, labelingTexture, LabelingConfiguration)
{
name = "Labeling Pass"
};

#if URP_PRESENT
instanceSegmentationUrpPass = new InstanceSegmentationUrpPass(myCamera, m_SegmentationTexture);
semanticSegmentationUrpPass = new SemanticSegmentationUrpPass(myCamera, m_LabelingTexture, LabelingConfiguration);
instanceSegmentationUrpPass = new InstanceSegmentationUrpPass(myCamera, segmentationTexture);
semanticSegmentationUrpPass = new SemanticSegmentationUrpPass(myCamera, labelingTexture, LabelingConfiguration);
#endif
if (produceSegmentationImages)

m_SegmentationAnnotationDefinition = SimulationManager.RegisterAnnotationDefinition("semantic segmentation", specs, "pixel-wise semantic segmentation label", "PNG");
m_ClassLabelingTextureReader = new RenderTextureReader<short>(m_LabelingTexture, myCamera,
m_ClassLabelingTextureReader = new RenderTextureReader<short>(labelingTexture, myCamera,
(frameCount, data, tex) => OnSemanticSegmentationImageRead(frameCount, data));
}

if (produceObjectCountAnnotations)
{
m_ObjectCountMetricDefinition = SimulationManager.RegisterMetricDefinition("object count", labelingMetricSpec, "Counts of objects for each label in the sensor's view", id: new Guid(m_ObjectCountID));
m_ObjectCountMetricDefinition = SimulationManager.RegisterMetricDefinition("object count", labelingMetricSpec, "Counts of objects for each label in the sensor's view", id: new Guid(objectCountId));
m_BoundingBoxAnnotationDefinition = SimulationManager.RegisterAnnotationDefinition("bounding box", labelingMetricSpec, "Bounding boxe for each labeled object visible to the sensor", id: new Guid(m_BoundingBoxID));
m_BoundingBoxAnnotationDefinition = SimulationManager.RegisterAnnotationDefinition("bounding box", labelingMetricSpec, "Bounding boxe for each labeled object visible to the sensor", id: new Guid(boundingBoxId));
m_VisiblePixelsMetricDefinition = SimulationManager.RegisterMetricDefinition("visible pixels", labelingMetricSpec, "Visible pixels for each visible object", id: new Guid(m_VisiblePixelsID));
m_VisiblePixelsMetricDefinition = SimulationManager.RegisterMetricDefinition("visible pixels", labelingMetricSpec, "Visible pixels for each visible object", id: new Guid(visiblePixelsId));
m_SegmentationReader = new RenderTextureReader<uint>(m_SegmentationTexture, myCamera, (frameCount, data, tex) =>
m_SegmentationReader = new RenderTextureReader<uint>(segmentationTexture, myCamera, (frameCount, data, tex) =>
{
if (segmentationImageReceived != null)
segmentationImageReceived(frameCount, data);

SimulationManager.SimulationEnding += OnSimulationEnding;
}
// ReSharper disable InconsistentNaming
[UsedImplicitly]
[UsedImplicitly]
[UsedImplicitly]
// ReSharper restore InconsistentNaming
void ProduceVisiblePixelsMetric(NativeArray<RenderedObjectInfo> renderedObjectInfos, int frameCount)
{

if (!SensorHandle.IsValid)
return;
var camera = this.GetComponent<Camera>();
camera.enabled = SensorHandle.ShouldCaptureThisFrame;
var cam = GetComponent<Camera>();
cam.enabled = SensorHandle.ShouldCaptureThisFrame;
m_AsyncCaptureInfos.RemoveSwapBack(i =>
!i.SegmentationAsyncAnnotation.IsPending &&

}
}
void CaptureRgbData(Camera camera)
void CaptureRgbData(Camera cam)
{
Profiler.BeginSample("CaptureDataFromLastFrame");
if (!captureRgbImages)

SensorHandle.ReportCapture(dxRootPath, SensorSpatialData.FromGameObjects(m_EgoMarker == null ? null : m_EgoMarker.gameObject, gameObject), m_PersistentSensorData.Select(kvp => (kvp.Key, kvp.Value)).ToArray());
Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> colorFunctor = null;
var width = camera.pixelWidth;
var height = camera.pixelHeight;
var flipY = ShouldFlipY(camera);
var width = cam.pixelWidth;
var height = cam.pixelHeight;
var flipY = ShouldFlipY(cam);
colorFunctor = r =>
{

}
};
CaptureCamera.Capture(camera, colorFunctor);
CaptureCamera.Capture(cam, colorFunctor);
Profiler.EndSample();
}

RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering;
}
void OnBeginCameraRendering(ScriptableRenderContext _, Camera camera)
void OnBeginCameraRendering(ScriptableRenderContext _, Camera cam)
if (camera != GetComponent<Camera>())
if (cam != GetComponent<Camera>())
return;
#if UNITY_EDITOR
if (UnityEditor.EditorApplication.isPaused)

CaptureRgbData(camera);
CaptureRgbData(cam);
}
void OnDisable()

m_ClassLabelingTextureReader?.Dispose();
m_ClassLabelingTextureReader = null;
if (m_SegmentationTexture != null)
m_SegmentationTexture.Release();
if (segmentationTexture != null)
segmentationTexture.Release();
m_SegmentationTexture = null;
if (m_LabelingTexture != null)
m_LabelingTexture.Release();
segmentationTexture = null;
if (labelingTexture != null)
labelingTexture.Release();
if (m_RenderedObjectInfoGenerator != null)
{

SensorHandle = default;
m_LabelingTexture = null;
labelingTexture = null;
}
void OnSemanticSegmentationImageRead(int frameCount, NativeArray<short> data)

asyncRequest.data = new AsyncSemanticSegmentationWrite()
{
dataArray = data.ToArray(),
width = m_LabelingTexture.width,
height = m_LabelingTexture.height,
width = labelingTexture.width,
height = labelingTexture.height,
path = path
};
asyncRequest.Start((r) =>

3
com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs


using System;
using System.Linq;
using Unity.Collections;
using Unity.Profiling;
using Unity.Simulation;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;

Texture2D m_CpuTexture;
Camera m_CameraRenderingToSource;
ProfilerMarker m_WaitingForCompletionMarker = new ProfilerMarker("RenderTextureReader_WaitingForCompletion");
/// <summary>
/// Creates a new <see cref="RenderTextureReader{T}"/> for the given <see cref="RenderTexture"/>, <see cref="Camera"/>, and image readback callback

1
com.unity.perception/Runtime/GroundTruth/RenderedObjectInfo.cs


using System;
// ReSharper disable NonReadonlyMemberInGetHashCode
namespace UnityEngine.Perception.GroundTruth
{

2
com.unity.perception/Runtime/GroundTruth/RenderedObjectInfoGenerator.cs


NativeList<int> m_InstanceIdToClassIdLookup;
LabelingConfiguration m_LabelingConfiguration;
// ReSharper disable once InvalidXmlDocComment
/// <summary>
/// Create a new CpuRenderedObjectInfoPass with the given LabelingConfiguration.
/// </summary>

59
com.unity.perception/Tests/Editor/BuildPerceptionPlayer.cs


using System;
using System.Collections.Generic;
using System.IO;
using NUnit.Framework;
using UnityEditor;
using UnityEditor.Build.Reporting;

{
public class BuildPerceptionPlayer
{
public List<EditorBuildSettingsScene> editorBuildSettingsScenes = new List<EditorBuildSettingsScene>();
public List<string> testScenesPaths = new List<string>();
public string testSceneBase = "default base scene";
private BuildReport report;
private BuildSummary summary;
private string buildPath = "Build/PerceptionBuild";
List<EditorBuildSettingsScene> m_EditorBuildSettingsScenes = new List<EditorBuildSettingsScene>();
BuildSummary m_Summary;
string m_BuildPath = "Build/PerceptionBuild";
[SetUp]
public void SetUp()

[Test]
public void BuildPlayerStandaloneWindows64()
{
BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64, buildPath, BuildOptions.IncludeTestAssemblies, out report, out summary);
Assert.AreEqual(BuildResult.Succeeded, summary.result, " BuildTarget.StandaloneWindows64 failed to build");
BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64, m_BuildPath, BuildOptions.IncludeTestAssemblies, out _, out m_Summary);
Assert.AreEqual(BuildResult.Succeeded, m_Summary.result, " BuildTarget.StandaloneWindows64 failed to build");
}
[RequirePlatformSupport(BuildTarget.StandaloneLinux64)]

BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneLinux64, buildPath, BuildOptions.IncludeTestAssemblies, out report, out summary);
Assert.AreEqual(BuildResult.Succeeded, summary.result, "BuildTarget.StandaloneLinux64 failed to build");
BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneLinux64, m_BuildPath, BuildOptions.IncludeTestAssemblies, out _, out m_Summary);
Assert.AreEqual(BuildResult.Succeeded, m_Summary.result, "BuildTarget.StandaloneLinux64 failed to build");
}
[UnityPlatform(RuntimePlatform.OSXEditor)]

{
BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneOSX, buildPath, BuildOptions.IncludeTestAssemblies, out report, out summary);
Assert.AreEqual(BuildResult.Succeeded, summary.result, "BuildTarget.StandaloneLinux64 failed to build");
BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneOSX, m_BuildPath, BuildOptions.IncludeTestAssemblies, out _, out m_Summary);
Assert.AreEqual(BuildResult.Succeeded, m_Summary.result, "BuildTarget.StandaloneLinux64 failed to build");
}
public void TestsScenesPath()

{
if (targetPath.Contains("BaseScene.unity"))
{
testSceneBase = targetPath;
editorBuildSettingsScenes.Add(new EditorBuildSettingsScene(targetPath, true));
m_EditorBuildSettingsScenes.Add(new EditorBuildSettingsScene(targetPath, true));
testScenesPaths.Add(targetPath);
editorBuildSettingsScenes.Add(new EditorBuildSettingsScene(targetPath, true));
m_EditorBuildSettingsScenes.Add(new EditorBuildSettingsScene(targetPath, true));
EditorBuildSettings.scenes = editorBuildSettingsScenes.ToArray();
EditorBuildSettings.scenes = m_EditorBuildSettingsScenes.ToArray();
public void BuildPlayer(BuildTargetGroup buildTargetGroup, BuildTarget buildTarget, string buildOutputPath, BuildOptions buildOptions,
void BuildPlayer(BuildTargetGroup buildTargetGroup, BuildTarget buildTarget, string buildOutputPath, BuildOptions buildOptions,
out BuildReport buildReport, out BuildSummary buildSummary)
{
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();

buildPlayerOptions.targetGroup = buildTargetGroup;
if (buildTarget == BuildTarget.StandaloneLinux64)
TurnOffBurstCompiler();
}
public void TurnOffBurstCompiler()
{
var newLine = Environment.NewLine;
const string BurstAOTSettingsFilePath = "ProjectSettings/BurstAotSettings_StandaloneLinux64.json";
string[] BurstAOTSettingsText = new[]
{
"{" + newLine,
@" ""MonoBehaviour"": {" ,
@" ""m_EditorHideFlags"": 0,",
@" ""m_Name"": """",",
@" ""m_EditorClassIdentifier"":""Unity.Burst.Editor:Unity.Burst.Editor:BurstPlatformAotSettings"",",
@" ""DisableOptimisations"": false,",
@" ""DisableSafetyChecks"": true,",
@" ""DisableBurstCompilation"": true",
" }",
"}"
};
File.WriteAllLines(BurstAOTSettingsFilePath, BurstAOTSettingsText);
AssetDatabase.Refresh();
}
}
}

10
com.unity.perception/Tests/Runtime/GroundTruthTests/GroundTruthTestBase.cs


{
public class GroundTruthTestBase
{
List<GameObject> objectsToDestroy = new List<GameObject>();
List<GameObject> m_ObjectsToDestroy = new List<GameObject>();
foreach (var o in objectsToDestroy)
foreach (var o in m_ObjectsToDestroy)
objectsToDestroy.Clear();
m_ObjectsToDestroy.Clear();
SimulationManager.ResetSimulation();
Time.timeScale = 1;

public void AddTestObjectForCleanup(GameObject @object) => objectsToDestroy.Add(@object);
public void AddTestObjectForCleanup(GameObject @object) => m_ObjectsToDestroy.Add(@object);
objectsToDestroy.Remove(@object);
m_ObjectsToDestroy.Remove(@object);
}
}
}

28
com.unity.perception/Tests/Runtime/GroundTruthTests/ObjectCountTests.cs


using UnityEngine;
using UnityEngine.Perception.GroundTruth;
using UnityEngine.TestTools;
using Object = UnityEngine.Object;
#if HDRP_PRESENT
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering.HighDefinition;

//Put a plane in front of the camera
var planeObject = TestHelper.CreateLabeledPlane(.1f, label);
yield return null;
GameObject.DestroyImmediate(planeObject);
Object.DestroyImmediate(planeObject);
planeObject = TestHelper.CreateLabeledPlane(.1f, label);
yield return null;
var planeObject2 = TestHelper.CreateLabeledPlane(.1f, label);

GameObject.DestroyImmediate(planeObject);
Object.DestroyImmediate(planeObject);
GameObject.DestroyImmediate(planeObject2);
Object.DestroyImmediate(planeObject2);
#if HDRP_PRESENT
//TODO: Remove this when DestroyImmediate properly calls Cleanup on the pass
var labelHistogramPass = (ObjectCountPass)cameraObject.GetComponent<CustomPassVolume>().customPasses.First(p => p is ObjectCountPass);

customPassVolume.isGlobal = true;
var rt = new RenderTexture(128, 128, 1, GraphicsFormat.R8G8B8A8_UNorm);
rt.Create();
var InstanceSegmentationPass = new InstanceSegmentationPass()
var instanceSegmentationPass = new InstanceSegmentationPass()
InstanceSegmentationPass.name = nameof(InstanceSegmentationPass);
InstanceSegmentationPass.EnsureInit();
customPassVolume.customPasses.Add(InstanceSegmentationPass);
var ObjectCountPass = new ObjectCountPass(camera);
ObjectCountPass.SegmentationTexture = rt;
ObjectCountPass.LabelingConfiguration = labelingConfiguration;
ObjectCountPass.name = nameof(ObjectCountPass);
customPassVolume.customPasses.Add(ObjectCountPass);
instanceSegmentationPass.name = nameof(instanceSegmentationPass);
instanceSegmentationPass.EnsureInit();
customPassVolume.customPasses.Add(instanceSegmentationPass);
var objectCountPass = new ObjectCountPass(camera);
objectCountPass.SegmentationTexture = rt;
objectCountPass.LabelingConfiguration = labelingConfiguration;
objectCountPass.name = nameof(objectCountPass);
customPassVolume.customPasses.Add(objectCountPass);
ObjectCountPass.ClassCountsReceived += onClassCountsReceived;
objectCountPass.ClassCountsReceived += onClassCountsReceived;
#endif
#if URP_PRESENT
var perceptionCamera = cameraObject.AddComponent<PerceptionCamera>();

9
com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerSensorSchedulingTests.cs


namespace GroundTruthTests
{
[TestFixture]
public class SimulationManager_SensorSchedulingTests
public class SimulationManagerSensorSchedulingTests
{
[TearDown]
public void TearDown()

newTimeScalesPerFrame[2] * period,
newTimeScalesPerFrame[3] * period
};
float[] unscaledDeltaTimeSamplesExpected = {
firstCaptureTime,
period,
period,
period
};
float[] deltaTimeSamples = new float[deltaTimeSamplesExpected.Length];
for (int i = 0; i < deltaTimeSamples.Length; i++)
{

//Assert.AreEqual(unscaledDeltaTimeSamplesExpected[i], Time.unscaledDeltaTime, 0.0001f);
}
}

/com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManager_SensorSchedulingTests.cs.meta → /com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerSensorSchedulingTests.cs.meta

/com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManager_SensorSchedulingTests.cs → /com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerSensorSchedulingTests.cs

正在加载...
取消
保存