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-17 21:56:35 +0000
committerjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-17 21:56:35 +0000
commit68eff95f3458adc808e3d700e0c682f80ef73ffd (patch)
tree972a01fd93442fc02ac79b6422957ea339989094 /gpu/command_buffer/service
parentf0ae6c416e43078578ae149dff532fa2d5f3b4af (diff)
downloadchromium_src-68eff95f3458adc808e3d700e0c682f80ef73ffd.zip
chromium_src-68eff95f3458adc808e3d700e0c682f80ef73ffd.tar.gz
chromium_src-68eff95f3458adc808e3d700e0c682f80ef73ffd.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= Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=122034 Review URL: https://chromiumcodereview.appspot.com/9380037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122593 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_;