예제 #1
0
        public override void OnVisualize(Visualizer visualizer)
        {
            VisualizeMarker.Begin();
            var lidarToWorld = Compensated ? Matrix4x4.identity : transform.localToWorldMatrix;

            PointCloudMaterial.SetMatrix("_LocalToWorld", lidarToWorld);
            PointCloudMaterial.SetFloat("_Size", PointSize * Utility.GetDpiScale());
            PointCloudMaterial.SetColor("_Color", PointColor);
            Graphics.DrawProcedural(PointCloudMaterial, new Bounds(transform.position, MaxDistance * Vector3.one), MeshTopology.Points, PointCloudBuffer.count, layer: LayerMask.NameToLayer("Sensor"));

            VisualizeMarker.End();
        }
예제 #2
0
        static void WriteHeader(Entities.Hash128 sceneGUID, SubSceneHeader header)
        {
            k_ProfileEntitiesSceneSaveHeader.Begin();

            string headerPath = EntityScenesPaths.GetPathAndCreateDirectory(sceneGUID, EntityScenesPaths.PathType.EntitiesHeader, "");

            AssetDatabase.CreateAsset(header, headerPath);

            //subscene.CacheSceneInformation();

            k_ProfileEntitiesSceneSaveHeader.End();
        }
예제 #3
0
    void PerformEnvironmentFlow()
    {
        s_PerformEnvironmentFlow_p.Begin();
        UrbTile[] Adjacency = OwningTile.GetAdjacent(true);

        for (int i = 0; i < MaxCond; i++)
        {
            PerformConditionFlow(i, Adjacency);
        }

        s_PerformEnvironmentFlow_p.End();
    }
        public void HandleAddObject(ulong clientId, Stream stream)
        {
#if DEVELOPMENT_BUILD || UNITY_EDITOR
            s_HandleAddObject.Begin();
#endif
            using (var reader = PooledNetworkReader.Get(stream))
            {
                var   isPlayerObject  = reader.ReadBool();
                var   networkId       = reader.ReadUInt64Packed();
                var   ownerClientId   = reader.ReadUInt64Packed();
                var   hasParent       = reader.ReadBool();
                ulong?parentNetworkId = null;

                if (hasParent)
                {
                    parentNetworkId = reader.ReadUInt64Packed();
                }

                var softSync   = reader.ReadBool();
                var prefabHash = reader.ReadUInt32Packed();

                Vector3?   pos = null;
                Quaternion?rot = null;
                if (reader.ReadBool())
                {
                    pos = new Vector3(reader.ReadSinglePacked(), reader.ReadSinglePacked(), reader.ReadSinglePacked());
                    rot = Quaternion.Euler(reader.ReadSinglePacked(), reader.ReadSinglePacked(), reader.ReadSinglePacked());
                }

                var hasPayload    = reader.ReadBool();
                var payLoadLength = hasPayload ? reader.ReadInt32Packed() : 0;

                var networkObject = NetworkManager.SpawnManager.CreateLocalNetworkObject(softSync, prefabHash, ownerClientId, parentNetworkId, pos, rot);
                NetworkManager.SpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, softSync, isPlayerObject, ownerClientId, stream, hasPayload, payLoadLength, true, false);

                Queue <BufferManager.BufferedMessage> bufferQueue = NetworkManager.BufferManager.ConsumeBuffersForNetworkId(networkId);

                // Apply buffered messages
                if (bufferQueue != null)
                {
                    while (bufferQueue.Count > 0)
                    {
                        BufferManager.BufferedMessage message = bufferQueue.Dequeue();
                        NetworkManager.HandleIncomingData(message.SenderClientId, message.NetworkChannel, new ArraySegment <byte>(message.NetworkBuffer.GetBuffer(), (int)message.NetworkBuffer.Position, (int)message.NetworkBuffer.Length), message.ReceiveTime, false);
                        BufferManager.RecycleConsumedBufferedMessage(message);
                    }
                }
            }
#if DEVELOPMENT_BUILD || UNITY_EDITOR
            s_HandleAddObject.End();
