OLD | NEW |
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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 static bool IsTextureComplete(const Texture* texture) { | 40 static bool IsTextureComplete(const Texture* texture) { |
41 return texture->texture_complete(); | 41 return texture->texture_complete(); |
42 } | 42 } |
43 static bool IsCubeComplete(const Texture* texture) { | 43 static bool IsCubeComplete(const Texture* texture) { |
44 return texture->cube_complete(); | 44 return texture->cube_complete(); |
45 } | 45 } |
46 }; | 46 }; |
47 | 47 |
48 class TextureManagerTest : public GpuServiceTest { | 48 class TextureManagerTest : public GpuServiceTest { |
49 public: | 49 public: |
50 static const GLint kMaxTextureSize = 32; | 50 static const GLint kMaxTextureSize = 16; |
51 static const GLint kMaxCubeMapTextureSize = 8; | 51 static const GLint kMaxCubeMapTextureSize = 8; |
52 static const GLint kMaxRectangleTextureSize = 32; | 52 static const GLint kMaxRectangleTextureSize = 16; |
53 static const GLint kMaxExternalTextureSize = 32; | 53 static const GLint kMaxExternalTextureSize = 16; |
54 static const GLint kMax3DTextureSize = 256; | 54 static const GLint kMax3DTextureSize = 256; |
55 static const GLint kMax2dLevels = 6; | 55 static const GLint kMax2dLevels = 5; |
56 static const GLint kMaxCubeMapLevels = 4; | 56 static const GLint kMaxCubeMapLevels = 4; |
57 static const GLint kMaxExternalLevels = 1; | 57 static const GLint kMaxExternalLevels = 1; |
58 static const bool kUseDefaultTextures = false; | 58 static const bool kUseDefaultTextures = false; |
59 | 59 |
60 TextureManagerTest() { | 60 TextureManagerTest() { |
61 // Always run with this command line, but the ES3 features are not | 61 // Always run with this command line, but the ES3 features are not |
62 // enabled without FeatureInfo::EnableES3Validators(). | 62 // enabled without FeatureInfo::EnableES3Validators(). |
63 base::CommandLine command_line(0, nullptr); | 63 base::CommandLine command_line(0, nullptr); |
64 command_line.AppendSwitch(switches::kEnableUnsafeES3APIs); | 64 command_line.AppendSwitch(switches::kEnableUnsafeES3APIs); |
65 feature_info_ = new FeatureInfo(command_line); | 65 feature_info_ = new FeatureInfo(command_line); |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 EXPECT_TRUE(manager.ValidForTarget(GL_TEXTURE_2D, 0, 2, 5, 1)); | 458 EXPECT_TRUE(manager.ValidForTarget(GL_TEXTURE_2D, 0, 2, 5, 1)); |
459 // Check NPOT width on level 1 | 459 // Check NPOT width on level 1 |
460 EXPECT_TRUE(manager.ValidForTarget(GL_TEXTURE_2D, 1, 5, 2, 1)); | 460 EXPECT_TRUE(manager.ValidForTarget(GL_TEXTURE_2D, 1, 5, 2, 1)); |
461 // Check NPOT height on level 1 | 461 // Check NPOT height on level 1 |
462 EXPECT_TRUE(manager.ValidForTarget(GL_TEXTURE_2D, 1, 2, 5, 1)); | 462 EXPECT_TRUE(manager.ValidForTarget(GL_TEXTURE_2D, 1, 2, 5, 1)); |
463 manager.Destroy(false); | 463 manager.Destroy(false); |
464 } | 464 } |
465 | 465 |
466 class TextureTestBase : public GpuServiceTest { | 466 class TextureTestBase : public GpuServiceTest { |
467 public: | 467 public: |
468 static const GLint kMaxTextureSize = 32; | 468 static const GLint kMaxTextureSize = 16; |
469 static const GLint kMaxCubeMapTextureSize = 8; | 469 static const GLint kMaxCubeMapTextureSize = 8; |
470 static const GLint kMaxRectangleTextureSize = 32; | 470 static const GLint kMaxRectangleTextureSize = 16; |
471 static const GLint kMax3DTextureSize = 256; | 471 static const GLint kMax3DTextureSize = 256; |
472 static const GLint kMax2dLevels = 6; | 472 static const GLint kMax2dLevels = 5; |
473 static const GLint kMaxCubeMapLevels = 4; | 473 static const GLint kMaxCubeMapLevels = 4; |
474 static const GLuint kClient1Id = 1; | 474 static const GLuint kClient1Id = 1; |
475 static const GLuint kService1Id = 11; | 475 static const GLuint kService1Id = 11; |
476 static const bool kUseDefaultTextures = false; | 476 static const bool kUseDefaultTextures = false; |
477 | 477 |
478 TextureTestBase() | 478 TextureTestBase() |
479 : feature_info_(new FeatureInfo()) { | 479 : feature_info_(new FeatureInfo()) { |
480 } | 480 } |
481 ~TextureTestBase() override { texture_ref_ = NULL; } | 481 ~TextureTestBase() override { texture_ref_ = NULL; } |
482 | 482 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 3, GL_RGBA, 4, 4, 1, | 677 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 3, GL_RGBA, 4, 4, 1, |
678 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(4, 4)); | 678 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(4, 4)); |
679 EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get())); | 679 EXPECT_TRUE(manager_->CanGenerateMipmaps(texture_ref_.get())); |
680 // Make mips. | 680 // Make mips. |
681 EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get())); | 681 EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get())); |
682 EXPECT_TRUE(manager_->CanRender(texture_ref_.get())); | 682 EXPECT_TRUE(manager_->CanRender(texture_ref_.get())); |
683 EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); | 683 EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); |
684 EXPECT_FALSE(manager_->HaveUnrenderableTextures()); | 684 EXPECT_FALSE(manager_->HaveUnrenderableTextures()); |
685 } | 685 } |
686 | 686 |
687 TEST_F(TextureTest, BaseLevel) { | |
688 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D); | |
689 Texture* texture = texture_ref_->texture(); | |
690 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), texture->target()); | |
691 // Check Setting level 1 to POT | |
692 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1, GL_RGBA, 4, 4, 1, | |
693 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(4, 4)); | |
694 SetParameter( | |
695 texture_ref_.get(), GL_TEXTURE_MIN_FILTER, GL_LINEAR, GL_NO_ERROR); | |
696 EXPECT_FALSE(manager_->CanRender(texture_ref_.get())); | |
697 EXPECT_TRUE(manager_->HaveUnrenderableTextures()); | |
698 SetParameter( | |
699 texture_ref_.get(), GL_TEXTURE_BASE_LEVEL, 1, GL_NO_ERROR); | |
700 EXPECT_TRUE(manager_->CanRender(texture_ref_.get())); | |
701 EXPECT_FALSE(manager_->HaveUnrenderableTextures()); | |
702 } | |
703 | |
704 TEST_F(TextureTest, BaseLevelMaxLevel) { | |
705 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D); | |
706 Texture* texture = texture_ref_->texture(); | |
707 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), texture->target()); | |
708 // Set up level 2, 3, 4. | |
709 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 2, GL_RGBA, 8, 8, 1, | |
710 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(8, 8)); | |
711 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 3, GL_RGBA, 4, 4, 1, | |
712 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(4, 4)); | |
713 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 4, GL_RGBA, 2, 2, 1, | |
714 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(2, 2)); | |
715 SetParameter( | |
716 texture_ref_.get(), GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR, | |
717 GL_NO_ERROR); | |
718 SetParameter( | |
719 texture_ref_.get(), GL_TEXTURE_MAG_FILTER, GL_LINEAR, GL_NO_ERROR); | |
720 EXPECT_FALSE(manager_->CanRender(texture_ref_.get())); | |
721 EXPECT_TRUE(manager_->HaveUnrenderableTextures()); | |
722 SetParameter( | |
723 texture_ref_.get(), GL_TEXTURE_BASE_LEVEL, 2, GL_NO_ERROR); | |
724 EXPECT_FALSE(manager_->CanRender(texture_ref_.get())); | |
725 EXPECT_TRUE(manager_->HaveUnrenderableTextures()); | |
726 SetParameter( | |
727 texture_ref_.get(), GL_TEXTURE_MAX_LEVEL, 4, GL_NO_ERROR); | |
728 EXPECT_TRUE(manager_->CanRender(texture_ref_.get())); | |
729 EXPECT_FALSE(manager_->HaveUnrenderableTextures()); | |
730 SetParameter( | |
731 texture_ref_.get(), GL_TEXTURE_BASE_LEVEL, 0, GL_NO_ERROR); | |
732 EXPECT_FALSE(manager_->CanRender(texture_ref_.get())); | |
733 EXPECT_TRUE(manager_->HaveUnrenderableTextures()); | |
734 } | |
735 | |
736 TEST_F(TextureMemoryTrackerTest, MarkMipmapsGenerated) { | 687 TEST_F(TextureMemoryTrackerTest, MarkMipmapsGenerated) { |
737 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D); | 688 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D); |
738 EXPECT_MEMORY_ALLOCATION_CHANGE(0, 64); | 689 EXPECT_MEMORY_ALLOCATION_CHANGE(0, 64); |
739 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, | 690 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, |
740 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(4, 4)); | 691 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(4, 4)); |
741 EXPECT_MEMORY_ALLOCATION_CHANGE(64, 0); | 692 EXPECT_MEMORY_ALLOCATION_CHANGE(64, 0); |
742 EXPECT_MEMORY_ALLOCATION_CHANGE(0, 84); | 693 EXPECT_MEMORY_ALLOCATION_CHANGE(0, 84); |
743 EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get())); | 694 EXPECT_TRUE(manager_->MarkMipmapsGenerated(texture_ref_.get())); |
744 EXPECT_MEMORY_ALLOCATION_CHANGE(84, 0); | 695 EXPECT_MEMORY_ALLOCATION_CHANGE(84, 0); |
745 EXPECT_MEMORY_ALLOCATION_CHANGE(0, 0); | 696 EXPECT_MEMORY_ALLOCATION_CHANGE(0, 0); |
(...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2378 ExpectValid(GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F); | 2329 ExpectValid(GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F); |
2379 ExpectValid(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8); | 2330 ExpectValid(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8); |
2380 ExpectValid(GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, | 2331 ExpectValid(GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, |
2381 GL_DEPTH32F_STENCIL8); | 2332 GL_DEPTH32F_STENCIL8); |
2382 | 2333 |
2383 ExpectInvalid(GL_RGB_INTEGER, GL_INT, GL_RGBA8); | 2334 ExpectInvalid(GL_RGB_INTEGER, GL_INT, GL_RGBA8); |
2384 } | 2335 } |
2385 | 2336 |
2386 } // namespace gles2 | 2337 } // namespace gles2 |
2387 } // namespace gpu | 2338 } // namespace gpu |
OLD | NEW |