Beispiel #1
0
        private unsafe string CheckJobDependencies(int type)
        {
            AtomicSafetyHandle safetyHandle = this.m_SafetyManager.GetSafetyHandle(type, true);
            int        maxCount             = AtomicSafetyHandle.GetReaderArray(safetyHandle, 0, IntPtr.Zero);
            JobHandle *handlePtr            = (JobHandle *)stackalloc byte[(((IntPtr)maxCount) * sizeof(JobHandle))];

            AtomicSafetyHandle.GetReaderArray(safetyHandle, maxCount, (IntPtr)handlePtr);
            int index = 0;

            while (true)
            {
                string str;
                if (index < maxCount)
                {
                    if (this.m_SafetyManager.HasReaderOrWriterDependency(type, handlePtr[index]))
                    {
                        index++;
                        continue;
                    }
                    str = $"The system {base.GetType()} reads {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetReaderName(safetyHandle, index)} but that type was not returned as a job dependency. To ensure correct behavior of other systems, the job or a dependency of it must be returned from the OnUpdate method.";
                }
                else if (!this.m_SafetyManager.HasReaderOrWriterDependency(type, AtomicSafetyHandle.GetWriter(safetyHandle)))
                {
                    str = $"The system {base.GetType()} writes {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetWriterName(safetyHandle)} but that was not returned as a job dependency. To ensure correct behavior of other systems, the job or a dependency of it must be returned from the OnUpdate method.";
                }
                else
                {
                    str = null;
                }
                return(str);
            }
        }