#endif
        }
예제 #5
0
        /// <summary>
        /// ProcessSendQueue
        /// Called to send both performance RPC and internal messages and then flush the outbound queue
        /// </summary>
        public void ProcessSendQueue()
        {
#if DEVELOPMENT_BUILD || UNITY_EDITOR
            s_ProcessSendQueue.Begin();
#endif

            RpcQueueSendAndFlush();

#if DEVELOPMENT_BUILD || UNITY_EDITOR
            s_ProcessSendQueue.End();
#endif
            InternalMessagesSendAndFlush();
        }
예제 #6
0
    public static void UnregisterAgent(UrbAgent Input)
    {
        s_UrbAgentMgr_UnRegister_p.Begin();
        if (Uninitialized)
        {
            return;
        }

        //We can attempt removal without checking if it contains
        //If we don't contain it... is a no-op.
        Agents.Remove(Input);
        s_UrbAgentMgr_UnRegister_p.End();
    }
예제 #7
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            k_ProfilerMarker.Begin();

            if (Set != null)
            {
                inputDeps = Set.Update(inputDeps);
            }

            k_ProfilerMarker.End();

            return(inputDeps);
        }
예제 #8
0
        /// <summary>
        /// ProcessSendQueue
        /// Called to send both performance RPC and internal messages and then flush the outbound queue
        /// </summary>
        internal void ProcessSendQueue(bool isListening)
        {
#if DEVELOPMENT_BUILD || UNITY_EDITOR
            s_ProcessSendQueue.Begin();
#endif

            RpcQueueSendAndFlush(isListening);

#if DEVELOPMENT_BUILD || UNITY_EDITOR
            s_ProcessSendQueue.End();
#endif
            InternalMessagesSendAndFlush(isListening);
        }
예제 #9
0
        internal static void HandleClientSwitchSceneCompleted(ulong clientId, Stream stream)
        {
#if DEVELOPMENT_BUILD || UNITY_EDITOR
            s_HandleClientSwitchSceneCompleted.Begin();
#endif
            using (var reader = PooledNetworkReader.Get(stream))
            {
                NetworkSceneManager.OnClientSwitchSceneCompleted(clientId, new Guid(reader.ReadByteArray()));
            }
#if DEVELOPMENT_BUILD || UNITY_EDITOR
            s_HandleClientSwitchSceneCompleted.End();
#endif
        }
        public unsafe void TestDisableFromPlayerConnectionDoesntSend()
        {
            ProfilerProtocolThread.Stream.buffer->m_BufferList->RecycleStreamAndFreeExtra();

            PlayerConnectionProfiler.Shutdown();

            ProfilerMarker marker = new ProfilerMarker("Test marker");

            marker.Begin();
            marker.End();

            Assert.Zero(ProfilerProtocolThread.Stream.buffer->m_BufferList->TotalBytes);
        }
예제 #11
0
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        _marker.Begin();
        var job = new Sys_TranslationAddVelocityJob
        {
            dt = UnityEngine.Time.deltaTime
        }.Schedule(this, inputDependencies);

        _marker.End();

        // Now that the job is set up, schedule it to be run.
        return(job);
    }
