Refactor stereo frame worker and interpolation tests for enhanced VR performance

- Updated stereo_frame_worker_smoke.cpp to allow dynamic headset rates and prediction lead time.
- Improved logging to include motion diagnostics and adjusted frame submission logic based on headset frequency.
- Enhanced stereo_interpolation_test.cpp with additional tests for camera motion separation and playback cadence.
- Introduced MkwVRReadSceneView function to read the camera view matrix for improved scene rendering.
- Modified VR first-person logic to support scene view reading and validation.
- Added scene_camera.hpp to encapsulate camera motion handling and inverse view calculations.
- Ensured that the VR integration layer correctly logs motion diagnostics and handles scene playback accurately.
This commit is contained in:
iChris4 committed 2026-10-01 00:37:49 +02:00
1 parent 85fab2fa09
commit e7eab8a6b2
19 files changed
+1978 -114

No files matched your search

+4
View File
@@ -573,6 +573,10 @@ void MkwVRFirstPersonRecenter() noexcept;
// anchor has been missing long enough to give up holding the last one.
FirstPersonAnchor MkwVRFirstPersonGetAnchor() noexcept;
// Checked guest-thread read of the camera that authored this frame's GX draws.
// Also available with first person off; render workers receive only its copy.
bool MkwVRReadSceneView(Mtx34& view) noexcept;
// Guest-frame inventory snapshot, sampled at the race draw boundary. A
// generation change invalidates any item retained by a prior race.
HeldItem MkwVRFirstPersonGetHeldItem() noexcept;
+10
View File
@@ -37,6 +37,7 @@
#endif
#include <aurora/aurora.h>
#include <aurora/gfx.h>
// Forward declaration for OSWakeupThread - used to wake threads on VI retrace queue
extern "C" void OSWakeupThread_HLE_801aaaa4(CpuContext* ctx);
@@ -538,6 +539,8 @@ void PaceToRetraceBoundary(Clock::time_point deadline) {
struct SceneAnchorPublication {
std::array<float, 12> anchor{};
bool valid = false;
std::array<float, 12> view{};
bool viewValid = false;
// The cockpit seat's exact world scale for this frame, or zero.
float unitsPerMeter = 0.0f;
};
@@ -550,6 +553,8 @@ SceneAnchorPublication PublishVrSceneAnchor() {
mkw::vr::MkwVRFirstPersonCommit();
const mkw::vr::FirstPersonAnchor anchor = mkw::vr::MkwVRFirstPersonGetAnchor();
SceneAnchorPublication publication;
// Only VR frame interpolation separates the camera, so nothing else pays for the read.
publication.viewValid = aurora_get_stereo_frame_interpolation() && mkw::vr::MkwVRReadSceneView(publication.view);
publication.valid = anchor.valid;
if (anchor.valid) {
std::copy(anchor.anchor_from_scene.begin(), anchor.anchor_from_scene.end(), publication.anchor.begin());
@@ -592,6 +597,8 @@ struct GxPresentRecord {
uint64_t scheduleIntervalNanos = 0;
std::array<float, 12> anchor{};
bool anchorValid = false;
std::array<float, 12> view{};
bool viewValid = false;
float anchorUnitsPerMeter = 0.0f;
AuroraCockpitItem cockpitItem{};
bool reportPaced = false;
@@ -613,6 +620,7 @@ void GxPresent_gx(GxPresentRecord record) {
}
aurora_set_stereo_cockpit_item(&record.cockpitItem);
aurora_set_stereo_local_player_count(record.localPlayerCount);
aurora_set_stereo_scene_view(record.viewValid ? record.view.data() : nullptr);
aurora_end_frame_ex(record.contentTag, record.imguiFrame);
g_auroraFrameActive.store(false, std::memory_order_release);
g_auroraFrameHadWork.store(false, std::memory_order_release);
@@ -695,6 +703,8 @@ void VI_HLE_PresentFrame(bool presentedXfb, bool paceToRetrace) {
const SceneAnchorPublication anchor = PublishVrSceneAnchor();
record.anchor = anchor.anchor;
record.anchorValid = anchor.valid;
record.view = anchor.view;
record.viewValid = anchor.viewValid;
record.anchorUnitsPerMeter = anchor.unitsPerMeter;
if (anchor.valid) {
const auto item = mkw::vr::MkwVRFirstPersonGetHeldItem();
+4
View File
@@ -1422,6 +1422,10 @@ void MkwVRFirstPersonRecenter() noexcept {
g_recenter_requested.store(true, std::memory_order_release);
}
bool MkwVRReadSceneView(Mtx34& view) noexcept {
return ReadSceneViewMatrix(view);
}
void MkwVRFirstPersonUpdate(uint64_t guest_frame_index, uint32_t race_camera_address) noexcept {
std::lock_guard lock(g_mutex);
g_state.held_item = {};
+1
View File
@@ -893,6 +893,7 @@ private:
}
const MkwVRPolicySnapshot policy = MkwVRPolicyGetSnapshot();
aurora_set_stereo_motion_logging(diagnostics::Enabled());
// Diagnostics lift the cap: a presentation flickering between the
// race and the virtual screen is exactly what a report needs to show.
if ((!presentation_logged || policy.presentation != logged_presentation) &&