예제 #1
0
        public override void UpdateSurface(CommandList commandList, Texture texture)
        {
            OculusOvr.SetQuadLayerParams(OverlayPtr, ref Position, ref Rotation, ref SurfaceSize, FollowHeadRotation);
            var index = OculusOvr.GetCurrentQuadLayerTargetIndex(ovrSession, OverlayPtr);

            commandList.Copy(texture, textures[index]);
        }
예제 #2
0
        public override void Commit(CommandList commandList, Texture renderFrame)
        {
            var index = OculusOvr.GetCurrentTargetIndex(ovrSession);

            commandList.Copy(renderFrame, textures[index]);
            overlayPtrs = overlays.Where(x => x.Enabled).Select(x => x.OverlayPtr).ToArray();
            OculusOvr.CommitFrame(ovrSession, overlayPtrs.Length, overlayPtrs);
        }
예제 #3
0
        /// <summary>
        /// Copies the content of this buffer from GPU memory to a CPU memory using a specific staging resource.
        /// </summary>
        /// <param name="stagingTexture">The staging buffer used to transfer the buffer.</param>
        /// <param name="toData">To data pointer.</param>
        /// <exception cref="System.ArgumentException">When strides is different from optimal strides, and TData is not the same size as the pixel format, or Width * Height != toData.Length</exception>
        /// <remarks>
        /// This method is only working when called from the main thread that is accessing the main <see cref="GraphicsDevice"/>.
        /// </remarks>
        public void GetData(CommandList commandList, Buffer stagingTexture, DataPointer toData)
        {
            // Check size validity of data to copy to
            if (toData.Size > this.Description.SizeInBytes)
            {
                throw new ArgumentException("Length of TData is larger than size of buffer");
            }

            // Copy the texture to a staging resource
            if (!ReferenceEquals(this, stagingTexture))
            {
                commandList.Copy(this, stagingTexture);
            }

            // Map the staging resource to a CPU accessible memory
            var mappedResource = commandList.MapSubresource(stagingTexture, 0, MapMode.Read);

            Utilities.CopyMemory(toData.Pointer, mappedResource.DataBox.DataPointer, toData.Size);
            // Make sure that we unmap the resource in case of an exception
            commandList.UnmapSubresource(mappedResource);
        }