예제 #12
0
        bool BeginReadRequest(int count, ref ReadRequest req)
        {
            if (count == 0)
            {
                return(false);
            }

            BeginReadMarker.Begin();

            RenderTexture texture = null;

            if (AvailableRenderTextures.Count != 0)
            {
                texture = AvailableRenderTextures.Pop();
                if (!texture.IsCreated())
                {
                    texture.Release();
                    texture = null;
                }
            }

            if (texture == null)
            {
                texture = new RenderTexture(RenderTextureWidth, RenderTextureHeight, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
            }
            texture.Create();

            SensorCamera.targetTexture = texture;
            SensorCamera.Render();

            req = new ReadRequest()
            {
                RenderTexture = texture,
                Index         = CurrentIndex,
                Count         = count,
                Origin        = SensorCamera.transform.position,

                CameraToWorldMatrix = SensorCamera.cameraToWorldMatrix,
            };

            if (!Compensated)
            {
                req.Transform = transform.worldToLocalMatrix;
            }

            BeginReadMarker.End();

            CurrentIndex = (CurrentIndex + count) % CurrentMeasurementsPerRotation;

            return(true);
        }
예제 #13
0
        bool BeginReadRequest(int count, ref ReadRequest req)
        {
            if (count == 0)
            {
                return(false);
            }

            BeginReadMarker.Begin();

            SensorRenderTarget renderTarget = null;

            if (AvailableRenderTextures.Count != 0)
            {
                renderTarget = AvailableRenderTextures.Pop();
            }

            if (renderTarget == null)
            {
                renderTarget = SensorRenderTarget.Create2D(RenderTextureWidth, RenderTextureHeight);
            }
            else if (!renderTarget.IsValid(RenderTextureWidth, RenderTextureHeight))
            {
                renderTarget.Release();
                renderTarget = SensorRenderTarget.Create2D(RenderTextureWidth, RenderTextureHeight);
            }

            activeTarget = renderTarget;
            SensorCamera.targetTexture = renderTarget;
            SensorCamera.Render();

            req = new ReadRequest()
            {
                TextureSet = renderTarget,
                Index      = CurrentIndex,
                Count      = count,
                Origin     = SensorCamera.transform.position,

                CameraToWorldMatrix = SensorCamera.cameraToWorldMatrix,
            };

            if (!Compensated)
            {
                req.Transform = transform.worldToLocalMatrix;
            }

            BeginReadMarker.End();

            CurrentIndex = (CurrentIndex + count) % CurrentMeasurementsPerRotation;

            return(true);
        }
예제 #14
0
        public void Render()
        {
            s_MarkerRender.Begin();

            if (BeforeDrawChain != null)
            {
                BeforeDrawChain(this);
            }

            Exception immediateException = null;

            if (m_FirstCommand != null)
            {
                if (!m_DrawInCameras)
                {
                    var viewport = panel.visualTree.layout;

                    Material standardMaterial = GetStandardMaterial();
                    standardMaterial?.SetPass(0);

                    var projection = ProjectionUtils.Ortho(viewport.xMin, viewport.xMax, viewport.yMax, viewport.yMin, -0.001f, 1.001f);
                    GL.LoadProjectionMatrix(projection);
                    GL.modelview = Matrix4x4.identity;

                    //TODO: Reactivate this guard check once InspectorWindow is fixed to stop adding VEs during OnGUI
                    //m_BlockDirtyRegistration = true;
                    device.EvaluateChain(m_FirstCommand, standardMaterial, standardMaterial, atlasManager?.atlas, vectorImageManager?.atlas, shaderInfoAllocator.atlas,
                                         (panel as BaseVisualElementPanel).scaledPixelsPerPoint, shaderInfoAllocator.transformConstants, shaderInfoAllocator.clipRectConstants,
                                         m_RenderNodesData[0].matPropBlock, true, ref immediateException);
                    //m_BlockDirtyRegistration = false;
                }
            }

            s_MarkerRender.End();

            if (immediateException != null)
            {
                if (GUIUtility.IsExitGUIException(immediateException))
                {
                    throw immediateException;
                }

                // Wrap the exception, this plays more nicely with the callstack logging.
                throw new ImmediateModeException(immediateException);
            }

            if (drawStats)
            {
                DrawStats();
            }
        }
예제 #15
0
        internal static void HandleDestroyObject(ulong clientId, Stream stream)
        {
#if DEVELOPMENT_BUILD || UNITY_EDITOR
            s_HandleDestroyObject.Begin();
#endif
            using (var reader = PooledNetworkReader.Get(stream))
            {
                ulong networkId = reader.ReadUInt64Packed();
                NetworkSpawnManager.OnDestroyObject(networkId, true);
            }
#if DEVELOPMENT_BUILD || UNITY_EDITOR
            s_HandleDestroyObject.End();
#endif
        }
        private void RetracePath(Node currNode)
        {
            _pathRetractingPerfMarker.Begin();
            Node current = currNode;

            while (current != null)
            {
                _path.Add(current.marker);
                current = current.parentNode;
            }

            _path.Reverse();
            _pathRetractingPerfMarker.End();
        }
예제 #17
0
 public Profile(string name)
 {
     _name = name;
     if (Markers.TryGetValue(_name, out var marker))
     {
         marker.Begin();
     }
     else
     {
         marker = new ProfilerMarker(_name);
         Markers.Add(_name, marker);
         marker.Begin();
     }
 }
        public static void BurstedProfilerMethods(ref ProfilerMarker marker)
        {
            EnsureBurstedOrThrow();

            // These API calls actually prove out a LOT of internal API burst-ability
            marker.Begin();
            marker.End();

            using (marker.Auto())
            {
            }

            ProfilerProtocolThread.SendNewFrame();
        }
예제 #19
0
 static void Internal_CallUpdateFunctions()
 {
     if (update != null)
     {
         var invocationList = update.GetInvocationList();
         foreach (var cb in invocationList)
         {
             var marker = new ProfilerMarker(cb.Method.Name);
             marker.Begin();
             cb.DynamicInvoke();
             marker.End();
         }
     }
 }
예제 #20
0
        internal static void HandleTimeSync(ulong clientId, Stream stream, float receiveTime)
        {
#if DEVELOPMENT_BUILD || UNITY_EDITOR
            s_HandleTimeSync.Begin();
#endif
            using (var reader = PooledNetworkReader.Get(stream))
            {
                float netTime = reader.ReadSinglePacked();
                NetworkManager.Singleton.UpdateNetworkTime(clientId, netTime, receiveTime);
            }
#if DEVELOPMENT_BUILD || UNITY_EDITOR
            s_HandleTimeSync.End();
#endif
        }
예제 #21
0
        public void PullFullData()
        {
            // Once the data has been pulled, it will have to be cleared when the profiler is
            ProfilerDriver.profileCleared += ClearData;

            int firstFrameIndex = ProfilerDriver.firstFrameIndex;
            int lastFrameIndex  = ProfilerDriver.lastFrameIndex;

            s_PullData.Begin();
            PullDataStatic(ref m_CaptureData, m_Markers, ref m_MarkerToIDMap, firstFrameIndex, lastFrameIndex);
            s_PullData.End();

            DataPulled = true;
        }
예제 #22
0
    public void Simulate()
    {
        if (doPhysics)
        {
            PhysXLib.StepPhysics(scene, Time.fixedDeltaTime, scratchMem, scratchKilobytes * 1024);

            foreach (PhysXBody body in bodies.Values)
            {
                body.UpdatePositionAndVelocity();
            }

            collisionCallbackMarker.Begin();
            foreach (PhysXCollision collision in PhysXSceneManager.ongoingCollisions)
            {
                collision.PopulateWithUnityObjects(bodies);
                PhysXBody body = null;
                if (bodies.TryGetValue(collision.self.ToInt64(), out body))
                {
                    try {
                        body.FireCollisionEvents(collision);
                    }
                    catch (Exception e) {
                        Debug.LogError("Exception: " + e.Message + "\n" + e.StackTrace);
                    }
                }
                PhysXCollision.ReleaseCollision(collision);
            }
            PhysXSceneManager.ongoingCollisions.Clear();

            foreach (PhysXTrigger trigger in PhysXSceneManager.ongoingTriggers)
            {
                trigger.PopulateWithUnityObjects(bodies);
                PhysXBody body = null;
                if (bodies.TryGetValue(trigger.self.ToInt64(), out body))
                {
                    try {
                        body.FireTriggerEvents(trigger);
                    }
                    catch (Exception e) {
                        Debug.LogError("Exception: " + e.Message + "\n" + e.StackTrace);
                    }
                }
                PhysXTrigger.ReleaseTrigger(trigger);
            }
            PhysXSceneManager.ongoingTriggers.Clear();
            collisionCallbackMarker.End();

            PhysXLib.StepGhostPhysics(scene, Time.fixedDeltaTime, scratchMem, scratchKilobytes * 1024);
        }
    }
        public static Entity ConvertGameObjectHierarchy(GameObject root, GameObjectConversionSettings settings)
        {
            using (s_ConvertScene.Auto())
            {
                Entity convertedEntity;
                using (var conversionWorld = CreateConversionWorld(settings))
                    using (var conversion = new Conversion(conversionWorld))
                    {
                        using (s_CreateEntitiesForGameObjects.Auto())
                            conversion.MappingSystem.AddGameObjectOrPrefab(root);

                        Convert(conversionWorld);

                        convertedEntity = conversion.MappingSystem.GetPrimaryEntity(root);

                        settings.ConversionWorldPreDispose?.Invoke(conversionWorld);

                        s_DestroyConversionWorld.Begin();
                    }
                s_DestroyConversionWorld.End();
                return(convertedEntity);
            }
        }
        internal static World CreateConversionWorld(World dstEntityWorld, Hash128 sceneGUID, ConversionFlags conversionFlags)
        {
            m_CreateConversionWorld.Begin();

            var gameObjectWorld = new World("GameObject World");

            gameObjectWorld.CreateSystem <GameObjectConversionMappingSystem>(dstEntityWorld, sceneGUID, conversionFlags);

            AddConversionSystems(gameObjectWorld);

            m_CreateConversionWorld.End();

            return(gameObjectWorld);
        }
        public static void Create(EntityManager entityManager, out NativeHashMap <Entity, bool> itemsColliding)
        {
            PerfMarkerTotal.Begin();

            var player             = Object.FindObjectOfType <Player>();
            var playfieldComponent = player.GetComponentInChildren <PlayfieldComponent>();
            var itemApis           = player.ColliderGenerators.ToArray();

            // 1. generate colliders
            PerfMarkerGenerateColliders.Begin();
            var colliderList = new List <ICollider>();

            var(playfieldCollider, glassCollider) = player.PlayfieldApi.CreateColliders();
            itemsColliding = new NativeHashMap <Entity, bool>(itemApis.Length, Allocator.Persistent);
            foreach (var itemApi in itemApis)
            {
                PerfMarkerCreateColliders.Begin();
                if (itemApi.ColliderEntity != Entity.Null)
                {
                    itemsColliding.Add(itemApi.ColliderEntity, itemApi.IsColliderEnabled);
                }
                itemApi.CreateColliders(colliderList, 0);
                PerfMarkerCreateColliders.End();
            }
            PerfMarkerGenerateColliders.End();

            // 2. allocate created colliders
            PerfMarkerCreateBlobAsset.Begin();
            var allocateColliderJob = new ColliderAllocationJob(colliderList, playfieldCollider, glassCollider);

            allocateColliderJob.Run();

            // retrieve result and dispose
            var colliderBlobAssetRef = allocateColliderJob.BlobAsset[0];

            allocateColliderJob.Dispose();
            PerfMarkerCreateBlobAsset.End();

            // 3. Create quadtree blob (BlobAssetReference<QuadTreeBlob>) from AABBs
            PerfMarkerCreateQuadTree.Begin();
            BlobAssetReference <QuadTreeBlob> quadTreeBlobAssetRef;

            using (var builder = new BlobBuilder(Allocator.Temp)) {
                ref var rootQuadTree = ref builder.ConstructRoot <QuadTreeBlob>();
                QuadTree.Create(builder, ref colliderBlobAssetRef.Value.Colliders, ref rootQuadTree.QuadTree,
                                playfieldComponent.BoundingBox.ToAabb());

                quadTreeBlobAssetRef = builder.CreateBlobAssetReference <QuadTreeBlob>(Allocator.Persistent);
            }
예제 #26
0
        /// <summary>
        /// ProcessReceiveQueue
        /// Public facing interface method to start processing all RPCs in the current inbound frame
        /// </summary>
        public void ProcessReceiveQueue(NetworkUpdateStage currentStage)
        {
            bool advanceFrameHistory = false;
            var  rpcQueueContainer   = NetworkManager.Singleton.RpcQueueContainer;

            if (rpcQueueContainer != null)
            {
#if DEVELOPMENT_BUILD || UNITY_EDITOR
                s_ProcessReceiveQueue.Begin();
#endif
                var currentFrame = rpcQueueContainer.GetQueueHistoryFrame(RpcQueueHistoryFrame.QueueFrameType.Inbound, currentStage);
                var nextFrame    = rpcQueueContainer.GetQueueHistoryFrame(RpcQueueHistoryFrame.QueueFrameType.Inbound, currentStage, true);
                if (nextFrame.IsDirty && nextFrame.HasLoopbackData)
                {
                    advanceFrameHistory = true;
                }

                if (currentFrame != null && currentFrame.IsDirty)
                {
                    var currentQueueItem = currentFrame.GetFirstQueueItem();
                    while (currentQueueItem.QueueItemType != RpcQueueContainer.QueueItemType.None)
                    {
                        advanceFrameHistory = true;

                        if (rpcQueueContainer.IsTesting())
                        {
                            Debug.Log($"RPC invoked during the {currentStage} update stage.");
                        }

                        NetworkManager.InvokeRpc(currentQueueItem);
                        ProfilerStatManager.RpcsQueueProc.Record();
                        PerformanceDataManager.Increment(ProfilerConstants.NumberOfRPCQueueProcessed);
                        currentQueueItem = currentFrame.GetNextQueueItem();
                    }

                    //We call this to dispose of the shared stream writer and stream
                    currentFrame.CloseQueue();
                }

                if (advanceFrameHistory)
                {
                    rpcQueueContainer.AdvanceFrameHistory(RpcQueueHistoryFrame.QueueFrameType.Inbound);
                }

#if DEVELOPMENT_BUILD || UNITY_EDITOR
                s_ProcessReceiveQueue.End();
#endif
            }
        }
        public void HandleAllClientsSwitchSceneCompleted(ulong clientId, Stream stream)
        {
#if DEVELOPMENT_BUILD || UNITY_EDITOR
            s_HandleAllClientsSwitchSceneCompleted.Begin();
#endif
            using (var reader = PooledNetworkReader.Get(stream))
            {
                var clientIds         = reader.ReadULongArray();
                var timedOutClientIds = reader.ReadULongArray();
                NetworkManager.SceneManager.AllClientsReady(clientIds, timedOutClientIds);
            }
#if DEVELOPMENT_BUILD || UNITY_EDITOR
            s_HandleAllClientsSwitchSceneCompleted.End();
#endif
        }
예제 #28
0
    private void RemoveConnection(GravNode gn1, GravNode gn2)
    {
        s_RemoveLinkCreateIP.Begin();
        int indexResult = gn1.FindLinkIndex(gn2);

        if (indexResult == -1)
        {
            Debug.LogError("Link not found");
            return;
        }
        s_RemoveLinkCreateIP.End();

        connections[indexResult].BreakLink(m_GravMesh);
        availableConnectionIndex.Enqueue(indexResult);
    }
 public static void RepaintOverlayPanels()
 {
     UIElementsUtility.GetAllPanels(panelsIteration);
     foreach (var panel in panelsIteration)
     {
         // at the moment, all runtime panels who do not use a rendertexure are rendered as overlays.
         // later on, they'll be filtered based on render mode
         if (panel.contextType == ContextType.Player && (panel as RuntimePanel).targetTexture == null)
         {
             s_RepaintProfilerMarker.Begin();
             panel.Repaint(Event.current);
             s_RepaintProfilerMarker.End();
         }
     }
 }
        public static void UpdateOpacityId(VisualElement ve, RenderChain renderChain)
        {
            k_UpdateOpacityIdMarker.Begin();

            if (ve.renderChainData.data != null)
            {
                DoUpdateOpacityId(ve, renderChain, ve.renderChainData.data);
            }

            if (ve.renderChainData.closingData != null)
            {
                DoUpdateOpacityId(ve, renderChain, ve.renderChainData.closingData);
            }

            k_UpdateOpacityIdMarker.End();
        }