summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service
diff options
context:
space:
mode:
authorjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-15 04:12:57 +0000
committerjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-15 04:12:57 +0000
commit2f9704c73793a303481b5fa49c76903f9e81eb02 (patch)
treee72dcd9bc380230eccfa3970e83e9a1791fcfc78 /gpu/command_buffer/service
parente190c9ea6211125a1c836d913d504643678a35c5 (diff)
downloadchromium_src-2f9704c73793a303481b5fa49c76903f9e81eb02.zip
chromium_src-2f9704c73793a303481b5fa49c76903f9e81eb02.tar.gz
chromium_src-2f9704c73793a303481b5fa49c76903f9e81eb02.tar.bz2
Use shared memory to update the renderer's view of the command buffer state.
The renderer can't receive UpdateState messages while it's executing javascript or NaCl, causing it to eventually flushsync once it fills up the command buffer or transfer buffer. To avoid this, share a piece of memory between the renderer and gpu process that the GPU can asynchronously update the state. A 4-slot asynchronous communication mechanism is used so that the renderer always receives a consistent copy of the state that was put in by the GPU process. BUG= TEST= Review URL: http://codereview.chromium.org/9380037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122034 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service')
-rw-r--r--gpu/command_buffer/service/command_buffer_service.cc18
-rw-r--r--gpu/command_buffer/service/command_buffer_service.h8
2 files changed, 26 insertions, 0 deletions
diff --git a/gpu/command_buffer/service/command_buffer_service.cc b/gpu/command_buffer/service/command_buffer_service.cc
index c5a1162..13d3098 100644
--- a/gpu/command_buffer/service/command_buffer_service.cc
+++ b/gpu/command_buffer/service/command_buffer_service.cc
@@ -9,6 +9,7 @@
#include "base/process_util.h"
#include "base/debug/trace_event.h"
#include "gpu/command_buffer/common/cmd_buffer_common.h"
+#include "gpu/command_buffer/common/command_buffer_shared.h"
using ::base::SharedMemory;
@@ -16,6 +17,7 @@ namespace gpu {
CommandBufferService::CommandBufferService()
: ring_buffer_id_(-1),
+ shared_state_(NULL),
num_entries_(0),
get_offset_(0),
put_offset_(0),
@@ -59,6 +61,13 @@ CommandBufferService::State CommandBufferService::GetLastState() {
return GetState();
}
+void CommandBufferService::UpdateState() {
+ if (shared_state_) {
+ CommandBufferService::State state = GetState();
+ shared_state_->Write(state);
+ }
+}
+
CommandBufferService::State CommandBufferService::FlushSync(
int32 put_offset, int32 last_known_get) {
if (put_offset < 0 || put_offset > num_entries_) {
@@ -98,6 +107,15 @@ void CommandBufferService::SetGetBuffer(int32 transfer_buffer_id) {
if (!get_buffer_change_callback_.is_null()) {
get_buffer_change_callback_.Run(ring_buffer_id_);
}
+
+ UpdateState();
+}
+
+void CommandBufferService::SetSharedStateBuffer(int32 transfer_buffer_id) {
+ gpu::Buffer buffer = GetTransferBuffer(transfer_buffer_id);
+ shared_state_ = reinterpret_cast<CommandBufferSharedState*>(buffer.ptr);
+
+ UpdateState();
}
void CommandBufferService::SetGetOffset(int32 get_offset) {
diff --git a/gpu/command_buffer/service/command_buffer_service.h b/gpu/command_buffer/service/command_buffer_service.h
index 7704636..2c59678 100644
--- a/gpu/command_buffer/service/command_buffer_service.h
+++ b/gpu/command_buffer/service/command_buffer_service.h
@@ -13,6 +13,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/shared_memory.h"
#include "gpu/command_buffer/common/command_buffer.h"
+#include "gpu/command_buffer/common/command_buffer_shared.h"
namespace gpu {
@@ -56,9 +57,16 @@ class CommandBufferService : public CommandBuffer {
const GetBufferChangedCallback& callback);
virtual void SetParseErrorCallback(const base::Closure& callback);
+ // Setup the transfer buffer that shared state should be copied into.
+ void SetSharedStateBuffer(int32 transfer_buffer_id);
+
+ // Copy the current state into the shared state transfer buffer.
+ void UpdateState();
+
private:
int32 ring_buffer_id_;
Buffer ring_buffer_;
+ CommandBufferSharedState* shared_state_;
int32 num_entries_;
int32 get_offset_;
int32 put_offset_;