summaryrefslogtreecommitdiffstats
path: root/o3d/gpu_plugin
diff options
context:
space:
mode:
authorapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-22 22:25:58 +0000
committerapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-22 22:25:58 +0000
commit60fca94ed614caad0109c1062f8260490cd85695 (patch)
tree57e10fafa5bec156eaa8fd5878bb1670df37adcf /o3d/gpu_plugin
parentff046e815788bea45e88baa982d9df8f61efb77e (diff)
downloadchromium_src-60fca94ed614caad0109c1062f8260490cd85695.zip
chromium_src-60fca94ed614caad0109c1062f8260490cd85695.tar.gz
chromium_src-60fca94ed614caad0109c1062f8260490cd85695.tar.bz2
Added support for getting and setting the CommandBuffer token and error.
See o3d/command_buffer/service/cross/cmd_buffer_engine.h. TEST=none BUG=none Review URL: http://codereview.chromium.org/207061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26871 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/gpu_plugin')
-rw-r--r--o3d/gpu_plugin/command_buffer.cc10
-rw-r--r--o3d/gpu_plugin/command_buffer.h35
-rw-r--r--o3d/gpu_plugin/command_buffer_unittest.cc20
3 files changed, 64 insertions, 1 deletions
diff --git a/o3d/gpu_plugin/command_buffer.cc b/o3d/gpu_plugin/command_buffer.cc
index badda14..04b1f41 100644
--- a/o3d/gpu_plugin/command_buffer.cc
+++ b/o3d/gpu_plugin/command_buffer.cc
@@ -11,7 +11,9 @@ CommandBuffer::CommandBuffer(NPP npp)
: npp_(npp),
size_(0),
get_offset_(0),
- put_offset_(0) {
+ put_offset_(0),
+ token_(0),
+ error_(ERROR_NO_ERROR) {
// Element zero is always NULL.
registered_objects_.push_back(NPObjectPointer<NPObject>());
}
@@ -152,5 +154,11 @@ NPObjectPointer<NPObject> CommandBuffer::GetRegisteredObject(int32 handle) {
return registered_objects_[handle];
}
+int32 CommandBuffer::ResetError() {
+ int32 last_error = error_;
+ error_ = ERROR_NO_ERROR;
+ return last_error;
+}
+
} // namespace gpu_plugin
} // namespace o3d
diff --git a/o3d/gpu_plugin/command_buffer.h b/o3d/gpu_plugin/command_buffer.h
index 145cbe7..31f60d1 100644
--- a/o3d/gpu_plugin/command_buffer.h
+++ b/o3d/gpu_plugin/command_buffer.h
@@ -22,6 +22,14 @@ namespace gpu_plugin {
// API to manage the put and get pointers.
class CommandBuffer : public DefaultNPObject<NPObject> {
public:
+ enum {
+ ERROR_NO_ERROR,
+ ERROR_INVALID_SIZE,
+ ERROR_OUT_OF_BOUNDS,
+ ERROR_UNKNOWN_COMMAND,
+ ERROR_INVALID_ARGUMENTS,
+ };
+
explicit CommandBuffer(NPP npp);
virtual ~CommandBuffer();
@@ -73,6 +81,29 @@ class CommandBuffer : public DefaultNPObject<NPObject> {
virtual NPObjectPointer<NPObject> GetRegisteredObject(int32 handle);
+ // Get the current token value. This is used for by the writer to defer
+ // changes to shared memory objects until the reader has reached a certain
+ // point in the command buffer. The reader is responsible for updating the
+ // token value, for example in response to an asynchronous set token command
+ // embedded in the command buffer. The default token value is zero.
+ int32 GetToken() {
+ return token_;
+ }
+
+ // Allows the reader to update the current token value.
+ void SetToken(int32 token) {
+ token_ = token;
+ }
+
+ // Get the current error status and reset it to ERROR_NO_ERROR.
+ // The default error status is ERROR_NO_ERROR.
+ int32 ResetError();
+
+ // Allows the reader to set the current error status.
+ void SetError(int32 error) {
+ error_ = error;
+ }
+
NP_UTILS_BEGIN_DISPATCHER_CHAIN(CommandBuffer, DefaultNPObject<NPObject>)
NP_UTILS_DISPATCHER(Initialize, bool(int32))
NP_UTILS_DISPATCHER(GetRingBuffer, NPObjectPointer<CHRSharedMemory>())
@@ -83,6 +114,8 @@ class CommandBuffer : public DefaultNPObject<NPObject> {
NP_UTILS_DISPATCHER(RegisterObject, int32(NPObjectPointer<NPObject>));
NP_UTILS_DISPATCHER(UnregisterObject,
void(NPObjectPointer<NPObject>, int32));
+ NP_UTILS_DISPATCHER(GetToken, int32());
+ NP_UTILS_DISPATCHER(ResetError, int32());
NP_UTILS_END_DISPATCHER_CHAIN
private:
@@ -94,6 +127,8 @@ class CommandBuffer : public DefaultNPObject<NPObject> {
scoped_ptr<Callback0::Type> put_offset_change_callback_;
std::vector<NPObjectPointer<NPObject> > registered_objects_;
std::set<int32> unused_registered_object_elements_;
+ int32 token_;
+ int32 error_;
};
} // namespace gpu_plugin
diff --git a/o3d/gpu_plugin/command_buffer_unittest.cc b/o3d/gpu_plugin/command_buffer_unittest.cc
index 435a0fc..b5e17d2 100644
--- a/o3d/gpu_plugin/command_buffer_unittest.cc
+++ b/o3d/gpu_plugin/command_buffer_unittest.cc
@@ -236,5 +236,25 @@ TEST_F(CommandBufferTest, UnregistersTwoLastRegisteredHandles) {
EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(1));
}
+TEST_F(CommandBufferTest, DefaultTokenIsZero) {
+ EXPECT_EQ(0, command_buffer_->GetToken());
+}
+
+TEST_F(CommandBufferTest, CanSetToken) {
+ command_buffer_->SetToken(7);
+ EXPECT_EQ(7, command_buffer_->GetToken());
+}
+
+TEST_F(CommandBufferTest, DefaultErrorIsNoError) {
+ EXPECT_EQ(CommandBuffer::ERROR_NO_ERROR, command_buffer_->ResetError());
+}
+
+TEST_F(CommandBufferTest, CanSetAndResetError) {
+ command_buffer_->SetError(CommandBuffer::ERROR_UNKNOWN_COMMAND);
+ EXPECT_EQ(CommandBuffer::ERROR_UNKNOWN_COMMAND,
+ command_buffer_->ResetError());
+ EXPECT_EQ(CommandBuffer::ERROR_NO_ERROR, command_buffer_->ResetError());
+}
+
} // namespace gpu_plugin
} // namespace o3d