Commit cddc0376 authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

VR: Decrease UI buffer render target size.

With Quad layers keeping the content quad high-res and crisp, we can
lower the buffer size of the rest of our UI which doesn't need to be as
high quality as the content quad.

The quality decrease is only barely noticeable on an A/B toggle, and
the performance win is huge (and necessary to get us back to 60fps on a
Pixel XL device).

Bug: 714304
Change-Id: I0f352f88789584e51815baafe0f25d69fb7e8780
Reviewed-on: https://chromium-review.googlesource.com/1024881Reviewed-by: default avatarIan Vollick <vollick@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552934}
parent a996afc1
......@@ -348,6 +348,11 @@ public class VrShellImpl
float displayWidthMeters = (dm.widthPixels / dm.xdpi) * INCHES_TO_METERS;
float displayHeightMeters = (dm.heightPixels / dm.ydpi) * INCHES_TO_METERS;
// Semi-arbitrary resolution cutoff that determines how much we scale our default buffer
// size in VR. This is so we can make the right performance/quality tradeoff for both the
// relatively low-res Pixel, and higher-res Pixel XL and other devices.
boolean lowDensity = dm.densityDpi <= DisplayMetrics.DENSITY_XXHIGH;
boolean hasOrCanRequestAudioPermission =
mActivity.getWindowAndroid().hasPermission(android.Manifest.permission.RECORD_AUDIO)
|| mActivity.getWindowAndroid().canRequestPermission(
......@@ -355,7 +360,7 @@ public class VrShellImpl
mNativeVrShell = nativeInit(mDelegate, forWebVr, webVrAutopresentationExpected, inCct,
!mVrBrowsingEnabled, hasOrCanRequestAudioPermission,
getGvrApi().getNativeGvrContext(), mReprojectedRendering, displayWidthMeters,
displayHeightMeters, dm.widthPixels, dm.heightPixels, pauseContent);
displayHeightMeters, dm.widthPixels, dm.heightPixels, pauseContent, lowDensity);
swapToTab(tab);
createTabList();
......@@ -1136,7 +1141,7 @@ public class VrShellImpl
boolean webVrAutopresentationExpected, boolean inCct, boolean browsingDisabled,
boolean hasOrCanRequestAudioPermission, long gvrApi, boolean reprojectedRendering,
float displayWidthMeters, float displayHeightMeters, int displayWidthPixels,
int displayHeightPixels, boolean pauseContent);
int displayHeightPixels, boolean pauseContent, boolean lowDensity);
private native void nativeSetSurface(long nativeVrShell, Surface surface);
private native void nativeSwapContents(long nativeVrShell, Tab tab);
private native void nativeSetAndroidGestureTarget(
......
......@@ -31,7 +31,8 @@ VrGLThread::VrGLThread(
const UiInitialState& ui_initial_state,
bool reprojected_rendering,
bool daydream_support,
bool pause_content)
bool pause_content,
bool low_density)
: base::android::JavaHandlerThread("VrShellGL"),
weak_vr_shell_(weak_vr_shell),
main_thread_task_runner_(std::move(main_thread_task_runner)),
......@@ -39,7 +40,8 @@ VrGLThread::VrGLThread(
ui_initial_state_(ui_initial_state),
reprojected_rendering_(reprojected_rendering),
daydream_support_(daydream_support),
pause_content_(pause_content) {}
pause_content_(pause_content),
low_density_(low_density) {}
VrGLThread::~VrGLThread() {
Stop();
......@@ -86,7 +88,7 @@ void VrGLThread::Init() {
vr_shell_gl_ = std::make_unique<VrShellGl>(
this, std::move(ui), gvr_api_, reprojected_rendering_, daydream_support_,
ui_initial_state_.in_web_vr, pause_content_);
ui_initial_state_.in_web_vr, pause_content_, low_density_);
weak_browser_ui_ = vr_shell_gl_->GetBrowserUiWeakPtr();
......
......@@ -46,7 +46,8 @@ class VrGLThread : public base::android::JavaHandlerThread,
const UiInitialState& ui_initial_state,
bool reprojected_rendering,
bool daydream_support,
bool pause_content);
bool pause_content,
bool low_density);
~VrGLThread() override;
base::WeakPtr<VrShellGl> GetVrShellGl();
......@@ -154,6 +155,7 @@ class VrGLThread : public base::android::JavaHandlerThread,
bool reprojected_rendering_;
bool daydream_support_;
bool pause_content_;
bool low_density_;
DISALLOW_COPY_AND_ASSIGN(VrGLThread);
};
......
......@@ -145,7 +145,8 @@ VrShell::VrShell(JNIEnv* env,
float display_height_meters,
int display_width_pixels,
int display_height_pixels,
bool pause_content)
bool pause_content,
bool low_density)
: web_vr_autopresentation_expected_(
ui_initial_state.web_vr_autopresentation_expected),
delegate_provider_(delegate),
......@@ -163,7 +164,7 @@ VrShell::VrShell(JNIEnv* env,
gl_thread_ = std::make_unique<VrGLThread>(
weak_ptr_factory_.GetWeakPtr(), main_thread_task_runner_, gvr_api,
ui_initial_state, reprojected_rendering_, HasDaydreamSupport(env),
pause_content);
pause_content, low_density);
ui_ = gl_thread_.get();
toolbar_ = std::make_unique<ToolbarHelper>(ui_, this);
autocomplete_controller_ =
......@@ -1263,7 +1264,8 @@ jlong JNI_VrShellImpl_Init(JNIEnv* env,
jfloat display_height_meters,
jint display_width_pixels,
jint display_pixel_height,
jboolean pause_content) {
jboolean pause_content,
jboolean low_density) {
UiInitialState ui_initial_state;
ui_initial_state.browsing_disabled = browsing_disabled;
ui_initial_state.in_cct = in_cct;
......@@ -1281,7 +1283,7 @@ jlong JNI_VrShellImpl_Init(JNIEnv* env,
VrShellDelegate::GetNativeVrShellDelegate(env, delegate),
reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering,
display_width_meters, display_height_meters, display_width_pixels,
display_pixel_height, pause_content));
display_pixel_height, pause_content, low_density));
}
} // namespace vr
......@@ -79,7 +79,8 @@ class VrShell : device::GvrGamepadDataProvider,
float display_height_meters,
int display_width_pixels,
int display_height_pixels,
bool pause_content);
bool pause_content,
bool low_density);
void SwapContents(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
const base::android::JavaParamRef<jobject>& web_contents);
......
......@@ -69,6 +69,9 @@ constexpr float kZFar = 10000.0f;
constexpr int kMultiSampleBuffer = 0;
constexpr int kNoMultiSampleBuffer = 1;
constexpr float kDefaultRenderTargetSizeScale = 0.75f;
constexpr float kLowDpiDefaultRenderTargetSizeScale = 0.9f;
// When display UI on top of WebVR, we use a seperate buffer. Normally, the
// buffer is set to recommended size to get best visual (i.e the buffer for
// rendering ChromeVR). We divide the recommended buffer size by this number to
......@@ -312,8 +315,10 @@ VrShellGl::VrShellGl(GlBrowserInterface* browser_interface,
bool reprojected_rendering,
bool daydream_support,
bool start_in_web_vr_mode,
bool pause_content)
: ui_(std::move(ui)),
bool pause_content,
bool low_density)
: low_density_(low_density),
ui_(std::move(ui)),
web_vr_mode_(start_in_web_vr_mode),
surfaceless_rendering_(reprojected_rendering),
daydream_support_(daydream_support),
......@@ -1110,18 +1115,30 @@ void VrShellGl::InitializeRenderer() {
specs_.push_back(gvr_api_->CreateBufferSpec());
specs_.push_back(gvr_api_->CreateBufferSpec());
gvr::Sizei default_size = specs_[0].GetSize();
render_size_default_ = {default_size.width, default_size.height};
render_size_webvr_ui_ = {default_size.width / kWebVrBrowserUiSizeFactor,
default_size.height / kWebVrBrowserUiSizeFactor};
gvr::Sizei max_size = gvr_api_->GetMaximumEffectiveRenderTargetSize();
float scale = low_density_ ? kLowDpiDefaultRenderTargetSizeScale
: kDefaultRenderTargetSizeScale;
render_size_default_ = {max_size.width * scale, max_size.height * scale};
render_size_webvr_ui_ = {max_size.width / kWebVrBrowserUiSizeFactor,
max_size.height / kWebVrBrowserUiSizeFactor};
specs_[kMultiSampleBuffer].SetSamples(2);
specs_[kMultiSampleBuffer].SetDepthStencilFormat(
GVR_DEPTH_STENCIL_FORMAT_NONE);
if (web_vr_mode_) {
specs_[kMultiSampleBuffer].SetSize(render_size_webvr_ui_.width(),
render_size_webvr_ui_.height());
} else {
specs_[kMultiSampleBuffer].SetSize(render_size_default_.width(),
render_size_default_.height());
}
specs_[kNoMultiSampleBuffer].SetSamples(1);
specs_[kNoMultiSampleBuffer].SetDepthStencilFormat(
GVR_DEPTH_STENCIL_FORMAT_NONE);
specs_[kNoMultiSampleBuffer].SetSize(render_size_default_.width(),
render_size_default_.height());
swap_chain_ = gvr_api_->CreateSwapChain(specs_);
......
......@@ -265,7 +265,8 @@ class VrShellGl : public device::mojom::VRPresentationProvider {
bool reprojected_rendering,
bool daydream_support,
bool start_in_web_vr_mode,
bool pause_content);
bool pause_content,
bool low_density);
~VrShellGl() override;
void Initialize();
......@@ -477,6 +478,7 @@ class VrShellGl : public device::mojom::VRPresentationProvider {
// The default size for the render buffers.
gfx::Size render_size_default_;
gfx::Size render_size_webvr_ui_;
const bool low_density_;
// WebVR currently supports multiple render path choices, with runtime
// selection based on underlying support being available and feature flags.
......
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