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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/strings/string_number_conversions.h" |
15 #include "gpu/command_buffer/client/client_test_helper.h" | 16 #include "gpu/command_buffer/client/client_test_helper.h" |
| 17 #include "gpu/command_buffer/service/context_state.h" |
16 #include "gpu/command_buffer/service/error_state_mock.h" | 18 #include "gpu/command_buffer/service/error_state_mock.h" |
17 #include "gpu/command_buffer/service/feature_info.h" | 19 #include "gpu/command_buffer/service/feature_info.h" |
18 #include "gpu/command_buffer/service/framebuffer_manager.h" | 20 #include "gpu/command_buffer/service/framebuffer_manager.h" |
19 #include "gpu/command_buffer/service/gl_stream_texture_image.h" | 21 #include "gpu/command_buffer/service/gl_stream_texture_image.h" |
20 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" | 22 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" |
21 #include "gpu/command_buffer/service/gpu_service_test.h" | 23 #include "gpu/command_buffer/service/gpu_service_test.h" |
22 #include "gpu/command_buffer/service/mailbox_manager.h" | 24 #include "gpu/command_buffer/service/mailbox_manager.h" |
23 #include "gpu/command_buffer/service/memory_tracking.h" | 25 #include "gpu/command_buffer/service/memory_tracking.h" |
24 #include "gpu/command_buffer/service/mocks.h" | 26 #include "gpu/command_buffer/service/mocks.h" |
25 #include "gpu/command_buffer/service/service_discardable_manager.h" | 27 #include "gpu/command_buffer/service/service_discardable_manager.h" |
26 #include "gpu/command_buffer/service/test_helper.h" | 28 #include "gpu/command_buffer/service/test_helper.h" |
| 29 #include "gpu/config/gpu_switches.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "ui/gl/gl_image_stub.h" | 31 #include "ui/gl/gl_image_stub.h" |
29 #include "ui/gl/gl_mock.h" | 32 #include "ui/gl/gl_mock.h" |
30 #include "ui/gl/gl_switches.h" | 33 #include "ui/gl/gl_switches.h" |
31 | 34 |
32 using ::testing::AtLeast; | 35 using ::testing::AtLeast; |
33 using ::testing::Pointee; | 36 using ::testing::Pointee; |
34 using ::testing::Return; | 37 using ::testing::Return; |
35 using ::testing::SetArgPointee; | 38 using ::testing::SetArgPointee; |
36 using ::testing::StrictMock; | 39 using ::testing::StrictMock; |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 GL_TEXTURE_SWIZZLE_R, GL_ALPHA); | 641 GL_TEXTURE_SWIZZLE_R, GL_ALPHA); |
639 manager.SetParameteri("TexParameteri", error_state_.get(), texture_ref.get(), | 642 manager.SetParameteri("TexParameteri", error_state_.get(), texture_ref.get(), |
640 GL_TEXTURE_SWIZZLE_A, GL_GREEN); | 643 GL_TEXTURE_SWIZZLE_A, GL_GREEN); |
641 | 644 |
642 EXPECT_CALL(*gl_, DeleteTextures(1, ::testing::Pointee(kServiceId))) | 645 EXPECT_CALL(*gl_, DeleteTextures(1, ::testing::Pointee(kServiceId))) |
643 .Times(1) | 646 .Times(1) |
644 .RetiresOnSaturation(); | 647 .RetiresOnSaturation(); |
645 manager.RemoveTexture(kClientId); | 648 manager.RemoveTexture(kClientId); |
646 } | 649 } |
647 | 650 |
| 651 // Test texture base level is set before texImage2D when workaround |
| 652 // RESET_TEXIMAGE2D_BASE_LEVEL is enabled |
| 653 TEST_F(TextureManagerTest, SetTextureBaseLevelBeforeTexImage2D) { |
| 654 GpuDriverBugWorkarounds gpu_driver_bug_workaround; |
| 655 gpu_driver_bug_workaround.reset_teximage2d_base_level = true; |
| 656 feature_info_ = new FeatureInfo(gpu_driver_bug_workaround); |
| 657 |
| 658 SetupFeatureInfo("", "OpenGL ES 3.0", CONTEXT_TYPE_OPENGLES3); |
| 659 TestHelper::SetupTextureManagerInitExpectations(gl_.get(), true, true, false, |
| 660 "", kUseDefaultTextures); |
| 661 TextureManager manager(nullptr, feature_info_.get(), kMaxTextureSize, |
| 662 kMaxCubeMapTextureSize, kMaxRectangleTextureSize, |
| 663 kMax3DTextureSize, kMaxArrayTextureLayers, |
| 664 kUseDefaultTextures, nullptr, &discardable_manager_); |
| 665 manager.Initialize(); |
| 666 |
| 667 // Create a texture. |
| 668 const GLuint kClientId = 1; |
| 669 const GLuint kServiceId = 11; |
| 670 manager.CreateTexture(kClientId, kServiceId); |
| 671 scoped_refptr<TextureRef> texture_ref(manager.GetTexture(kClientId)); |
| 672 manager.SetTarget(texture_ref.get(), GL_TEXTURE_2D); |
| 673 GLint base_level = 2; |
| 674 GLint width = 4; |
| 675 GLint height = 4; |
| 676 manager.SetLevelInfo(texture_ref.get(), GL_TEXTURE_2D, base_level, GL_RGBA, |
| 677 width, height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 678 gfx::Rect(4, 4)); |
| 679 |
| 680 SetParameter(texture_ref.get(), GL_TEXTURE_BASE_LEVEL, base_level, |
| 681 GL_NO_ERROR); |
| 682 |
| 683 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0)) |
| 684 .Times(1) |
| 685 .RetiresOnSaturation(); |
| 686 EXPECT_CALL(*gl_, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, |
| 687 GL_UNSIGNED_BYTE, nullptr)) |
| 688 .Times(1) |
| 689 .RetiresOnSaturation(); |
| 690 EXPECT_CALL(*gl_, |
| 691 TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, base_level)) |
| 692 .Times(1) |
| 693 .RetiresOnSaturation(); |
| 694 |
| 695 TextureManager::DoTexImageArguments args = { |
| 696 GL_TEXTURE_2D, |
| 697 0, |
| 698 GL_RGBA, |
| 699 1, |
| 700 1, |
| 701 1, |
| 702 0, |
| 703 GL_RGBA, |
| 704 GL_UNSIGNED_BYTE, |
| 705 nullptr, |
| 706 0, |
| 707 0, |
| 708 TextureManager::DoTexImageArguments::kTexImage2D}; |
| 709 EXPECT_CALL(*gl_, GetError()) |
| 710 .WillOnce(Return(GL_NO_ERROR)) |
| 711 .WillOnce(Return(GL_NO_ERROR)) |
| 712 .RetiresOnSaturation(); |
| 713 DecoderTextureState texture_state_(feature_info_->workarounds()); |
| 714 texture_state_.tex_image_failed = true; |
| 715 DecoderFramebufferState framebuffer_state_; |
| 716 ContextState state_(feature_info_.get(), NULL, NULL); |
| 717 const char* func_name = "glTexImage2D"; |
| 718 manager.DoTexImage(&texture_state_, &state_, &framebuffer_state_, func_name, |
| 719 texture_ref.get(), args); |
| 720 |
| 721 EXPECT_CALL(*gl_, DeleteTextures(1, ::testing::Pointee(kServiceId))) |
| 722 .Times(1) |
| 723 .RetiresOnSaturation(); |
| 724 manager.RemoveTexture(kClientId); |
| 725 } |
| 726 |
648 class TextureTestBase : public GpuServiceTest { | 727 class TextureTestBase : public GpuServiceTest { |
649 public: | 728 public: |
650 static const GLint kMaxTextureSize = 32; | 729 static const GLint kMaxTextureSize = 32; |
651 static const GLint kMaxCubeMapTextureSize = 8; | 730 static const GLint kMaxCubeMapTextureSize = 8; |
652 static const GLint kMaxRectangleTextureSize = 32; | 731 static const GLint kMaxRectangleTextureSize = 32; |
653 static const GLint kMax3DTextureSize = 512; | 732 static const GLint kMax3DTextureSize = 512; |
654 static const GLint kMaxArrayTextureLayers = 256; | 733 static const GLint kMaxArrayTextureLayers = 256; |
655 static const GLint kMax2dLevels = 6; | 734 static const GLint kMax2dLevels = 6; |
656 static const GLint kMaxCubeMapLevels = 4; | 735 static const GLint kMaxCubeMapLevels = 4; |
657 static const GLuint kClient1Id = 1; | 736 static const GLuint kClient1Id = 1; |
(...skipping 2068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2726 ExpectValid( | 2805 ExpectValid( |
2727 true, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8); | 2806 true, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8); |
2728 ExpectValid(true, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, | 2807 ExpectValid(true, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, |
2729 GL_DEPTH32F_STENCIL8); | 2808 GL_DEPTH32F_STENCIL8); |
2730 | 2809 |
2731 ExpectInvalid(true, GL_RGB_INTEGER, GL_INT, GL_RGBA8); | 2810 ExpectInvalid(true, GL_RGB_INTEGER, GL_INT, GL_RGBA8); |
2732 } | 2811 } |
2733 | 2812 |
2734 } // namespace gles2 | 2813 } // namespace gles2 |
2735 } // namespace gpu | 2814 } // namespace gpu |
OLD | NEW |