public static unsafe void CheckNoAliasFieldCompareWithParentStruct(ref ContainerOfManyNoAliasFields s)
 {
     s.s0.Compare(ref s);
     s.s1.Compare(ref s);
     s.s2.Compare(ref s);
     s.s3.Compare(ref s);
 }
        public static unsafe void CheckNoAliasOfSubStructs(ref ContainerOfManyNoAliasFields s)
        {
            // Since ptr1 and ptr2 have [NoAlias], they do not alias within the same struct instance.
            ExpectNotAliased(s.s0.ptr1, s.s0.ptr2);
            ExpectNotAliased(s.s1.ptr1, s.s1.ptr2);
            ExpectNotAliased(s.s2.ptr1, s.s2.ptr2);
            ExpectNotAliased(s.s3.ptr1, s.s3.ptr2);

            // Across s0 and s1 their pointers can alias each other though.
            ExpectAliased(s.s0.ptr1, s.s1.ptr1);
            ExpectAliased(s.s0.ptr1, s.s1.ptr2);
            ExpectAliased(s.s0.ptr2, s.s1.ptr1);
            ExpectAliased(s.s0.ptr2, s.s1.ptr2);

            // Also s2 can alias with s0 and s1 (because they do not have [NoAlias]).
            ExpectAliased(s.s2.ptr1, s.s0.ptr1);
            ExpectAliased(s.s2.ptr1, s.s0.ptr2);
            ExpectAliased(s.s2.ptr2, s.s1.ptr1);
            ExpectAliased(s.s2.ptr2, s.s1.ptr2);

            // Also s3 can alias with s0 and s1 (because they do not have [NoAlias]).
            ExpectAliased(s.s3.ptr1, s.s0.ptr1);
            ExpectAliased(s.s3.ptr1, s.s0.ptr2);
            ExpectAliased(s.s3.ptr2, s.s1.ptr1);
            ExpectAliased(s.s3.ptr2, s.s1.ptr2);

            // But s2 and s3 cannot alias each other (they both have [NoAlias]).
            ExpectNotAliased(s.s2.ptr1, s.s3.ptr1);
            ExpectNotAliased(s.s2.ptr1, s.s3.ptr2);
            ExpectNotAliased(s.s2.ptr2, s.s3.ptr1);
            ExpectNotAliased(s.s2.ptr2, s.s3.ptr2);
        }
Пример #3
0
            public void Compare(ref ContainerOfManyNoAliasFields other)
            {
#if UNITY_2020_1_OR_NEWER || UNITY_BURST_EXPERIMENTAL_FEATURE_ALIASING
                // Check that we can definitely alias with another struct which contains the same type as ourself.
                Unity.Burst.Aliasing.ExpectAlias(ref this, ref other);
#endif
            }
Пример #4
0
        public unsafe static void CheckNoAliasOfSubStructs(ref ContainerOfManyNoAliasFields s)
        {
            // Since s2 has [NoAlias], s0 and s1 do not alias with it.
            Unity.Burst.Aliasing.ExpectNoAlias(ref s.s0, ref s.s2);
            Unity.Burst.Aliasing.ExpectNoAlias(ref s.s1, ref s.s2);

            // Since ptr1 has [NoAlias], it does not alias with ptr2 within the same struct instance.
            Unity.Burst.Aliasing.ExpectNoAlias(s.s0.ptr1, s.s0.ptr2);
            Unity.Burst.Aliasing.ExpectNoAlias(s.s1.ptr1, s.s1.ptr2);
            Unity.Burst.Aliasing.ExpectNoAlias(s.s2.ptr1, s.s2.ptr2);

            // Across s0 and s1 their pointers can alias each other though.
            Unity.Burst.Aliasing.ExpectAlias(s.s0.ptr1, s.s1.ptr1);
            Unity.Burst.Aliasing.ExpectAlias(s.s0.ptr1, s.s1.ptr2);
            Unity.Burst.Aliasing.ExpectAlias(s.s0.ptr2, s.s1.ptr1);
            Unity.Burst.Aliasing.ExpectAlias(s.s0.ptr2, s.s1.ptr2);

            // But s2 cannot alias with s0 or s1's pointers.
            Unity.Burst.Aliasing.ExpectNoAlias(s.s2.ptr1, s.s0.ptr1);
            Unity.Burst.Aliasing.ExpectNoAlias(s.s2.ptr1, s.s0.ptr2);
            Unity.Burst.Aliasing.ExpectNoAlias(s.s2.ptr2, s.s1.ptr1);
            Unity.Burst.Aliasing.ExpectNoAlias(s.s2.ptr2, s.s1.ptr2);
        }
 public void Compare(ref ContainerOfManyNoAliasFields other)
 {
     // Check that we can definitely alias with another struct which contains the same type as ourself.
     ExpectAliased(in this, in other);
 }