Commit 92effd56 authored by Ian Vollick's avatar Ian Vollick Committed by Commit Bot

[vr] Revert frame time plumbing in VrShellGl

The following CL caused a regression in DrawFrame wall time (and a
progression in self time).
https://chromium-review.googlesource.com/c/chromium/src/+/752344

I'd changed how we plumbed the current frame time in VrShellGl and this
CL speculatively reverts that change.

TBR=klausw@chromium.org,mthiesse@chromium.org

Bug: None
Change-Id: Ie89dfcf515b0c87614bcdeb27a3d87c21ffc83f4
Reviewed-on: https://chromium-review.googlesource.com/763047Reviewed-by: default avatarIan Vollick <vollick@chromium.org>
Commit-Queue: Ian Vollick <vollick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515463}
parent 46aa3c25
...@@ -411,7 +411,7 @@ void VrShellGl::OnWebVRFrameAvailable() { ...@@ -411,7 +411,7 @@ void VrShellGl::OnWebVRFrameAvailable() {
ui_->OnWebVrFrameAvailable(); ui_->OnWebVrFrameAvailable();
DrawFrame(frame_index, base::TimeTicks::Now()); DrawFrame(frame_index);
if (web_vr_mode_) if (web_vr_mode_)
++webvr_frames_received_; ++webvr_frames_received_;
ScheduleOrCancelWebVrFrameTimeout(); ScheduleOrCancelWebVrFrameTimeout();
...@@ -536,8 +536,7 @@ void VrShellGl::InitializeRenderer() { ...@@ -536,8 +536,7 @@ void VrShellGl::InitializeRenderer() {
browser_->GvrDelegateReady(gvr_api_->GetViewerType()); browser_->GvrDelegateReady(gvr_api_->GetViewerType());
} }
void VrShellGl::UpdateController(const gfx::Transform& head_pose, void VrShellGl::UpdateController(const gfx::Transform& head_pose) {
base::TimeTicks current_time) {
TRACE_EVENT0("gpu", "VrShellGl::UpdateController"); TRACE_EVENT0("gpu", "VrShellGl::UpdateController");
gvr::Mat4f gvr_head_pose; gvr::Mat4f gvr_head_pose;
TransformToGvrMat(head_pose, &gvr_head_pose); TransformToGvrMat(head_pose, &gvr_head_pose);
...@@ -549,13 +548,11 @@ void VrShellGl::UpdateController(const gfx::Transform& head_pose, ...@@ -549,13 +548,11 @@ void VrShellGl::UpdateController(const gfx::Transform& head_pose,
controller_data.connected = false; controller_data.connected = false;
browser_->UpdateGamepadData(controller_data); browser_->UpdateGamepadData(controller_data);
HandleControllerInput(laser_origin, vr::GetForwardVector(head_pose), HandleControllerInput(laser_origin, vr::GetForwardVector(head_pose));
current_time);
} }
void VrShellGl::HandleControllerInput(const gfx::Point3F& laser_origin, void VrShellGl::HandleControllerInput(const gfx::Point3F& laser_origin,
const gfx::Vector3dF& head_direction, const gfx::Vector3dF& head_direction) {
base::TimeTicks current_time) {
if (is_exiting_) { if (is_exiting_) {
// When we're exiting, we don't show the reticle and the only input // When we're exiting, we don't show the reticle and the only input
// processing we do is to handle immediate exits. // processing we do is to handle immediate exits.
...@@ -609,7 +606,7 @@ void VrShellGl::HandleControllerInput(const gfx::Point3F& laser_origin, ...@@ -609,7 +606,7 @@ void VrShellGl::HandleControllerInput(const gfx::Point3F& laser_origin,
controller_model.laser_origin = laser_origin; controller_model.laser_origin = laser_origin;
vr::ReticleModel reticle_model; vr::ReticleModel reticle_model;
ui_->input_manager()->HandleInput(current_time, controller_model, ui_->input_manager()->HandleInput(base::TimeTicks::Now(), controller_model,
&reticle_model, &gesture_list); &reticle_model, &gesture_list);
ui_->OnControllerUpdated(controller_model, reticle_model); ui_->OnControllerUpdated(controller_model, reticle_model);
} }
...@@ -756,14 +753,16 @@ void VrShellGl::UpdateEyeInfos(const gfx::Transform& head_pose, ...@@ -756,14 +753,16 @@ void VrShellGl::UpdateEyeInfos(const gfx::Transform& head_pose,
} }
} }
void VrShellGl::DrawFrame(int16_t frame_index, base::TimeTicks current_time) { void VrShellGl::DrawFrame(int16_t frame_index) {
TRACE_EVENT1("gpu", "VrShellGl::DrawFrame", "frame", frame_index); TRACE_EVENT1("gpu", "VrShellGl::DrawFrame", "frame", frame_index);
if (!webvr_delayed_frame_submit_.IsCancelled()) { if (!webvr_delayed_frame_submit_.IsCancelled()) {
webvr_delayed_frame_submit_.Cancel(); webvr_delayed_frame_submit_.Cancel();
DrawIntoAcquiredFrame(frame_index, current_time); DrawIntoAcquiredFrame(frame_index);
return; return;
} }
base::TimeTicks current_time = base::TimeTicks::Now();
CHECK(!acquired_frame_); CHECK(!acquired_frame_);
// Reset the viewport list to just the pair of viewports for the // Reset the viewport list to just the pair of viewports for the
...@@ -820,7 +819,7 @@ void VrShellGl::DrawFrame(int16_t frame_index, base::TimeTicks current_time) { ...@@ -820,7 +819,7 @@ void VrShellGl::DrawFrame(int16_t frame_index, base::TimeTicks current_time) {
// WebVR handles controller input in OnVsync. // WebVR handles controller input in OnVsync.
if (!ShouldDrawWebVr()) if (!ShouldDrawWebVr())
UpdateController(render_info_primary_.head_pose, current_time); UpdateController(render_info_primary_.head_pose);
bool textures_changed = ui_->scene()->UpdateTextures(); bool textures_changed = ui_->scene()->UpdateTextures();
...@@ -848,11 +847,10 @@ void VrShellGl::DrawFrame(int16_t frame_index, base::TimeTicks current_time) { ...@@ -848,11 +847,10 @@ void VrShellGl::DrawFrame(int16_t frame_index, base::TimeTicks current_time) {
if (!acquired_frame_) if (!acquired_frame_)
return; return;
DrawIntoAcquiredFrame(frame_index, current_time); DrawIntoAcquiredFrame(frame_index);
} }
void VrShellGl::DrawIntoAcquiredFrame(int16_t frame_index, void VrShellGl::DrawIntoAcquiredFrame(int16_t frame_index) {
base::TimeTicks current_time) {
TRACE_EVENT1("gpu", "VrShellGl::DrawIntoAcquiredFrame", "frame", frame_index); TRACE_EVENT1("gpu", "VrShellGl::DrawIntoAcquiredFrame", "frame", frame_index);
last_used_head_pose_ = render_info_primary_.head_pose; last_used_head_pose_ = render_info_primary_.head_pose;
...@@ -1145,9 +1143,9 @@ void VrShellGl::OnVSync(base::TimeTicks frame_time) { ...@@ -1145,9 +1143,9 @@ void VrShellGl::OnVSync(base::TimeTicks frame_time) {
// DrawFrame. // DrawFrame.
gfx::Transform head_pose; gfx::Transform head_pose;
device::GvrDelegate::GetGvrPoseWithNeckModel(gvr_api_.get(), &head_pose); device::GvrDelegate::GetGvrPoseWithNeckModel(gvr_api_.get(), &head_pose);
UpdateController(head_pose, frame_time); UpdateController(head_pose);
} else { } else {
DrawFrame(-1, frame_time); DrawFrame(-1);
} }
} }
......
...@@ -122,8 +122,8 @@ class VrShellGl : public device::mojom::VRPresentationProvider { ...@@ -122,8 +122,8 @@ class VrShellGl : public device::mojom::VRPresentationProvider {
int viewport_offset, int viewport_offset,
const gfx::Size& render_size, const gfx::Size& render_size,
vr::RenderInfo* out_render_info); vr::RenderInfo* out_render_info);
void DrawFrame(int16_t frame_index, base::TimeTicks current_time); void DrawFrame(int16_t frame_index);
void DrawIntoAcquiredFrame(int16_t frame_index, base::TimeTicks current_time); void DrawIntoAcquiredFrame(int16_t frame_index);
void DrawFrameSubmitWhenReady(int16_t frame_index, void DrawFrameSubmitWhenReady(int16_t frame_index,
const gfx::Transform& head_pose, const gfx::Transform& head_pose,
std::unique_ptr<gl::GLFenceEGL> fence); std::unique_ptr<gl::GLFenceEGL> fence);
...@@ -132,13 +132,11 @@ class VrShellGl : public device::mojom::VRPresentationProvider { ...@@ -132,13 +132,11 @@ class VrShellGl : public device::mojom::VRPresentationProvider {
void DrawWebVr(); void DrawWebVr();
bool WebVrPoseByteIsValid(int pose_index_byte); bool WebVrPoseByteIsValid(int pose_index_byte);
void UpdateController(const gfx::Transform& head_pose, void UpdateController(const gfx::Transform& head_pose);
base::TimeTicks current_time);
void SendImmediateExitRequestIfNecessary(); void SendImmediateExitRequestIfNecessary();
void HandleControllerInput(const gfx::Point3F& laser_origin, void HandleControllerInput(const gfx::Point3F& laser_origin,
const gfx::Vector3dF& head_direction, const gfx::Vector3dF& head_direction);
base::TimeTicks current_time);
void HandleControllerAppButtonActivity( void HandleControllerAppButtonActivity(
const gfx::Vector3dF& controller_direction); const gfx::Vector3dF& controller_direction);
void CreateUiSurface(); void CreateUiSurface();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment