Class VRCompositor

  • public class VRCompositor
    extends java.lang.Object
    Allows the application to interact with the compositor.
    • Method Detail

      • VRCompositor_GetTrackingSpace

        public static int VRCompositor_GetTrackingSpace()
        Gets current tracking space returned by WaitGetPoses.
      • nVRCompositor_WaitGetPoses

        public static int nVRCompositor_WaitGetPoses​(long pRenderPoseArray,
                                                     int unRenderPoseArrayCount,
                                                     long pGamePoseArray,
                                                     int unGamePoseArrayCount)
        Unsafe version of: WaitGetPoses
      • VRCompositor_WaitGetPoses

        public static int VRCompositor_WaitGetPoses​(TrackedDevicePose.Buffer pRenderPoseArray,
                                                    TrackedDevicePose.Buffer pGamePoseArray)
        Scene applications should call this function to get poses to render with (and optionally poses predicted an additional frame out to use for gameplay). This function will block until "running start" milliseconds before the start of the frame, and should be called at the last moment before needing to start rendering.
      • nVRCompositor_GetLastPoses

        public static int nVRCompositor_GetLastPoses​(long pRenderPoseArray,
                                                     int unRenderPoseArrayCount,
                                                     long pGamePoseArray,
                                                     int unGamePoseArrayCount)
        Unsafe version of: GetLastPoses
      • nVRCompositor_GetLastPoseForTrackedDeviceIndex

        public static int nVRCompositor_GetLastPoseForTrackedDeviceIndex​(int unDeviceIndex,
                                                                         long pOutputPose,
                                                                         long pOutputGamePose)
      • nVRCompositor_Submit

        public static int nVRCompositor_Submit​(int eEye,
                                               long pTexture,
                                               long pBounds,
                                               int nSubmitFlags)
        Unsafe version of: Submit
      • VRCompositor_Submit

        public static int VRCompositor_Submit​(int eEye,
                                              Texture pTexture,
                                              VRTextureBounds pBounds,
                                              int nSubmitFlags)
        Updated scene texture to display.

        If pBounds is NULL the entire texture will be used. If called from an OpenGL app, consider adding a glFlush after submitting both frames to signal the driver to start processing, otherwise it may wait until the command buffer fills up, causing the app to miss frames.

        OpenGL dirty state: glBindTexture

        eEye - one of:
        nSubmitFlags - one of:
        return codes:
        • IsNotSceneApplication (make sure to call VR_Init with VRApplication_Scene)
        • DoNotHaveFocus (some other app has taken focus)
        • TextureIsOnWrongDevice (application did not use proper AdapterIndex - see IVRSystem.GetDXGIOutputInfo)
        • SharedTexturesNotSupported (application needs to call CreateDXGIFactory1 or later before creating DX device)
        • TextureUsesUnsupportedFormat (scene textures must be compatible with DXGI sharing rules - e.g. uncompressed, no mips, etc.)
        • InvalidTexture (usually means bad arguments passed in)
        • AlreadySubmitted (app has submitted two left textures or two right textures in a single frame - i.e. before calling WaitGetPoses again)
      • VRCompositor_ClearLastSubmittedFrame

        public static void VRCompositor_ClearLastSubmittedFrame()
        Clears the frame that was sent with the last call to Submit. This will cause the compositor to show the grid until Submit is called again.
      • VRCompositor_PostPresentHandoff

        public static void VRCompositor_PostPresentHandoff()
        Call immediately after presenting your app's window (i.e. companion window) to unblock the compositor.

        This is an optional call, which only needs to be used if you can't instead call WaitGetPoses immediately after Present(). For example, if your engine's render and game loop are not on separate threads, or blocking the render thread until 3ms before the next vsync would introduce a deadlock of some sort. This function tells the compositor that you have finished all rendering after having Submitted buffers for both eyes, and it is free to start its rendering work. This should only be called from the same thread you are rendering on.

      • nVRCompositor_GetFrameTiming

        public static boolean nVRCompositor_GetFrameTiming​(long pTiming,
                                                           int unFramesAgo)
        Unsafe version of: GetFrameTiming
      • VRCompositor_GetFrameTiming

        public static boolean VRCompositor_GetFrameTiming​(CompositorFrameTiming.Buffer pTiming)
        Returns true if timing data is filled it. Sets oldest timing info if nFramesAgo is larger than the stored history.

        Be sure to set timing.size = sizeof(Compositor_FrameTiming) on struct passed in before calling this function.

      • nVRCompositor_GetFrameTimings

        public static int nVRCompositor_GetFrameTimings​(long pTiming,
                                                        int nFrames)
        Unsafe version of: GetFrameTimings
      • VRCompositor_GetFrameTimings

        public static int VRCompositor_GetFrameTimings​(CompositorFrameTiming.Buffer pTiming)
        Interface for copying a range of timing data. Frames are returned in ascending order (oldest to newest) with the last being the most recent frame. Only the first entry's m_nSize needs to be set, as the rest will be inferred from that. Returns total number of entries filled out.
      • VRCompositor_GetFrameTimeRemaining

        public static float VRCompositor_GetFrameTimeRemaining()
        Returns the time in seconds left in the current (as identified by FrameTiming's frameIndex) frame.

        Due to "running start", this value may roll over to the next frame before ever reaching 0.0.

      • nVRCompositor_GetCumulativeStats

        public static void nVRCompositor_GetCumulativeStats​(long pStats,
                                                            int nStatsSizeInBytes)
        Unsafe version of: GetCumulativeStats
      • VRCompositor_GetCumulativeStats

        public static void VRCompositor_GetCumulativeStats​(CompositorCumulativeStats pStats,
                                                           int nStatsSizeInBytes)
        Fills out stats accumulated for the last connected application.
        nStatsSizeInBytes - must be sizeof( Compositor_CumulativeStats )
      • VRCompositor_GetCumulativeStats

        public static void VRCompositor_GetCumulativeStats​(CompositorCumulativeStats pStats)
        Fills out stats accumulated for the last connected application.
      • VRCompositor_FadeToColor

        public static void VRCompositor_FadeToColor​(float fSeconds,
                                                    float fRed,
                                                    float fGreen,
                                                    float fBlue,
                                                    float fAlpha,
                                                    boolean bBackground)
        Fades the view on the HMD to the specified color.

        The fade will take fSeconds, and the color values are between 0.0 and 1.0. This color is faded on top of the scene based on the alpha parameter. Removing the fade color instantly would be FadeToColor( 0.0, 0.0, 0.0, 0.0, 0.0 ). Values are in un-premultiplied alpha space.

      • nVRCompositor_GetCurrentFadeColor

        public static void nVRCompositor_GetCurrentFadeColor​(boolean bBackground,
                                                             long __functionAddress,
                                                             long __result)
        public static void nVRCompositor_GetCurrentFadeColor​(boolean bBackground,
                                                             long __result)
        Unsafe version of: GetCurrentFadeColor
      • VRCompositor_GetCurrentFadeColor

        public static HmdColor VRCompositor_GetCurrentFadeColor​(boolean bBackground,
                                                                HmdColor __result)
        Get current fade color value.
      • VRCompositor_FadeGrid

        public static void VRCompositor_FadeGrid​(float fSeconds,
                                                 boolean bFadeIn)
        Fading the Grid in or out in fSeconds.
      • VRCompositor_GetCurrentGridAlpha

        public static float VRCompositor_GetCurrentGridAlpha()
        Get current alpha value of grid.
      • nVRCompositor_SetSkyboxOverride

        public static int nVRCompositor_SetSkyboxOverride​(long pTextures,
                                                          int unTextureCount)
        Unsafe version of: SetSkyboxOverride
      • VRCompositor_SetSkyboxOverride

        public static int VRCompositor_SetSkyboxOverride​(Texture.Buffer pTextures)
        Override the skybox used in the compositor (e.g. for during level loads when the app can't feed scene images fast enough)

        Order is Front, Back, Left, Right, Top, Bottom. If only a single texture is passed, it is assumed in lat-long format. If two are passed, it is assumed a lat-long stereo pair.

      • VRCompositor_ClearSkyboxOverride

        public static void VRCompositor_ClearSkyboxOverride()
        Resets compositor skybox back to defaults.
      • VRCompositor_CompositorBringToFront

        public static void VRCompositor_CompositorBringToFront()
        Brings the compositor window to the front. This is useful for covering any other window that may be on the HMD and is obscuring the compositor window.
      • VRCompositor_CompositorGoToBack

        public static void VRCompositor_CompositorGoToBack()
        Pushes the compositor window to the back. This is useful for allowing other applications to draw directly to the HMD.
      • VRCompositor_CompositorQuit

        public static void VRCompositor_CompositorQuit()
        Tells the compositor process to clean up and exit. You do not need to call this function at shutdown. Under normal circumstances the compositor will manage its own life cycle based on what applications are running.
      • VRCompositor_IsFullscreen

        public static boolean VRCompositor_IsFullscreen()
        Return whether the compositor is fullscreen.
      • VRCompositor_GetCurrentSceneFocusProcess

        public static int VRCompositor_GetCurrentSceneFocusProcess()
        Returns the process ID of the process that is currently rendering the scene.
      • VRCompositor_GetLastFrameRenderer

        public static int VRCompositor_GetLastFrameRenderer()
        Returns the process ID of the process that rendered the last frame (or 0 if the compositor itself rendered the frame).
        0 when fading out from an app and the app's process Id when fading into an app
      • VRCompositor_CanRenderScene

        public static boolean VRCompositor_CanRenderScene()
        Returns true if the current process has the scene focus.
      • VRCompositor_ShowMirrorWindow

        public static void VRCompositor_ShowMirrorWindow()
        Opens the headset view (as either a window or docked widget depending on user's preferences) that displays what the user sees in the headset.
      • VRCompositor_HideMirrorWindow

        public static void VRCompositor_HideMirrorWindow()
        Closes the headset view, either as a window or docked widget.
      • VRCompositor_IsMirrorWindowVisible

        public static boolean VRCompositor_IsMirrorWindowVisible()
        Returns true if the headset view (either as a window or docked widget) is shown.
      • VRCompositor_CompositorDumpImages

        public static void VRCompositor_CompositorDumpImages()
        Writes back buffer and stereo left/right pair from the application to a 'screenshots' folder in the SteamVR runtime root.
      • VRCompositor_ShouldAppRenderWithLowResources

        public static boolean VRCompositor_ShouldAppRenderWithLowResources()
        Let an app know it should be rendering with low resources.
      • VRCompositor_ForceInterleavedReprojectionOn

        public static void VRCompositor_ForceInterleavedReprojectionOn​(boolean bOverride)
        Override interleaved reprojection logic to force on.
      • VRCompositor_ForceReconnectProcess

        public static void VRCompositor_ForceReconnectProcess()
        Force reconnecting to the compositor process.
      • VRCompositor_SuspendRendering

        public static void VRCompositor_SuspendRendering​(boolean bSuspend)
        Temporarily suspends rendering (useful for finer control over scene transitions).
      • nVRCompositor_GetMirrorTextureD3D11

        public static int nVRCompositor_GetMirrorTextureD3D11​(int eEye,
                                                              long pD3D11DeviceOrResource,
                                                              long ppD3D11ShaderResourceView)
        Unsafe version of: GetMirrorTextureD3D11
      • VRCompositor_GetMirrorTextureD3D11

        public static int VRCompositor_GetMirrorTextureD3D11​(int eEye,
                                                             long pD3D11DeviceOrResource,
                                                             PointerBuffer ppD3D11ShaderResourceView)
        Opens a shared D3D11 texture with the undistorted composited image for each eye.

        Use ReleaseMirrorTextureD3D11 when finished instead of calling Release on the resource itself.

      • VRCompositor_ReleaseMirrorTextureD3D11

        public static void VRCompositor_ReleaseMirrorTextureD3D11​(long pD3D11ShaderResourceView)
        Releases a shared D3D11 texture.
      • nVRCompositor_GetMirrorTextureGL

        public static int nVRCompositor_GetMirrorTextureGL​(int eEye,
                                                           long pglTextureId,
                                                           long pglSharedTextureHandle)
        Unsafe version of: GetMirrorTextureGL
      • VRCompositor_GetMirrorTextureGL

        public static int VRCompositor_GetMirrorTextureGL​(int eEye,
                                                          java.nio.IntBuffer pglTextureId,
                                                          PointerBuffer pglSharedTextureHandle)
        Access to mirror textures from OpenGL.
      • VRCompositor_ReleaseSharedGLTexture

        public static boolean VRCompositor_ReleaseSharedGLTexture​(int glTextureId,
                                                                  long glSharedTextureHandle)
      • VRCompositor_LockGLSharedTextureForAccess

        public static void VRCompositor_LockGLSharedTextureForAccess​(long glSharedTextureHandle)
      • VRCompositor_UnlockGLSharedTextureForAccess

        public static void VRCompositor_UnlockGLSharedTextureForAccess​(long glSharedTextureHandle)
      • nVRCompositor_GetVulkanInstanceExtensionsRequired

        public static int nVRCompositor_GetVulkanInstanceExtensionsRequired​(long pchValue,
                                                                            int unBufferSize)
      • VRCompositor_GetVulkanInstanceExtensionsRequired

        public static int VRCompositor_GetVulkanInstanceExtensionsRequired​(@Nullable
                                                                           java.nio.ByteBuffer pchValue)
        public static java.lang.String VRCompositor_GetVulkanInstanceExtensionsRequired​(int unBufferSize)
        Returns 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing null. The string will be a space separated list of-required instance extensions to enable in VkCreateInstance.
      • nVRCompositor_GetVulkanDeviceExtensionsRequired

        public static int nVRCompositor_GetVulkanDeviceExtensionsRequired​(long pPhysicalDevice,
                                                                          long pchValue,
                                                                          int unBufferSize)
      • VRCompositor_GetVulkanDeviceExtensionsRequired

        public static int VRCompositor_GetVulkanDeviceExtensionsRequired​(long pPhysicalDevice,
                                                                         java.nio.ByteBuffer pchValue)
        public static java.lang.String VRCompositor_GetVulkanDeviceExtensionsRequired​(long pPhysicalDevice,
                                                                                      int unBufferSize)
        Returns 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing null. The string will be a space separated list of required device extensions to enable in VkCreateDevice.
      • VRCompositor_SetExplicitTimingMode

        public static void VRCompositor_SetExplicitTimingMode​(int eTimingMode)

        Vulkan/D3D12 Only

        There are two purposes for SetExplicitTimingMode:

        1. To get a more accurate GPU timestamp for when the frame begins in Vulkan/D3D12 applications.
        2. (Optional) To avoid having WaitGetPoses access the Vulkan queue so that the queue can be accessed from another thread while WaitGetPoses is executing.

        More accurate GPU timestamp for the start of the frame is achieved by the application calling SubmitExplicitTimingData immediately before its first submission to the Vulkan/D3D12 queue. This is more accurate because normally this GPU timestamp is recorded during WaitGetPoses. In D3D11, WaitGetPoses queues a GPU timestamp write, but it does not actually get submitted to the GPU until the application flushes. By using SubmitExplicitTimingData, the timestamp is recorded at the same place for Vulkan/D3D12 as it is for D3D11, resulting in a more accurate GPU time measurement for the frame.

        Avoiding WaitGetPoses accessing the Vulkan queue can be achieved using SetExplicitTimingMode as well. If this is desired, the application should set the timing mode to VR.EVRCompositorTimingMode_VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff and MUST call PostPresentHandoff itself. If these conditions are met, then WaitGetPoses is guaranteed not to access the queue. Note that PostPresentHandoff and SubmitExplicitTimingData will access the queue, so only WaitGetPoses becomes safe for accessing the queue from another thread.

      • VRCompositor_SubmitExplicitTimingData

        public static int VRCompositor_SubmitExplicitTimingData()

        Vulkan/D3D12 Only

        Submit explicit timing data. When SetExplicitTimingMode is true, this must be called immediately before the application's first vkQueueSubmit (Vulkan) or ID3D12CommandQueue::ExecuteCommandLists (D3D12) of each frame. This function will insert a GPU timestamp write just before the application starts its rendering. This function will perform a vkQueueSubmit on Vulkan so must not be done simultaneously with VkQueue operations on another thread.

        VR.EVRCompositorError_VRCompositorError_RequestFailed if SetExplicitTimingMode is not enabled
      • VRCompositor_IsMotionSmoothingEnabled

        public static boolean VRCompositor_IsMotionSmoothingEnabled()
        Indicates whether or not motion smoothing is enabled by the user settings.

        If you want to know if motion smoothing actually triggered due to a late frame, check CompositorFrameTiming m_nReprojectionFlags & VRCompositor_ReprojectionMotion instead.

      • VRCompositor_IsMotionSmoothingSupported

        public static boolean VRCompositor_IsMotionSmoothingSupported()
        Indicates whether or not motion smoothing is supported by the current hardware.
      • VRCompositor_IsCurrentSceneFocusAppLoading

        public static boolean VRCompositor_IsCurrentSceneFocusAppLoading()
        Indicates whether or not the current scene focus app is currently loading.

        This is inferred from its use of FadeGrid to explicitly fade to the compositor to cover up the fact that it cannot render at a sustained full framerate during this time.