diff options
author | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-12 20:09:57 +0000 |
---|---|---|
committer | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-12 20:09:57 +0000 |
commit | ce9eea60c922efff7c680a7a127480a799e06e94 (patch) | |
tree | 6e34093d78d48fe4d1132c4d8eef2817d32e2203 /gpu | |
parent | 8c3bd1d8c71d8432beb624ce1434ca962665de90 (diff) | |
download | chromium_src-ce9eea60c922efff7c680a7a127480a799e06e94.zip chromium_src-ce9eea60c922efff7c680a7a127480a799e06e94.tar.gz chromium_src-ce9eea60c922efff7c680a7a127480a799e06e94.tar.bz2 |
implemented latch support in renderer process. this corresponds with a webkit patch.
https://bugs.webkit.org/show_bug.cgi?id=58003
BUG=72671
TEST=see attachment in bug for test. only green should be seen.
Review URL: http://codereview.chromium.org/6810009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81295 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
24 files changed, 138 insertions, 99 deletions
diff --git a/gpu/GLES2/gl2ext.h b/gpu/GLES2/gl2ext.h index 02da1ea..d9d64e0 100644 --- a/gpu/GLES2/gl2ext.h +++ b/gpu/GLES2/gl2ext.h @@ -962,12 +962,12 @@ typedef void (GL_APIENTRYP PFNGLREQUESTEXTENSIONCHROMIUM) (const GLchar *extensi #define glSetLatchCHROMIUM GLES2_GET_FUN(SetLatchCHROMIUM) #define glWaitLatchCHROMIUM GLES2_GET_FUN(WaitLatchCHROMIUM) #if !defined(GLES2_USE_CPP_BINDINGS) -GL_APICALL void GL_APIENTRY glSetLatchCHROMIUM (GLint shm_id, GLuint latch_id); -GL_APICALL void GL_APIENTRY glWaitLatchCHROMIUM (GLint shm_id, GLuint latch_id); +GL_APICALL void GL_APIENTRY glSetLatchCHROMIUM (GLuint latch_id); +GL_APICALL void GL_APIENTRY glWaitLatchCHROMIUM (GLuint latch_id); #endif #else -typedef void (GL_APIENTRYP PFNGLSETLATCHCHROMIUM) (GLint shm_id, GLuint latch_id); -typedef void (GL_APIENTRYP PFNGLWaitLATCHCHROMIUM) (GLint shm_id, GLuint latch_id); +typedef void (GL_APIENTRYP PFNGLSETLATCHCHROMIUM) (GLuint latch_id); +typedef void (GL_APIENTRYP PFNGLWaitLATCHCHROMIUM) (GLuint latch_id); #endif #endif diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index bd5bef7..dd9bfab 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -211,8 +211,8 @@ GL_APICALL void GL_APIENTRY glCopyTextureToParentTextureCHROMIUM (GLidBi GL_APICALL void GL_APIENTRY glResizeCHROMIUM (GLuint width, GLuint height); GL_APICALL const GLchar* GL_APIENTRY glGetRequestableExtensionsCHROMIUM (void); GL_APICALL void GL_APIENTRY glRequestExtensionCHROMIUM (const char* extension); -GL_APICALL void GL_APIENTRY glSetLatchCHROMIUM (GLint shm_id, GLuint latch_id); -GL_APICALL void GL_APIENTRY glWaitLatchCHROMIUM (GLint shm_id, GLuint latch_id); +GL_APICALL void GL_APIENTRY glSetLatchCHROMIUM (GLuint latch_id); +GL_APICALL void GL_APIENTRY glWaitLatchCHROMIUM (GLuint latch_id); """ # This is the list of all commmands that will be generated and their Id. diff --git a/gpu/command_buffer/client/gles2_c_lib_autogen.h b/gpu/command_buffer/client/gles2_c_lib_autogen.h index bbc0faa..9a75761 100644 --- a/gpu/command_buffer/client/gles2_c_lib_autogen.h +++ b/gpu/command_buffer/client/gles2_c_lib_autogen.h @@ -877,15 +877,13 @@ void GLES2RequestExtensionCHROMIUM(const char* extension) { GPU_CLIENT_LOG("RequestExtensionCHROMIUM" << "(" << extension << ")"); gles2::GetGLContext()->RequestExtensionCHROMIUM(extension); } -void GLES2SetLatchCHROMIUM(GLint shm_id, GLuint latch_id) { - GPU_CLIENT_LOG( - "SetLatchCHROMIUM" << "(" << shm_id << ", " << latch_id << ")"); - gles2::GetGLContext()->SetLatchCHROMIUM(shm_id, latch_id); +void GLES2SetLatchCHROMIUM(GLuint latch_id) { + GPU_CLIENT_LOG("SetLatchCHROMIUM" << "(" << latch_id << ")"); + gles2::GetGLContext()->SetLatchCHROMIUM(latch_id); } -void GLES2WaitLatchCHROMIUM(GLint shm_id, GLuint latch_id) { - GPU_CLIENT_LOG( - "WaitLatchCHROMIUM" << "(" << shm_id << ", " << latch_id << ")"); - gles2::GetGLContext()->WaitLatchCHROMIUM(shm_id, latch_id); +void GLES2WaitLatchCHROMIUM(GLuint latch_id) { + GPU_CLIENT_LOG("WaitLatchCHROMIUM" << "(" << latch_id << ")"); + gles2::GetGLContext()->WaitLatchCHROMIUM(latch_id); } #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_C_LIB_AUTOGEN_H_ diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h index dc50582..c0adf24 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h +++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h @@ -1215,14 +1215,14 @@ c.Init(bucket_id); } - void SetLatchCHROMIUM(GLint shm_id, GLuint latch_id) { + void SetLatchCHROMIUM(GLuint latch_id) { gles2::SetLatchCHROMIUM& c = GetCmdSpace<gles2::SetLatchCHROMIUM>(); - c.Init(shm_id, latch_id); + c.Init(latch_id); } - void WaitLatchCHROMIUM(GLint shm_id, GLuint latch_id) { + void WaitLatchCHROMIUM(GLuint latch_id) { gles2::WaitLatchCHROMIUM& c = GetCmdSpace<gles2::WaitLatchCHROMIUM>(); - c.Init(shm_id, latch_id); + c.Init(latch_id); } #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_AUTOGEN_H_ diff --git a/gpu/command_buffer/client/gles2_demo.cc b/gpu/command_buffer/client/gles2_demo.cc index daa51d2..91ef9bf2 100644 --- a/gpu/command_buffer/client/gles2_demo.cc +++ b/gpu/command_buffer/client/gles2_demo.cc @@ -78,7 +78,7 @@ bool GLES2Demo::Setup(void* hwnd, int32 size) { size_t transfer_buffer_size = 512 * 1024; int32 transfer_buffer_id = - command_buffer->CreateTransferBuffer(transfer_buffer_size); + command_buffer->CreateTransferBuffer(transfer_buffer_size, -1); Buffer transfer_buffer = command_buffer->GetTransferBuffer(transfer_buffer_id); if (!transfer_buffer.ptr) diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index 5e05132..bb392b0 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -889,12 +889,12 @@ const GLchar* GetRequestableExtensionsCHROMIUM(); void RequestExtensionCHROMIUM(const char* extension); -void SetLatchCHROMIUM(GLint shm_id, GLuint latch_id) { - helper_->SetLatchCHROMIUM(shm_id, latch_id); +void SetLatchCHROMIUM(GLuint latch_id) { + helper_->SetLatchCHROMIUM(latch_id); } -void WaitLatchCHROMIUM(GLint shm_id, GLuint latch_id) { - helper_->WaitLatchCHROMIUM(shm_id, latch_id); +void WaitLatchCHROMIUM(GLuint latch_id) { + helper_->WaitLatchCHROMIUM(latch_id); } #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_AUTOGEN_H_ diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc index c18c34a..d7ca276 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -62,7 +62,7 @@ class GLES2MockCommandBufferHelper : public CommandBuffer { state_.get_offset = get_offset; } - virtual int32 CreateTransferBuffer(size_t size) { + virtual int32 CreateTransferBuffer(size_t size, int32 id_request) { transfer_buffer_.reset(new int8[size]); transfer_buffer_buffer_.ptr = transfer_buffer_.get(); transfer_buffer_buffer_.size = size; @@ -79,7 +79,8 @@ class GLES2MockCommandBufferHelper : public CommandBuffer { } virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory, - size_t size) { + size_t size, + int32 id_request) { GPU_NOTREACHED(); return -1; } @@ -189,7 +190,7 @@ class GLES2ImplementationTest : public testing::Test { command_buffer_->Initialize(kCommandBufferSizeBytes); EXPECT_EQ(kTransferBufferId, - command_buffer_->CreateTransferBuffer(kTransferBufferSize)); + command_buffer_->CreateTransferBuffer(kTransferBufferSize, -1)); transfer_buffer_ = command_buffer_->GetTransferBuffer(kTransferBufferId); ClearTransferBuffer(); diff --git a/gpu/command_buffer/client/mapped_memory.cc b/gpu/command_buffer/client/mapped_memory.cc index 1a63c6f..689b576b 100644 --- a/gpu/command_buffer/client/mapped_memory.cc +++ b/gpu/command_buffer/client/mapped_memory.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -52,7 +52,7 @@ void* MappedMemoryManager::Alloc( // Make a new chunk to satisfy the request. CommandBuffer* cmd_buf = helper_->command_buffer(); - int32 id = cmd_buf->CreateTransferBuffer(size); + int32 id = cmd_buf->CreateTransferBuffer(size, -1); if (id == -1) { return NULL; } diff --git a/gpu/command_buffer/common/command_buffer.h b/gpu/command_buffer/common/command_buffer.h index bcc39ea..4cbcef1 100644 --- a/gpu/command_buffer/common/command_buffer.h +++ b/gpu/command_buffer/common/command_buffer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -84,14 +84,21 @@ class CommandBuffer { virtual void SetGetOffset(int32 get_offset) = 0; // Create a transfer buffer and return a handle that uniquely - // identifies it or -1 on error. - virtual int32 CreateTransferBuffer(size_t size) = 0; + // identifies it or -1 on error. id_request lets the caller request a + // specific id for the transfer buffer, or -1 if the caller does not care. + // If the requested id can not be fulfilled, a different id will be returned. + // id_request must be either -1 or between 0 and 100. + virtual int32 CreateTransferBuffer(size_t size, int32 id_request) = 0; // Register an existing shared memory object and get an ID that can be used // to identify it in the command buffer. Callee dups the handle until - // DestroyTransferBuffer is called. + // DestroyTransferBuffer is called. id_request lets the caller request a + // specific id for the transfer buffer, or -1 if the caller does not care. + // If the requested id can not be fulfilled, a different id will be returned. + // id_request must be either -1 or between 0 and 100. virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory, - size_t size) = 0; + size_t size, + int32 id_request) = 0; // Destroy a transfer buffer and recycle the handle. virtual void DestroyTransferBuffer(int32 id) = 0; diff --git a/gpu/command_buffer/common/command_buffer_mock.h b/gpu/command_buffer/common/command_buffer_mock.h index 2966801..8281f7f 100644 --- a/gpu/command_buffer/common/command_buffer_mock.h +++ b/gpu/command_buffer/common/command_buffer_mock.h @@ -28,11 +28,12 @@ class MockCommandBuffer : public CommandBuffer { MOCK_METHOD1(Flush, void(int32 put_offset)); MOCK_METHOD1(FlushSync, State(int32 put_offset)); MOCK_METHOD1(SetGetOffset, void(int32 get_offset)); - MOCK_METHOD1(CreateTransferBuffer, int32(size_t size)); + MOCK_METHOD2(CreateTransferBuffer, int32(size_t size, int32 id_request)); MOCK_METHOD1(DestroyTransferBuffer, void(int32 handle)); MOCK_METHOD1(GetTransferBuffer, Buffer(int32 handle)); - MOCK_METHOD2(RegisterTransferBuffer, int32(base::SharedMemory* shared_memory, - size_t size)); + MOCK_METHOD3(RegisterTransferBuffer, int32(base::SharedMemory* shared_memory, + size_t size, + int32 id_request)); MOCK_METHOD1(SetToken, void(int32 token)); MOCK_METHOD1(SetParseError, void(error::Error error)); diff --git a/gpu/command_buffer/common/constants.h b/gpu/command_buffer/common/constants.h index c028fc9..521a8b6 100644 --- a/gpu/command_buffer/common/constants.h +++ b/gpu/command_buffer/common/constants.h @@ -40,6 +40,12 @@ namespace error { // failure. const int32 kInvalidSharedMemoryId = -1; +// Common Command Buffer shared memory transfer buffer ID. +const int32 kCommandBufferSharedMemoryId = 4; + +// Common Latch shared memory transfer buffer ID. +const int32 kLatchSharedMemoryId = 5; + } // namespace gpu #endif // GPU_COMMAND_BUFFER_COMMON_CONSTANTS_H_ diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index 4e97bc5..340273a 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -8914,30 +8914,26 @@ struct SetLatchCHROMIUM { header.SetCmd<ValueType>(); } - void Init(GLint _shm_id, GLuint _latch_id) { + void Init(GLuint _latch_id) { SetHeader(); - shm_id = _shm_id; latch_id = _latch_id; } - void* Set(void* cmd, GLint _shm_id, GLuint _latch_id) { - static_cast<ValueType*>(cmd)->Init(_shm_id, _latch_id); + void* Set(void* cmd, GLuint _latch_id) { + static_cast<ValueType*>(cmd)->Init(_latch_id); return NextCmdAddress<ValueType>(cmd); } gpu::CommandHeader header; - int32 shm_id; uint32 latch_id; }; -COMPILE_ASSERT(sizeof(SetLatchCHROMIUM) == 12, - Sizeof_SetLatchCHROMIUM_is_not_12); +COMPILE_ASSERT(sizeof(SetLatchCHROMIUM) == 8, + Sizeof_SetLatchCHROMIUM_is_not_8); COMPILE_ASSERT(offsetof(SetLatchCHROMIUM, header) == 0, OffsetOf_SetLatchCHROMIUM_header_not_0); -COMPILE_ASSERT(offsetof(SetLatchCHROMIUM, shm_id) == 4, - OffsetOf_SetLatchCHROMIUM_shm_id_not_4); -COMPILE_ASSERT(offsetof(SetLatchCHROMIUM, latch_id) == 8, - OffsetOf_SetLatchCHROMIUM_latch_id_not_8); +COMPILE_ASSERT(offsetof(SetLatchCHROMIUM, latch_id) == 4, + OffsetOf_SetLatchCHROMIUM_latch_id_not_4); struct WaitLatchCHROMIUM { typedef WaitLatchCHROMIUM ValueType; @@ -8952,30 +8948,26 @@ struct WaitLatchCHROMIUM { header.SetCmd<ValueType>(); } - void Init(GLint _shm_id, GLuint _latch_id) { + void Init(GLuint _latch_id) { SetHeader(); - shm_id = _shm_id; latch_id = _latch_id; } - void* Set(void* cmd, GLint _shm_id, GLuint _latch_id) { - static_cast<ValueType*>(cmd)->Init(_shm_id, _latch_id); + void* Set(void* cmd, GLuint _latch_id) { + static_cast<ValueType*>(cmd)->Init(_latch_id); return NextCmdAddress<ValueType>(cmd); } gpu::CommandHeader header; - int32 shm_id; uint32 latch_id; }; -COMPILE_ASSERT(sizeof(WaitLatchCHROMIUM) == 12, - Sizeof_WaitLatchCHROMIUM_is_not_12); +COMPILE_ASSERT(sizeof(WaitLatchCHROMIUM) == 8, + Sizeof_WaitLatchCHROMIUM_is_not_8); COMPILE_ASSERT(offsetof(WaitLatchCHROMIUM, header) == 0, OffsetOf_WaitLatchCHROMIUM_header_not_0); -COMPILE_ASSERT(offsetof(WaitLatchCHROMIUM, shm_id) == 4, - OffsetOf_WaitLatchCHROMIUM_shm_id_not_4); -COMPILE_ASSERT(offsetof(WaitLatchCHROMIUM, latch_id) == 8, - OffsetOf_WaitLatchCHROMIUM_latch_id_not_8); +COMPILE_ASSERT(offsetof(WaitLatchCHROMIUM, latch_id) == 4, + OffsetOf_WaitLatchCHROMIUM_latch_id_not_4); #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_AUTOGEN_H_ diff --git a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h index 603b71e..a69078a 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h @@ -3510,30 +3510,26 @@ TEST(GLES2FormatTest, SetLatchCHROMIUM) { SetLatchCHROMIUM cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, - static_cast<GLint>(11), - static_cast<GLuint>(12)); + static_cast<GLuint>(11)); EXPECT_EQ(static_cast<uint32>(SetLatchCHROMIUM::kCmdId), cmd.header.command); EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); - EXPECT_EQ(static_cast<GLint>(11), cmd.shm_id); - EXPECT_EQ(static_cast<GLuint>(12), cmd.latch_id); + EXPECT_EQ(static_cast<GLuint>(11), cmd.latch_id); } TEST(GLES2FormatTest, WaitLatchCHROMIUM) { WaitLatchCHROMIUM cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, - static_cast<GLint>(11), - static_cast<GLuint>(12)); + static_cast<GLuint>(11)); EXPECT_EQ(static_cast<uint32>(WaitLatchCHROMIUM::kCmdId), cmd.header.command); EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); - EXPECT_EQ(static_cast<GLint>(11), cmd.shm_id); - EXPECT_EQ(static_cast<GLuint>(12), cmd.latch_id); + EXPECT_EQ(static_cast<GLuint>(11), cmd.latch_id); } #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_TEST_AUTOGEN_H_ diff --git a/gpu/command_buffer/service/command_buffer_service.cc b/gpu/command_buffer/service/command_buffer_service.cc index ab59473..86453eb 100644 --- a/gpu/command_buffer/service/command_buffer_service.cc +++ b/gpu/command_buffer/service/command_buffer_service.cc @@ -125,22 +125,27 @@ void CommandBufferService::SetGetOffset(int32 get_offset) { get_offset_ = get_offset; } -int32 CommandBufferService::CreateTransferBuffer(size_t size) { +int32 CommandBufferService::CreateTransferBuffer(size_t size, + int32 id_request) { SharedMemory buffer; if (!buffer.CreateAnonymous(size)) return -1; - return RegisterTransferBuffer(&buffer, size); + return RegisterTransferBuffer(&buffer, size, id_request); } int32 CommandBufferService::RegisterTransferBuffer( - base::SharedMemory* shared_memory, size_t size) { + base::SharedMemory* shared_memory, size_t size, int32 id_request) { // Check we haven't exceeded the range that fits in a 32-bit integer. if (unused_registered_object_elements_.empty()) { if (registered_objects_.size() > std::numeric_limits<uint32>::max()) return -1; } + // Check that the requested ID is sane (not too large, or less than -1) + if (id_request != -1 && (id_request > 100 || id_request < -1)) + return -1; + // Duplicate the handle. base::SharedMemoryHandle duped_shared_memory_handle; if (!shared_memory->ShareToProcess(base::GetCurrentProcessHandle(), @@ -160,6 +165,25 @@ int32 CommandBufferService::RegisterTransferBuffer( buffer.ptr = duped_shared_memory->memory(); buffer.size = size; buffer.shared_memory = duped_shared_memory.release(); + + // If caller requested specific id, first try to use id_request. + if (id_request != -1) { + int32 cur_size = static_cast<int32>(registered_objects_.size()); + if (cur_size <= id_request) { + // Pad registered_objects_ to reach id_request. + registered_objects_.resize(static_cast<size_t>(id_request + 1)); + for (int32 id = cur_size; id < id_request; ++id) + unused_registered_object_elements_.insert(id); + registered_objects_[id_request] = buffer; + return id_request; + } else if (!registered_objects_[id_request].shared_memory) { + // id_request is already in free list. + registered_objects_[id_request] = buffer; + unused_registered_object_elements_.erase(id_request); + return id_request; + } + } + if (unused_registered_object_elements_.empty()) { int32 handle = static_cast<int32>(registered_objects_.size()); registered_objects_.push_back(buffer); diff --git a/gpu/command_buffer/service/command_buffer_service.h b/gpu/command_buffer/service/command_buffer_service.h index 0203623..a83a4e5 100644 --- a/gpu/command_buffer/service/command_buffer_service.h +++ b/gpu/command_buffer/service/command_buffer_service.h @@ -32,9 +32,10 @@ class CommandBufferService : public CommandBuffer { virtual void Flush(int32 put_offset); virtual State FlushSync(int32 put_offset); virtual void SetGetOffset(int32 get_offset); - virtual int32 CreateTransferBuffer(size_t size); + virtual int32 CreateTransferBuffer(size_t size, int32 id_request); virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory, - size_t size); + size_t size, + int32 id_request); virtual void DestroyTransferBuffer(int32 id); virtual Buffer GetTransferBuffer(int32 handle); virtual void SetToken(int32 token); diff --git a/gpu/command_buffer/service/common_decoder_unittest.cc b/gpu/command_buffer/service/common_decoder_unittest.cc index c71c92e..7099265 100644 --- a/gpu/command_buffer/service/common_decoder_unittest.cc +++ b/gpu/command_buffer/service/common_decoder_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -131,7 +131,8 @@ class MockCommandBufferEngine : public CommandBufferEngine { private: bool IsValidSharedMemoryId(int32 shm_id) { - return shm_id == kValidShmId || shm_id == kStartValidShmId; + return shm_id == kValidShmId || shm_id == kStartValidShmId || + shm_id == gpu::kLatchSharedMemoryId; } int8 buffer_[kBufferSize]; diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc index aa0f51b..61514a8 100644 --- a/gpu/command_buffer/service/feature_info.cc +++ b/gpu/command_buffer/service/feature_info.cc @@ -107,6 +107,7 @@ void FeatureInfo::AddFeatures(const char* desired_features) { AddExtensionString("GL_CHROMIUM_resource_safe"); AddExtensionString("GL_CHROMIUM_resize"); AddExtensionString("GL_CHROMIUM_strict_attribs"); + AddExtensionString("GL_CHROMIUM_latch"); // Only turn this feature on if it is requested. Not by default. if (desired_features && ext.Desire("GL_CHROMIUM_webglsl")) { diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index e2bfc7a..9702902 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -6274,7 +6274,13 @@ error::Error GLES2DecoderImpl::HandleSwapBuffers( error::Error GLES2DecoderImpl::HandleSetLatchCHROMIUM( uint32 immediate_data_size, const gles2::SetLatchCHROMIUM& c) { - int32 shm_id = c.shm_id; + // Ensure the side effects of previous commands are visible to other contexts. + // There is no need to do this for ANGLE because it uses a + // single D3D device for all contexts. + if (!IsAngle()) + glFlush(); + + int32 shm_id = gpu::kLatchSharedMemoryId; uint32 latch_id = c.latch_id; uint32 shm_offset = 0; base::subtle::Atomic32* latch; @@ -6292,7 +6298,7 @@ error::Error GLES2DecoderImpl::HandleSetLatchCHROMIUM( error::Error GLES2DecoderImpl::HandleWaitLatchCHROMIUM( uint32 immediate_data_size, const gles2::WaitLatchCHROMIUM& c) { - int32 shm_id = c.shm_id; + int32 shm_id = gpu::kLatchSharedMemoryId; uint32 latch_id = c.latch_id; uint32 shm_offset = 0; base::subtle::Atomic32* latch; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 89cae82..99b41de 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -15,6 +15,7 @@ #include "gpu/command_buffer/service/program_manager.h" #include "gpu/command_buffer/service/test_helper.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/gfx/gl/gl_implementation.h" using ::gfx::MockGLInterface; using ::testing::_; @@ -2873,6 +2874,13 @@ TEST_F(GLES2DecoderWithShaderTest, VertexAttribPointer) { } TEST_F(GLES2DecoderTest, SetLatch) { + bool isAngle = false; +#if defined(OS_WIN) + isAngle = (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2); +#endif + if (!isAngle) { + EXPECT_CALL(*gl_, Flush()).Times(3); + } const uint32 kLatchId = 1; base::subtle::Atomic32* latches = static_cast<base::subtle::Atomic32*>( shared_memory_base_); @@ -2881,20 +2889,17 @@ TEST_F(GLES2DecoderTest, SetLatch) { latches[kLatchId] = 0; latches[kLastValidLatchId] = 0; SetLatchCHROMIUM cmd; - // Check bad shared memory id. - cmd.Init(kInvalidSharedMemoryId, kLatchId); - EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); // Check out of range latch id. - cmd.Init(shared_memory_id_, kInvalidLatchId); + cmd.Init(kInvalidLatchId); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); - cmd.Init(shared_memory_id_, kLatchId); + cmd.Init(kLatchId); // Check valid latch. EXPECT_EQ(0, latches[kLatchId]); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(1, latches[kLatchId]); // Check last valid latch. EXPECT_EQ(0, latches[kLastValidLatchId]); - cmd.Init(shared_memory_id_, kLastValidLatchId); + cmd.Init(kLastValidLatchId); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(1, latches[kLastValidLatchId]); } @@ -2908,21 +2913,18 @@ TEST_F(GLES2DecoderTest, WaitLatch) { latches[kLatchId] = 0; latches[kLastValidLatchId] = 0; WaitLatchCHROMIUM cmd; - // Check bad shared memory id. - cmd.Init(kInvalidSharedMemoryId, kLatchId); - EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); // Check out of range latch id. - cmd.Init(shared_memory_id_, kInvalidLatchId); + cmd.Init(kInvalidLatchId); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); // Check valid latch. - cmd.Init(shared_memory_id_, kLatchId); + cmd.Init(kLatchId); EXPECT_EQ(0, latches[kLatchId]); EXPECT_EQ(error::kWaiting, ExecuteCmd(cmd)); latches[kLatchId] = 1; EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(0, latches[kLatchId]); // Check last valid latch. - cmd.Init(shared_memory_id_, kLastValidLatchId); + cmd.Init(kLastValidLatchId); EXPECT_EQ(0, latches[kLastValidLatchId]); EXPECT_EQ(error::kWaiting, ExecuteCmd(cmd)); latches[kLastValidLatchId] = 1; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h index ed1f025..2d027f7 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h @@ -287,7 +287,8 @@ class GLES2DecoderTestBase : public testing::Test { } virtual Buffer GetSharedMemoryBuffer(int32 shm_id) { - return shm_id == kSharedMemoryId ? valid_buffer_ : invalid_buffer_; + return shm_id == kSharedMemoryId || shm_id == gpu::kLatchSharedMemoryId ? + valid_buffer_ : invalid_buffer_; } void ClearSharedMemory() { diff --git a/gpu/demos/framework/window.cc b/gpu/demos/framework/window.cc index 1440110..fead4ac 100644 --- a/gpu/demos/framework/window.cc +++ b/gpu/demos/framework/window.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -78,7 +78,7 @@ bool Window::CreateRenderContext(gfx::PluginWindowHandle hwnd) { } int32 transfer_buffer_id = - command_buffer->CreateTransferBuffer(kTransferBufferSize); + command_buffer->CreateTransferBuffer(kTransferBufferSize, -1); Buffer transfer_buffer = command_buffer->GetTransferBuffer(transfer_buffer_id); if (transfer_buffer.ptr == NULL) return false; diff --git a/gpu/pgl/command_buffer_pepper.cc b/gpu/pgl/command_buffer_pepper.cc index c508b53..38b642e 100644 --- a/gpu/pgl/command_buffer_pepper.cc +++ b/gpu/pgl/command_buffer_pepper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -139,7 +139,7 @@ void CommandBufferPepper::SetGetOffset(int32 get_offset) { GPU_NOTREACHED(); } -int32 CommandBufferPepper::CreateTransferBuffer(size_t size) { +int32 CommandBufferPepper::CreateTransferBuffer(size_t size, int32 id_request) { int32_t id; if (NPERR_NO_ERROR != device_->createBuffer(npp_, context_, size, &id)) return -1; @@ -149,7 +149,8 @@ int32 CommandBufferPepper::CreateTransferBuffer(size_t size) { int32 CommandBufferPepper::RegisterTransferBuffer( base::SharedMemory* shared_memory, - size_t size) { + size_t size, + int32 id_request) { // Not implemented by proxy. GPU_NOTREACHED(); return -1; diff --git a/gpu/pgl/command_buffer_pepper.h b/gpu/pgl/command_buffer_pepper.h index 8f990da..446ec4a 100644 --- a/gpu/pgl/command_buffer_pepper.h +++ b/gpu/pgl/command_buffer_pepper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -37,11 +37,12 @@ class CommandBufferPepper : public gpu::CommandBuffer { virtual void Flush(int32 put_offset); virtual State FlushSync(int32 put_offset); virtual void SetGetOffset(int32 get_offset); - virtual int32 CreateTransferBuffer(size_t size); + virtual int32 CreateTransferBuffer(size_t size, int32 id_request); virtual void DestroyTransferBuffer(int32 id); virtual gpu::Buffer GetTransferBuffer(int32 handle); virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory, - size_t size); + size_t size, + int32 id_request); virtual void SetToken(int32 token); virtual void SetParseError(gpu::error::Error error); diff --git a/gpu/pgl/pgl.cc b/gpu/pgl/pgl.cc index c3b62f1..d98cb62 100644 --- a/gpu/pgl/pgl.cc +++ b/gpu/pgl/pgl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -77,7 +77,7 @@ PGLBoolean PGLContextImpl::Initialize(int32 transfer_buffer_size) { gpu::Buffer buffer = command_buffer_->GetRingBuffer(); if (gles2_helper_->Initialize(buffer.size)) { transfer_buffer_id_ = - command_buffer_->CreateTransferBuffer(kTransferBufferSize); + command_buffer_->CreateTransferBuffer(kTransferBufferSize, -1); gpu::Buffer transfer_buffer = command_buffer_->GetTransferBuffer(transfer_buffer_id_); if (transfer_buffer.ptr) { |