Skip to content

Commit

Permalink
Merge branch 'praydog:pd-upscaler' into pd-upscaler
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyhodge authored Dec 10, 2023
2 parents 98ecc51 + 7000647 commit f2e9f34
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
18 changes: 5 additions & 13 deletions src/mods/VR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1554,24 +1554,16 @@ void VR::update_hmd_state() {
// Update the poses used for the game
// If we used the data directly from the WaitGetPoses call, we would have to lock a different mutex and wait a long time
// This is because the WaitGetPoses call is blocking, and we don't want to block any game logic
{
if (runtime->wants_reset_origin && runtime->ready()) {
std::unique_lock _{ runtime->pose_mtx };
if (runtime->wants_reset_origin && runtime->ready() && runtime->got_first_valid_poses) {
std::unique_lock _{ runtime->pose_mtx };
set_rotation_offset(glm::identity<glm::quat>());
m_standing_origin = get_position_unsafe(vr::k_unTrackedDeviceIndex_Hmd);

set_rotation_offset(glm::identity<glm::quat>());
m_standing_origin = get_position_unsafe(vr::k_unTrackedDeviceIndex_Hmd);

runtime->wants_reset_origin = false;
}
runtime->wants_reset_origin = false;
}

runtime->update_matrices(m_nearz, m_farz);

// On first run, set the standing origin to the headset position
if (!runtime->got_first_poses) {
m_standing_origin = get_position(vr::k_unTrackedDeviceIndex_Hmd);
}

runtime->got_first_poses = true;

// Forcefully update the camera transform after submitting the frame
Expand Down
1 change: 1 addition & 0 deletions src/mods/vr/runtimes/OpenVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ VRRuntime::Error OpenVR::synchronize_frame() {
auto ret = vr::VRCompositor()->WaitGetPoses(this->real_render_poses.data(), vr::k_unMaxTrackedDeviceCount, this->real_game_poses.data(), vr::k_unMaxTrackedDeviceCount);

if (ret == vr::VRCompositorError_None) {
this->got_first_valid_poses = true;
this->got_first_sync = true;
this->frame_synced = true;
}
Expand Down
6 changes: 5 additions & 1 deletion src/mods/vr/runtimes/OpenXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ VRRuntime::Error OpenXR::update_poses() {

const auto display_time = this->frame_state.predictedDisplayTime + (XrDuration)(this->frame_state.predictedDisplayPeriod * this->prediction_scale);

if (display_time == 0) {
if (display_time <= 1000) {
return VRRuntime::Error::SUCCESS;
}

Expand Down Expand Up @@ -108,6 +108,10 @@ VRRuntime::Error OpenXR::update_poses() {
}
}

if (!this->got_first_valid_poses) {
this->got_first_valid_poses = (this->view_space_location.locationFlags & (XR_SPACE_LOCATION_POSITION_VALID_BIT | XR_SPACE_LOCATION_ORIENTATION_VALID_BIT)) != 0;
}

this->needs_pose_update = false;
this->got_first_poses = true;
return VRRuntime::Error::SUCCESS;
Expand Down
1 change: 1 addition & 0 deletions src/mods/vr/runtimes/VRRuntime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ struct VRRuntime {
// will return VRCompositorError_DoNotHaveFocus
bool needs_pose_update{true};
bool got_first_poses{false};
bool got_first_valid_poses{false};
bool got_first_sync{false};
bool frame_synced{false};
bool handle_pause{false};
Expand Down

0 comments on commit f2e9f34

Please sign in to comment.