示例#1
0
        public void GetResults(TraversalResult[] results)
        {
            if (results == null || results.Length == 0)
            {
                return;
            }

            var resultData = IntPtr.Zero;
            var resultsPtr = GCHandle.Alloc(results, GCHandleType.Pinned);


            CheckError(TraversalApi.rtuTraversalMapResults(mTraversal, ref resultData));

            if (resultData == IntPtr.Zero)
            {
                throw new OptixException("Traversal Error: Results buffer cannot be mapped");
            }

            MemoryHelper.BlitMemory(resultsPtr.AddrOfPinnedObject(), resultData, (uint)(mCurrentNumRays * 8u));

            CheckError(TraversalApi.rtuTraversalUnmapResults(mTraversal));
            resultsPtr.Free();
        }
示例#2
0
        public void Read <T>(ref T r)
            where T : struct
        {
            if (!mCanRead)
            {
                throw new NotSupportedException("Optix Error: BufferStream: Cannot read from non Output Optix buffers");
            }

            var elemSize    = Marshal.SizeOf <T>();
            var sizeInBytes = elemSize;

            // internal checks
            if (mPosition + sizeInBytes > mSize)
            {
                throw new EndOfStreamException();
            }

            var l = GCHandle.Alloc(r, GCHandleType.Pinned);

            MemoryHelper.BlitMemory(new IntPtr(this.Buffer.ToInt64() + mPosition), l.AddrOfPinnedObject(), (uint)sizeInBytes);
            mPosition += sizeInBytes;
            l.Free();
        }