summaryrefslogtreecommitdiffstats
path: root/o3d/gpu_plugin/command_buffer.h
diff options
context:
space:
mode:
authorapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-21 23:24:18 +0000
committerapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-21 23:24:18 +0000
commitb19ed717676f1dcf50e8bb530404019a3fbb308a (patch)
tree5ba3d65e39b878a05290d612fa705fa8e14f498d /o3d/gpu_plugin/command_buffer.h
parenta33457b842b5b8e70622d7c73f266bb94dec6a49 (diff)
downloadchromium_src-b19ed717676f1dcf50e8bb530404019a3fbb308a.zip
chromium_src-b19ed717676f1dcf50e8bb530404019a3fbb308a.tar.gz
chromium_src-b19ed717676f1dcf50e8bb530404019a3fbb308a.tar.bz2
Implemented get and put offset synchronization via NPObject interface in GPU plugin CommandBuffer.
Added GPUProcessor which handles commands (currently 4-byte "colors") put into the command buffer. TEST=none BUG=none Review URL: http://codereview.chromium.org/203003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26762 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/gpu_plugin/command_buffer.h')
-rw-r--r--o3d/gpu_plugin/command_buffer.h49
1 files changed, 40 insertions, 9 deletions
diff --git a/o3d/gpu_plugin/command_buffer.h b/o3d/gpu_plugin/command_buffer.h
index d7be196..40b8ff3 100644
--- a/o3d/gpu_plugin/command_buffer.h
+++ b/o3d/gpu_plugin/command_buffer.h
@@ -5,6 +5,9 @@
#ifndef O3D_GPU_PLUGIN_COMMAND_BUFFER_H_
#define O3D_GPU_PLUGIN_COMMAND_BUFFER_H_
+#include "base/message_loop.h"
+#include "base/scoped_ptr.h"
+#include "base/task.h"
#include "o3d/gpu_plugin/np_utils/default_np_object.h"
#include "o3d/gpu_plugin/np_utils/np_dispatcher.h"
#include "o3d/gpu_plugin/system_services/shared_memory_public.h"
@@ -22,28 +25,56 @@ class CommandBuffer : public DefaultNPObject<NPObject> {
// Create a shared memory buffer of the given size.
virtual bool Initialize(int32 size);
- // Gets the shared memory object for the command buffer.
- virtual NPObjectPointer<NPObject> GetSharedMemory();
+ // Gets the shared memory ring buffer object for the command buffer.
+ virtual NPObjectPointer<CHRSharedMemory> GetRingBuffer();
- // The client calls this to update its put offset.
- virtual void SetPutOffset(int32 offset);
+ virtual int32 GetSize();
- // The client calls this to get the servers current get offset.
+ // The writer calls this to update its put offset. This function returns the
+ // reader's most recent get offset. Does not return until after the put offset
+ // change callback has been invoked. Returns -1 if the put offset is invalid.
+ virtual int32 SyncOffsets(int32 put_offset);
+
+ // Returns the current get offset. This can be called from any thread.
virtual int32 GetGetOffset();
+ // Sets the current get offset. This can be called from any thread.
+ virtual void SetGetOffset(int32 get_offset);
+
+ // Returns the current put offset. This can be called from any thread.
+ virtual int32 GetPutOffset();
+
+ // Sets a callback that should be posted on another thread whenever the put
+ // offset is changed. The callback must not return until some progress has
+ // been made (unless the command buffer is empty), i.e. the
+ // get offset must have changed. It need not process the entire command
+ // buffer though. This allows concurrency between the writer and the reader
+ // while giving the writer a means of waiting for the reader to make some
+ // progress before attempting to write more to the command buffer. Avoiding
+ // the use of a synchronization primitive like a condition variable to
+ // synchronize reader and writer reduces the risk of deadlock.
+ // Takes ownership of callback. The callback is invoked on the plugin thread.
+ virtual void SetPutOffsetChangeCallback(Callback0::Type* callback);
+
NP_UTILS_BEGIN_DISPATCHER_CHAIN(CommandBuffer, DefaultNPObject<NPObject>)
NP_UTILS_DISPATCHER(Initialize, bool(int32))
- NP_UTILS_DISPATCHER(SetPutOffset, void(int32))
- NP_UTILS_DISPATCHER(GetGetOffset, int32())
- NP_UTILS_DISPATCHER(GetSharedMemory, NPObjectPointer<NPObject>())
+ NP_UTILS_DISPATCHER(GetRingBuffer, NPObjectPointer<CHRSharedMemory>())
+ NP_UTILS_DISPATCHER(GetSize, int32())
+ NP_UTILS_DISPATCHER(SyncOffsets, int32(int32))
+ NP_UTILS_DISPATCHER(GetGetOffset, int32());
+ NP_UTILS_DISPATCHER(GetPutOffset, int32());
NP_UTILS_END_DISPATCHER_CHAIN
private:
NPP npp_;
NPObjectPointer<CHRSharedMemory> shared_memory_;
+ int32 size_;
+ int32 get_offset_;
+ int32 put_offset_;
+ scoped_ptr<Callback0::Type> put_offset_change_callback_;
};
} // namespace gpu_plugin
} // namespace o3d
-#endif // O3D_GPU_PLUGIN_COMMAND_BUFFER_H_
+#endif // O3D_GPU_PLUGIN_COMMAND_BUFFER_H_ \ No newline at end of file