Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Merged
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
8 changes: 5 additions & 3 deletions app/src/main/cpp/BrowserWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,10 +1422,12 @@ BrowserWorld::TickImmersive() {
m.device->SetRenderMode(device::RenderMode::Immersive);

const bool supportsFrameAhead = m.device->SupportsFramePrediction(DeviceDelegate::FramePrediction::ONE_FRAME_AHEAD);
auto framePrediction = DeviceDelegate::FramePrediction::ONE_FRAME_AHEAD;
VRB_GL_CHECK(glDepthMask(GL_FALSE));
if (!supportsFrameAhead || (m.externalVR->GetVRState() != ExternalVR::VRState::Rendering)) {
// Do not use one frame ahead prediction if not supported or we are rendering the spinner.
m.device->StartFrame(DeviceDelegate::FramePrediction::NO_FRAME_AHEAD);
framePrediction = DeviceDelegate::FramePrediction::NO_FRAME_AHEAD;
m.device->StartFrame(framePrediction);
m.externalVR->PushFramePoses(m.device->GetHeadTransform(), m.controllers->GetControllers(),
m.context->GetTimestamp());
}
Expand All @@ -1435,15 +1437,15 @@ BrowserWorld::TickImmersive() {
m.externalVR->GetFrameResult(surfaceHandle, textureWidth, textureHeight, leftEye, rightEye);
ExternalVR::VRState state = m.externalVR->GetVRState();
if (supportsFrameAhead) {
if (m.externalVR->WasFirstPresentingFrame()) {
if (framePrediction != DeviceDelegate::FramePrediction::ONE_FRAME_AHEAD) {
// StartFrame() has been already called to render the spinner, do not call it again.
// Instead, repeat the XR frame and render the spinner while we transition
// to one frame ahead prediction.
state = ExternalVR::VRState::Loading;
} else {
// Predict poses for one frame ahead and push the data to shmem so Gecko
// can start the next XR RAF ASAP.
m.device->StartFrame(DeviceDelegate::FramePrediction::ONE_FRAME_AHEAD);
m.device->StartFrame(framePrediction);
}
m.externalVR->PushFramePoses(m.device->GetHeadTransform(), m.controllers->GetControllers(),
m.context->GetTimestamp());
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/cpp/ExternalVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ struct ExternalVR::State {
vrb::Vector eyeOffsets[device::EyeCount];
uint64_t lastFrameId = 0;
bool firstPresentingFrame = false;
bool wasFirstPresentingFrame = false;
bool compositorEnabled = false;
bool waitingForExit = false;

Expand Down Expand Up @@ -456,7 +455,6 @@ ExternalVR::WaitFrameResult() {
m.PullBrowserStateWhileLocked();
while (true) {
if (!IsPresenting() || m.browser.layerState[0].layer_stereo_immersive.frameId != m.lastFrameId) {
m.wasFirstPresentingFrame = m.firstPresentingFrame;
m.firstPresentingFrame = false;
m.system.displayState.lastSubmittedFrameSuccessful = true;
m.system.displayState.lastSubmittedFrameId = m.browser.layerState[0].layer_stereo_immersive.frameId;
Expand All @@ -482,10 +480,6 @@ ExternalVR::WaitFrameResult() {
return true;
}

bool ExternalVR::WasFirstPresentingFrame() const {
return m.wasFirstPresentingFrame;
}

void
ExternalVR::CompleteEnumeration()
{
Expand Down
1 change: 0 additions & 1 deletion app/src/main/cpp/ExternalVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class ExternalVR : public ImmersiveDisplay {
VRState GetVRState() const;
void PushFramePoses(const vrb::Matrix& aHeadTransform, const std::vector<Controller>& aControllers, const double aTimestamp);
bool WaitFrameResult();
bool WasFirstPresentingFrame() const;
void GetFrameResult(int32_t& aSurfaceHandle,
int32_t& aTextureWidth,
int32_t& aTextureHeight,
Expand Down