The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

c/main: Add enum to select FoV source

+60 -21
+60 -21
src/xrt/compositor/main/comp_renderer.c
··· 1 - // Copyright 2019-2023, Collabora, Ltd. 1 + // Copyright 2019-2024, Collabora, Ltd. 2 2 // SPDX-License-Identifier: BSL-1.0 3 3 /*! 4 4 * @file ··· 68 68 * Private struct(s). 69 69 * 70 70 */ 71 + 72 + /*! 73 + * What is the source of the FoV values used for the final image that the 74 + * compositor produces and is sent to the hardware (or software). 75 + */ 76 + enum comp_target_fov_source 77 + { 78 + /*! 79 + * The FoV values used for the final target is taken from the 80 + * distortion information on the @ref xrt_hmd_parts struct. 81 + */ 82 + COMP_TARGET_FOV_SOURCE_DISTORTION, 83 + 84 + /*! 85 + * The FoV values used for the final target is taken from the 86 + * those returned from the device's get_views. 87 + */ 88 + COMP_TARGET_FOV_SOURCE_DEVICE_VIEWS, 89 + }; 71 90 72 91 /*! 73 92 * Holds associated vulkan objects and state to render with a distortion. ··· 244 263 245 264 static void 246 265 calc_pose_data(struct comp_renderer *r, 266 + enum comp_target_fov_source fov_source, 247 267 struct xrt_fov out_fovs[2], 248 268 struct xrt_pose out_world[2], 249 269 struct xrt_pose out_eye[2]) ··· 257 277 }; 258 278 259 279 struct xrt_space_relation head_relation = XRT_SPACE_RELATION_ZERO; 260 - struct xrt_fov fovs[2] = XRT_STRUCT_INIT; 261 - struct xrt_pose poses[2] = XRT_STRUCT_INIT; 280 + struct xrt_fov xdev_fovs[2] = XRT_STRUCT_INIT; 281 + struct xrt_pose xdev_poses[2] = XRT_STRUCT_INIT; 262 282 263 283 xrt_device_get_view_poses( // 264 284 r->c->xdev, // xdev ··· 266 286 r->c->frame.rendering.predicted_display_time_ns, // at_timestamp_ns 267 287 2, // view_count 268 288 &head_relation, // out_head_relation 269 - fovs, // out_fovs 270 - poses); // out_poses 289 + xdev_fovs, // out_fovs 290 + xdev_poses); // out_poses 291 + 292 + struct xrt_fov dist_fov[2] = XRT_STRUCT_INIT; 293 + for (uint32_t i = 0; i < 2; i++) { 294 + dist_fov[i] = r->c->xdev->hmd->distortion.fov[i]; 295 + } 296 + 297 + bool use_xdev = false; // Probably what we want. 298 + 299 + switch (fov_source) { 300 + case COMP_TARGET_FOV_SOURCE_DISTORTION: use_xdev = false; break; 301 + case COMP_TARGET_FOV_SOURCE_DEVICE_VIEWS: use_xdev = true; break; 302 + } 271 303 272 304 for (uint32_t i = 0; i < 2; i++) { 273 - const struct xrt_fov fov = fovs[i]; 274 - const struct xrt_pose eye_pose = poses[i]; 305 + const struct xrt_fov fov = use_xdev ? xdev_fovs[i] : dist_fov[i]; 306 + const struct xrt_pose eye_pose = xdev_poses[i]; 275 307 276 308 struct xrt_space_relation result = {0}; 277 309 struct xrt_relation_chain xrc = {0}; ··· 752 784 * @pre render_gfx_init(rr, &c->nr) 753 785 */ 754 786 static XRT_CHECK_RESULT VkResult 755 - dispatch_graphics(struct comp_renderer *r, struct render_gfx *rr) 787 + dispatch_graphics(struct comp_renderer *r, struct render_gfx *rr, enum comp_target_fov_source fov_source) 756 788 { 757 789 COMP_TRACE_MARKER(); 758 790 ··· 778 810 struct xrt_fov fovs[2]; 779 811 struct xrt_pose world_poses[2]; 780 812 struct xrt_pose eye_poses[2]; 781 - calc_pose_data(r, fovs, world_poses, eye_poses); 782 - 783 - // We are rendering for distortion, use their fov values. 784 - struct xrt_fov target_fovs[2] = { 785 - r->c->xdev->hmd->distortion.fov[0], 786 - r->c->xdev->hmd->distortion.fov[1], 787 - }; 813 + calc_pose_data( // 814 + r, // r 815 + fov_source, // fov_source 816 + fovs, // fovs[2] 817 + world_poses, // world_poses[2] 818 + eye_poses); // eye_poses[2] 788 819 789 820 // Need to be begin for all paths. 790 821 render_gfx_begin(rr); ··· 800 831 c->base.slot.layer_count, // layer_count 801 832 world_poses, // world_poses 802 833 eye_poses, // eye_poses 803 - target_fovs, // fovs 834 + fovs, // fovs 804 835 vertex_rots, // vertex_rots 805 836 rtr, // rtr 806 837 viewport_datas, // viewport_datas ··· 831 862 * @pre render_compute_init(crc, &c->nr) 832 863 */ 833 864 static XRT_CHECK_RESULT VkResult 834 - dispatch_compute(struct comp_renderer *r, struct render_compute *crc) 865 + dispatch_compute(struct comp_renderer *r, struct render_compute *crc, enum comp_target_fov_source fov_source) 835 866 { 836 867 COMP_TRACE_MARKER(); 837 868 ··· 847 878 // Device view information. 848 879 struct xrt_fov fovs[2]; // Unused 849 880 struct xrt_pose world_poses[2]; 850 - struct xrt_pose eye_poses[2]; // New eye poses, unused. 851 - calc_pose_data(r, fovs, world_poses, eye_poses); 881 + struct xrt_pose eye_poses[2]; 882 + calc_pose_data( // 883 + r, // r 884 + fov_source, // fov_source 885 + fovs, // fovs[2] 886 + world_poses, // world_poses[2] 887 + eye_poses); // eye_poses[2] 852 888 853 889 // Target Vulkan resources.. 854 890 VkImage target_image = r->c->target->images[r->acquired_buffer].handle; ··· 928 964 929 965 comp_target_update_timings(ct); 930 966 967 + // Hardcoded for now. 968 + enum comp_target_fov_source fov_source = COMP_TARGET_FOV_SOURCE_DISTORTION; 969 + 931 970 bool use_compute = r->settings->use_compute; 932 971 struct render_gfx rr = {0}; 933 972 struct render_compute crc = {0}; ··· 935 974 VkResult res = VK_SUCCESS; 936 975 if (use_compute) { 937 976 render_compute_init(&crc, &c->nr); 938 - res = dispatch_compute(r, &crc); 977 + res = dispatch_compute(r, &crc, fov_source); 939 978 } else { 940 979 render_gfx_init(&rr, &c->nr); 941 - res = dispatch_graphics(r, &rr); 980 + res = dispatch_graphics(r, &rr, fov_source); 942 981 } 943 982 if (res != VK_SUCCESS) { 944 983 return XRT_ERROR_VULKAN;