示例#1
0
 public void Init()
 {
     rng = new Random(1);
     u   = (uint4 *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <uint4>() * iterations, UnsafeUtility.AlignOf <uint4>(), Allocator.Persistent);
     for (int i = 0; i < iterations; ++i)
     {
         u[i] = 0;
     }
 }
                public void Init()
                {
                    f4 = (float4 *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <float4>() * 10000, UnsafeUtility.AlignOf <float4>(), Allocator.Persistent);
                    for (int i = 0; i < 10000; ++i)
                    {
                        f4[i] = new float4(1.0f, 2.0f, 3.0f, 4.0f);
                    }

                    u4 = (uint4 *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <uint4>() * 10000, UnsafeUtility.AlignOf <uint4>(), Allocator.Persistent);
                    for (int i = 0; i < 10000; ++i)
                    {
                        u4[i] = new uint4(100, 101, 102, 103);
                    }
                }
示例#3
0
                public void Init()
                {
                    v = (float4x4 *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <float4x4>() * 100000, UnsafeUtility.AlignOf <float4x4>(), Allocator.Persistent);
                    for (int i = 0; i < 100000; ++i)
                    {
                        v[i] = new float4x4(1.0f);
                    }

                    hash = (uint4 *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <uint4>() * 100000, UnsafeUtility.AlignOf <uint4>(), Allocator.Persistent);
                    for (int i = 0; i < 100000; ++i)
                    {
                        hash[i] = 0;
                    }
                }
                public void Init()
                {
                    rng = (Random *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <Random>() * 10000, UnsafeUtility.AlignOf <Random>(), Allocator.Persistent);
                    for (int i = 0; i < 10000; ++i)
                    {
                        rng[i] = new Unity.Mathematics.Random(1);
                    }

                    u = (uint4 *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <uint4>() * 10000, UnsafeUtility.AlignOf <uint4>(), Allocator.Persistent);
                    for (int i = 0; i < 10000; ++i)
                    {
                        u[i] = 0;
                    }
                }
                public void Init()
                {
                    rng = new Random(1);
                    v   = (float4x4 *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <float4x4>() * iterations, UnsafeUtility.AlignOf <float4x4>(), Allocator.Persistent);
                    for (int i = 0; i < iterations; ++i)
                    {
                        v[i] = new float4x4(1.0f);
                    }

                    hash = (uint4 *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <uint4>() * iterations, UnsafeUtility.AlignOf <uint4>(), Allocator.Persistent);
                    for (int i = 0; i < iterations; ++i)
                    {
                        hash[i] = 0;
                    }
                }
示例#6
0
        static unsafe JobHandle?GetJointsJob(
            void *input,
            int count,
            GLTFComponentType inputType,
            int inputByteStride,
            uint4 *output,
            int outputByteStride,
            ICodeLogger logger
            )
        {
            Profiler.BeginSample("GetJointsJob");
            JobHandle?jobHandle;

            switch (inputType)
            {
            case GLTFComponentType.UnsignedByte:
                var jointsUInt8Job = new Jobs.ConvertBoneJointsUInt8ToUInt32Job();
                jointsUInt8Job.inputByteStride  = inputByteStride > 0 ? inputByteStride : 4;
                jointsUInt8Job.input            = (byte *)input;
                jointsUInt8Job.outputByteStride = outputByteStride;
                jointsUInt8Job.result           = output;
                jobHandle = jointsUInt8Job.Schedule(count, GltfImport.DefaultBatchCount);
                break;

            case GLTFComponentType.UnsignedShort:
                var jointsUInt16Job = new Jobs.ConvertBoneJointsUInt16ToUInt32Job();
                jointsUInt16Job.inputByteStride  = inputByteStride > 0 ? inputByteStride : 8;
                jointsUInt16Job.input            = (byte *)input;
                jointsUInt16Job.outputByteStride = outputByteStride;
                jointsUInt16Job.result           = output;
                jobHandle = jointsUInt16Job.Schedule(count, GltfImport.DefaultBatchCount);
                break;

            default:
                logger?.Error(LogCode.TypeUnsupported, "Joints", inputType.ToString());
                jobHandle = null;
                break;
            }

            Profiler.EndSample();
            return(jobHandle);
        }
		/// <summary>
		/// Creates a new CudaRegisteredHostMemory_uint4 from an existing IntPtr. IntPtr must be page size aligned (4KBytes)!
		/// </summary>
		/// <param name="hostPointer">must be page size aligned (4KBytes)</param>
		/// <param name="size">In elements</param>
		public CudaRegisteredHostMemory_uint4(IntPtr hostPointer, SizeT size)
		{
			_intPtr = hostPointer;
			_size = size;
			_typeSize = (SizeT)Marshal.SizeOf(typeof(uint4));
			_ptr = (uint4*)_intPtr;
		}