Skip to content

Commit

Permalink
Revert 119430 - Make transferbuffer increase in size dynamically
Browse files Browse the repository at this point in the history
TEST=unit tests
BUG=101431


Review URL: http://codereview.chromium.org/9113069

TBR=gman@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9298005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119436 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
kinuko@chromium.org committed Jan 27, 2012
1 parent f6813d1 commit 2f38c45
Show file tree
Hide file tree
Showing 25 changed files with 1,396 additions and 2,232 deletions.
42 changes: 23 additions & 19 deletions content/renderer/gpu/renderer_gl_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "gpu/command_buffer/client/gles2_cmd_helper.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/command_buffer/client/transfer_buffer.h"
#include "gpu/command_buffer/common/constants.h"
#endif // ENABLE_GPU

Expand All @@ -32,9 +31,7 @@ namespace {
const int32 kCommandBufferSize = 1024 * 1024;
// TODO(kbr): make the transfer buffer size configurable via context
// creation attributes.
const size_t kStartTransferBufferSize = 1 * 1024 * 1024;
const size_t kMinTransferBufferSize = 1 * 256 * 1024;
const size_t kMaxTransferBufferSize = 16 * 1024 * 1024;
const int32 kTransferBufferSize = 1024 * 1024;

// Singleton used to initialize and terminate the gles2 library.
class GLES2Initializer {
Expand Down Expand Up @@ -284,7 +281,7 @@ RendererGLContext::RendererGLContext(GpuChannelHost* channel)
parent_texture_id_(0),
command_buffer_(NULL),
gles2_helper_(NULL),
transfer_buffer_(NULL),
transfer_buffer_id_(-1),
gles2_implementation_(NULL),
last_error_(SUCCESS),
frame_number_(0) {
Expand Down Expand Up @@ -395,24 +392,31 @@ bool RendererGLContext::Initialize(bool onscreen,
TRACE_EVENT0("gpu", "RendererGLContext::Initialize::CreateTransferBuffer");
// Create a transfer buffer used to copy resources between the renderer
// process and the GPU process.
transfer_buffer_ = new gpu::TransferBuffer(gles2_helper_);
transfer_buffer_id_ = command_buffer_->CreateTransferBuffer(
kTransferBufferSize, gpu::kCommandBufferSharedMemoryId);
if (transfer_buffer_id_ < 0) {
Destroy();
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) {
Destroy();
return false;
}

// Create the object exposing the OpenGL API.
gles2_implementation_ = new gpu::gles2::GLES2Implementation(
gles2_helper_,
transfer_buffer_,
transfer_buffer.size,
transfer_buffer.ptr,
transfer_buffer_id_,
share_resources,
bind_generates_resources);

if (!gles2_implementation_->Initialize(
kStartTransferBufferSize,
kMinTransferBufferSize,
kMaxTransferBufferSize)) {
Destroy();
return false;
}

return true;
}

Expand All @@ -433,10 +437,10 @@ void RendererGLContext::Destroy() {
gles2_implementation_ = NULL;
}

if (transfer_buffer_) {
delete transfer_buffer_;
transfer_buffer_ = NULL;
}
// Do not destroy this transfer buffer here, because commands are still
// in flight on the GPU process that may access them. When the command buffer
// is destroyed, the associated shared memory will be cleaned up.
transfer_buffer_id_ = -1;

delete gles2_helper_;
gles2_helper_ = NULL;
Expand Down
3 changes: 1 addition & 2 deletions content/renderer/gpu/renderer_gl_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class CommandBufferProxy;
class GURL;

namespace gpu {
class TransferBuffer;
namespace gles2 {
class GLES2CmdHelper;
class GLES2Implementation;
Expand Down Expand Up @@ -200,7 +199,7 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext>,
uint32 parent_texture_id_;
CommandBufferProxy* command_buffer_;
gpu::gles2::GLES2CmdHelper* gles2_helper_;
gpu::TransferBuffer* transfer_buffer_;
int32 transfer_buffer_id_;
gpu::gles2::GLES2Implementation* gles2_implementation_;
Error last_error_;
int frame_number_;
Expand Down
15 changes: 6 additions & 9 deletions gpu/command_buffer/build_gles2_cmd_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3220,10 +3220,9 @@ def WriteGLES2ImplementationUnitTest(self, func, file):
typedef %(name)s::Result Result;
Result::Type result = 0;
Cmds expected;
ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
expected.cmd.Init(%(cmd_args)s, result1.id, result1.offset);
EXPECT_CALL(*command_buffer(), OnFlush())
.WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
expected.cmd.Init(%(cmd_args)s, transfer_buffer_id_, 0);
EXPECT_CALL(*command_buffer_, OnFlush(_))
.WillOnce(SetMemory(SizedResultHelper<Result::Type>(1)))
.RetiresOnSaturation();
gl_->%(name)s(%(args)s, &result);
EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
Expand Down Expand Up @@ -4146,12 +4145,10 @@ def WriteGLES2ImplementationUnitTest(self, func, file):
typedef %(name)s::Result Result;
Cmds expected;
ExpectedMemoryInfo result1 =
GetExpectedResultMemory(sizeof(%(name)s::Result));
expected.cmd.Init(1, result1.id, result1.offset);
expected.cmd.Init(1, transfer_buffer_id_, 0);
EXPECT_CALL(*command_buffer(), OnFlush())
.WillOnce(SetMemory(result1.ptr, uint32(1)))
EXPECT_CALL(*command_buffer_, OnFlush(_))
.WillOnce(SetMemory(uint32(1)))
.RetiresOnSaturation();
GLboolean result = gl_->%(name)s(1);
Expand Down
138 changes: 0 additions & 138 deletions gpu/command_buffer/client/client_test_helper.cc

This file was deleted.

76 changes: 0 additions & 76 deletions gpu/command_buffer/client/client_test_helper.h

This file was deleted.

Loading

0 comments on commit 2f38c45

Please sign in to comment.