The open source OpenXR runtime
0
fork

Configure Feed

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

d/rift: Rendering fixes + driver cleanup

Switches off simple device setup.

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2428>

+43 -43
+1 -6
src/xrt/drivers/CMakeLists.txt
··· 241 241 endif() 242 242 243 243 if(XRT_BUILD_DRIVER_RIFT) 244 - add_library( 245 - drv_rift STATIC 246 - rift/rift_hmd.c 247 - rift/rift_distortion.c 248 - rift/rift_prober.c 249 - ) 244 + add_library(drv_rift STATIC rift/rift_hmd.c rift/rift_distortion.c rift/rift_prober.c) 250 245 target_include_directories(drv_rift SYSTEM PRIVATE) 251 246 target_link_libraries( 252 247 drv_rift
+1 -1
src/xrt/drivers/rift/rift_distortion.c
··· 406 406 struct xrt_uv_triplet tan_fov_chroma = 407 407 rift_transform_screen_ndc_to_tan_fov_space_chroma(&distortion_render_info, source_ndc); 408 408 409 - #if 0 // no distortion 409 + #if 0 // no distortion (green channel doesn't have any chromatic aberration correction) 410 410 struct xrt_uv_triplet sample_tex_coord = { 411 411 .r = m_vec2_add(m_vec2_mul(tan_fov_chroma.g, eye_to_source_uv->scale), eye_to_source_uv->offset), 412 412 .g = m_vec2_add(m_vec2_mul(tan_fov_chroma.g, eye_to_source_uv->scale), eye_to_source_uv->offset),
+39 -30
src/xrt/drivers/rift/rift_hmd.c
··· 301 301 * We unpack them in the higher 21 bit values first and then shift 302 302 * them down to the lower in order to get the sign bits correct. 303 303 * 304 - * Code taken/reformated from OpenHMD's rift driver 304 + * Code taken/reformatted from OpenHMD's rift driver 305 305 */ 306 306 static void 307 307 rift_decode_sample(const uint8_t *in, int32_t *out) ··· 384 384 remote_sample_timestamp_ns); 385 385 386 386 int64_t local_timestamp_ns; 387 - // if we havent synchronized our clocks, just do nothing 387 + // if we haven't synchronized our clocks, just do nothing 388 388 if (!m_clock_windowed_skew_tracker_to_local(hmd->clock_tracker, remote_sample_timestamp_ns, 389 389 &local_timestamp_ns)) { 390 390 return 0; ··· 467 467 HMD_ERROR(hmd, "Failed to get device config, reason %d", result); 468 468 goto error; 469 469 } 470 - HMD_INFO(hmd, "Got display info from hmd, res: %dx%d", hmd->display_info.resolution_x, 471 - hmd->display_info.resolution_y); 470 + HMD_DEBUG(hmd, "Got display info from hmd, res: %dx%d", hmd->display_info.resolution_x, 471 + hmd->display_info.resolution_y); 472 472 473 473 result = rift_get_config(hmd, &hmd->config); 474 474 if (result < 0) { 475 475 HMD_ERROR(hmd, "Failed to get device config, reason %d", result); 476 476 goto error; 477 477 } 478 - HMD_INFO(hmd, "Got config from hmd, config flags: %X", hmd->config.config_flags); 478 + HMD_DEBUG(hmd, "Got config from hmd, config flags: %X", hmd->config.config_flags); 479 479 480 480 if (getenv("RIFT_POWER_OVERRIDE") != NULL) { 481 481 hmd->config.config_flags |= RIFT_CONFIG_REPORT_OVERRIDE_POWER; 482 - HMD_INFO(hmd, "Force-enabling the override power config flag."); 482 + HMD_INFO(hmd, "Enabling the override power config flag."); 483 + } else { 484 + hmd->config.config_flags &= ~RIFT_CONFIG_REPORT_OVERRIDE_POWER; 485 + HMD_DEBUG(hmd, "Disabling the override power config flag."); 483 486 } 484 487 485 488 // force enable calibration use and auto calibration ··· 503 506 HMD_ERROR(hmd, "Failed to set the device config, reason %d", result); 504 507 goto error; 505 508 } 506 - HMD_INFO(hmd, "After writing, HMD has config flags: %X", hmd->config.config_flags); 509 + HMD_DEBUG(hmd, "After writing, HMD has config flags: %X", hmd->config.config_flags); 507 510 508 511 if (getenv("RIFT_USE_FIRMWARE_DISTORTION") != NULL) { 509 512 // get the lens distortions ··· 555 558 hmd->extra_display_info.eye_to_source_uv = 556 559 rift_calculate_uv_scale_and_offset_from_ndc_scale_and_offset(hmd->extra_display_info.eye_to_source_ndc); 557 560 558 - // This list should be ordered, most preferred first. 559 561 size_t idx = 0; 560 562 hmd->base.hmd->blend_modes[idx++] = XRT_BLEND_MODE_OPAQUE; 561 563 hmd->base.hmd->blend_mode_count = idx; ··· 566 568 hmd->base.get_visibility_mask = rift_hmd_get_visibility_mask; 567 569 hmd->base.destroy = rift_hmd_destroy; 568 570 571 + hmd->base.hmd->distortion.models = XRT_DISTORTION_MODEL_COMPUTE; 572 + hmd->base.hmd->distortion.preferred = XRT_DISTORTION_MODEL_COMPUTE; 569 573 hmd->base.compute_distortion = rift_hmd_compute_distortion; 574 + u_distortion_mesh_fill_in_compute(&hmd->base); 570 575 571 576 hmd->pose = (struct xrt_pose)XRT_POSE_IDENTITY; 572 577 hmd->log_level = debug_get_log_option_rift_log(); ··· 582 587 hmd->base.device_type = XRT_DEVICE_TYPE_HMD; 583 588 hmd->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_POSE; 584 589 hmd->base.supported.orientation_tracking = true; 585 - hmd->base.supported.position_tracking = false; 590 + hmd->base.supported.position_tracking = false; // set to true once we are trying to get the sensor 6dof to work 586 591 587 592 // Set up display details 588 - // refresh rate 589 593 hmd->base.hmd->screens[0].nominal_frame_interval_ns = time_s_to_ns(1.0f / 75.0f); 590 594 591 - struct u_device_simple_info info; 592 - info.display.w_pixels = hmd->display_info.resolution_x; 593 - info.display.h_pixels = hmd->display_info.resolution_y; 594 - info.display.w_meters = MICROMETERS_TO_METERS(hmd->display_info.display_width); 595 - info.display.h_meters = MICROMETERS_TO_METERS(hmd->display_info.display_height); 596 - 597 - info.lens_horizontal_separation_meters = MICROMETERS_TO_METERS(hmd->display_info.lens_separation); 598 - info.lens_vertical_position_meters = MICROMETERS_TO_METERS(hmd->display_info.center_v); 599 - 600 - hmd->extra_display_info.icd = info.lens_horizontal_separation_meters; 601 - 602 - // hardcode some "okay" values 603 - info.fov[0] = 93; 604 - info.fov[1] = 93; 595 + hmd->extra_display_info.icd = MICROMETERS_TO_METERS(hmd->display_info.lens_separation); 605 596 606 597 char *icd_str = getenv("RIFT_OVERRIDE_ICD"); 607 598 if (icd_str != NULL) { ··· 615 606 } else { 616 607 HMD_ERROR(hmd, "Failed to parse ICD override, expected float in millimeters, got %s", icd_str); 617 608 } 609 + } else { 610 + HMD_DEBUG(hmd, "Using default ICD of %f", hmd->extra_display_info.icd); 618 611 } 619 612 620 - if (!u_device_setup_split_side_by_side(&hmd->base, &info)) { 621 - HMD_ERROR(hmd, "Failed to setup basic device info"); 622 - goto error; 613 + // screen is rotated, so we need to undo that here 614 + hmd->base.hmd->screens[0].h_pixels = hmd->display_info.resolution_x; 615 + hmd->base.hmd->screens[0].w_pixels = hmd->display_info.resolution_y; 616 + 617 + // TODO: properly apply using rift_extra_display_info.screen_gap_meters, but this isn't necessary on DK2, where 618 + // the gap is always 0 619 + uint16_t view_width = hmd->display_info.resolution_x / 2; 620 + uint16_t view_height = hmd->display_info.resolution_y; 621 + 622 + for (uint32_t i = 0; i < 2; ++i) { 623 + hmd->base.hmd->views[i].display.w_pixels = view_width; 624 + hmd->base.hmd->views[i].display.h_pixels = view_height; 625 + 626 + hmd->base.hmd->views[i].viewport.x_pixels = 0; 627 + hmd->base.hmd->views[i].viewport.y_pixels = (1 - i) * (hmd->display_info.resolution_x / 2); 628 + hmd->base.hmd->views[i].viewport.w_pixels = view_height; // screen is rotated, so swap w and h 629 + hmd->base.hmd->views[i].viewport.h_pixels = view_width; 630 + hmd->base.hmd->views[i].rot = u_device_rotation_left; 623 631 } 624 632 625 633 switch (hmd->variant) { 634 + default: 626 635 case RIFT_VARIANT_DK2: 627 - // TODO: figure out how to calculate this programatically, right now this is hardcoded with data dumped 628 - // from oculus' OpenXR runtime 636 + // TODO: figure out how to calculate this programmatically, right now this is hardcoded with data dumped 637 + // from oculus' OpenXR runtime, some of the math for this is in rift_distortion.c, used for 638 + // calculating distortion 629 639 hmd->base.hmd->distortion.fov[0].angle_up = 0.92667186; 630 640 hmd->base.hmd->distortion.fov[0].angle_down = -0.92667186; 631 641 hmd->base.hmd->distortion.fov[0].angle_left = -0.8138836; ··· 636 646 hmd->base.hmd->distortion.fov[1].angle_left = -0.82951474; 637 647 hmd->base.hmd->distortion.fov[1].angle_right = 0.8138836; 638 648 break; 639 - default: break; 640 649 } 641 650 642 651 // Just put an initial identity value in the tracker
+1 -1
src/xrt/drivers/rift/rift_interface.h
··· 81 81 RIFT_CONFIG_REPORT_AUTO_CALIBRATION = 1 << 3, 82 82 // stop sending IN reports when the device has stopped moving for Interval milliseconds 83 83 RIFT_CONFIG_REPORT_MOTION_KEEP_ALIVE = 1 << 4, 84 - // stop sending IN reports when the device has stopped recieving feature reports for Interval milliseconds 84 + // stop sending IN reports when the device has stopped receiving feature reports for Interval milliseconds 85 85 RIFT_CONFIG_REPORT_COMMAND_KEEP_ALIVE = 1 << 5, 86 86 // output the IN report data in the coordinate system used by LibOVR relative to the tracker, otherwise, report 87 87 // in the coordinate system of the device
+1 -1
src/xrt/drivers/rift/rift_prober.c
··· 45 45 return -1; 46 46 } 47 47 48 - // Some non-oculus devices (VR-Tek HMDs) re-use the same USB IDs as the oculus headsets, so we should check the 48 + // Some non-oculus devices (VR-Tek HMDs) reuse the same USB IDs as the oculus headsets, so we should check the 49 49 // manufacturer 50 50 if (strncmp((const char *)manufacturer, "Oculus VR, Inc.", sizeof(manufacturer)) != 0) { 51 51 return -1;
-4
src/xrt/targets/common/CMakeLists.txt
··· 24 24 target_sources(target_lists PRIVATE target_builder_rgb_tracking.c) 25 25 endif() 26 26 27 - if(XRT_BUILD_DRIVER_RIFT) 28 - target_sources(target_lists PRIVATE target_builder_rift.c) 29 - endif() 30 - 31 27 if(XRT_BUILD_DRIVER_RIFT_S) 32 28 target_sources(target_lists PRIVATE target_builder_rift_s.c) 33 29 endif()
src/xrt/targets/common/target_builder_rift.c

This is a binary file and will not be displayed.