Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: gpu/command_buffer/service/texture_manager_unittest.cc

Issue 2301823003: [Command Buffer] We may need to adjust texture format when clear texture level by tex{Sub}Image (Closed)
Patch Set: copy-texture-image-luma-format.html still fails in Windows Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/texture_manager.h" 5 #include "gpu/command_buffer/service/texture_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 static const bool kUseDefaultTextures = false; 699 static const bool kUseDefaultTextures = false;
700 700
701 TextureTestBase() 701 TextureTestBase()
702 : feature_info_(new FeatureInfo()) { 702 : feature_info_(new FeatureInfo()) {
703 } 703 }
704 ~TextureTestBase() override { texture_ref_ = NULL; } 704 ~TextureTestBase() override { texture_ref_ = NULL; }
705 705
706 protected: 706 protected:
707 void SetUpBase(MemoryTracker* memory_tracker, const std::string& extensions) { 707 void SetUpBase(MemoryTracker* memory_tracker, const std::string& extensions) {
708 GpuServiceTest::SetUp(); 708 GpuServiceTest::SetUp();
709 if (!extensions.empty()) { 709 TestHelper::SetupFeatureInfoInitExpectations(gl_.get(),
710 TestHelper::SetupFeatureInfoInitExpectations(gl_.get(), 710 extensions.c_str());
711 extensions.c_str()); 711 feature_info_->InitializeForTesting();
712 feature_info_->InitializeForTesting();
713 }
714 712
715 manager_.reset(new TextureManager(memory_tracker, 713 manager_.reset(new TextureManager(memory_tracker,
716 feature_info_.get(), 714 feature_info_.get(),
717 kMaxTextureSize, 715 kMaxTextureSize,
718 kMaxCubeMapTextureSize, 716 kMaxCubeMapTextureSize,
719 kMaxRectangleTextureSize, 717 kMaxRectangleTextureSize,
720 kMax3DTextureSize, 718 kMax3DTextureSize,
721 kMaxArrayTextureLayers, 719 kMaxArrayTextureLayers,
722 kUseDefaultTextures)); 720 kUseDefaultTextures));
723 decoder_.reset(new ::testing::StrictMock<gles2::MockGLES2Decoder>()); 721 decoder_.reset(new ::testing::StrictMock<gles2::MockGLES2Decoder>());
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D); 1615 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
1618 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 1616 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1,
1619 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect()); 1617 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect());
1620 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1, GL_RGBA, 4, 4, 1, 1618 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1, GL_RGBA, 4, 4, 1,
1621 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect()); 1619 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect());
1622 Texture* texture = texture_ref_->texture(); 1620 Texture* texture = texture_ref_->texture();
1623 EXPECT_FALSE(texture->SafeToRenderFrom()); 1621 EXPECT_FALSE(texture->SafeToRenderFrom());
1624 EXPECT_TRUE(manager_->HaveUnsafeTextures()); 1622 EXPECT_TRUE(manager_->HaveUnsafeTextures());
1625 EXPECT_TRUE(manager_->HaveUnclearedMips()); 1623 EXPECT_TRUE(manager_->HaveUnclearedMips());
1626 EXPECT_EQ(2, texture->num_uncleared_mips()); 1624 EXPECT_EQ(2, texture->num_uncleared_mips());
1625 EXPECT_CALL(*decoder_.get(), GetFeatureInfo())
1626 .WillRepeatedly(Return(feature_info_.get()));
1627 manager_->ClearRenderableLevels(decoder_.get(), texture_ref_.get()); 1627 manager_->ClearRenderableLevels(decoder_.get(), texture_ref_.get());
1628 EXPECT_TRUE(texture->SafeToRenderFrom()); 1628 EXPECT_TRUE(texture->SafeToRenderFrom());
1629 EXPECT_FALSE(manager_->HaveUnsafeTextures()); 1629 EXPECT_FALSE(manager_->HaveUnsafeTextures());
1630 EXPECT_FALSE(manager_->HaveUnclearedMips()); 1630 EXPECT_FALSE(manager_->HaveUnclearedMips());
1631 EXPECT_EQ(0, texture->num_uncleared_mips()); 1631 EXPECT_EQ(0, texture->num_uncleared_mips());
1632 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 1632 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1,
1633 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(2, 2)); 1633 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(2, 2));
1634 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1, GL_RGBA, 4, 4, 1, 1634 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1, GL_RGBA, 4, 4, 1,
1635 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(4, 3)); 1635 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(4, 3));
1636 EXPECT_FALSE(texture->SafeToRenderFrom()); 1636 EXPECT_FALSE(texture->SafeToRenderFrom());
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 2103
2104 // See if we can clear the previously uncleared level now. 2104 // See if we can clear the previously uncleared level now.
2105 EXPECT_EQ(level0, 2105 EXPECT_EQ(level0,
2106 GetLevelInfo(restored_texture.get(), GL_TEXTURE_RECTANGLE_ARB, 0)); 2106 GetLevelInfo(restored_texture.get(), GL_TEXTURE_RECTANGLE_ARB, 0));
2107 EXPECT_CALL(*decoder_, ClearLevel(_, _, _, _, _, _, _, _, _)) 2107 EXPECT_CALL(*decoder_, ClearLevel(_, _, _, _, _, _, _, _, _))
2108 .WillRepeatedly(Return(true)); 2108 .WillRepeatedly(Return(true));
2109 // The code path taken when IsCompressedTextureFormat returns true 2109 // The code path taken when IsCompressedTextureFormat returns true
2110 // is covered best by the WebGL 2.0 conformance tests. 2110 // is covered best by the WebGL 2.0 conformance tests.
2111 EXPECT_CALL(*decoder_, IsCompressedTextureFormat(_)) 2111 EXPECT_CALL(*decoder_, IsCompressedTextureFormat(_))
2112 .WillRepeatedly(Return(false)); 2112 .WillRepeatedly(Return(false));
2113 EXPECT_CALL(*decoder_.get(), GetFeatureInfo())
2114 .WillRepeatedly(Return(feature_info_.get()));
2113 EXPECT_TRUE(manager_->ClearTextureLevel( 2115 EXPECT_TRUE(manager_->ClearTextureLevel(
2114 decoder_.get(), restored_texture.get(), GL_TEXTURE_RECTANGLE_ARB, 0)); 2116 decoder_.get(), restored_texture.get(), GL_TEXTURE_RECTANGLE_ARB, 0));
2115 } 2117 }
2116 2118
2117 TEST_F(ProduceConsumeTextureTest, ProduceConsumeExternal) { 2119 TEST_F(ProduceConsumeTextureTest, ProduceConsumeExternal) {
2118 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_EXTERNAL_OES); 2120 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_EXTERNAL_OES);
2119 Texture* texture = texture_ref_->texture(); 2121 Texture* texture = texture_ref_->texture();
2120 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), texture->target()); 2122 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), texture->target());
2121 LevelInfo level0(GL_TEXTURE_EXTERNAL_OES, GL_RGBA, 1, 1, 1, 0, 2123 LevelInfo level0(GL_TEXTURE_EXTERNAL_OES, GL_RGBA, 1, 1, 1, 0,
2122 GL_UNSIGNED_BYTE, gfx::Rect()); 2124 GL_UNSIGNED_BYTE, gfx::Rect());
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
2747 ExpectValid( 2749 ExpectValid(
2748 true, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8); 2750 true, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8);
2749 ExpectValid(true, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, 2751 ExpectValid(true, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV,
2750 GL_DEPTH32F_STENCIL8); 2752 GL_DEPTH32F_STENCIL8);
2751 2753
2752 ExpectInvalid(true, GL_RGB_INTEGER, GL_INT, GL_RGBA8); 2754 ExpectInvalid(true, GL_RGB_INTEGER, GL_INT, GL_RGBA8);
2753 } 2755 }
2754 2756
2755 } // namespace gles2 2757 } // namespace gles2
2756 } // namespace gpu 2758 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698