Exemplo n.º 1
0
 public PrimeEngine(RayFormat rayFormat, RayHitType hitType, RTPBufferType bufferType = RTPBufferType.Host, bool useCPU = false)
 {
     _rayFormat  = rayFormat;
     _hitType    = hitType;
     _bufferType = bufferType;
     _context    = new PrimeContext(!useCPU);
 }
Exemplo n.º 2
0
        public static unsafe PrimeBuffer Create <T>(PrimeContext ctx, PrimeBufferDesc desc, T[] data)
            where T : struct
        {
            var dataToCopy = new Memory <T>(data);
            var data2Cpy   = dataToCopy.Pin();
            var dataLength = Unsafe.SizeOf <T>() * data.Length;
            var dataPtr    = IntPtr.Zero;

            if (desc.Type == RTPBufferType.CudaLinear)
            {
                //CudaDriverApi.CudaCall(CudaDriverApi.cuMemAlloc(ref dataPtr, (uint) dataLength));

                CudaRunTimeApi.CudaCall(CudaRunTimeApi.cudaMalloc(ref dataPtr, (uint)dataLength));
                CudaRunTimeApi.CudaCall(CudaRunTimeApi.cudaMemcpy(dataPtr.ToPointer(), new IntPtr(data2Cpy.Pointer), (uint)dataLength, CudaMemCpyKind.cudaMemcpyHostToDevice));
                // CudaDriverApi.CudaCall(CudaDriverApi.cuMemcpyHtoD(ref dataPtr, data2Cpy.Pointer, (uint) dataLength));
            }
            else
            {
                dataPtr = Marshal.AllocHGlobal(dataLength);
                GC.AddMemoryPressure(dataLength);
                var span = new Span <T>(data);
                MemoryHelper.CopyFromManaged(ref span, dataPtr, (uint)data.Length);
                // Unsafe.Copy(dataPtr.ToPointer(), ref data);
            }
            data2Cpy.Dispose();

            var buffer = new PrimeBuffer(ctx, desc, dataPtr)
            {
                size = dataLength
            };

            return(buffer);
        }
Exemplo n.º 3
0
        public static PrimeBuffer Create <T>(PrimeContext ctx, PrimeBufferDesc desc, T[] data)
        {
            var h    = GCHandle.Alloc(data, GCHandleType.Pinned);
            var span = new Span <T>(data);

            //MemoryHelper.CopyFromManaged(ref span, );
            throw new NotImplementedException();
        }
Exemplo n.º 4
0
 public PrimeModel(PrimeContext context) : base(context)
 {
     CheckError(PrimeApi.rtpModelCreate(context.InternalPtr, out InternalPtr));
 }
Exemplo n.º 5
0
 public PrimeBuffer(PrimeContext context, PrimeBufferDesc fmt, IntPtr data) : base(context)
 {
     _dataPointer = data;
     CheckError(PrimeApi.rtpBufferDescCreate(context.InternalPtr, (RTPbufferformat)fmt.Format, (RTPbuffertype)fmt.Type, data, out InternalPtr));
 }
Exemplo n.º 6
0
 protected OptixPrimeNode(PrimeContext context)
 {
     this.mContext = context;
 }
Exemplo n.º 7
0
 public PrimeQuery(PrimeContext context, PrimeModel model, QueryType queryType) : base(context)
 {
     _queryType = queryType;
     CheckError(PrimeApi.rtpQueryCreate(model.InternalPtr, (RTPquerytype)queryType, out InternalPtr));
 }