The open source OpenXR runtime

xrt: adapt driver to new compute_distortion api change

Co-authored-by: Korcan Hussein <korcan.hussein@collabora.com>
Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2367>

authored by

Simon Zeni
Korcan Hussein
and committed by
Korcan Hussein
02fae7c2 e1eda30a

+61 -83
+2 -2
src/xrt/auxiliary/util/u_device.c
··· 547 547 return XRT_ERROR_NOT_IMPLEMENTED; 548 548 } 549 549 550 - bool 550 + xrt_result_t 551 551 u_device_ni_compute_distortion( 552 552 struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result) 553 553 { 554 554 E(compute_distortion); 555 - return false; 555 + return XRT_ERROR_NOT_IMPLEMENTED; 556 556 } 557 557 558 558 xrt_result_t
+1 -1
src/xrt/auxiliary/util/u_device.h
··· 248 248 * 249 249 * @ingroup aux_util 250 250 */ 251 - bool 251 + xrt_result_t 252 252 u_device_ni_compute_distortion( 253 253 struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result); 254 254
+10 -17
src/xrt/auxiliary/util/u_distortion_mesh.c
··· 25 25 DEBUG_GET_ONCE_NUM_OPTION(mesh_size, "XRT_MESH_SIZE", 64) 26 26 27 27 28 - typedef bool (*func_calc)(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result); 28 + typedef xrt_result_t (*func_calc)( 29 + struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result); 29 30 30 31 static int 31 32 index_for(int row, int col, uint32_t stride, uint32_t offset) ··· 398 399 } 399 400 400 401 401 - bool 402 - u_compute_distortion_none(float u, float v, struct xrt_uv_triplet *result) 403 - { 404 - result->r.x = u; 405 - result->r.y = v; 406 - result->g.x = u; 407 - result->g.y = v; 408 - result->b.x = u; 409 - result->b.y = v; 410 - return true; 411 - } 412 - 413 - 414 - 415 402 /* 416 403 * 417 404 * No distortion. 418 405 * 419 406 */ 420 407 421 - bool 408 + xrt_result_t 422 409 u_distortion_mesh_none(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result) 423 410 { 424 - return u_compute_distortion_none(u, v, result); 411 + result->r.x = u; 412 + result->r.y = v; 413 + result->g.x = u; 414 + result->g.y = v; 415 + result->b.x = u; 416 + result->b.y = v; 417 + return XRT_SUCCESS; 425 418 } 426 419 427 420 void
+1 -9
src/xrt/auxiliary/util/u_distortion_mesh.h
··· 165 165 */ 166 166 167 167 /*! 168 - * Identity distortion correction sets all result coordinates to u,v. 169 - * 170 - * @ingroup aux_distortion 171 - */ 172 - bool 173 - u_compute_distortion_none(float u, float v, struct xrt_uv_triplet *result); 174 - 175 - /*! 176 168 * Helper function for none distortion devices. 177 169 * 178 170 * @ingroup aux_distortion 179 171 */ 180 - bool 172 + xrt_result_t 181 173 u_distortion_mesh_none(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result); 182 174 183 175
+3 -2
src/xrt/drivers/android/android_sensors.c
··· 231 231 * 232 232 */ 233 233 234 - static bool 234 + static xrt_result_t 235 235 android_device_compute_distortion( 236 236 struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result) 237 237 { 238 238 struct android_device *d = android_device(xdev); 239 - return u_compute_distortion_cardboard(&d->cardboard.values[view], u, v, result); 239 + u_compute_distortion_cardboard(&d->cardboard.values[view], u, v, result); 240 + return XRT_SUCCESS; 240 241 } 241 242 242 243
+1 -2
src/xrt/drivers/multi_wrapper/multi.c
··· 16 16 17 17 #include "multi.h" 18 18 19 - 20 19 DEBUG_GET_ONCE_LOG_OPTION(multi_log, "MULTI_LOG", U_LOGGING_WARN) 21 20 22 21 #define MULTI_TRACE(d, ...) U_LOG_XDEV_IFL_T(&d->base, d->log_level, __VA_ARGS__) ··· 217 216 return xrt_device_get_tracked_pose(xdev, XRT_INPUT_GENERIC_HEAD_POSE, at_timestamp_ns, out_head_relation); 218 217 } 219 218 220 - static bool 219 + static xrt_result_t 221 220 compute_distortion(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result) 222 221 { 223 222 struct multi_device *d = (struct multi_device *)xdev;
+14 -12
src/xrt/drivers/north_star/ns_hmd.c
··· 418 418 return XRT_SUCCESS; 419 419 } 420 420 421 - bool 421 + static xrt_result_t 422 422 ns_mesh_calc(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result) 423 423 { 424 424 struct ns_hmd *ns = ns_hmd(xdev); 425 425 NS_DEBUG(ns, "Called!"); 426 426 // struct xrt_vec2 warped_uv; 427 + 427 428 switch (ns->config.distortion_type) { 428 429 case NS_DISTORTION_TYPE_GEOMETRIC_3D: { 429 430 struct xrt_vec2 uv = {u, v}; ··· 437 438 result->g.y = warped_uv.y; 438 439 result->b.x = warped_uv.x; 439 440 result->b.y = warped_uv.y; 440 - return true; 441 - } 442 - case NS_DISTORTION_TYPE_POLYNOMIAL_2D: { 443 - return u_compute_distortion_ns_p2d(&ns->config.dist_p2d, view, u, v, result); 444 - } 445 - case NS_DISTORTION_TYPE_MOSHI_MESHGRID: { 446 - return u_compute_distortion_ns_meshgrid(&ns->config.dist_meshgrid, view, u, v, result); 447 - } 448 - default: { 449 - assert(false); 450 - return false; 441 + 442 + res = true; 443 + break; 451 444 } 445 + case NS_DISTORTION_TYPE_POLYNOMIAL_2D: 446 + u_compute_distortion_ns_p2d(&ns->config.dist_p2d, view, u, v, result); 447 + break; 448 + case NS_DISTORTION_TYPE_MOSHI_MESHGRID: 449 + u_compute_distortion_ns_meshgrid(&ns->config.dist_meshgrid, view, u, v, result); 450 + break; 451 + default: assert(false); break; 452 452 } 453 + 454 + return XRT_SUCCESS; 453 455 } 454 456 455 457 /*
+4 -4
src/xrt/drivers/ohmd/oh_device.c
··· 719 719 result->b = b_uv; 720 720 } 721 721 722 - static bool 722 + static xrt_result_t 723 723 compute_distortion_openhmd(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result) 724 724 { 725 725 struct oh_device *ohd = oh_device(xdev); 726 726 u_compute_distortion_openhmd(&ohd->distortion.openhmd[view], u, v, result); 727 - return true; 727 + return XRT_SUCCESS; 728 728 } 729 729 730 - static bool 730 + static xrt_result_t 731 731 compute_distortion_vive(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result) 732 732 { 733 733 struct oh_device *ohd = oh_device(xdev); 734 734 u_compute_distortion_vive(&ohd->distortion.vive[view], u, v, result); 735 - return true; 735 + return XRT_SUCCESS; 736 736 } 737 737 738 738 static inline void
+2 -2
src/xrt/drivers/psvr/psvr_device.c
··· 1006 1006 u_device_free(&psvr->base); 1007 1007 } 1008 1008 1009 - static bool 1009 + static xrt_result_t 1010 1010 psvr_compute_distortion(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result) 1011 1011 { 1012 1012 struct psvr_device *psvr = psvr_device(xdev); 1013 1013 1014 1014 u_compute_distortion_panotools(&psvr->vals, u, v, result); 1015 - return true; 1015 + return XRT_SUCCESS; 1016 1016 } 1017 1017 1018 1018
+2 -2
src/xrt/drivers/rift/rift_distortion.c
··· 390 390 } 391 391 #endif 392 392 393 - bool 393 + xrt_result_t 394 394 rift_hmd_compute_distortion(struct xrt_device *dev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result) 395 395 { 396 396 #define TO_NDC(x) ((x * 2) - 1) ··· 420 420 421 421 *out_result = sample_tex_coord; 422 422 423 - return true; 423 + return XRT_SUCCESS; 424 424 425 425 #undef TO_NDC 426 426 }
+1 -1
src/xrt/drivers/rift/rift_distortion.h
··· 36 36 void 37 37 rift_fill_in_default_distortions(struct rift_hmd *hmd); 38 38 39 - bool 39 + xrt_result_t 40 40 rift_hmd_compute_distortion(struct xrt_device *dev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result);
+2 -2
src/xrt/drivers/rift_s/rift_s_hmd.c
··· 151 151 } 152 152 } 153 153 154 - static bool 154 + static xrt_result_t 155 155 rift_s_compute_distortion(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result) 156 156 { 157 157 struct rift_s_hmd *hmd = (struct rift_s_hmd *)(xdev); 158 158 u_compute_distortion_panotools(&hmd->distortion_vals[view], u, v, result); 159 - return true; 159 + return XRT_SUCCESS; 160 160 } 161 161 162 162 #if 0
+2 -2
src/xrt/drivers/simula/svr_hmd.c
··· 134 134 } 135 135 136 136 //!@todo: remove hard-coding and move to u_distortion_mesh 137 - bool 137 + static xrt_result_t 138 138 svr_mesh_calc(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result) 139 139 { 140 140 struct svr_hmd *svr = svr_hmd(xdev); ··· 208 208 result->g = tc[1]; 209 209 result->b = tc[2]; 210 210 211 - return true; 211 + return XRT_SUCCESS; 212 212 } 213 213 214 214
+4 -4
src/xrt/drivers/steamvr_lh/device.cpp
··· 218 218 this->inputs = inputs_vec.data(); 219 219 this->input_count = inputs_vec.size(); 220 220 221 - this->xrt_device::get_view_poses = &device_bouncer<HmdDevice, &HmdDevice::get_view_poses, xrt_result_t>; 222 - #define SETUP_MEMBER_FUNC(name) this->xrt_device::name = &device_bouncer<HmdDevice, &HmdDevice::name> 221 + #define SETUP_MEMBER_FUNC(name) this->xrt_device::name = &device_bouncer<HmdDevice, &HmdDevice::name, xrt_result_t> 222 + SETUP_MEMBER_FUNC(get_view_poses); 223 223 SETUP_MEMBER_FUNC(compute_distortion); 224 224 SETUP_MEMBER_FUNC(set_brightness); 225 225 SETUP_MEMBER_FUNC(get_brightness); ··· 620 620 return XRT_SUCCESS; 621 621 } 622 622 623 - bool 623 + xrt_result_t 624 624 HmdDevice::compute_distortion(uint32_t view, float u, float v, xrt_uv_triplet *out_result) 625 625 { 626 626 vr::EVREye eye = (view == 0) ? vr::Eye_Left : vr::Eye_Right; ··· 628 628 out_result->r = {coords.rfRed[0], coords.rfRed[1]}; 629 629 out_result->g = {coords.rfGreen[0], coords.rfGreen[1]}; 630 630 out_result->b = {coords.rfBlue[0], coords.rfBlue[1]}; 631 - return true; 631 + return XRT_SUCCESS; 632 632 } 633 633 634 634 void
+1 -1
src/xrt/drivers/steamvr_lh/device.hpp
··· 138 138 xrt_fov *out_fovs, 139 139 xrt_pose *out_poses); 140 140 141 - bool 141 + xrt_result_t 142 142 compute_distortion(uint32_t view, float u, float v, xrt_uv_triplet *out_result); 143 143 144 144 void
+2 -2
src/xrt/drivers/survive/survive_driver.c
··· 901 901 return XRT_SUCCESS; 902 902 } 903 903 904 - static bool 904 + static xrt_result_t 905 905 compute_distortion(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result) 906 906 { 907 907 struct survive_device *d = (struct survive_device *)xdev; ··· 913 913 result->g.y = 1.0f - result->g.y; 914 914 result->b.y = 1.0f - result->b.y; 915 915 } 916 - return true; 916 + return XRT_SUCCESS; 917 917 } 918 918 919 919 static bool
+2 -2
src/xrt/drivers/vive/vive_device.c
··· 974 974 u_var_add_ro_text(d, d->gui.hand_status, "Tracker status"); 975 975 } 976 976 977 - static bool 977 + static xrt_result_t 978 978 compute_distortion(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result) 979 979 { 980 980 XRT_TRACE_MARKER(); ··· 988 988 result->g.y = 1.0f - result->g.y; 989 989 result->b.y = 1.0f - result->b.y; 990 990 } 991 - return true; 991 + return XRT_SUCCESS; 992 992 } 993 993 994 994 void
+2 -2
src/xrt/drivers/wmr/wmr_hmd.c
··· 1247 1247 u_device_free(&wh->base); 1248 1248 } 1249 1249 1250 - static bool 1250 + static xrt_result_t 1251 1251 compute_distortion_wmr(struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result) 1252 1252 { 1253 1253 DRV_TRACE_MARKER(); ··· 1304 1304 result->g = tc[1]; 1305 1305 result->b = tc[2]; 1306 1306 1307 - return true; 1307 + return XRT_SUCCESS; 1308 1308 } 1309 1309 1310 1310 /*
+1 -8
src/xrt/drivers/xreal_air/xreal_air_hmd.c
··· 1166 1166 u_device_free(&hmd->base); 1167 1167 } 1168 1168 1169 - static bool 1170 - xreal_air_hmd_compute_distortion( 1171 - struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result) 1172 - { 1173 - return u_compute_distortion_none(u, v, result); 1174 - } 1175 - 1176 1169 /* 1177 1170 * 1178 1171 * Exported functions. ··· 1195 1188 hmd->base.update_inputs = xreal_air_hmd_update_inputs; 1196 1189 hmd->base.get_tracked_pose = xreal_air_hmd_get_tracked_pose; 1197 1190 hmd->base.get_view_poses = u_device_get_view_poses; 1198 - hmd->base.compute_distortion = xreal_air_hmd_compute_distortion; 1191 + hmd->base.compute_distortion = u_distortion_mesh_none; 1199 1192 hmd->base.destroy = xreal_air_hmd_destroy; 1200 1193 hmd->base.name = XRT_DEVICE_GENERIC_HMD; 1201 1194 hmd->base.device_type = XRT_DEVICE_TYPE_HMD;
+2 -3
src/xrt/include/xrt/xrt_device.h
··· 567 567 * @param v vertical texture coordinate 568 568 * @param[out] out_result corresponding u,v pairs for all three color channels. 569 569 */ 570 - bool (*compute_distortion)( 570 + xrt_result_t (*compute_distortion)( 571 571 struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result); 572 572 573 573 /*! ··· 887 887 xrt_device_compute_distortion( 888 888 struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result) 889 889 { 890 - xdev->compute_distortion(xdev, view, u, v, out_result); 891 - return XRT_SUCCESS; 890 + return xdev->compute_distortion(xdev, view, u, v, out_result); 892 891 } 893 892 894 893 /*!
+2 -3
src/xrt/ipc/client/ipc_client_hmd.c
··· 177 177 return xret; 178 178 } 179 179 180 - static bool 180 + static xrt_result_t 181 181 ipc_client_hmd_compute_distortion( 182 182 struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result) 183 183 { ··· 191 191 u, // 192 192 v, // 193 193 out_result); // 194 - IPC_CHK_WITH_RET(ich->ipc_c, xret, "ipc_call_device_compute_distortion", false); 195 194 196 - return xret == XRT_SUCCESS; 195 + IPC_CHK_ALWAYS_RET(ich->ipc_c, xret, "ipc_call_device_compute_distortion"); 197 196 } 198 197 199 198 static bool