Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(926)

Unified Diff: content/renderer/render_widget.cc

Issue 22900018: cc: Set the mapped memory reclaim limit for the renderer compositor on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate code reviews Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 0f3d037e01178c8a8f87537bb631774f97193678..3a73ba172a03e1574e84f9d9a40c63edc32fd1f8 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -62,6 +62,7 @@
#include "webkit/renderer/compositor_bindings/web_rendering_stats_impl.h"
#if defined(OS_ANDROID)
+#include "base/android/sys_utils.h"
#include "content/renderer/android/synchronous_compositor_factory.h"
#endif
@@ -647,17 +648,14 @@ bool RenderWidget::ForceCompositingModeEnabled() {
}
scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
#if defined(OS_ANDROID)
- if (SynchronousCompositorFactory* factory =
- SynchronousCompositorFactory::GetInstance()) {
+ if (SynchronousCompositorFactory* factory =
+ SynchronousCompositorFactory::GetInstance()) {
return factory->CreateOutputSurface(routing_id());
}
#endif
- uint32 output_surface_id = next_output_surface_id_++;
-
// Explicitly disable antialiasing for the compositor. As of the time of
// this writing, the only platform that supported antialiasing for the
// compositor was Mac OS X, because the on-screen OpenGL context creation
@@ -674,14 +672,18 @@ scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) {
attributes.noAutomaticFlushes = true;
attributes.depth = false;
attributes.stencil = false;
+
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(cc::switches::kForceDirectLayerDrawing))
attributes.stencil = true;
+
scoped_refptr<ContextProviderCommandBuffer> context_provider;
if (!fallback) {
context_provider = ContextProviderCommandBuffer::Create(
CreateGraphicsContext3D(attributes));
}
+ uint32 output_surface_id = next_output_surface_id_++;
if (!context_provider.get()) {
if (!command_line.HasSwitch(switches::kEnableSoftwareCompositing))
return scoped_ptr<cc::OutputSurface>();
@@ -2523,10 +2525,39 @@ RenderWidget::CreateGraphicsContext3D(
RenderThreadImpl::current(),
weak_ptr_factory_.GetWeakPtr()));
- if (!context->InitializeWithDefaultBufferSizes(
+#if defined(OS_ANDROID)
+ // If we raster too fast we become upload bound, and pending
+ // uploads consume memory. For maximum upload throughput, we would
+ // want to allow for upload_throughput * pipeline_time of pending
+ // uploads, after which we are just wasting memory. Since we don't
+ // know our upload throughput yet, this just caps our memory usage.
+ size_t divider = 1;
+ if (base::android::SysUtils::IsLowEndDevice())
+ divider = 3;
+
+ // For reference Nexus10 can upload 1MB in about 2.5ms.
+ const size_t kMaxBytesUploadedPerMs = (2 * 1024 * 1024) / (5 * divider);
jamesr 2013/09/09 19:35:37 These are not compile-time constants, they're comp
kaanb 2013/09/09 21:04:36 Done.
+ // Deadline to draw a frame to achieve 60 frames per second.
+ const size_t kMillisecondsPerFrame = 16;
jamesr 2013/09/09 18:34:10 not all displays are 60Hz and 60Hz isn't 16ms
+ // Assuming a two frame deep pipeline between the CPU and the GPU.
jamesr 2013/09/09 18:34:10 yuck! this code doesn't know anything about what t
+ const size_t kMaxTransferBufferUsageBytes =
+ 2 * kMillisecondsPerFrame * kMaxBytesUploadedPerMs;
+ // We keep the MappedMemoryReclaimLimit the same as the upload limit
+ // to avoid unnecessarily stalling the compositor thread.
+ const size_t kMappedMemoryReclaimLimit = kMaxTransferBufferUsageBytes;
+#else
+ const size_t kMappedMemoryReclaimLimit =
+ WebGraphicsContext3DCommandBufferImpl::kNoLimit;
reveman 2013/09/09 19:51:20 Oh, is this changing the behavior on non-Android?!
kaanb 2013/09/09 21:04:36 No, it doesn't change the behavior on non-Android.
+#endif
+ if (!context->Initialize(
attributes,
false /* bind generates resources */,
- CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE))
+ CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE,
+ kDefaultCommandBufferSize,
+ kDefaultStartTransferBufferSize,
+ kDefaultMinTransferBufferSize,
+ kDefaultMaxTransferBufferSize,
+ kMappedMemoryReclaimLimit))
return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
return context.Pass();
}
« no previous file with comments | « content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698