Beispiel #1
0
        public void double3x3_inverse_burst()
        {
            FunctionPointer <double3x3_inverse.TestFunction> testFunction = BurstCompiler.CompileFunctionPointer <double3x3_inverse.TestFunction>(double3x3_inverse.BurstTestFunction);
            var args = new double3x3_inverse.Arguments();

            args.Init();

            Measure.Method(() =>
            {
                testFunction.Invoke(ref args);
            })
            .Definition(sampleUnit: SampleUnit.Microsecond)
            .WarmupCount(1)
            .MeasurementCount(10)
            .Run();
            args.Dispose();
        }
Beispiel #2
0
        public void float2_hash_burst()
        {
            FunctionPointer <float2_hash.TestFunction> testFunction = BurstCompiler.CompileFunctionPointer <float2_hash.TestFunction>(float2_hash.BurstTestFunction);
            var args = new float2_hash.Arguments();

            args.Init();

            Measure.Method(() =>
            {
                testFunction.Invoke(ref args);
            })
            .Definition(sampleUnit: SampleUnit.Microsecond)
            .WarmupCount(1)
            .MeasurementCount(10)
            .Run();
            args.Dispose();
        }
        public void Random_NextDouble2_burst()
        {
            FunctionPointer <Random_NextDouble2.TestFunction> testFunction = BurstCompiler.CompileFunctionPointer <Random_NextDouble2.TestFunction>(Random_NextDouble2.BurstTestFunction);
            var args = new Random_NextDouble2.Arguments();

            args.Init();

            Measure.Method(() =>
            {
                testFunction.Invoke(ref args);
            })
            .Definition(sampleUnit: SampleUnit.Microsecond)
            .WarmupCount(1)
            .MeasurementCount(10)
            .Run();
            args.Dispose();
        }
Beispiel #4
0
        public void orthonormal_basis_double_burst()
        {
            FunctionPointer <orthonormal_basis_double.TestFunction> testFunction = BurstCompiler.CompileFunctionPointer <orthonormal_basis_double.TestFunction>(orthonormal_basis_double.BurstTestFunction);
            var args = new orthonormal_basis_double.Arguments();

            args.Init();

            var burstSampleGroup = new SampleGroup("Burst", SampleUnit.Microsecond);            Measure.Method(() =>

            {
                testFunction.Invoke(ref args);
            })
            .SampleGroup(burstSampleGroup)
            .WarmupCount(1)
            .MeasurementCount(10)
            .Run();
            args.Dispose();
        }
Beispiel #5
0
        public void float4x4_EulerXYZ_burst()
        {
            FunctionPointer <float4x4_EulerXYZ.TestFunction> testFunction = BurstCompiler.CompileFunctionPointer <float4x4_EulerXYZ.TestFunction>(float4x4_EulerXYZ.BurstTestFunction);
            var args = new float4x4_EulerXYZ.Arguments();

            args.Init();

            var burstSampleGroup = new SampleGroup("Burst", SampleUnit.Microsecond);            Measure.Method(() =>

            {
                testFunction.Invoke(ref args);
            })
            .SampleGroup(burstSampleGroup)
            .WarmupCount(1)
            .MeasurementCount(10)
            .Run();
            args.Dispose();
        }
        public void quaternion_to_RigidTransform_burst()
        {
            FunctionPointer <quaternion_to_RigidTransform.TestFunction> testFunction = BurstCompiler.CompileFunctionPointer <quaternion_to_RigidTransform.TestFunction>(quaternion_to_RigidTransform.BurstTestFunction);
            var args = new quaternion_to_RigidTransform.Arguments();

            args.Init();

            var burstSampleGroup = new SampleGroup("Burst", SampleUnit.Microsecond);            Measure.Method(() =>

            {
                testFunction.Invoke(ref args);
            })
            .SampleGroup(burstSampleGroup)
            .WarmupCount(1)
            .MeasurementCount(10)
            .Run();
            args.Dispose();
        }
Beispiel #7
0
        public void Random_NextUint_burst()
        {
            FunctionPointer <Random_NextUint.TestFunction> testFunction = BurstCompiler.CompileFunctionPointer <Random_NextUint.TestFunction>(Random_NextUint.BurstTestFunction);
            var args = new Random_NextUint.Arguments();

            args.Init();

            var burstSampleGroup = new SampleGroup("Burst", SampleUnit.Microsecond);            Measure.Method(() =>

            {
                testFunction.Invoke(ref args);
            })
            .SampleGroup(burstSampleGroup)
            .WarmupCount(1)
            .MeasurementCount(10)
            .Run();
            args.Dispose();
        }
        internal static void RemoveManagedReferences(EntityDataAccess *mgr, int *sharedIndex, int count)
        {
#if !UNITY_IOS
            if (!UseDelegate())
            {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                if (_bfp_RemoveManagedReferences.Data == IntPtr.Zero)
                {
                    throw new InvalidOperationException("Burst Interop Classes must be initialized manually");
                }
#endif

                var fp = new FunctionPointer <Managed._dlg_RemoveManagedReferences>(_bfp_RemoveManagedReferences.Data);
                fp.Invoke((IntPtr)mgr, (IntPtr)sharedIndex, count);
                return;
            }
#endif
            _RemoveManagedReferences(mgr, sharedIndex, count);
        }
