diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-27 23:06:19 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-27 23:06:19 +0000 |
commit | 06b73aa26473f9ec6bec009d11329a10cad27350 (patch) | |
tree | 953a5ab22e1fd30e918a47a0eebd72860c0bad69 /ppapi | |
parent | d052176a98e0f9803b276dc43daa08b3fd310055 (diff) | |
download | chromium_src-06b73aa26473f9ec6bec009d11329a10cad27350.zip chromium_src-06b73aa26473f9ec6bec009d11329a10cad27350.tar.gz chromium_src-06b73aa26473f9ec6bec009d11329a10cad27350.tar.bz2 |
Revert "Revert 119430 - Make transferbuffer increase in size dynamically"
This reverts commit 2f38c45427c68fe731c1f5c05256b6c141a6a590.
BUG=101431
TEST=
TBR=apatrick@chromium.org
Review URL: http://codereview.chromium.org/9121057
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119509 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
6 files changed, 41 insertions, 45 deletions
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons b/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons index 2bfed5d..050e419 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons +++ b/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons @@ -35,6 +35,7 @@ command_buffer_client_srcs = [ 'command_buffer/client/gles2_lib.cc', 'command_buffer/client/mapped_memory.cc', 'command_buffer/client/ring_buffer.cc', + 'command_buffer/client/transfer_buffer.cc', 'command_buffer/common/id_allocator.cc', ] diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc index 2fc4bd6..a3220f9 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc @@ -7,6 +7,7 @@ #include "native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h" #include "gpu/command_buffer/client/gles2_implementation.h" +#include "gpu/command_buffer/client/transfer_buffer.h" #include "native_client/src/shared/ppapi_proxy/command_buffer_nacl.h" #include "native_client/src/shared/ppapi_proxy/object_serialize.h" #include "native_client/src/shared/ppapi_proxy/plugin_callback.h" @@ -25,8 +26,10 @@ namespace ppapi_proxy { namespace { -const int32 kRingBufferSize = 4096 * 1024; -const int32 kTransferBufferSize = 4096 * 1024; +const size_t kRingBufferSize = 4 * 1024 * 1024; +const size_t kStartTransferBufferSize = 4 * 1024 * 1024; +const size_t kMinTransferBufferSize = 256 * 1024; +const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; int32_t GetNumAttribs(const int32_t* attrib_list) { int32_t num = 0; @@ -181,6 +184,7 @@ PluginGraphics3D::~PluginGraphics3D() { DebugPrintf("PluginGraphics3D::~PluginGraphics3D()\n"); // Explicitly tear down scopted pointers; ordering below matters. gles2_implementation_.reset(); + transfer_buffer_.reset(); gles2_helper_.reset(); command_buffer_.reset(); // Invalidate the cache. @@ -213,19 +217,16 @@ bool PluginGraphics3D::InitFromBrowserResource(PP_Resource res) { if (command_buffer_->Initialize()) { gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer_.get())); if (gles2_helper_->Initialize(kRingBufferSize)) { - // Request id -1 to signify 'don't care' - int32 transfer_buffer_id = - command_buffer_->CreateTransferBuffer(kTransferBufferSize, -1); - gpu::Buffer transfer_buffer = - command_buffer_->GetTransferBuffer(transfer_buffer_id); - if (transfer_buffer.ptr) { - gles2_implementation_.reset(new gpu::gles2::GLES2Implementation( - gles2_helper_.get(), - transfer_buffer.size, - transfer_buffer.ptr, - transfer_buffer_id, - false, - true)); + transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); + gles2_implementation_.reset(new gpu::gles2::GLES2Implementation( + gles2_helper_.get(), + transfer_buffer_.get(), + false, + true)); + if (gles2_implementation_->Initialize( + kStartTransferBufferSize, + kMinTransferBufferSize, + kMaxTransferBufferSize)) { return true; } } diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h index 115cc25..84af986 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,6 +15,7 @@ namespace gpu { class CommandBuffer; +class TransferBuffer; namespace gles2 { class GLES2CmdHelper; class GLES2Implementation; @@ -63,6 +64,7 @@ class PluginGraphics3D : public PluginResource { // GLES2 Implementation objects. scoped_ptr<gpu::CommandBuffer> command_buffer_; scoped_ptr<gpu::gles2::GLES2Implementation> gles2_implementation_; + scoped_ptr<gpu::TransferBuffer> transfer_buffer_; scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; PP_Instance instance_id_; diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy_untrusted.gyp b/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy_untrusted.gyp index 58dad08..80f2a11 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy_untrusted.gyp +++ b/ppapi/native_client/src/shared/ppapi_proxy/ppapi_proxy_untrusted.gyp @@ -34,6 +34,7 @@ '<(DEPTH)/gpu/command_buffer/client/gles2_cmd_helper.cc', '<(DEPTH)/gpu/command_buffer/client/gles2_implementation.cc', '<(DEPTH)/gpu/command_buffer/client/program_info_manager.cc', + '<(DEPTH)/gpu/command_buffer/client/transfer_buffer.cc', '<(DEPTH)/gpu/command_buffer/client/gles2_lib.cc', '<(DEPTH)/gpu/command_buffer/client/mapped_memory.cc', '<(DEPTH)/gpu/command_buffer/client/ring_buffer.cc', diff --git a/ppapi/shared_impl/ppb_graphics_3d_shared.cc b/ppapi/shared_impl/ppb_graphics_3d_shared.cc index d444516..37b3d0b 100644 --- a/ppapi/shared_impl/ppb_graphics_3d_shared.cc +++ b/ppapi/shared_impl/ppb_graphics_3d_shared.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,24 +7,23 @@ #include "base/logging.h" #include "gpu/command_buffer/client/gles2_cmd_helper.h" #include "gpu/command_buffer/client/gles2_implementation.h" +#include "gpu/command_buffer/client/transfer_buffer.h" #include "ppapi/c/pp_errors.h" namespace ppapi { PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(PP_Instance instance) - : Resource(instance), - transfer_buffer_id_(-1) { + : Resource(instance) { } PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(const HostResource& host_resource) - : Resource(host_resource), - transfer_buffer_id_(-1) { + : Resource(host_resource) { } PPB_Graphics3D_Shared::~PPB_Graphics3D_Shared() { // Make sure that GLES2 implementation has already been destroyed. - DCHECK_EQ(transfer_buffer_id_, -1); DCHECK(!gles2_helper_.get()); + DCHECK(!transfer_buffer_.get()); DCHECK(!gles2_impl_.get()); } @@ -110,39 +109,30 @@ bool PPB_Graphics3D_Shared::CreateGLES2Impl(int32 command_buffer_size, // Create a transfer buffer used to copy resources between the renderer // process and the GPU process. - transfer_buffer_id_ = - command_buffer->CreateTransferBuffer(transfer_buffer_size, -1); - if (transfer_buffer_id_ < 0) - return false; - - // Map the buffer into the renderer process's address space. - gpu::Buffer transfer_buffer = - command_buffer->GetTransferBuffer(transfer_buffer_id_); - if (!transfer_buffer.ptr) - return false; + const int32 kMinTransferBufferSize = 256 * 1024; + const int32 kMaxTransferBufferSize = 16 * 1024 * 1024; + transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); // Create the object exposing the OpenGL API. gles2_impl_.reset(new gpu::gles2::GLES2Implementation( gles2_helper_.get(), - transfer_buffer.size, - transfer_buffer.ptr, - transfer_buffer_id_, + transfer_buffer_.get(), false, true)); + if (!gles2_impl_->Initialize( + transfer_buffer_size, + kMinTransferBufferSize, + std::max(kMaxTransferBufferSize, transfer_buffer_size))) { + return false; + } + return true; } void PPB_Graphics3D_Shared::DestroyGLES2Impl() { gles2_impl_.reset(); - - if (transfer_buffer_id_ != -1) { - gpu::CommandBuffer* command_buffer = GetCommandBuffer(); - DCHECK(command_buffer); - command_buffer->DestroyTransferBuffer(transfer_buffer_id_); - transfer_buffer_id_ = -1; - } - + transfer_buffer_.reset(); gles2_helper_.reset(); } diff --git a/ppapi/shared_impl/ppb_graphics_3d_shared.h b/ppapi/shared_impl/ppb_graphics_3d_shared.h index 8804181..2a89e40 100644 --- a/ppapi/shared_impl/ppb_graphics_3d_shared.h +++ b/ppapi/shared_impl/ppb_graphics_3d_shared.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,6 +15,7 @@ namespace gpu { class CommandBuffer; +class TransferBuffer; namespace gles2 { class GLES2CmdHelper; class GLES2Implementation; @@ -68,8 +69,8 @@ class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared void DestroyGLES2Impl(); private: - int32 transfer_buffer_id_; scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; + scoped_ptr<gpu::TransferBuffer> transfer_buffer_; scoped_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; // Callback that needs to be executed when swap-buffers is completed. |