Commit 362e6d60 authored by jbauman@chromium.org's avatar jbauman@chromium.org

Disable automatic flushes on compositor contexts.

The compositor contexts handle flushes themselves, so they don't need the automatic flushes, which can hurt performance.

BUG=152393


Review URL: https://chromiumcodereview.appspot.com/11099029

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162434 0039d316-1c4b-4281-b951-d872f2087c98
parent a8738b81
......@@ -246,6 +246,7 @@ void CompositorImpl::applyScrollAndScale(const WebKit::WebSize& scrollDelta,
WebKit::WebCompositorOutputSurface* CompositorImpl::createOutputSurface() {
WebKit::WebGraphicsContext3D::Attributes attrs;
attrs.shareResources = true;
attrs.noAutomaticFlushes = true;
GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance();
GURL url("chrome://gpu/Compositor::createContext3D");
base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client;
......
......@@ -400,6 +400,7 @@ class GpuProcessTransportFactory :
attrs.depth = false;
attrs.stencil = false;
attrs.antialias = false;
attrs.noAutomaticFlushes = true;
GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance();
GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon");
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
......
......@@ -343,6 +343,9 @@ bool WebGraphicsContext3DCommandBufferImpl::CreateContext(
if (!gles2_helper_->Initialize(kCommandBufferSize))
return false;
if (attributes_.noAutomaticFlushes)
gles2_helper_->SetAutomaticFlushes(false);
// Create a transfer buffer used to copy resources between the renderer
// process and the GPU process.
transfer_buffer_ = new gpu::TransferBuffer(gles2_helper_);
......
......@@ -1914,6 +1914,7 @@ WebKit::WebCompositorOutputSurface* RenderViewImpl::createOutputSurface() {
WebKit::WebGraphicsContext3D::Attributes attributes;
attributes.antialias = false;
attributes.shareResources = true;
attributes.noAutomaticFlushes = true;
WebGraphicsContext3D* context = CreateGraphicsContext3D(attributes);
if (!context)
return NULL;
......
......@@ -28,9 +28,14 @@ CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer)
commands_issued_(0),
usable_(true),
context_lost_(false),
flush_automatically_(true),
last_flush_time_(0) {
}
void CommandBufferHelper::SetAutomaticFlushes(bool enabled) {
flush_automatically_ = enabled;
}
bool CommandBufferHelper::IsContextLost() {
if (!context_lost_) {
context_lost_ = error::IsError(command_buffer()->GetLastError());
......@@ -241,8 +246,9 @@ void CommandBufferHelper::WaitForAvailableEntries(int32 count) {
((get_offset() == last_put_sent_) ? 16 : 2);
if (pending > limit) {
Flush();
} else if (commands_issued_ % kCommandsPerFlushCheck == 0) {
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
} else if (flush_automatically_ &&
(commands_issued_ % kCommandsPerFlushCheck == 0)) {
#if !defined(OS_ANDROID)
// Allow this command buffer to be pre-empted by another if a "reasonable"
// amount of work has been done. On highend machines, this reduces the
// latency of GPU commands. However, on Android, this can cause the
......
......@@ -44,6 +44,10 @@ class GPU_EXPORT CommandBufferHelper {
// buffer.
bool Initialize(int32 ring_buffer_size);
// Sets whether the command buffer should automatically flush periodically
// to try to increase performance. Defaults to true.
void SetAutomaticFlushes(bool enabled);
// True if the context is lost.
bool IsContextLost();
......@@ -292,6 +296,7 @@ class GPU_EXPORT CommandBufferHelper {
int commands_issued_;
bool usable_;
bool context_lost_;
bool flush_automatically_;
// Using C runtime instead of base because this file cannot depend on base.
clock_t last_flush_time_;
......
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