diff options
author | chirantan <chirantan@chromium.org> | 2015-05-22 11:15:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-22 18:15:40 +0000 |
commit | 1b81bc40235207ece7fe8cae3e7c1d828f7aa68f (patch) | |
tree | e131fbae72170b08b2c09779bf0edfdd851c2b32 | |
parent | 56e65858b85d1c39dc1a91f470c04f703cf2cb08 (diff) | |
download | chromium_src-1b81bc40235207ece7fe8cae3e7c1d828f7aa68f.zip chromium_src-1b81bc40235207ece7fe8cae3e7c1d828f7aa68f.tar.gz chromium_src-1b81bc40235207ece7fe8cae3e7c1d828f7aa68f.tar.bz2 |
Revert of Add PERSISTENT_MAP usage for GpuMemoryBuffers. (patchset #11 id:330001 of https://codereview.chromium.org/1139903005/)
Reason for revert:
The is causing the freon chrome on chrome os build to fail. Looks like a case for PERSISTENT_MAP also needs to be added to ui::GbmSurfaceFactory::CanCreateNativePixmap() in ui/ozone/platform/drm/gbm_surface_factory.cc. Here is a link to a failing build: https://uberchromegw.corp.google.com/i/chromeos/builders/amd64-generic_freon%20chromium%20PFQ/builds/1151
Original issue's description:
> Add PERSISTENT_MAP usage for GpuMemoryBuffers.
>
> A GpuMemoryBuffer with this usage flag will always point at the
> same memory contents each time it is mapped. This will enable
> partial tile updates by avoiding rastering content from the
> previous frame again in the compositor.
>
> R=reveman,piman
> BUG=489447
>
> Committed: https://crrev.com/77180b4434d93f45022b8c65110344cdced4b19d
> Cr-Commit-Position: refs/heads/master@{#330987}
TBR=reveman@chromium.org,alexst@chromium.org,piman@chromium.org,sky@chromium.org,danakj@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=489447
Review URL: https://codereview.chromium.org/1151943003
Cr-Commit-Position: refs/heads/master@{#331140}
14 files changed, 41 insertions, 202 deletions
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc index 50d0d82..7c90c64 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc @@ -469,8 +469,6 @@ void BrowserMainLoop::EarlyInitialization() { if (parsed_command_line_.HasSwitch(switches::kEnableNativeGpuMemoryBuffers)) { BrowserGpuChannelHostFactory::EnableGpuMemoryBufferFactoryUsage( gfx::GpuMemoryBuffer::MAP); - BrowserGpuChannelHostFactory::EnableGpuMemoryBufferFactoryUsage( - gfx::GpuMemoryBuffer::PERSISTENT_MAP); } #if defined(USE_OZONE) diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc index 6173d6c..112405f 100644 --- a/content/browser/compositor/gpu_process_transport_factory.cc +++ b/content/browser/compositor/gpu_process_transport_factory.cc @@ -402,19 +402,7 @@ void GpuProcessTransportFactory::RemoveCompositor(ui::Compositor* compositor) { bool GpuProcessTransportFactory::DoesCreateTestContexts() { return false; } uint32 GpuProcessTransportFactory::GetImageTextureTarget() { - // TODO(reveman): We currently assume that the compositor will use BGRA_8888 - // if it's able to, and RGBA_8888 otherwise. Since we don't know what it will - // use we hardcode BGRA_8888 here for now. We should instead - // move decisions about GpuMemoryBuffer format to the browser embedder so we - // know it here, and pass that decision to the compositor for each usage. - // crbug.com/490362 - gfx::GpuMemoryBuffer::Format format = gfx::GpuMemoryBuffer::BGRA_8888; - - // TODO(danakj): When one-copy uploads support partial update, change this - // usage to PERSISTENT_MAP for one-copy. - gfx::GpuMemoryBuffer::Usage usage = gfx::GpuMemoryBuffer::MAP; - - return BrowserGpuChannelHostFactory::GetImageTextureTarget(format, usage); + return BrowserGpuChannelHostFactory::GetImageTextureTarget(); } cc::SharedBitmapManager* GpuProcessTransportFactory::GetSharedBitmapManager() { diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.cc b/content/browser/gpu/browser_gpu_channel_host_factory.cc index 4019ccb..205542c 100644 --- a/content/browser/gpu/browser_gpu_channel_host_factory.cc +++ b/content/browser/gpu/browser_gpu_channel_host_factory.cc @@ -43,38 +43,8 @@ namespace { base::LazyInstance<std::set<gfx::GpuMemoryBuffer::Usage>> g_enabled_gpu_memory_buffer_usages; - -bool IsGpuMemoryBufferFactoryConfigurationSupported( - gfx::GpuMemoryBuffer::Format format, - gfx::GpuMemoryBuffer::Usage usage, - gfx::GpuMemoryBufferType type) { - switch (type) { - case gfx::SHARED_MEMORY_BUFFER: - // Shared memory buffers must be created in-process. - return false; -#if defined(OS_MACOSX) - case gfx::IO_SURFACE_BUFFER: - return GpuMemoryBufferFactoryIOSurface:: - IsGpuMemoryBufferConfigurationSupported(format, usage); -#endif -#if defined(OS_ANDROID) - case gfx::SURFACE_TEXTURE_BUFFER: - return GpuMemoryBufferFactorySurfaceTexture:: - IsGpuMemoryBufferConfigurationSupported(format, usage); -#endif -#if defined(USE_OZONE) - case gfx::OZONE_NATIVE_BUFFER: - return GpuMemoryBufferFactoryOzoneNativeBuffer:: - IsGpuMemoryBufferConfigurationSupported(format, usage); -#endif - default: - NOTREACHED(); - return false; - } } -} // namespace - BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; struct BrowserGpuChannelHostFactory::CreateRequest { @@ -284,23 +254,17 @@ bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferFactoryUsageEnabled( } // static -uint32 BrowserGpuChannelHostFactory::GetImageTextureTarget( - gfx::GpuMemoryBuffer::Format format, - gfx::GpuMemoryBuffer::Usage usage) { - if (!IsGpuMemoryBufferFactoryUsageEnabled(usage)) +uint32 BrowserGpuChannelHostFactory::GetImageTextureTarget() { + if (!IsGpuMemoryBufferFactoryUsageEnabled(gfx::GpuMemoryBuffer::MAP)) return GL_TEXTURE_2D; std::vector<gfx::GpuMemoryBufferType> supported_types; GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); DCHECK(!supported_types.empty()); - // The GPU service will always use the preferred type, if the |format| and - // |usage| allows. + // The GPU service will always use the preferred type. gfx::GpuMemoryBufferType type = supported_types[0]; - if (!IsGpuMemoryBufferFactoryConfigurationSupported(format, usage, type)) - return GL_TEXTURE_2D; - switch (type) { case gfx::SURFACE_TEXTURE_BUFFER: case gfx::OZONE_NATIVE_BUFFER: @@ -507,15 +471,33 @@ bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferConfigurationSupported( if (!IsGpuMemoryBufferFactoryUsageEnabled(usage)) return false; + // Preferred type is always used by factory. std::vector<gfx::GpuMemoryBufferType> supported_types; GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); DCHECK(!supported_types.empty()); - - // The GPU service will always use the preferred type, if the |format| and - // |usage| allows. - gfx::GpuMemoryBufferType type = supported_types[0]; - - return IsGpuMemoryBufferFactoryConfigurationSupported(format, usage, type); + switch (supported_types[0]) { + case gfx::SHARED_MEMORY_BUFFER: + // Shared memory buffers must be created in-process. + return false; +#if defined(OS_MACOSX) + case gfx::IO_SURFACE_BUFFER: + return GpuMemoryBufferFactoryIOSurface:: + IsGpuMemoryBufferConfigurationSupported(format, usage); +#endif +#if defined(OS_ANDROID) + case gfx::SURFACE_TEXTURE_BUFFER: + return GpuMemoryBufferFactorySurfaceTexture:: + IsGpuMemoryBufferConfigurationSupported(format, usage); +#endif +#if defined(USE_OZONE) + case gfx::OZONE_NATIVE_BUFFER: + return GpuMemoryBufferFactoryOzoneNativeBuffer:: + IsGpuMemoryBufferConfigurationSupported(format, usage); +#endif + default: + NOTREACHED(); + return false; + } } void BrowserGpuChannelHostFactory::CreateGpuMemoryBuffer( diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.h b/content/browser/gpu/browser_gpu_channel_host_factory.h index aac6e69..b4df563 100644 --- a/content/browser/gpu/browser_gpu_channel_host_factory.h +++ b/content/browser/gpu/browser_gpu_channel_host_factory.h @@ -29,8 +29,7 @@ class CONTENT_EXPORT BrowserGpuChannelHostFactory gfx::GpuMemoryBuffer::Usage usage); static bool IsGpuMemoryBufferFactoryUsageEnabled( gfx::GpuMemoryBuffer::Usage usage); - static uint32 GetImageTextureTarget(gfx::GpuMemoryBuffer::Format format, - gfx::GpuMemoryBuffer::Usage usage); + static uint32 GetImageTextureTarget(); // Overridden from GpuChannelHostFactory: bool IsMainThread() override; diff --git a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc index 2db48f1..70184a0 100644 --- a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc +++ b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc @@ -99,9 +99,8 @@ BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferCommon( // by factory. if (!gpu_memory_buffer_factory_host_->IsGpuMemoryBufferConfigurationSupported( format, usage)) { - DCHECK(GpuMemoryBufferImplSharedMemory::IsFormatSupported(format)) - << format; - DCHECK(GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage)) << usage; + DCHECK(GpuMemoryBufferImplSharedMemory::IsFormatSupported(format)); + DCHECK_EQ(usage, gfx::GpuMemoryBuffer::MAP); return GpuMemoryBufferImplSharedMemory::Create( g_next_gpu_memory_buffer_id.GetNext(), size, format); } @@ -143,8 +142,8 @@ void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForChildProcess( format, usage)) { // Early out if we cannot fallback to shared memory buffer. if (!GpuMemoryBufferImplSharedMemory::IsFormatSupported(format) || - !GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage) || - !GpuMemoryBufferImplSharedMemory::IsSizeValidForFormat(size, format)) { + !GpuMemoryBufferImplSharedMemory::IsSizeValidForFormat(size, format) || + usage != gfx::GpuMemoryBuffer::MAP) { callback.Run(gfx::GpuMemoryBufferHandle()); return; } diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 2d0d2c6..9179690 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -1133,22 +1133,10 @@ static void AppendCompositorCommandLineFlags(base::CommandLine* command_line) { if (IsForceGpuRasterizationEnabled()) command_line->AppendSwitch(switches::kForceGpuRasterization); - // TODO(reveman): We currently assume that the compositor will use BGRA_8888 - // if it's able to, and RGBA_8888 otherwise. Since we don't know what it will - // use we hardcode BGRA_8888 here for now. We should instead - // move decisions about GpuMemoryBuffer format to the browser embedder so we - // know it here, and pass that decision to the compositor for each usage. - // crbug.com/490362 - gfx::GpuMemoryBuffer::Format format = gfx::GpuMemoryBuffer::BGRA_8888; - - // TODO(danakj): When one-copy uploads support partial update, change this - // usage to PERSISTENT_MAP for one-copy. - gfx::GpuMemoryBuffer::Usage usage = gfx::GpuMemoryBuffer::MAP; - command_line->AppendSwitchASCII( switches::kUseImageTextureTarget, base::UintToString( - BrowserGpuChannelHostFactory::GetImageTextureTarget(format, usage))); + BrowserGpuChannelHostFactory::GetImageTextureTarget())); // Appending disable-gpu-feature switches due to software rendering list. GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); diff --git a/content/common/child_process_host_impl.cc b/content/common/child_process_host_impl.cc index 3fa4dc8..69a6350 100644 --- a/content/common/child_process_host_impl.cc +++ b/content/common/child_process_host_impl.cc @@ -323,9 +323,11 @@ void ChildProcessHostImpl::OnAllocateGpuMemoryBuffer( // and handle failure in a controlled way when not. We just need to make // sure |format| and |usage| are supported here. if (GpuMemoryBufferImplSharedMemory::IsFormatSupported(format) && - GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage)) { + usage == gfx::GpuMemoryBuffer::MAP) { *handle = GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( - g_next_gpu_memory_buffer_id.GetNext(), gfx::Size(width, height), format, + g_next_gpu_memory_buffer_id.GetNext(), + gfx::Size(width, height), + format, peer_process_.Handle()); } } diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc b/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc index e9faba8..02a5048 100644 --- a/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc +++ b/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc @@ -120,19 +120,6 @@ bool GpuMemoryBufferImplSharedMemory::IsFormatSupported(Format format) { } // static -bool GpuMemoryBufferImplSharedMemory::IsUsageSupported(Usage usage) { - switch (usage) { - case MAP: - case PERSISTENT_MAP: - return true; - case SCANOUT: - return false; - } - NOTREACHED(); - return false; -} - -// static bool GpuMemoryBufferImplSharedMemory::IsSizeValidForFormat( const gfx::Size& size, Format format) { diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h b/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h index 97d6b73..ce526a6 100644 --- a/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h +++ b/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h @@ -31,7 +31,6 @@ class GpuMemoryBufferImplSharedMemory : public GpuMemoryBufferImpl { const DestructionCallback& callback); static bool IsFormatSupported(Format format); - static bool IsUsageSupported(Usage usage); static bool IsSizeValidForFormat(const gfx::Size& size, Format format); // Overridden from gfx::GpuMemoryBuffer: diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_unittest.cc b/content/common/gpu/client/gpu_memory_buffer_impl_unittest.cc index a0ac335..94046f1 100644 --- a/content/common/gpu/client/gpu_memory_buffer_impl_unittest.cc +++ b/content/common/gpu/client/gpu_memory_buffer_impl_unittest.cc @@ -79,8 +79,7 @@ TEST_P(GpuMemoryBufferImplTest, CreateFromHandle) { TEST_P(GpuMemoryBufferImplTest, Map) { const int kBufferId = 1; - // Use a multiple of 4 for both dimensions to support compressed formats. - gfx::Size buffer_size(4, 4); + gfx::Size buffer_size(2, 2); for (auto configuration : supported_configurations_) { if (configuration.usage != gfx::GpuMemoryBuffer::MAP) @@ -139,98 +138,6 @@ TEST_P(GpuMemoryBufferImplTest, Map) { } } -TEST_P(GpuMemoryBufferImplTest, PersistentMap) { - const int kBufferId = 1; - - // Use a multiple of 4 for both dimensions to support compressed formats. - gfx::Size buffer_size(4, 4); - - for (auto configuration : supported_configurations_) { - if (configuration.usage != gfx::GpuMemoryBuffer::PERSISTENT_MAP) - continue; - - scoped_ptr<GpuMemoryBufferImpl> buffer( - GpuMemoryBufferImpl::CreateFromHandle( - CreateGpuMemoryBuffer(kBufferId, buffer_size, configuration.format, - configuration.usage), - buffer_size, configuration.format, - base::Bind(&GpuMemoryBufferImplTest::DestroyGpuMemoryBuffer, - base::Unretained(this), kBufferId))); - ASSERT_TRUE(buffer); - EXPECT_FALSE(buffer->IsMapped()); - - size_t num_planes = - GpuMemoryBufferImpl::NumberOfPlanesForGpuMemoryBufferFormat( - configuration.format); - - // Map buffer into user space. - scoped_ptr<void* []> mapped_buffers(new void* [num_planes]); - bool rv = buffer->Map(mapped_buffers.get()); - ASSERT_TRUE(rv); - EXPECT_TRUE(buffer->IsMapped()); - - // Get strides. - scoped_ptr<int[]> strides(new int[num_planes]); - buffer->GetStride(strides.get()); - - // Copy and compare mapped buffers. - for (size_t plane = 0; plane < num_planes; ++plane) { - size_t row_size_in_bytes; - EXPECT_TRUE(GpuMemoryBufferImpl::RowSizeInBytes( - buffer_size.width(), configuration.format, plane, - &row_size_in_bytes)); - - scoped_ptr<char[]> data(new char[row_size_in_bytes]); - memset(data.get(), 0x2a + plane, row_size_in_bytes); - - size_t height = - buffer_size.height() / - GpuMemoryBufferImpl::SubsamplingFactor(configuration.format, plane); - for (size_t y = 0; y < height; ++y) { - memcpy(static_cast<char*>(mapped_buffers[plane]) + y * strides[plane], - data.get(), row_size_in_bytes); - EXPECT_EQ(memcmp(static_cast<char*>(mapped_buffers[plane]) + - y * strides[plane], - data.get(), row_size_in_bytes), - 0); - } - } - - buffer->Unmap(); - EXPECT_FALSE(buffer->IsMapped()); - - // Remap the buffer, and compare again. It should contain the same data. - rv = buffer->Map(mapped_buffers.get()); - ASSERT_TRUE(rv); - EXPECT_TRUE(buffer->IsMapped()); - - buffer->GetStride(strides.get()); - - for (size_t plane = 0; plane < num_planes; ++plane) { - size_t row_size_in_bytes; - EXPECT_TRUE(GpuMemoryBufferImpl::RowSizeInBytes( - buffer_size.width(), configuration.format, plane, - &row_size_in_bytes)); - - scoped_ptr<char[]> data(new char[row_size_in_bytes]); - memset(data.get(), 0x2a + plane, row_size_in_bytes); - - size_t height = - buffer_size.height() / - GpuMemoryBufferImpl::SubsamplingFactor(configuration.format, plane); - for (size_t y = 0; y < height; ++y) { - EXPECT_EQ(memcmp(static_cast<char*>(mapped_buffers[plane]) + - y * strides[plane], - data.get(), row_size_in_bytes), - 0); - } - } - - buffer->Unmap(); - EXPECT_FALSE(buffer->IsMapped()); - } -} - std::vector<gfx::GpuMemoryBufferType> GetSupportedGpuMemoryBufferTypes() { std::vector<gfx::GpuMemoryBufferType> supported_types; GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); diff --git a/content/common/gpu/gpu_memory_buffer_factory_shared_memory.cc b/content/common/gpu/gpu_memory_buffer_factory_shared_memory.cc index 8273de8..4c8f0e9 100644 --- a/content/common/gpu/gpu_memory_buffer_factory_shared_memory.cc +++ b/content/common/gpu/gpu_memory_buffer_factory_shared_memory.cc @@ -24,13 +24,9 @@ void GpuMemoryBufferFactorySharedMemory:: std::vector<Configuration>* configurations) { const Configuration supported_configurations[] = { {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::MAP}, - {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::MAP}, - {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, {gfx::GpuMemoryBuffer::BGRA_8888, gfx::GpuMemoryBuffer::MAP}, - {gfx::GpuMemoryBuffer::BGRA_8888, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, - {gfx::GpuMemoryBuffer::YUV_420, gfx::GpuMemoryBuffer::MAP}, - {gfx::GpuMemoryBuffer::YUV_420, gfx::GpuMemoryBuffer::PERSISTENT_MAP}}; + {gfx::GpuMemoryBuffer::YUV_420, gfx::GpuMemoryBuffer::MAP}}; configurations->assign( supported_configurations, supported_configurations + arraysize(supported_configurations)); diff --git a/ui/gfx/gpu_memory_buffer.h b/ui/gfx/gpu_memory_buffer.h index dc18ed4..121bd02 100644 --- a/ui/gfx/gpu_memory_buffer.h +++ b/ui/gfx/gpu_memory_buffer.h @@ -59,10 +59,7 @@ class GFX_EXPORT GpuMemoryBuffer { // The usage mode affects how a buffer can be used. Only buffers created with // MAP can be mapped into the client's address space and accessed by the CPU. - // PERSISTENT_MAP adds the additional condition that successive Map() calls - // (with Unmap() calls between) will return a pointer to the same memory - // contents. - enum Usage { MAP, PERSISTENT_MAP, SCANOUT, USAGE_LAST = SCANOUT }; + enum Usage { MAP, SCANOUT, USAGE_LAST = SCANOUT }; virtual ~GpuMemoryBuffer() {} diff --git a/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc b/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc index 88f45e4..51ff149 100644 --- a/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc +++ b/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc @@ -111,8 +111,6 @@ SurfaceFactoryOzone::BufferUsage GetOzoneUsageFor( switch (usage) { case gfx::GpuMemoryBuffer::MAP: return SurfaceFactoryOzone::MAP; - case gfx::GpuMemoryBuffer::PERSISTENT_MAP: - return SurfaceFactoryOzone::PERSISTENT_MAP; case gfx::GpuMemoryBuffer::SCANOUT: return SurfaceFactoryOzone::SCANOUT; } diff --git a/ui/ozone/public/surface_factory_ozone.h b/ui/ozone/public/surface_factory_ozone.h index 52073f8..0fbf9e89 100644 --- a/ui/ozone/public/surface_factory_ozone.h +++ b/ui/ozone/public/surface_factory_ozone.h @@ -70,7 +70,6 @@ class OZONE_BASE_EXPORT SurfaceFactoryOzone { enum BufferUsage { MAP, - PERSISTENT_MAP, SCANOUT, }; |