Beispiel #2
0
        unsafe string CheckJobDependencies(int type)
        {
            var h = m_SafetyManager.GetSafetyHandle(type, true);

            var        readerCount = AtomicSafetyHandle.GetReaderArray(h, 0, IntPtr.Zero);
            JobHandle *readers     = stackalloc JobHandle[readerCount];

            AtomicSafetyHandle.GetReaderArray(h, readerCount, (IntPtr)readers);

            for (var i = 0; i < readerCount; ++i)
            {
                if (!m_SafetyManager.HasReaderOrWriterDependency(type, readers[i]))
                {
                    return($"The system {GetType()} reads {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetReaderName(h, i)} but that type was not returned as a job dependency. To ensure correct behavior of other systems, the job or a dependency of it must be returned from the OnUpdate method.");
                }
            }

            if (!m_SafetyManager.HasReaderOrWriterDependency(type, AtomicSafetyHandle.GetWriter(h)))
            {
                return($"The system {GetType()} writes {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetWriterName(h)} but that was not returned as a job dependency. To ensure correct behavior of other systems, the job or a dependency of it must be returned from the OnUpdate method.");
            }

            return(null);
        }
        void CheckJobDependencies(int type, bool isReading, JobHandle dependency)
        {
            var h = m_SafetyManager.GetSafetyHandle(type, true);

            unsafe
            {
                if (!isReading)
                {
                    var        readerCount = AtomicSafetyHandle.GetReaderArray(h, 0, IntPtr.Zero);
                    JobHandle *readers     = stackalloc JobHandle[readerCount];
                    AtomicSafetyHandle.GetReaderArray(h, readerCount, (IntPtr)readers);

                    for (var i = 0; i < readerCount; ++i)
                    {
                        if (!JobHandle.CheckFenceIsDependencyOrDidSyncFence(readers[i], dependency))
                        {
                            throw new InvalidOperationException($"The system {GetType()} reads {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetReaderName(h, i)} but that type was not returned as a job dependency. To ensure correct behavior of other systems, the job or a dependency of it must be returned from the OnUpdate method.");
                        }
                    }
                }

                var writer = AtomicSafetyHandle.GetWriter(h);
                if (!JobHandle.CheckFenceIsDependencyOrDidSyncFence(writer, dependency))
                {
                    throw new InvalidOperationException($"The system {GetType()} writes {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetWriterName(h)} but that was not returned as a job dependency. To ensure correct behavior of other systems, the job or a dependency of it must be returned from the OnUpdate method.");
                }
            }
        }
            internal string FormatToString(FixedString64 systemTypeName)
            {
                int type             = m_ProblematicTypeIndex;
                AtomicSafetyHandle h = m_ProblematicHandle;

                if (!IsWrite)
                {
                    int i = m_ReaderIndex;
                    return($"The system {systemTypeName} reads {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetReaderName(h, i)} but that type was not assigned to the Dependency property. To ensure correct behavior of other systems, the job or a dependency must be assigned to the Dependency property before returning from the OnUpdate method.");
                }
                else
                {
                    return($"The system {systemTypeName} writes {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetWriterName(h)} but that type was not assigned to the Dependency property. To ensure correct behavior of other systems, the job or a dependency must be assigned to the Dependency property before returning from the OnUpdate method.");
                }
            }
            internal string FormatToString(Type systemType)
            {
                int type             = m_ProblematicTypeIndex;
                AtomicSafetyHandle h = m_ProblematicHandle;

                if (!IsWrite)
                {
                    int i = m_ReaderIndex;
                    if (typeof(JobComponentSystem).IsAssignableFrom(systemType))
                    {
                        return
                            ($"The system {systemType} reads {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetReaderName(h, i)} but that type was not returned as a job dependency. To ensure correct behavior of other systems, the job or a dependency of it must be returned from the OnUpdate method.");
                    }
                    else
                    {
                        return
                            ($"The system {systemType} reads {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetReaderName(h, i)} but that type was not assigned to the Dependency property. To ensure correct behavior of other systems, the job or a dependency must be assigned to the Dependency property before returning from the OnUpdate method.");
                    }
                }
                else
                {
                    if (typeof(JobComponentSystem).IsAssignableFrom(systemType))
                    {
                        return($"The system {systemType} writes {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetWriterName(h)} but that was not returned as a job dependency. To ensure correct behavior of other systems, the job or a dependency of it must be returned from the OnUpdate method.");
                    }
                    else
                    {
                        return($"The system {systemType} writes {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetWriterName(h)} but that type was not assigned to the Dependency property. To ensure correct behavior of other systems, the job or a dependency must be assigned to the Dependency property before returning from the OnUpdate method.");
                    }
                }
            }
        static string CheckJobDependencies(object system, int type, ComponentDependencyManager *dependencyManager)
        {
            var h = dependencyManager->Safety.GetSafetyHandle(type, true);

            var        readerCount = AtomicSafetyHandle.GetReaderArray(h, 0, IntPtr.Zero);
            JobHandle *readers     = stackalloc JobHandle[readerCount];

            AtomicSafetyHandle.GetReaderArray(h, readerCount, (IntPtr)readers);

            for (var i = 0; i < readerCount; ++i)
            {
                if (!dependencyManager->HasReaderOrWriterDependency(type, readers[i]))
                {
                    if (IsSystemV1(system))
                    {
                        return($"The system {system.GetType()} reads {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetReaderName(h, i)} but that type was not returned as a job dependency. To ensure correct behavior of other systems, the job or a dependency of it must be returned from the OnUpdate method.");
                    }
                    else
                    {
                        return($"The system {system.GetType()} reads {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetReaderName(h, i)} but that type was not assigned to the Dependency property. To ensure correct behavior of other systems, the job or a dependency must be assigned to the Dependency property before returning from the OnUpdate method.");
                    }
                }
            }

            if (!dependencyManager->HasReaderOrWriterDependency(type, AtomicSafetyHandle.GetWriter(h)))
            {
                if (IsSystemV1(system))
                {
                    return($"The system {system.GetType()} writes {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetWriterName(h)} but that was not returned as a job dependency. To ensure correct behavior of other systems, the job or a dependency of it must be returned from the OnUpdate method.");
                }
                else
                {
                    return($"The system {system.GetType()} writes {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetWriterName(h)} but that type was not assigned to the Dependency property. To ensure correct behavior of other systems, the job or a dependency must be assigned to the Dependency property before returning from the OnUpdate method.");
                }
            }

            return(null);
        }