浏览代码

Updates from previous repository.

/main
Jon Hogins 5 年前
当前提交
bee1a474
共有 5 个文件被更改,包括 12 次插入186 次删除
  1. 2
      com.unity.perception/LICENSE.md
  2. 32
      com.unity.perception/Runtime/GroundTruth/GroundTruthPass.cs
  3. 22
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
  4. 70
      com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs
  5. 72
      com.unity.perception/Third Party Notices.md

2
com.unity.perception/LICENSE.md


Perception copyright © 2019 Unity Technologies ApS
Perception copyright © 2020 Unity Technologies ApS
Unless expressly provided otherwise, the Software under this license is made available strictly on an “AS IS” BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. Please review the license for details on these and other terms and conditions.

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


var labelSetupSystem = World.DefaultGameObjectInjectionWorld?.GetExistingSystem<GroundTruthLabelSetupSystem>();
labelSetupSystem?.Deactivate(this);
}
protected RendererListDesc CreateRendererListDesc(HDCamera hdCamera, CullingResults cullingResult, string overrideMaterialPassName, int overrideMaterialPassIndex, Material overrideMaterial, LayerMask layerMask)
{
var shaderPasses = new[]
{
new ShaderTagId("Forward"), // HD Lit shader
new ShaderTagId("ForwardOnly"), // HD Unlit shader
new ShaderTagId("SRPDefaultUnlit"), // Cross SRP Unlit shader
new ShaderTagId(overrideMaterialPassName), // The override material shader
};
var stateBlock = new RenderStateBlock(0)
{
depthState = new DepthState(true, CompareFunction.LessEqual),
};
PerObjectData renderConfig = hdCamera.frameSettings.IsEnabled(FrameSettingsField.Shadowmask) ? HDUtils.k_RendererConfigurationBakedLightingWithShadowMask : HDUtils.k_RendererConfigurationBakedLighting;
var result = new RendererListDesc(shaderPasses, cullingResult, hdCamera.camera)
{
rendererConfiguration = renderConfig,
renderQueueRange = GetRenderQueueRange(RenderQueueType.All),
sortingCriteria = SortingCriteria.CommonOpaque,
excludeObjectMotionVectors = false,
overrideMaterial = overrideMaterial,
overrideMaterialPassIndex = overrideMaterialPassIndex,
stateBlock = stateBlock,
layerMask = layerMask,
};
return result;
}
}
}
#endif

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


#if HDRP_PRESENT
InstanceSegmentationPass m_SegmentationPass;
SemanticSegmentationPass m_SemanticSegmentationPass;
ObjectCountPass m_ObjectCountPass;
#endif
MetricDefinition m_ObjectCountMetricDefinition;
AnnotationDefinition m_BoundingBoxAnnotationDefinition;

{
name = "Labeling Pass"
};
m_ObjectCountPass = new ObjectCountPass(myCamera)
{
name = "Label Histogram Pass",
SegmentationTexture = m_SegmentationTexture,
LabelingConfiguration = LabelingConfiguration,
WriteToLog = false
};
m_ObjectCountPass.ClassCountsReceived += OnClassCountsReceived;
SetupPasses(customPassVolume);
#endif

{
customPassVolume.customPasses.Remove(m_SegmentationPass);
customPassVolume.customPasses.Remove(m_SemanticSegmentationPass);
customPassVolume.customPasses.Remove(m_ObjectCountPass);
if (produceSegmentationImages || produceObjectCountAnnotations)
customPassVolume.customPasses.Add(m_SegmentationPass);

if (produceObjectCountAnnotations)
{
customPassVolume.customPasses.Add(m_ObjectCountPass);
}
}
#endif

//Based on logic in HDRenderPipeline.PrepareFinalBlitParameters
return camera.targetTexture != null || hdAdditionalCameraData.flipYMode == HDAdditionalCameraData.FlipYMode.ForceFlipY || camera.cameraType == CameraType.Game;
#elif URP_PRESENT
return false;
return SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 && (camera.targetTexture != null || camera.cameraType == CameraType.Game);
#else
return false;
#endif

