diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-18 01:19:56 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-18 01:19:56 +0000 |
commit | 4874aae4718d407f7f4de1b71f0c02b9a2065474 (patch) | |
tree | b45785becc371fa65bef1cc5ff7fc7c9ef2e0487 /gpu | |
parent | 33301e7aca7557eac750c8bb9a7c241bbd12e1c7 (diff) | |
download | chromium_src-4874aae4718d407f7f4de1b71f0c02b9a2065474.zip chromium_src-4874aae4718d407f7f4de1b71f0c02b9a2065474.tar.gz chromium_src-4874aae4718d407f7f4de1b71f0c02b9a2065474.tar.bz2 |
GPU process - parent GL context does not delete the textures it shares with child contexts.
The child contexts create them and are then responsible for deleting them. This fixed a crash where the child contexts were passing an invalid texture ID to glBlitFramebufferANGLE.
TEST=can't reproduce bug locally anymore, trybots
BUG=75661
Review URL: http://codereview.chromium.org/6670074
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78642 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 3 | ||||
-rw-r--r-- | gpu/command_buffer/service/texture_manager.cc | 4 | ||||
-rw-r--r-- | gpu/command_buffer/service/texture_manager.h | 13 | ||||
-rw-r--r-- | gpu/command_buffer/service/texture_manager_unittest.cc | 24 |
4 files changed, 38 insertions, 6 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 23a9bac..c263eae 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.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. @@ -1972,6 +1972,7 @@ bool GLES2DecoderImpl::Initialize( GLuint service_id = offscreen_saved_color_texture_->id(); TextureManager::TextureInfo* info = parent_->CreateTextureInfo(parent_client_texture_id, service_id); + info->SetNotOwned(); parent_->texture_manager()->SetInfoTarget(info, GL_TEXTURE_2D); } diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc index 025669e..cf6f468 100644 --- a/gpu/command_buffer/service/texture_manager.cc +++ b/gpu/command_buffer/service/texture_manager.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. @@ -67,7 +67,7 @@ void TextureManager::Destroy(bool have_context) { while (!texture_infos_.empty()) { if (have_context) { TextureInfo* info = texture_infos_.begin()->second; - if (!info->IsDeleted()) { + if (!info->IsDeleted() && info->owned_) { GLuint service_id = info->service_id(); glDeleteTextures(1, &service_id); info->MarkAsDeleted(); diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h index 20a4c11..ee3367b 100644 --- a/gpu/command_buffer/service/texture_manager.h +++ b/gpu/command_buffer/service/texture_manager.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. @@ -40,7 +40,8 @@ class TextureManager { max_level_set_(-1), texture_complete_(false), cube_complete_(false), - npot_(false) { + npot_(false), + owned_(true) { } // True if this texture meets all the GLES2 criteria for rendering. @@ -109,6 +110,10 @@ class TextureManager { return target() && !IsDeleted(); } + void SetNotOwned() { + owned_ = false; + } + private: friend class TextureManager; friend class base::RefCounted<TextureInfo>; @@ -217,6 +222,10 @@ class TextureManager { // Whether this texture has ever been bound. bool has_been_bound_; + // Whether the associated context group owns this texture and should delete + // it. + bool owned_; + DISALLOW_COPY_AND_ASSIGN(TextureInfo); }; diff --git a/gpu/command_buffer/service/texture_manager_unittest.cc b/gpu/command_buffer/service/texture_manager_unittest.cc index 73cc152..0b59fc5 100644 --- a/gpu/command_buffer/service/texture_manager_unittest.cc +++ b/gpu/command_buffer/service/texture_manager_unittest.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. @@ -114,6 +114,28 @@ TEST_F(TextureManagerTest, Destroy) { ASSERT_TRUE(info1 == NULL); } +TEST_F(TextureManagerTest, DestroyUnowned) { + const GLuint kClient1Id = 1; + const GLuint kService1Id = 11; + EXPECT_FALSE(manager_.HaveUnrenderableTextures()); + // Check we can create texture. + TextureManager::TextureInfo* created_info = + manager_.CreateTextureInfo(&feature_info_, kClient1Id, kService1Id); + created_info->SetNotOwned(); + + // Check texture got created. + TextureManager::TextureInfo* info1 = manager_.GetTextureInfo(kClient1Id); + ASSERT_TRUE(info1 != NULL); + EXPECT_CALL(*gl_, DeleteTextures(4, _)) + .Times(1) + .RetiresOnSaturation(); + + // Check that it is not freed if it is not owned. + manager_.Destroy(true); + info1 = manager_.GetTextureInfo(kClient1Id); + ASSERT_TRUE(info1 == NULL); +} + TEST_F(TextureManagerTest, MaxValues) { // Check we get the right values for the max sizes. EXPECT_EQ(kMax2dLevels, manager_.MaxLevelsForTarget(GL_TEXTURE_2D)); |