Beispiel #9
0
        public void ProblemWithFunctionPointer()
        {
            Assert.Throws <ArgumentException>(() =>
            {
                GenericDelegate <int> d = (int i) => i++;
                IntPtr pFunc            = Marshal.GetFunctionPointerForDelegate(d);
                var dmd = Marshal.GetDelegateForFunctionPointer <GenericDelegate <int> >(pFunc);
                int r   = dmd.Invoke(1);
                Assert.AreEqual(2, r);
                Debug.Log(r);

                FunctionPointerDuplicate <GenericDelegate <int> > fpFuncDup = new FunctionPointerDuplicate <GenericDelegate <int> >(pFunc);
                r = fpFuncDup.InvokeWithGenericMarshalFunc(1);
                Assert.AreEqual(2, r);
                Debug.Log(r);

                FunctionPointer <GenericDelegate <int> > fpFunc = new FunctionPointer <GenericDelegate <int> >(pFunc);
                r = fpFunc.Invoke(1);
                Assert.AreEqual(2, r);
                Debug.Log(r);
            });
        }
 unsafe public void Execute()
 {
     FunctionPointer.Invoke(ref *Blah);
 }
Beispiel #11
0
 public static int Conclude(FunctionPointer p)
 {
     //run the function irrespective of whether it is run / event run
     p.Invoke();
     throw  new NotImplementedException();
 }
Beispiel #12
0
        private void RenderMesh(
            int startIndex,
            int parentIndex,
            int currentIndex,
            NativeArray <UIVertexData> vertexData,
            UIContextData *context,
            NativeArray <ushort> indices,
            UIGraphData graph,
            GraphInfo graphInfo,
            NativeArray <NodeInfo> nodeInfo,
            NativeArray <UIPassState> stateLayout,
            NativeArray <SubMeshInfo> subMeshes,
            bool renderNow,
            bool updateSubmeshCount,
            bool accumulate,
            ref int subMeshIndex,
            ref int renderIndex,
            ref float4 bounds

            )
        {
            var           info         = nodeInfo[currentIndex];
            HeaderConfig *headerConfig = (HeaderConfig *)(graph.value + info.nodeOffset).ToPointer();
            var           state        = stateLayout[currentIndex];

            if (accumulate)
            {
                state.globalBox += state.localBox;
                if (parentIndex >= 0)
                {
                    state.globalBox += stateLayout[parentIndex].inner;
                }
                stateLayout[currentIndex] = state;
            }
            if (headerConfig->IsDedicatedNode)
            {
                if (updateSubmeshCount)
                {
                    subMeshes[subMeshIndex] = new SubMeshInfo(++subMeshIndex, currentIndex);
                }
                renderNow = currentIndex == startIndex;
            }
            if (renderNow)
            {
                bool display = true;
                bool visible = true;
                if (graph.TryGetConfigBlock(currentIndex, UIConfigLayoutTable.DisplayConfig, out IntPtr displayConfig))
                {
                    var dc = ((DisplayConfig *)displayConfig.ToPointer());
                    display = dc->display == VisibilityStyle.Visible;
                    visible = dc->visible == VisibilityStyle.Visible;
                }
                if (display)
                {
                    FunctionPointer <UIRenderPass> render = headerConfig->schemaIndex >= 0 ? schema.Value.elements[headerConfig->schemaIndex].render : default;
                    if (render.IsCreated)
                    {
                        render.Invoke(
                            graph.value,
                            (NodeInfo *)UnsafeUtility.AddressOf(ref info),
                            (UIPassState *)UnsafeUtility.AddressOf(ref state),
                            (UIVertexData *)(((IntPtr)vertexData.GetUnsafePtr()) + (renderIndex * UnsafeUtility.SizeOf <UIVertexData>() * 4)).ToPointer(),
                            context
                            );
                    }
                    for (int j = 0; j < info.renderBoxCount; j++)
                    {
                        indices[(renderIndex + j) * 6]       = (ushort)((renderIndex + j) * 4);
                        indices[((renderIndex + j) * 6) + 1] = (ushort)(((renderIndex + j) * 4) + 2);
                        indices[((renderIndex + j) * 6) + 2] = (ushort)(((renderIndex + j) * 4) + 1);
                        indices[((renderIndex + j) * 6) + 3] = (ushort)(((renderIndex + j) * 4) + 2);
                        indices[((renderIndex + j) * 6) + 4] = (ushort)(((renderIndex + j) * 4) + 3);
                        indices[((renderIndex + j) * 6) + 5] = (ushort)(((renderIndex + j) * 4) + 1);
                        UpdateBounds(vertexData, (renderIndex + j) * 4, ref bounds);
                    }
                }
                if (!display || !visible)
                {
                    UnsafeUtility.MemClear((((IntPtr)vertexData.GetUnsafePtr()) + (renderIndex * UnsafeUtility.SizeOf <UIVertexData>() * 4)).ToPointer(), UnsafeUtility.SizeOf <UIVertexData>() * info.renderBoxCount * 4);
                    UnsafeUtility.MemClear((((IntPtr)indices.GetUnsafePtr()) + (renderIndex * UnsafeUtility.SizeOf <ushort>() * 6)).ToPointer(), UnsafeUtility.SizeOf <ushort>() * info.renderBoxCount * 6);
                }
                renderIndex += info.renderBoxCount;
            }
            for (int i = 0; i < headerConfig->childCount; i++)
            {
                RenderMesh(startIndex, currentIndex, UnsafeUtility.ReadArrayElement <int>((graph.value + info.childrenOffset).ToPointer(), i), vertexData, context, indices, graph, graphInfo, nodeInfo, stateLayout, subMeshes, renderNow, updateSubmeshCount, accumulate, ref subMeshIndex, ref renderIndex, ref bounds);
            }
        }