示例#1
0
 public static bool InitVulkan(GameBase baseGame)
 {
     vkTexData = new VRVulkanTextureData_t {
         m_pDevice           = baseGame.GraphicsDevice.NativeDevice.Handle,         // struct VkDevice_T *
         m_pPhysicalDevice   = baseGame.GraphicsDevice.NativePhysicalDevice.Handle, // struct VkPhysicalDevice_T *
         m_pInstance         = baseGame.GraphicsDevice.NativeInstance.Handle,       // struct VkInstance_T *
         m_pQueue            = baseGame.GraphicsDevice.NativeCommandQueue.Handle,   // struct VkQueue_T *
         m_nQueueFamilyIndex = 0                                                    // 0 is hardcoded index during vulkan creation
     };
     Valve.VR.OpenVR.Compositor.SetExplicitTimingMode(EVRCompositorTimingMode.Explicit_ApplicationPerformsPostPresentHandoff);
     return(true);
 }
示例#2
0
文件: OpenVR.cs 项目: nesrak1/xenko
 public static bool InitVulkan(GameBase baseGame)
 {
     vkTexData = new VRVulkanTextureData_t {
         m_pDevice           = baseGame.GraphicsDevice.NativeDevice.NativeHandle,                // struct VkDevice_T *
         m_pPhysicalDevice   = baseGame.GraphicsDevice.NativePhysicalDevice.NativeHandle,        // struct VkPhysicalDevice_T *
         m_pInstance         = baseGame.GraphicsDevice.NativeInstance.NativeHandle,              // struct VkInstance_T *
         m_pQueue            = baseGame.GraphicsDevice.NativeDevice.GetQueue(0, 0).NativeHandle, // struct VkQueue_T *
         m_nQueueFamilyIndex = 0,
         m_nFormat           = (uint)37,                                                         //VkFormat.VK_FORMAT_R8G8B8A8_UNORM (37)
     };
     Valve.VR.OpenVR.Compositor.SetExplicitTimingMode(EVRCompositorTimingMode.Explicit_ApplicationPerformsPostPresentHandoff);
     return(true);
 }
示例#3
0
        public static unsafe bool Submit(int eyeIndex, Texture texture, ref RectangleF viewport)
        {
            var bounds = new VRTextureBounds_t {
                uMin = viewport.X,
                uMax = viewport.Width,
                vMin = viewport.Y,
                vMax = viewport.Height,
            };

#if XENKO_GRAPHICS_API_VULKAN
            var vkTexDataCopy = new VRVulkanTextureData_t {
                m_pDevice         = vkTexData.m_pDevice,
                m_pPhysicalDevice = vkTexData.m_pPhysicalDevice,
                m_pInstance       = vkTexData.m_pInstance,
                m_pQueue          = vkTexData.m_pQueue,
                m_nHeight         = (uint)texture.Height,
                m_nWidth          = (uint)texture.Width,
                m_nImage          = (ulong)texture.NativeImage.Handle,
                m_nSampleCount    = texture.IsMultisample ? (uint)texture.MultisampleCount : 1,
                m_nFormat         = (uint)texture.NativeFormat
            };
            var tex = new Texture_t {
                eType       = ETextureType.Vulkan,
                handle      = (IntPtr)(&vkTexDataCopy),
                eColorSpace = EColorSpace.Auto
            };
            Valve.VR.OpenVR.Compositor.SubmitExplicitTimingData();
            return(Valve.VR.OpenVR.Compositor.Submit(eyeIndex == 0 ? EVREye.Eye_Left : EVREye.Eye_Right, ref tex, ref bounds, EVRSubmitFlags.Submit_Default) == EVRCompositorError.None);
#elif XENKO_GRAPHICS_API_DIRECT3D11
            var tex = new Texture_t {
                eType       = ETextureType.DirectX,
                handle      = texture.SharedHandle,
                eColorSpace = EColorSpace.Auto,
            };
            return(Valve.VR.OpenVR.Compositor.Submit(eyeIndex == 0 ? EVREye.Eye_Left : EVREye.Eye_Right, ref tex, ref bounds, EVRSubmitFlags.Submit_Default) == EVRCompositorError.None);
#endif
        }