summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/client
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 17:05:13 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 17:05:13 +0000
commitb21265f88af52046652bfefe2909f048f0a3c2b8 (patch)
tree48830cbd442dc02192e3b17e0a40a8f8edd9fe82 /gpu/command_buffer/client
parentf39f4b3f8638814272875f37d8b6f574c86d2079 (diff)
downloadchromium_src-b21265f88af52046652bfefe2909f048f0a3c2b8.zip
chromium_src-b21265f88af52046652bfefe2909f048f0a3c2b8.tar.gz
chromium_src-b21265f88af52046652bfefe2909f048f0a3c2b8.tar.bz2
Step 1: Changing CommandBufferHelper to only use a portion
of the command buffer. This brought out the fact that there were lots of places in the code mixing size in bytes with num command buffer entries. This fixes most of those issues. No public interface uses num command buffer entries except gpu::CommandBuffer::State where it makes sense. TEST=relying on unit tests, conformance tests and chrome BUG=none Review URL: http://codereview.chromium.org/2008014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47041 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/client')
-rw-r--r--gpu/command_buffer/client/cmd_buffer_helper.cc8
-rw-r--r--gpu/command_buffer/client/cmd_buffer_helper.h6
-rw-r--r--gpu/command_buffer/client/cmd_buffer_helper_test.cc4
-rw-r--r--gpu/command_buffer/client/fenced_allocator_test.cc4
-rw-r--r--gpu/command_buffer/client/gles2_demo.cc2
-rw-r--r--gpu/command_buffer/client/gles2_implementation_unittest.cc12
-rw-r--r--gpu/command_buffer/client/ring_buffer_test.cc4
7 files changed, 24 insertions, 16 deletions
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.cc b/gpu/command_buffer/client/cmd_buffer_helper.cc
index 4f9d725..72724d7 100644
--- a/gpu/command_buffer/client/cmd_buffer_helper.cc
+++ b/gpu/command_buffer/client/cmd_buffer_helper.cc
@@ -19,14 +19,18 @@ CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer)
put_(0) {
}
-bool CommandBufferHelper::Initialize() {
+bool CommandBufferHelper::Initialize(int32 ring_buffer_size) {
ring_buffer_ = command_buffer_->GetRingBuffer();
if (!ring_buffer_.ptr)
return false;
CommandBuffer::State state = command_buffer_->GetState();
entries_ = static_cast<CommandBufferEntry*>(ring_buffer_.ptr);
- entry_count_ = state.size;
+ int32 num_ring_buffer_entries = ring_buffer_size / sizeof(CommandBufferEntry);
+ if (num_ring_buffer_entries > state.num_entries) {
+ return false;
+ }
+ entry_count_ = num_ring_buffer_entries;
put_ = state.put_offset;
SynchronizeState(state);
return true;
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.h b/gpu/command_buffer/client/cmd_buffer_helper.h
index af18226..cc93057 100644
--- a/gpu/command_buffer/client/cmd_buffer_helper.h
+++ b/gpu/command_buffer/client/cmd_buffer_helper.h
@@ -36,7 +36,11 @@ class CommandBufferHelper {
explicit CommandBufferHelper(CommandBuffer* command_buffer);
virtual ~CommandBufferHelper();
- bool Initialize();
+ // Initializes the CommandBufferHelper.
+ // Parameters:
+ // ring_buffer_size: The size of the ring buffer portion of the command
+ // buffer.
+ bool Initialize(int32 ring_buffer_size);
// Flushes the commands, setting the put pointer to let the buffer interface
// know that new commands have been added. After a flush returns, the command
diff --git a/gpu/command_buffer/client/cmd_buffer_helper_test.cc b/gpu/command_buffer/client/cmd_buffer_helper_test.cc
index 2f1d4af..a61d83b 100644
--- a/gpu/command_buffer/client/cmd_buffer_helper_test.cc
+++ b/gpu/command_buffer/client/cmd_buffer_helper_test.cc
@@ -41,7 +41,7 @@ class CommandBufferHelperTest : public testing::Test {
.WillRepeatedly(Return(error::kNoError));
command_buffer_.reset(new CommandBufferService);
- command_buffer_->Initialize(kNumCommandEntries);
+ command_buffer_->Initialize(kCommandBufferSizeBytes);
Buffer ring_buffer = command_buffer_->GetRingBuffer();
parser_ = new CommandParser(ring_buffer.ptr,
@@ -59,7 +59,7 @@ class CommandBufferHelperTest : public testing::Test {
api_mock_->set_engine(gpu_processor_.get());
helper_.reset(new CommandBufferHelper(command_buffer_.get()));
- helper_->Initialize();
+ helper_->Initialize(kCommandBufferSizeBytes);
}
virtual void TearDown() {
diff --git a/gpu/command_buffer/client/fenced_allocator_test.cc b/gpu/command_buffer/client/fenced_allocator_test.cc
index 1d5c970..21b511a 100644
--- a/gpu/command_buffer/client/fenced_allocator_test.cc
+++ b/gpu/command_buffer/client/fenced_allocator_test.cc
@@ -42,7 +42,7 @@ class BaseFencedAllocatorTest : public testing::Test {
Return(error::kNoError)));
command_buffer_.reset(new CommandBufferService);
- command_buffer_->Initialize(kBufferSize / sizeof(CommandBufferEntry));
+ command_buffer_->Initialize(kBufferSize);
Buffer ring_buffer = command_buffer_->GetRingBuffer();
parser_ = new CommandParser(ring_buffer.ptr,
@@ -60,7 +60,7 @@ class BaseFencedAllocatorTest : public testing::Test {
api_mock_->set_engine(gpu_processor_.get());
helper_.reset(new CommandBufferHelper(command_buffer_.get()));
- helper_->Initialize();
+ helper_->Initialize(kBufferSize);
}
int32 GetToken() {
diff --git a/gpu/command_buffer/client/gles2_demo.cc b/gpu/command_buffer/client/gles2_demo.cc
index b2a0497..365cf53 100644
--- a/gpu/command_buffer/client/gles2_demo.cc
+++ b/gpu/command_buffer/client/gles2_demo.cc
@@ -66,7 +66,7 @@ bool GLES2Demo::Setup(void* hwnd, int32 size) {
NewCallback(gpu_processor, &GPUProcessor::ProcessCommands));
GLES2CmdHelper* helper = new GLES2CmdHelper(command_buffer.get());
- if (!helper->Initialize()) {
+ if (!helper->Initialize(size)) {
// TODO(gman): cleanup.
return false;
}
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc
index b73b889..78a0682 100644
--- a/gpu/command_buffer/client/gles2_implementation_unittest.cc
+++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc
@@ -22,8 +22,8 @@ class GLES2MockCommandBufferHelper : public CommandBuffer {
virtual bool Initialize(int32 size) {
ring_buffer_.reset(new CommandBufferEntry[size]);
ring_buffer_buffer_.ptr = ring_buffer_.get();
- ring_buffer_buffer_.size = size * sizeof(ring_buffer_[0]);
- state_.size = size;
+ ring_buffer_buffer_.size = size;
+ state_.num_entries = size / sizeof(ring_buffer_[0]);
state_.token = 10000; // All token checks in the tests should pass.
return true;
}
@@ -150,7 +150,7 @@ class GLES2ImplementationTest : public testing::Test {
virtual void SetUp() {
command_buffer_.reset(new MockGLES2CommandBuffer());
- command_buffer_->Initialize(kNumCommandEntries);
+ command_buffer_->Initialize(kCommandBufferSizeBytes);
EXPECT_EQ(kTransferBufferId,
command_buffer_->CreateTransferBuffer(kTransferBufferSize));
@@ -158,7 +158,7 @@ class GLES2ImplementationTest : public testing::Test {
ClearTransferBuffer();
helper_.reset(new GLES2CmdHelper(command_buffer_.get()));
- helper_->Initialize();
+ helper_->Initialize(kCommandBufferSizeBytes);
#if defined(GLES2_SUPPORT_CLIENT_SIDE_BUFFERS)
EXPECT_CALL(*command_buffer_, OnFlush(_))
@@ -681,8 +681,8 @@ TEST_F(GLES2ImplementationTest, ReadPixels2Reads) {
scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]);
EXPECT_CALL(*command_buffer_, OnFlush(_))
- .WillOnce(SetMemory(uint32(1)))
- .WillOnce(SetMemory(uint32(1)))
+ .WillOnce(SetMemory(static_cast<uint32>(1)))
+ .WillOnce(SetMemory(static_cast<uint32>(1)))
.RetiresOnSaturation();
gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get());
diff --git a/gpu/command_buffer/client/ring_buffer_test.cc b/gpu/command_buffer/client/ring_buffer_test.cc
index 8af4eb5..b2ffb01 100644
--- a/gpu/command_buffer/client/ring_buffer_test.cc
+++ b/gpu/command_buffer/client/ring_buffer_test.cc
@@ -43,7 +43,7 @@ class BaseRingBufferTest : public testing::Test {
Return(error::kNoError)));
command_buffer_.reset(new CommandBufferService);
- command_buffer_->Initialize(kBufferSize / sizeof(CommandBufferEntry));
+ command_buffer_->Initialize(kBufferSize);
Buffer ring_buffer = command_buffer_->GetRingBuffer();
parser_ = new CommandParser(ring_buffer.ptr,
@@ -61,7 +61,7 @@ class BaseRingBufferTest : public testing::Test {
api_mock_->set_engine(gpu_processor_.get());
helper_.reset(new CommandBufferHelper(command_buffer_.get()));
- helper_->Initialize();
+ helper_->Initialize(kBufferSize);
}
int32 GetToken() {