void OnSimulationEnding()
{
#if HDRP_PRESENT
m_ObjectCountPass.WaitForAllRequests();
#endif
m_ClassLabelingTextureReader?.WaitForAllImages();
m_ClassLabelingTextureReader?.Dispose();
m_ClassLabelingTextureReader = null;

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


public class RenderTextureReader<T> : IDisposable where T : struct
{
RenderTexture m_Source;
int m_NumSwapFrames = 2;
struct ReadbackRequest
{
public AsyncGPUReadbackRequest asyncGpuReadbackRequest;
public int frameCount;
}
// this array is 1:1 with the swap chain array and stores the readback requests for each texture
ReadbackRequest?[] m_ReadbackRequests;
Action<AsyncGPUReadbackRequest>[] m_ReadbackRequestDelegates;
int m_NextSwapChainIndex;
int m_NextFrameToCapture;
Texture2D m_CpuTexture;

m_NextFrameToCapture = Time.frameCount;
if (!GraphicsUtilities.SupportsAsyncReadback())
{
m_NumSwapFrames = 0;
}
else
{
m_ReadbackRequests = new ReadbackRequest?[m_NumSwapFrames];
m_ReadbackRequestDelegates = new Action<AsyncGPUReadbackRequest>[m_NumSwapFrames];
for (var i = 0; i < m_NumSwapFrames; i++)
{
var iForDelegate = i;
m_ReadbackRequestDelegates[i] = request => OnGpuReadback(request, iForDelegate);
}
}
RenderPipelineManager.endFrameRendering += OnEndFrameRendering;
}

return;
}
ProcessReadbackRequests(m_NextSwapChainIndex);
Assert.IsFalse(m_ReadbackRequests[m_NextSwapChainIndex].HasValue);
m_ReadbackRequests[m_NextSwapChainIndex] = new ReadbackRequest
{
asyncGpuReadbackRequest = AsyncGPUReadback.Request(m_Source, 0, m_Source.graphicsFormat, m_ReadbackRequestDelegates[m_NextSwapChainIndex]),
frameCount = Time.frameCount
};
m_NextSwapChainIndex = (m_NextSwapChainIndex + 1) % m_NumSwapFrames;
var commandBuffer = CommandBufferPool.Get("RenderTextureReader");
var frameCount = Time.frameCount;
commandBuffer.RequestAsyncReadback(m_Source, r => OnGpuReadback(r, frameCount));
context.ExecuteCommandBuffer(commandBuffer);
context.Submit();
CommandBufferPool.Release(commandBuffer);
void OnGpuReadback(AsyncGPUReadbackRequest request, int swapChainIndex)
void OnGpuReadback(AsyncGPUReadbackRequest request, int frameCount)
//TODO: add equality operators to AsyncGPUReadbackRequest
if (request.hasError)
{
Debug.LogError("Error reading segmentation image from GPU");

m_ImageReadCallback(m_ReadbackRequests[swapChainIndex].Value.frameCount, request.GetData<T>(), m_Source);
}
m_ReadbackRequests[swapChainIndex] = null;
}
void ProcessReadbackRequests( int swapChainIndexToForce = -1, bool forceAll = false)
{
for (var i = 0; i < m_NumSwapFrames; i++)
{
var currentReadbackRequest = m_ReadbackRequests[i];
if (currentReadbackRequest.HasValue)
{
var readbackRequest = currentReadbackRequest.Value.asyncGpuReadbackRequest;
if (swapChainIndexToForce == i || forceAll)
{
using (m_WaitingForCompletionMarker.Auto())
readbackRequest.WaitForCompletion();
m_ReadbackRequests[i] = null;
}
}
m_ImageReadCallback(frameCount, request.GetData<T>(), m_Source);
ProcessReadbackRequests(forceAll: true);
AsyncGPUReadback.WaitAllRequests();
}
public void Dispose()

72
com.unity.perception/Third Party Notices.md


This package contains third-party software components governed by the license(s) indicated below:
---------
Component Name: QuickGraph
License Type: MS-PL
https://github.com/YaccConstructor/QuickGraph/blob/master/LICENSE.txt
---------
Component Name: ExtendedScriptableObjectDrawer
License Type: MIT
https://opensource.org/licenses/MIT
---------
Component Name: ReorderableList
License Type: MIT
https://opensource.org/licenses/MIT
---------
Component Name: SceneReference
License type: Don't Be a Jerk: The Open Source Software License
License text:
Don't Be a Jerk: The Open Source Software License.
Adapted from: https://github.com/evantahler/Dont-be-a-Jerk
_I_ am the software author - JohannesMP on Github.
_You_ are the user of this software. You might be a _we_, and that's OK!
This is free, open source software. I will never charge you to use,
license, or obtain this software. Doing so would make me a jerk.
You may use the content of this project (and by "project" I mean the immediate
directory containing this license, and all its files) for whatever you want.
Personal use, Educational use, Corporate use, and all other uses are OK!
I offer no warranty on anything in this project, and you are using it at
your own risk, of your own free will. I've tried my best to ensure that
there are no gaping security holes where using this software might erase
your hard drive or give you constipation, but it might happen. I'm sorry.
However, I warned you, so you can't sue me. Suing people over free
software would make you a jerk.
If you find bugs, it would be nice if you let me know so I can fix them.
You don't have to, but it would be appreciated.
Speaking of bugs, I am not obligated to fix anything, nor am I obligated
to add any features for you, though I will consider your suggestions.
Feeling entitled about free software would make you a jerk.
If you add a new feature or fix a bug, it would be nice if you contributed
it back to the project, but you don't have to. The repository/site you
obtained this software from should contain a way for you to contact me.
Contributing to open source makes you awesome!
If you use this software, you may remove this license, and don't have to
give me any credit, but it would be great if you did.
Don't be a jerk. Enjoy your free software! :)
This package contains no third-party software components.
正在加载...
取消
保存