diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-01 05:06:35 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-01 05:06:35 +0000 |
commit | baed42c24524270f2927f9f2b1f78645a2a31afb (patch) | |
tree | d91c2741513a0545e691a50cfac24b05c10d97e7 /gpu | |
parent | 85f2e0b4302ba5021faa6a20743b6b5316aa9e19 (diff) | |
download | chromium_src-baed42c24524270f2927f9f2b1f78645a2a31afb.zip chromium_src-baed42c24524270f2927f9f2b1f78645a2a31afb.tar.gz chromium_src-baed42c24524270f2927f9f2b1f78645a2a31afb.tar.bz2 |
Route GenMailboxCHROMIUM through GpuControl
This allows the fast path to work in GLES2Implementation rather than needing
WGC3DCBI.
BUG=181120
R=sievers@chromium.org
Review URL: https://codereview.chromium.org/24714002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226145 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
18 files changed, 71 insertions, 103 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index 83700f6..88e8702 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -1559,11 +1559,9 @@ _FUNCTION_INFO = { 'resource_types': 'Buffers', }, 'GenMailboxCHROMIUM': { - 'type': 'Manual', - 'cmd_args': 'GLuint bucket_id', - 'result': ['SizedResult<GLint>'], - 'client_test': False, - 'unit_test': False, + 'type': 'HandWritten', + 'immediate': False, + 'impl_func': False, 'extension': True, 'chromium': True, }, diff --git a/gpu/command_buffer/client/client_test_helper.h b/gpu/command_buffer/client/client_test_helper.h index e3c35f3..3119578 100644 --- a/gpu/command_buffer/client/client_test_helper.h +++ b/gpu/command_buffer/client/client_test_helper.h @@ -94,6 +94,8 @@ class MockClientGpuControl : public GpuControl { unsigned internalformat, int32* id)); MOCK_METHOD1(DestroyGpuMemoryBuffer, void(int32 id)); + MOCK_METHOD2(GenerateMailboxNames, bool(unsigned num, + std::vector<gpu::Mailbox>* names)); private: DISALLOW_COPY_AND_ASSIGN(MockClientGpuControl); diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h index 8d2fd7d..89f6c9b 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h +++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h @@ -1911,14 +1911,6 @@ } } - void GenMailboxCHROMIUM(GLuint bucket_id) { - gles2::cmds::GenMailboxCHROMIUM* c = - GetCmdSpace<gles2::cmds::GenMailboxCHROMIUM>(); - if (c) { - c->Init(bucket_id); - } - } - void ProduceTextureCHROMIUM( GLenum target, uint32 mailbox_shm_id, uint32 mailbox_shm_offset) { gles2::cmds::ProduceTextureCHROMIUM* c = diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 54e47a5..e467102 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -3400,13 +3400,12 @@ void GLES2Implementation::GenMailboxCHROMIUM( << static_cast<const void*>(mailbox) << ")"); TRACE_EVENT0("gpu", "GLES2::GenMailboxCHROMIUM"); - helper_->GenMailboxCHROMIUM(kResultBucketId); - - std::vector<GLbyte> result; - GetBucketContents(kResultBucketId, &result); - - std::copy(result.begin(), result.end(), mailbox); - CheckGLError(); + std::vector<gpu::Mailbox> names; + if (!gpu_control_->GenerateMailboxNames(1, &names)) { + SetGLError(GL_OUT_OF_MEMORY, "glGenMailboxCHROMIUM", "Generate failed."); + return; + } + memcpy(mailbox, names[0].name, GL_MAILBOX_SIZE_CHROMIUM); } void GLES2Implementation::PushGroupMarkerEXT( diff --git a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h index a1ea587..5a8f660 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h @@ -1735,6 +1735,7 @@ TEST_F(GLES2ImplementationTest, VertexAttribDivisorANGLE) { gl_->VertexAttribDivisorANGLE(1, 2); EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); } +// TODO: Implement unit test for GenMailboxCHROMIUM TEST_F(GLES2ImplementationTest, ProduceTextureCHROMIUM) { GLbyte data[64] = {0}; diff --git a/gpu/command_buffer/common/gles2_cmd_format.h b/gpu/command_buffer/common/gles2_cmd_format.h index 76bb3fe..49c0270 100644 --- a/gpu/command_buffer/common/gles2_cmd_format.h +++ b/gpu/command_buffer/common/gles2_cmd_format.h @@ -540,6 +540,13 @@ COMPILE_ASSERT(offsetof(GetUniformLocationBucket, location_shm_id) == 12, COMPILE_ASSERT(offsetof(GetUniformLocationBucket, location_shm_offset) == 16, OffsetOf_GetUniformLocationBucket_location_shm_offset_not_16); +struct GenMailboxCHROMIUM { + typedef GenMailboxCHROMIUM ValueType; + static const CommandId kCmdId = kGenMailboxCHROMIUM; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + CommandHeader header; +}; + struct InsertSyncPointCHROMIUM { typedef InsertSyncPointCHROMIUM ValueType; static const CommandId kCmdId = kInsertSyncPointCHROMIUM; diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index 11b9901..31f93e8 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -10145,42 +10145,6 @@ COMPILE_ASSERT(offsetof(VertexAttribDivisorANGLE, index) == 4, COMPILE_ASSERT(offsetof(VertexAttribDivisorANGLE, divisor) == 8, OffsetOf_VertexAttribDivisorANGLE_divisor_not_8); -struct GenMailboxCHROMIUM { - typedef GenMailboxCHROMIUM ValueType; - static const CommandId kCmdId = kGenMailboxCHROMIUM; - static const cmd::ArgFlags kArgFlags = cmd::kFixed; - - typedef SizedResult<GLint> Result; - - static uint32 ComputeSize() { - return static_cast<uint32>(sizeof(ValueType)); // NOLINT - } - - void SetHeader() { - header.SetCmd<ValueType>(); - } - - void Init(GLuint _bucket_id) { - SetHeader(); - bucket_id = _bucket_id; - } - - void* Set(void* cmd, GLuint _bucket_id) { - static_cast<ValueType*>(cmd)->Init(_bucket_id); - return NextCmdAddress<ValueType>(cmd); - } - - gpu::CommandHeader header; - uint32 bucket_id; -}; - -COMPILE_ASSERT(sizeof(GenMailboxCHROMIUM) == 8, - Sizeof_GenMailboxCHROMIUM_is_not_8); -COMPILE_ASSERT(offsetof(GenMailboxCHROMIUM, header) == 0, - OffsetOf_GenMailboxCHROMIUM_header_not_0); -COMPILE_ASSERT(offsetof(GenMailboxCHROMIUM, bucket_id) == 4, - OffsetOf_GenMailboxCHROMIUM_bucket_id_not_4); - struct ProduceTextureCHROMIUM { typedef ProduceTextureCHROMIUM ValueType; static const CommandId kCmdId = kProduceTextureCHROMIUM; 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 740e6cb..bf08b82 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h @@ -3985,19 +3985,7 @@ TEST_F(GLES2FormatTest, VertexAttribDivisorANGLE) { next_cmd, sizeof(cmd)); } -TEST_F(GLES2FormatTest, GenMailboxCHROMIUM) { - cmds::GenMailboxCHROMIUM& cmd = *GetBufferAs<cmds::GenMailboxCHROMIUM>(); - void* next_cmd = cmd.Set( - &cmd, - static_cast<GLuint>(11)); - EXPECT_EQ(static_cast<uint32>(cmds::GenMailboxCHROMIUM::kCmdId), - cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); - EXPECT_EQ(static_cast<GLuint>(11), cmd.bucket_id); - CheckBytesWrittenMatchesExpectedSize( - next_cmd, sizeof(cmd)); -} - +// TODO(gman): Write test for GenMailboxCHROMIUM TEST_F(GLES2FormatTest, ProduceTextureCHROMIUM) { cmds::ProduceTextureCHROMIUM& cmd = *GetBufferAs<cmds::ProduceTextureCHROMIUM>(); diff --git a/gpu/command_buffer/common/gpu_control.h b/gpu/command_buffer/common/gpu_control.h index 503c745..61b5cb1 100644 --- a/gpu/command_buffer/common/gpu_control.h +++ b/gpu/command_buffer/common/gpu_control.h @@ -5,6 +5,9 @@ #ifndef GPU_COMMAND_BUFFER_COMMON_GPU_CONTROL_H_ #define GPU_COMMAND_BUFFER_COMMON_GPU_CONTROL_H_ +#include <vector> + +#include "gpu/command_buffer/common/mailbox.h" #include "gpu/command_buffer/common/types.h" #include "gpu/gpu_export.h" @@ -33,6 +36,11 @@ class GPU_EXPORT GpuControl { // Destroy a gpu memory buffer. The ID must be positive. virtual void DestroyGpuMemoryBuffer(int32 id) = 0; + // Generates n unique mailbox names that can be used with + // GL_texture_mailbox_CHROMIUM. + virtual bool GenerateMailboxNames(unsigned num, + std::vector<gpu::Mailbox>* names) = 0; + private: DISALLOW_COPY_AND_ASSIGN(GpuControl); }; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index e42a44c..ca0d06a 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -9897,15 +9897,7 @@ void GLES2DecoderImpl::DoTexStorage2DEXT( error::Error GLES2DecoderImpl::HandleGenMailboxCHROMIUM( uint32 immediate_data_size, const cmds::GenMailboxCHROMIUM& c) { - MailboxName name; - mailbox_manager()->GenerateMailboxName(&name); - uint32 bucket_id = static_cast<uint32>(c.bucket_id); - Bucket* bucket = CreateBucket(bucket_id); - - bucket->SetSize(GL_MAILBOX_SIZE_CHROMIUM); - bucket->SetData(&name, 0, GL_MAILBOX_SIZE_CHROMIUM); - - return error::kNoError; + return error::kUnknownCommand; } void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 906eb88..05d0759 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -7339,25 +7339,6 @@ TEST_F(GLES2DecoderTest, BeginEndQueryEXTGetErrorQueryCHROMIUM) { static_cast<GLenum>(sync->result)); } -TEST_F(GLES2DecoderTest, GenMailboxCHROMIUM) { - const uint32 kBucketId = 123; - - GenMailboxCHROMIUM gen_mailbox_cmd; - gen_mailbox_cmd.Init(kBucketId); - EXPECT_EQ(error::kNoError, ExecuteCmd(gen_mailbox_cmd)); - - CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); - ASSERT_TRUE(bucket != NULL); - ASSERT_EQ(static_cast<uint32>(GL_MAILBOX_SIZE_CHROMIUM), bucket->size()); - - static const GLbyte zero[GL_MAILBOX_SIZE_CHROMIUM] = { - 0 - }; - EXPECT_NE(0, memcmp(zero, - bucket->GetData(0, GL_MAILBOX_SIZE_CHROMIUM), - sizeof(zero))); -} - TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) { GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; group().mailbox_manager()->GenerateMailboxName( diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h index 58611bf..4052b96 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h @@ -47,6 +47,7 @@ // TODO(gman): DrawElementsInstancedANGLE // TODO(gman): VertexAttribDivisorANGLE // TODO(gman): GenMailboxCHROMIUM + // TODO(gman): ProduceTextureCHROMIUM // TODO(gman): ProduceTextureCHROMIUMImmediate // TODO(gman): ConsumeTextureCHROMIUM diff --git a/gpu/command_buffer/service/gpu_control_service.cc b/gpu/command_buffer/service/gpu_control_service.cc index 64ea261..2a34b8c 100644 --- a/gpu/command_buffer/service/gpu_control_service.cc +++ b/gpu/command_buffer/service/gpu_control_service.cc @@ -6,14 +6,17 @@ #include "gpu/command_buffer/client/gpu_memory_buffer_factory.h" #include "gpu/command_buffer/service/gpu_memory_buffer_manager.h" +#include "gpu/command_buffer/service/mailbox_manager.h" namespace gpu { GpuControlService::GpuControlService( GpuMemoryBufferManagerInterface* gpu_memory_buffer_manager, - GpuMemoryBufferFactory* gpu_memory_buffer_factory) + GpuMemoryBufferFactory* gpu_memory_buffer_factory, + gles2::MailboxManager* mailbox_manager) : gpu_memory_buffer_manager_(gpu_memory_buffer_manager), - gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { + gpu_memory_buffer_factory_(gpu_memory_buffer_factory), + mailbox_manager_(mailbox_manager) { } GpuControlService::~GpuControlService() { @@ -75,4 +78,16 @@ bool GpuControlService::RegisterGpuMemoryBuffer( internalformat); } +bool GpuControlService::GenerateMailboxNames( + unsigned num, std::vector<gpu::Mailbox>* names) { + DCHECK(names->empty()); + names->resize(num); + for (unsigned i = 0; i < num; ++i) { + gles2::MailboxName name; + mailbox_manager_->GenerateMailboxName(&name); + (*names)[i].SetName(name.key); + } + return true; +} + } // namespace gpu diff --git a/gpu/command_buffer/service/gpu_control_service.h b/gpu/command_buffer/service/gpu_control_service.h index 6b781f8..1dce9d1 100644 --- a/gpu/command_buffer/service/gpu_control_service.h +++ b/gpu/command_buffer/service/gpu_control_service.h @@ -15,10 +15,15 @@ namespace gpu { class GpuMemoryBufferFactory; class GpuMemoryBufferManagerInterface; +namespace gles2 { +class MailboxManager; +} + class GPU_EXPORT GpuControlService : public GpuControl { public: GpuControlService(GpuMemoryBufferManagerInterface* gpu_memory_buffer_manager, - GpuMemoryBufferFactory* gpu_memory_buffer_factory); + GpuMemoryBufferFactory* gpu_memory_buffer_factory, + gles2::MailboxManager* mailbox_manager); virtual ~GpuControlService(); // Overridden from GpuControl: @@ -30,6 +35,8 @@ class GPU_EXPORT GpuControlService : public GpuControl { unsigned internalformat, int32* id) OVERRIDE; virtual void DestroyGpuMemoryBuffer(int32 id) OVERRIDE; + virtual bool GenerateMailboxNames(unsigned num, + std::vector<gpu::Mailbox>* names) OVERRIDE; // Register an existing gpu memory buffer and get an ID that can be used // to identify it in the command buffer. @@ -42,6 +49,7 @@ class GPU_EXPORT GpuControlService : public GpuControl { private: GpuMemoryBufferManagerInterface* gpu_memory_buffer_manager_; GpuMemoryBufferFactory* gpu_memory_buffer_factory_; + gles2::MailboxManager* mailbox_manager_; typedef std::map<int32, linked_ptr<gfx::GpuMemoryBuffer> > GpuMemoryBufferMap; GpuMemoryBufferMap gpu_memory_buffers_; diff --git a/gpu/command_buffer/service/in_process_command_buffer.cc b/gpu/command_buffer/service/in_process_command_buffer.cc index 778ca7d..cd5e8602 100644 --- a/gpu/command_buffer/service/in_process_command_buffer.cc +++ b/gpu/command_buffer/service/in_process_command_buffer.cc @@ -406,7 +406,8 @@ bool InProcessCommandBuffer::InitializeOnGpuThread( gpu_control_.reset( new GpuControlService(decoder_->GetContextGroup()->image_manager(), - g_gpu_memory_buffer_factory)); + g_gpu_memory_buffer_factory, + decoder_->GetContextGroup()->mailbox_manager())); supports_gpu_memory_buffer_ = gpu_control_->SupportsGpuMemoryBuffer(); decoder_->set_engine(gpu_scheduler_.get()); @@ -675,6 +676,13 @@ void InProcessCommandBuffer::DestroyGpuMemoryBuffer(int32 id) { QueueTask(task); } +bool InProcessCommandBuffer::GenerateMailboxNames( + unsigned num, std::vector<gpu::Mailbox>* names) { + CheckSequencedThread(); + base::AutoLock lock(command_buffer_lock_); + return gpu_control_->GenerateMailboxNames(num, names); +} + gpu::error::Error InProcessCommandBuffer::GetLastError() { CheckSequencedThread(); return last_state_.error; diff --git a/gpu/command_buffer/service/in_process_command_buffer.h b/gpu/command_buffer/service/in_process_command_buffer.h index 96f2642..c736e8f 100644 --- a/gpu/command_buffer/service/in_process_command_buffer.h +++ b/gpu/command_buffer/service/in_process_command_buffer.h @@ -117,6 +117,8 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, unsigned internalformat, int32* id) OVERRIDE; virtual void DestroyGpuMemoryBuffer(int32 id) OVERRIDE; + virtual bool GenerateMailboxNames(unsigned num, + std::vector<gpu::Mailbox>* names) OVERRIDE; // The serializer interface to the GPU service (i.e. thread). class SchedulerClient { diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc index 4568c53..4a69a14 100644 --- a/gpu/command_buffer/tests/gl_manager.cc +++ b/gpu/command_buffer/tests/gl_manager.cc @@ -133,7 +133,8 @@ void GLManager::Initialize(const GLManager::Options& options) { gpu_control_.reset( new GpuControlService(decoder_->GetContextGroup()->image_manager(), - options.gpu_memory_buffer_factory)); + options.gpu_memory_buffer_factory, + decoder_->GetContextGroup()->mailbox_manager())); gpu_scheduler_.reset(new GpuScheduler(command_buffer_.get(), decoder_.get(), diff --git a/gpu/gles2_conform_support/egl/display.cc b/gpu/gles2_conform_support/egl/display.cc index cdc4fdb..53a73a7 100644 --- a/gpu/gles2_conform_support/egl/display.cc +++ b/gpu/gles2_conform_support/egl/display.cc @@ -123,7 +123,8 @@ EGLSurface Display::CreateWindowSurface(EGLConfig config, gpu_scheduler_.reset(new gpu::GpuScheduler(command_buffer.get(), decoder_.get(), NULL)); - gpu_control_.reset(new gpu::GpuControlService(NULL, NULL)); + gpu_control_.reset(new gpu::GpuControlService(NULL, NULL, + group->mailbox_manager())); decoder_->set_engine(gpu_scheduler_.get()); gfx::Size size(create_offscreen_width_, create_offscreen_height_); |