AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
GpuTimingCamera.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using UnityEngine;
5 
6 namespace HoloToolkit.Unity
7 {
12  public class GpuTimingCamera : MonoBehaviour
13  {
14  public string TimingTag = "Frame";
15 
16  private Camera timingCamera;
17 
18  private void Start()
19  {
20  timingCamera = GetComponent<Camera>();
21  Debug.Assert(timingCamera, "GpuTimingComponent must be attached to a Camera.");
22  }
23 
24  protected void OnPreRender()
25  {
26  if (timingCamera.stereoActiveEye == Camera.MonoOrStereoscopicEye.Left || timingCamera.stereoActiveEye == Camera.MonoOrStereoscopicEye.Mono)
27  {
28  GpuTiming.BeginSample(TimingTag);
29  }
30  }
31 
32  protected void OnPostRender()
33  {
34  if (timingCamera.stereoActiveEye == Camera.MonoOrStereoscopicEye.Right || timingCamera.stereoActiveEye == Camera.MonoOrStereoscopicEye.Mono)
35  {
37  }
38  }
39  }
40 }
static void EndSample()
Ends the GPU sample currently in flight.
Definition: GpuTiming.cs:78
static bool BeginSample(string eventId)
Begins sampling GPU time.
Definition: GpuTiming.cs:48
Tracks the GPU time spent rendering a camera. For stereo rendering sampling is made from the beginnin...
Encapsulates access to GPU timing methods.
Definition: GpuTiming.cs:14