summaryrefslogtreecommitdiffstats
path: root/webkit/gpu
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-04 02:51:37 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-04 02:51:37 +0000
commit87bc3e95e3bae8e76c17b3955aac361faee1ec50 (patch)
tree8abf6af6bb7b8da4f4bc93de475900289227e955 /webkit/gpu
parentfe939ae4e80a657a3fdd55132fa572ce678c1eef (diff)
downloadchromium_src-87bc3e95e3bae8e76c17b3955aac361faee1ec50.zip
chromium_src-87bc3e95e3bae8e76c17b3955aac361faee1ec50.tar.gz
chromium_src-87bc3e95e3bae8e76c17b3955aac361faee1ec50.tar.bz2
make command buffer work in DRT
Note several tests get different results than the non-command buffer path. I'm not sure if that's bugs in this impl, bugs in the command buffer or bugs else where but that's kind of the point. This CL is supposed to help find those bugs. Is there something I should do to mark them to be fixed before checking this in? Should I leave webkit_support.cc out of this CL? TEST=ran layout tests BUG=84157 R=jamesr@chromium.org Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=87879 Review URL: http://codereview.chromium.org/7085002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87910 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/gpu')
-rw-r--r--webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc38
1 files changed, 33 insertions, 5 deletions
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
index db6010f..25795a7 100644
--- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
+++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
@@ -18,6 +18,7 @@
#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
+#include "base/message_loop.h"
#include "base/memory/singleton.h"
#include "base/metrics/histogram.h"
#include "gpu/command_buffer/client/gles2_lib.h"
@@ -75,6 +76,8 @@ class GLInProcessContext : public base::SupportsWeakPtr<GLInProcessContext> {
~GLInProcessContext();
+ void PumpCommands(bool sync);
+
// Create a GLInProcessContext that renders directly to a view. The view and
// the associated window must not be destroyed until the returned
// GLInProcessContext has been destroyed, otherwise the GPU process might
@@ -249,13 +252,18 @@ class LatchAllocator {
LatchAllocator();
~LatchAllocator();
+ base::SharedMemoryHandle handle() const { return shm_->handle(); }
+ base::SharedMemory* shared_memory() { return shm_.get(); }
+
bool AllocateLatch(uint32* latch_id);
bool FreeLatch(uint32 latch_id);
private:
friend struct DefaultSingletonTraits<LatchAllocator>;
- scoped_array<uint32> latches_;
+ scoped_ptr<base::SharedMemory> shm_;
+ // Pointer to mapped shared memory.
+ volatile uint32* latches_;
DISALLOW_COPY_AND_ASSIGN(LatchAllocator);
};
@@ -268,7 +276,10 @@ LatchAllocator* LatchAllocator::GetInstance() {
}
LatchAllocator::LatchAllocator() {
- latches_.reset(new uint32[size()]);
+ shm_.reset(new base::SharedMemory());
+ shm_->CreateAndMapAnonymous(size());
+
+ latches_ = static_cast<uint32*>(shm_->memory());
// Mark all latches as unallocated.
for (uint32 i = 0; i < kMaxLatchesPerRenderer; ++i)
latches_[i] = kFreeLatch;
@@ -371,6 +382,15 @@ void GLInProcessContext::ResizeOffscreen(const gfx::Size& size) {
}
}
+void GLInProcessContext::PumpCommands(bool /* sync */) {
+ ::gpu::CommandBuffer::State state;
+ do {
+ gpu_scheduler_->PutChanged(true);
+ MessageLoop::current()->RunAllPending();
+ state = command_buffer_->GetState();
+ } while (state.get_offset != state.put_offset);
+}
+
uint32 GLInProcessContext::GetParentTextureId() {
return parent_texture_id_;
}
@@ -591,7 +611,7 @@ bool GLInProcessContext::Initialize(bool onscreen,
}
command_buffer_->SetPutOffsetChangeCallback(
- NewCallback(gpu_scheduler_, &GpuScheduler::PutChanged));
+ NewCallback(this, &GLInProcessContext::PumpCommands));
// Create the GLES2 helper, which writes the command buffer protocol.
gles2_helper_ = new GLES2CmdHelper(command_buffer_.get());
@@ -617,6 +637,16 @@ bool GLInProcessContext::Initialize(bool onscreen,
return false;
}
+ // Register transfer buffer so that the context can access latches.
+ LatchAllocator* latch_shm = LatchAllocator::GetInstance();
+ latch_transfer_buffer_id_ = command_buffer_->RegisterTransferBuffer(
+ latch_shm->shared_memory(), LatchAllocator::size(),
+ ::gpu::kLatchSharedMemoryId);
+ if (latch_transfer_buffer_id_ != ::gpu::kLatchSharedMemoryId) {
+ Destroy();
+ return false;
+ }
+
// If this is a child context, setup latches for synchronization between child
// and parent.
if (parent_.get()) {
@@ -809,8 +839,6 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::initialize(
}
makeContextCurrent();
- fprintf(stderr, "Running command buffer\n");
-
return true;
}