14#include "xrt/xrt_config_build.h"
31#include "openvr_interfaces_unified.h"
40namespace xrt::state_trackers::openvr {
59 if (this->
xsc !=
nullptr) {
60 xrt_swapchain_release_image(this->
xsc, this->swapchain_index);
63 xrt_swapchain_reference(&this->
xsc,
nullptr);
90 uint32_t storage_format{0};
91 uint32_t sample_format{0};
97 uint32_t storage_format,
98 uint32_t sample_format,
113 std::array<xrt_fov, 2> fovs;
114 std::array<xrt_pose, 2> T_head_eyes;
123 std::optional<FrameState> active_frame{std::nullopt};
125 std::array<std::optional<EyeState>, 2> frame_eye_states{std::nullopt, std::nullopt};
127 std::array<SwapchainCache, 2> swapchain_caches{};
140#ifdef XRT_HAVE_VULKAN
156 VkSampler sampler{VK_NULL_HANDLE};
159 VkPipelineCache pipeline_cache{VK_NULL_HANDLE};
162 VkPipelineLayout pipeline_layout{VK_NULL_HANDLE};
165 VkDescriptorPool descriptor_pool{VK_NULL_HANDLE};
168 VkDescriptorSetLayout descriptor_set_layout{VK_NULL_HANDLE};
171 VkDescriptorSet descriptor_set{VK_NULL_HANDLE};
174 std::array<VkPipeline, RENDER_BLIT_RESOLVE_COLOR_MODE_COUNT> pipelines{};
178 std::optional<RenderStateCache> render_state_cache{std::nullopt};
180 std::shared_ptr<Events> events{};
183 std::optional<timepoint_ns> last_predicted_display_time{std::nullopt};
184 std::optional<time_duration_ns> last_predicted_display_period{std::nullopt};
186 std::array<vr::TrackedDevicePose_t, vr::k_unMaxTrackedDeviceCount> last_render_poses{};
187 std::array<vr::TrackedDevicePose_t, vr::k_unMaxTrackedDeviceCount> last_game_poses{};
189 vr::ETrackingUniverseOrigin current_tracking_universe{vr::ETrackingUniverseOrigin::TrackingUniverseSeated};
192#ifdef XRT_HAVE_VULKAN
198 SetupVulkanCompositor(
openvr_logger &logger, vr::VRVulkanTextureData_t &vulkan_data);
201 DestroyVulkanResources();
207 vr::VRVulkanTextureData_t &texture_data,
208 VkFormat storage_format,
209 vr::EColorSpace color_space,
213 vr::EVRCompositorError
216 vr::VRVulkanTextureData_t &texture_data,
217 vr::EColorSpace color_space,
218 const vr::VRTextureBounds_t &bounds);
221 GetVulkanOutputDevice(
openvr_logger &logger, uint64_t *out_device, VkInstance pInstance);
226 GetProjectionLayerDataForEye(vr::EVREye eye,
const EyeState &eye_state);
229 vr::EVRCompositorError
236 std::shared_ptr<Events> &events);
244 vr::EVRCompositorError
248 vr::EVRCompositorError
252 const vr::VRTextureBounds_t &bounds,
253 vr::EVRSubmitFlags nSubmitFlags);
257 uint64_t *out_device,
258 vr::ETextureType texture_type,
259 VkInstance pInstance);
262 GetTimeForPredictions();
268 GetFrameRenderState(std::array<xrt_fov, 2> &fovs,
269 std::array<xrt_pose, 2> &T_head_eyes,
int64_t timepoint_ns
Integer timestamp type.
Definition u_time.h:77
int64_t time_duration_ns
Integer duration type in nanoseconds.
Definition u_time.h:88
xrt_swapchain_usage_bits
Usage of the swapchain images.
Definition xrt_compositor.h:563
xrt_swapchain_create_flags
Special flags for creating swapchain images.
Definition xrt_compositor.h:545
enum xrt_result xrt_result_t
Result type used across Monado.
Implementation of OpenVR event handling and related functionality.
The NEW compositor rendering code header.
Shader loading interface.
Definition m_space.cpp:87
Holds all shaders.
Definition render_shaders_interface.h:26
Helper struct to make code easier to read.
Definition render_distortion.c:183
A bundle of Vulkan functions and objects, used by both Compositor and Compositor client code.
Definition vk_helpers.h:81
Small helper to manage lock around a command pool.
Definition vk_cmd_pool.h:33
Definition openvr_compositor.hpp:120
vr::EVRCompositorError Submit(openvr_logger &logger, vr::EVREye eye, const vr::Texture_t &texture, const vr::VRTextureBounds_t &bounds, vr::EVRSubmitFlags nSubmitFlags)
Submits a texture for an eye, completing the frame if both eyes have been submit.
Definition openvr_compositor.cpp:208
vr::EVRCompositorError WaitBeginFrame(openvr_logger &logger)
Waits for the next frame and begins it, cancelling/releasing any previously active frame and it's res...
Definition openvr_compositor.cpp:142
Definition openvr_compositor.hpp:68
Definition openvr_compositor.hpp:43
xrt_swapchain * xsc
The swapchain in use.
Definition openvr_compositor.hpp:45
xrt_rect bounds
The sub-image of the runtime swapchain texture to submit to the compositor.
Definition openvr_compositor.hpp:55
uint32_t swapchain_index
The index into the eye's swapchain for the currently held texture.
Definition openvr_compositor.hpp:47
uint32_t width
The width of the currently held runtime swapchain texture.
Definition openvr_compositor.hpp:50
uint32_t height
The height of the currently held runtime swapchain texture.
Definition openvr_compositor.hpp:52
Definition openvr_compositor.hpp:73
Definition openvr_compositor.hpp:112
Since eye textures are created by the clients, and not the runtime, we have to do a copy into a runti...
Definition openvr_compositor.hpp:84
void Reset()
Resets the internal state of the cache, releasing any swapchain it holds.
Definition openvr_compositor.cpp:94
xrt_result_t EnsureSwapchain(xrt_compositor *xc, uint32_t storage_format, uint32_t sample_format, uint32_t width, uint32_t height, xrt_swapchain_usage_bits usage_bits, xrt_swapchain_create_flags flags)
Ensures that there is a swapchain in the cache with the given properties, creating one if necessary.
Definition openvr_compositor.cpp:31
Definition openvr_logger.hpp:30
Main compositor server interface.
Definition xrt_compositor.h:2290
Base class for a Vulkan client compositor.
Definition xrt_compositor.h:2085
Common compositor client interface/base.
Definition xrt_compositor.h:1046
All of the pure data values associated with a single view in a projection layer.
Definition xrt_compositor.h:261
A pose composed of a position and orientation.
Definition xrt_defines.h:492
Image rectangle.
Definition xrt_defines.h:457
Common swapchain interface/base.
Definition xrt_compositor.h:593
The system compositor handles composition for a system.
Definition xrt_compositor.h:2531
A collection of xrt_device, and an interface for identifying the roles they have been assigned.
Definition xrt_system.h:215
Time-keeping: a clock that is steady, convertible to system time, and ideally high-resolution.
Common Vulkan code header.
Header declaring XRT graphics interfaces.
Header defining an xrt display or controller device.
Header defining an XRT graphics provider.
Header for system objects.