diff options
author | reveman <reveman@chromium.org> | 2015-06-11 17:13:20 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-12 00:14:08 +0000 |
commit | 8569f079e8d932b4eaebf7548a74dd264d92b920 (patch) | |
tree | 28bfdc6a09b44d672c359a2b8ab97b5141211464 | |
parent | cb71f9f7b183e8ce4dedcf2fd3ca90b2b7a02b66 (diff) | |
download | chromium_src-8569f079e8d932b4eaebf7548a74dd264d92b920.zip chromium_src-8569f079e8d932b4eaebf7548a74dd264d92b920.tar.gz chromium_src-8569f079e8d932b4eaebf7548a74dd264d92b920.tar.bz2 |
cc: Fix lost context handling when using native GpuMemoryBuffers.
GpuMemoryBuffer allocation can fail when using native
GpuMemoryBuffers as they are allocated by the GPU process.
This is a minimal set of changes to keep as much logic as
possible the same in lost context situations.
BUG=486922
TEST=content/test/gpu/run_gpu_test.py context_lost --extra-browser-args=--enable-native-gpu-memory-buffers --story-filter=GpuCrash.GPUProcessCrashesExactlyOnce
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1178303003
Cr-Commit-Position: refs/heads/master@{#334092}
-rw-r--r-- | cc/resources/resource_provider.cc | 16 | ||||
-rw-r--r-- | cc/resources/resource_provider_unittest.cc | 24 | ||||
-rw-r--r-- | content/child/child_gpu_memory_buffer_manager.cc | 6 | ||||
-rw-r--r-- | content/common/gpu/client/gpu_memory_buffer_impl.cc | 2 |
4 files changed, 27 insertions, 21 deletions
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index 087f0fe..079d034 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc @@ -1051,6 +1051,8 @@ ResourceProvider::ScopedWriteLockGpuMemoryBuffer:: if (!gpu_memory_buffer_) return; + resource_provider_->LazyCreate(resource_); + if (!resource_->image_id) { GLES2Interface* gl = resource_provider_->ContextGL(); DCHECK(gl); @@ -1900,21 +1902,20 @@ void ResourceProvider::LazyAllocate(Resource* resource) { resource->allocated = true; GLES2Interface* gl = ContextGL(); gfx::Size& size = resource->size; - DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); ResourceFormat format = resource->format; - gl->BindTexture(GL_TEXTURE_2D, resource->gl_id); + gl->BindTexture(resource->target, resource->gl_id); if (use_texture_storage_ext_ && IsFormatSupportedForStorage(format, use_texture_format_bgra_) && (resource->hint & TEXTURE_HINT_IMMUTABLE)) { GLenum storage_format = TextureToStorageFormat(format); - gl->TexStorage2DEXT(GL_TEXTURE_2D, 1, storage_format, size.width(), + gl->TexStorage2DEXT(resource->target, 1, storage_format, size.width(), size.height()); } else { // ETC1 does not support preallocation. if (format != ETC1) { - gl->TexImage2D(GL_TEXTURE_2D, 0, GLInternalFormat(format), size.width(), - size.height(), 0, GLDataFormat(format), GLDataType(format), - NULL); + gl->TexImage2D(resource->target, 0, GLInternalFormat(format), + size.width(), size.height(), 0, GLDataFormat(format), + GLDataType(format), NULL); } } } @@ -1942,8 +1943,7 @@ void ResourceProvider::CopyResource(ResourceId source_id, DCHECK(source_resource->origin == Resource::INTERNAL); DCHECK_EQ(source_resource->exported_count, 0); DCHECK_EQ(RESOURCE_TYPE_GL_TEXTURE, source_resource->type); - DCHECK(source_resource->allocated); - LazyCreate(source_resource); + LazyAllocate(source_resource); Resource* dest_resource = GetResource(dest_id); DCHECK(!dest_resource->locked_for_write); diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc index 2982a3d..0b27a83 100644 --- a/cc/resources/resource_provider_unittest.cc +++ b/cc/resources/resource_provider_unittest.cc @@ -3370,6 +3370,12 @@ TEST_P(ResourceProviderTest, Image_GLTexture) { id = resource_provider->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); + EXPECT_CALL(*context, NextTextureId()) + .WillOnce(Return(kTextureId)) + .RetiresOnSaturation(); + EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)) + .Times(1) + .RetiresOnSaturation(); EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA)) .WillOnce(Return(kImageId)) .RetiresOnSaturation(); @@ -3379,11 +3385,8 @@ TEST_P(ResourceProviderTest, Image_GLTexture) { EXPECT_TRUE(lock.GetGpuMemoryBuffer()); } - EXPECT_CALL(*context, NextTextureId()) - .WillOnce(Return(kTextureId)) - .RetiresOnSaturation(); - // Once in CreateTextureId and once in BindForSampling - EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) + EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)) + .Times(1) .RetiresOnSaturation(); EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) .Times(1) @@ -3452,6 +3455,12 @@ TEST_P(ResourceProviderTest, CopyResource_GLTexture) { source_id = resource_provider->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); + EXPECT_CALL(*context, NextTextureId()) + .WillOnce(Return(kSourceTextureId)) + .RetiresOnSaturation(); + EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kSourceTextureId)) + .Times(1) + .RetiresOnSaturation(); EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA)) .WillOnce(Return(kImageId)) .RetiresOnSaturation(); @@ -3475,11 +3484,8 @@ TEST_P(ResourceProviderTest, CopyResource_GLTexture) { GL_UNSIGNED_BYTE, nullptr)) .Times(1) .RetiresOnSaturation(); - EXPECT_CALL(*context, NextTextureId()) - .WillOnce(Return(kSourceTextureId)) - .RetiresOnSaturation(); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kSourceTextureId)) - .Times(2) + .Times(1) .RetiresOnSaturation(); EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) .Times(1) diff --git a/content/child/child_gpu_memory_buffer_manager.cc b/content/child/child_gpu_memory_buffer_manager.cc index 990e2e5..5513e59 100644 --- a/content/child/child_gpu_memory_buffer_manager.cc +++ b/content/child/child_gpu_memory_buffer_manager.cc @@ -44,15 +44,15 @@ ChildGpuMemoryBufferManager::AllocateGpuMemoryBuffer( IPC::Message* message = new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer( size.width(), size.height(), format, usage, &handle); bool success = sender_->Send(message); - if (!success) - return scoped_ptr<gfx::GpuMemoryBuffer>(); + if (!success || handle.is_null()) + return nullptr; scoped_ptr<GpuMemoryBufferImpl> buffer(GpuMemoryBufferImpl::CreateFromHandle( handle, size, format, usage, base::Bind(&DeletedGpuMemoryBuffer, sender_, handle.id))); if (!buffer) { sender_->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer(handle.id, 0)); - return scoped_ptr<gfx::GpuMemoryBuffer>(); + return nullptr; } return buffer.Pass(); diff --git a/content/common/gpu/client/gpu_memory_buffer_impl.cc b/content/common/gpu/client/gpu_memory_buffer_impl.cc index 5088f10..8976742 100644 --- a/content/common/gpu/client/gpu_memory_buffer_impl.cc +++ b/content/common/gpu/client/gpu_memory_buffer_impl.cc @@ -68,7 +68,7 @@ scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( #endif default: NOTREACHED(); - return scoped_ptr<GpuMemoryBufferImpl>(); + return nullptr; } } |