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

Side by Side Diff: content/renderer/render_widget.cc

Issue 221783002: Revert of gpu: Raise GL_OUT_OF_MEMORY when BeginQueryEXT fails to allocate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/debug/trace_event_synthetic_delay.h" 10 #include "base/debug/trace_event_synthetic_delay.h"
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 } 909 }
910 #endif 910 #endif
911 911
912 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 912 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
913 bool use_software = fallback; 913 bool use_software = fallback;
914 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) 914 if (command_line.HasSwitch(switches::kDisableGpuCompositing))
915 use_software = true; 915 use_software = true;
916 916
917 scoped_refptr<ContextProviderCommandBuffer> context_provider; 917 scoped_refptr<ContextProviderCommandBuffer> context_provider;
918 if (!use_software) { 918 if (!use_software) {
919 // Explicitly disable antialiasing for the compositor. As of the time of
920 // this writing, the only platform that supported antialiasing for the
921 // compositor was Mac OS X, because the on-screen OpenGL context creation
922 // code paths on Windows and Linux didn't yet have multisampling support.
923 // Mac OS X essentially always behaves as though it's rendering offscreen.
924 // Multisampling has a heavy cost especially on devices with relatively low
925 // fill rate like most notebooks, and the Mac implementation would need to
926 // be optimized to resolve directly into the IOSurface shared between the
927 // GPU and browser processes. For these reasons and to avoid platform
928 // disparities we explicitly disable antialiasing.
929 blink::WebGraphicsContext3D::Attributes attributes;
930 attributes.antialias = false;
931 attributes.shareResources = true;
932 attributes.noAutomaticFlushes = true;
933 attributes.depth = false;
934 attributes.stencil = false;
919 context_provider = ContextProviderCommandBuffer::Create( 935 context_provider = ContextProviderCommandBuffer::Create(
920 CreateGraphicsContext3D(), "RenderCompositor"); 936 CreateGraphicsContext3D(attributes),
937 "RenderCompositor");
921 if (!context_provider.get()) { 938 if (!context_provider.get()) {
922 // Cause the compositor to wait and try again. 939 // Cause the compositor to wait and try again.
923 return scoped_ptr<cc::OutputSurface>(); 940 return scoped_ptr<cc::OutputSurface>();
924 } 941 }
925 } 942 }
926 943
927 uint32 output_surface_id = next_output_surface_id_++; 944 uint32 output_surface_id = next_output_surface_id_++;
928 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer)) { 945 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer)) {
929 DCHECK(is_threaded_compositing_enabled_); 946 DCHECK(is_threaded_compositing_enabled_);
930 return scoped_ptr<cc::OutputSurface>( 947 return scoped_ptr<cc::OutputSurface>(
(...skipping 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after
2810 #if defined(OS_ANDROID) 2827 #if defined(OS_ANDROID)
2811 void RenderWidget::UpdateSelectionRootBounds() { 2828 void RenderWidget::UpdateSelectionRootBounds() {
2812 } 2829 }
2813 #endif 2830 #endif
2814 2831
2815 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { 2832 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const {
2816 return true; 2833 return true;
2817 } 2834 }
2818 2835
2819 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> 2836 scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
2820 RenderWidget::CreateGraphicsContext3D() { 2837 RenderWidget::CreateGraphicsContext3D(
2838 const blink::WebGraphicsContext3D::Attributes& attributes) {
2821 if (!webwidget_) 2839 if (!webwidget_)
2822 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); 2840 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
2823 if (CommandLine::ForCurrentProcess()->HasSwitch( 2841 if (CommandLine::ForCurrentProcess()->HasSwitch(
2824 switches::kDisableGpuCompositing)) 2842 switches::kDisableGpuCompositing))
2825 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); 2843 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
2826 if (!RenderThreadImpl::current()) 2844 if (!RenderThreadImpl::current())
2827 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); 2845 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
2828 CauseForGpuLaunch cause = 2846 CauseForGpuLaunch cause =
2829 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; 2847 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
2830 scoped_refptr<GpuChannelHost> gpu_channel_host( 2848 scoped_refptr<GpuChannelHost> gpu_channel_host(
2831 RenderThreadImpl::current()->EstablishGpuChannelSync(cause)); 2849 RenderThreadImpl::current()->EstablishGpuChannelSync(cause));
2832 if (!gpu_channel_host) 2850 if (!gpu_channel_host)
2833 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); 2851 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
2834 2852
2835 // Explicitly disable antialiasing for the compositor. As of the time of
2836 // this writing, the only platform that supported antialiasing for the
2837 // compositor was Mac OS X, because the on-screen OpenGL context creation
2838 // code paths on Windows and Linux didn't yet have multisampling support.
2839 // Mac OS X essentially always behaves as though it's rendering offscreen.
2840 // Multisampling has a heavy cost especially on devices with relatively low
2841 // fill rate like most notebooks, and the Mac implementation would need to
2842 // be optimized to resolve directly into the IOSurface shared between the
2843 // GPU and browser processes. For these reasons and to avoid platform
2844 // disparities we explicitly disable antialiasing.
2845 blink::WebGraphicsContext3D::Attributes attributes;
2846 attributes.antialias = false;
2847 attributes.shareResources = true;
2848 attributes.noAutomaticFlushes = true;
2849 attributes.depth = false;
2850 attributes.stencil = false;
2851 bool bind_generates_resources = false;
2852 bool lose_context_when_out_of_memory = true;
2853 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; 2853 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
2854 #if defined(OS_ANDROID) 2854 #if defined(OS_ANDROID)
2855 // If we raster too fast we become upload bound, and pending 2855 // If we raster too fast we become upload bound, and pending
2856 // uploads consume memory. For maximum upload throughput, we would 2856 // uploads consume memory. For maximum upload throughput, we would
2857 // want to allow for upload_throughput * pipeline_time of pending 2857 // want to allow for upload_throughput * pipeline_time of pending
2858 // uploads, after which we are just wasting memory. Since we don't 2858 // uploads, after which we are just wasting memory. Since we don't
2859 // know our upload throughput yet, this just caps our memory usage. 2859 // know our upload throughput yet, this just caps our memory usage.
2860 size_t divider = 1; 2860 size_t divider = 1;
2861 if (base::android::SysUtils::IsLowEndDevice()) 2861 if (base::android::SysUtils::IsLowEndDevice())
2862 divider = 6; 2862 divider = 6;
2863 // For reference Nexus10 can upload 1MB in about 2.5ms. 2863 // For reference Nexus10 can upload 1MB in about 2.5ms.
2864 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider); 2864 const double max_mb_uploaded_per_ms = 2.0 / (5 * divider);
2865 // Deadline to draw a frame to achieve 60 frames per second. 2865 // Deadline to draw a frame to achieve 60 frames per second.
2866 const size_t kMillisecondsPerFrame = 16; 2866 const size_t kMillisecondsPerFrame = 16;
2867 // Assuming a two frame deep pipeline between the CPU and the GPU. 2867 // Assuming a two frame deep pipeline between the CPU and the GPU.
2868 size_t max_transfer_buffer_usage_mb = 2868 size_t max_transfer_buffer_usage_mb =
2869 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms); 2869 static_cast<size_t>(2 * kMillisecondsPerFrame * max_mb_uploaded_per_ms);
2870 static const size_t kBytesPerMegabyte = 1024 * 1024; 2870 static const size_t kBytesPerMegabyte = 1024 * 1024;
2871 // We keep the MappedMemoryReclaimLimit the same as the upload limit 2871 // We keep the MappedMemoryReclaimLimit the same as the upload limit
2872 // to avoid unnecessarily stalling the compositor thread. 2872 // to avoid unnecessarily stalling the compositor thread.
2873 limits.mapped_memory_reclaim_limit = 2873 limits.mapped_memory_reclaim_limit =
2874 max_transfer_buffer_usage_mb * kBytesPerMegabyte; 2874 max_transfer_buffer_usage_mb * kBytesPerMegabyte;
2875 #endif 2875 #endif
2876 2876
2877 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( 2877 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
2878 new WebGraphicsContext3DCommandBufferImpl(surface_id(), 2878 new WebGraphicsContext3DCommandBufferImpl(
2879 GetURLForGraphicsContext3D(), 2879 surface_id(),
2880 gpu_channel_host.get(), 2880 GetURLForGraphicsContext3D(),
2881 attributes, 2881 gpu_channel_host.get(),
2882 bind_generates_resources, 2882 attributes,
2883 lose_context_when_out_of_memory, 2883 false /* bind generates resources */,
2884 limits, 2884 limits,
2885 NULL)); 2885 NULL));
2886 return context.Pass(); 2886 return context.Pass();
2887 } 2887 }
2888 2888
2889 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { 2889 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) {
2890 swapped_out_frames_.AddObserver(frame); 2890 swapped_out_frames_.AddObserver(frame);
2891 } 2891 }
2892 2892
2893 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { 2893 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) {
2894 swapped_out_frames_.RemoveObserver(frame); 2894 swapped_out_frames_.RemoveObserver(frame);
2895 } 2895 }
2896 2896
2897 } // namespace content 2897 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/renderer/renderer_webkitplatformsupport_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698