Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/mods/vr/runtimes/OpenXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,14 @@ VRRuntime::Error OpenXR::update_matrices(float nearz, float farz) {
};
};

bool fov_updated = (
memcmp(&this->views[0].fov, &this->last_fovs[0], sizeof(XrFovf)) != 0
|| memcmp(&this->views[1].fov, &this->last_fovs[1], sizeof(XrFovf)) != 0
); // XrFovf is a POD type, so we compare it byte-by-byte

// if we've not yet derived an eye projection matrix, or we've changed the projection, derive it here
// Hacky way to check for an uninitialised eye matrix - is there something better, is this necessary?
if (this->should_recalculate_eye_projections || this->last_eye_matrix_nearz != nearz || this->projections[0][2][3] == 0) {
if (this->should_recalculate_eye_projections || this->last_eye_matrix_nearz != nearz || this->projections[0][2][3] == 0 || fov_updated) {
// deriving the texture bounds when modifying projections requires left and right raw projections so get them all before we start:
std::unique_lock __{this->eyes_mtx};
const auto& left_fov = this->views[0].fov;
Expand All @@ -572,6 +577,11 @@ VRRuntime::Error OpenXR::update_matrices(float nearz, float farz) {
this->projections[1] = get_mat(1);
this->should_recalculate_eye_projections = false;
this->last_eye_matrix_nearz = nearz;

if (fov_updated) {
this->last_fovs[0] = this->views[0].fov;
this->last_fovs[1] = this->views[1].fov;
}
}
// don't allow the eye matrices to be derived again until after the next frame sync
this->should_update_eye_matrices = false;
Expand Down
3 changes: 3 additions & 0 deletions src/mods/vr/runtimes/OpenXR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ struct OpenXR final : public VRRuntime {
std::vector<XrView> views{};
std::vector<XrView> stage_views{};

std::array<XrFovf, 2> last_fovs{};


//std::deque<std::vector<XrView>> stage_view_queue{};
struct PipelineState {
XrFrameState frame_state{XR_TYPE_FRAME_STATE};
Expand Down
Loading