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 "content/common/gpu/gpu_memory_allocation.h" | 5 #include "content/common/gpu/gpu_memory_allocation.h" |
6 #include "content/common/gpu/gpu_memory_manager.h" | 6 #include "content/common/gpu/gpu_memory_manager.h" |
7 #include "content/common/gpu/gpu_memory_manager_client.h" | 7 #include "content/common/gpu/gpu_memory_manager_client.h" |
8 #include "content/common/gpu/gpu_memory_tracking.h" | 8 #include "content/common/gpu/gpu_memory_tracking.h" |
9 #include "ui/gfx/size_conversions.h" | 9 #include "ui/gfx/size_conversions.h" |
10 | 10 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 157 } |
158 }; | 158 }; |
159 | 159 |
160 class GpuMemoryManagerTest : public testing::Test { | 160 class GpuMemoryManagerTest : public testing::Test { |
161 protected: | 161 protected: |
162 static const uint64 kFrontbufferLimitForTest = 3; | 162 static const uint64 kFrontbufferLimitForTest = 3; |
163 | 163 |
164 GpuMemoryManagerTest() | 164 GpuMemoryManagerTest() |
165 : memmgr_(0, kFrontbufferLimitForTest) { | 165 : memmgr_(0, kFrontbufferLimitForTest) { |
166 memmgr_.TestingDisableScheduleManage(); | 166 memmgr_.TestingDisableScheduleManage(); |
167 memmgr_.TestingSetUseNonuniformMemoryPolicy(false); | |
168 } | 167 } |
169 | 168 |
170 virtual void SetUp() { | 169 virtual void SetUp() { |
171 } | 170 } |
172 | 171 |
173 static int32 GenerateUniqueSurfaceId() { | 172 static int32 GenerateUniqueSurfaceId() { |
174 static int32 surface_id_ = 1; | 173 static int32 surface_id_ = 1; |
175 return surface_id_++; | 174 return surface_id_++; |
176 } | 175 } |
177 | 176 |
178 bool IsAllocationForegroundForSurfaceYes( | 177 bool IsAllocationForegroundForSurfaceYes( |
179 const GpuMemoryAllocation& alloc) { | 178 const GpuMemoryAllocation& alloc) { |
180 return alloc.browser_allocation.suggest_have_frontbuffer && | 179 return alloc.browser_allocation.suggest_have_frontbuffer && |
181 !alloc.renderer_allocation.have_backbuffer_when_not_visible && | 180 !alloc.renderer_allocation.have_backbuffer_when_not_visible; |
182 alloc.renderer_allocation.bytes_limit_when_visible >= | |
183 GetMinimumClientAllocation(); | |
184 } | 181 } |
185 bool IsAllocationBackgroundForSurfaceYes( | 182 bool IsAllocationBackgroundForSurfaceYes( |
186 const GpuMemoryAllocation& alloc) { | 183 const GpuMemoryAllocation& alloc) { |
187 return alloc.browser_allocation.suggest_have_frontbuffer && | 184 return alloc.browser_allocation.suggest_have_frontbuffer && |
188 !alloc.renderer_allocation.have_backbuffer_when_not_visible && | 185 !alloc.renderer_allocation.have_backbuffer_when_not_visible; |
189 alloc.renderer_allocation.bytes_limit_when_not_visible <= | |
190 memmgr_.GetCurrentNonvisibleAvailableGpuMemory(); | |
191 } | 186 } |
192 bool IsAllocationHibernatedForSurfaceYes( | 187 bool IsAllocationHibernatedForSurfaceYes( |
193 const GpuMemoryAllocation& alloc) { | 188 const GpuMemoryAllocation& alloc) { |
194 return !alloc.browser_allocation.suggest_have_frontbuffer && | 189 return !alloc.browser_allocation.suggest_have_frontbuffer && |
195 !alloc.renderer_allocation.have_backbuffer_when_not_visible && | 190 !alloc.renderer_allocation.have_backbuffer_when_not_visible; |
196 alloc.renderer_allocation.bytes_limit_when_not_visible <= | |
197 memmgr_.GetCurrentNonvisibleAvailableGpuMemory(); | |
198 } | 191 } |
199 bool IsAllocationForegroundForSurfaceNo( | 192 bool IsAllocationForegroundForSurfaceNo( |
200 const GpuMemoryAllocation& alloc) { | 193 const GpuMemoryAllocation& alloc) { |
201 return !alloc.browser_allocation.suggest_have_frontbuffer && | 194 return !alloc.browser_allocation.suggest_have_frontbuffer && |
202 !alloc.renderer_allocation.have_backbuffer_when_not_visible && | 195 !alloc.renderer_allocation.have_backbuffer_when_not_visible && |
203 alloc.renderer_allocation.bytes_limit_when_visible == | 196 alloc.renderer_allocation.bytes_limit_when_visible == |
204 GetMinimumClientAllocation(); | 197 GetMinimumClientAllocation(); |
205 } | 198 } |
206 bool IsAllocationBackgroundForSurfaceNo( | 199 bool IsAllocationBackgroundForSurfaceNo( |
207 const GpuMemoryAllocation& alloc) { | 200 const GpuMemoryAllocation& alloc) { |
(...skipping 29 matching lines...) Expand all Loading... |
237 } | 230 } |
238 | 231 |
239 uint64 GetMaximumClientAllocation() { | 232 uint64 GetMaximumClientAllocation() { |
240 return memmgr_.GetMaximumClientAllocation(); | 233 return memmgr_.GetMaximumClientAllocation(); |
241 } | 234 } |
242 | 235 |
243 uint64 GetMinimumClientAllocation() { | 236 uint64 GetMinimumClientAllocation() { |
244 return memmgr_.GetMinimumClientAllocation(); | 237 return memmgr_.GetMinimumClientAllocation(); |
245 } | 238 } |
246 | 239 |
247 GpuMemoryManager memmgr_; | |
248 }; | |
249 | |
250 class GpuMemoryManagerTestNonuniform : public GpuMemoryManagerTest { | |
251 protected: | |
252 void SetClientStats( | 240 void SetClientStats( |
253 FakeClient* client, | 241 FakeClient* client, |
254 uint64 required, | 242 uint64 required, |
255 uint64 nicetohave) { | 243 uint64 nicetohave) { |
256 client->SetManagedMemoryStats( | 244 client->SetManagedMemoryStats( |
257 GpuManagedMemoryStats(required, nicetohave, 0, false)); | 245 GpuManagedMemoryStats(required, nicetohave, 0, false)); |
258 } | 246 } |
| 247 |
| 248 GpuMemoryManager memmgr_; |
259 }; | 249 }; |
260 | 250 |
261 // Test GpuMemoryManager::Manage basic functionality. | 251 // Test GpuMemoryManager::Manage basic functionality. |
262 // Expect memory allocation to set suggest_have_frontbuffer/backbuffer | 252 // Expect memory allocation to set suggest_have_frontbuffer/backbuffer |
263 // according to visibility and last used time for stubs with surface. | 253 // according to visibility and last used time for stubs with surface. |
264 // Expect memory allocation to be shared according to share groups for stubs | 254 // Expect memory allocation to be shared according to share groups for stubs |
265 // without a surface. | 255 // without a surface. |
266 TEST_F(GpuMemoryManagerTest, TestManageBasicFunctionality) { | 256 TEST_F(GpuMemoryManagerTest, TestManageBasicFunctionality) { |
267 // Test stubs with surface. | 257 // Test stubs with surface. |
268 FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true), | 258 FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true), |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 EXPECT_EQ(8ul, memmgr_.bytes_allocated_managed_visible_); | 700 EXPECT_EQ(8ul, memmgr_.bytes_allocated_managed_visible_); |
711 EXPECT_EQ(6ul, memmgr_.bytes_allocated_managed_nonvisible_); | 701 EXPECT_EQ(6ul, memmgr_.bytes_allocated_managed_nonvisible_); |
712 | 702 |
713 // Decrease allocation amounts. | 703 // Decrease allocation amounts. |
714 stub1.SetManagedMemoryStats(GpuManagedMemoryStats(0, 0, 4, false)); | 704 stub1.SetManagedMemoryStats(GpuManagedMemoryStats(0, 0, 4, false)); |
715 stub2.SetManagedMemoryStats(GpuManagedMemoryStats(0, 0, 6, false)); | 705 stub2.SetManagedMemoryStats(GpuManagedMemoryStats(0, 0, 6, false)); |
716 EXPECT_EQ(6ul, memmgr_.bytes_allocated_managed_visible_); | 706 EXPECT_EQ(6ul, memmgr_.bytes_allocated_managed_visible_); |
717 EXPECT_EQ(4ul, memmgr_.bytes_allocated_managed_nonvisible_); | 707 EXPECT_EQ(4ul, memmgr_.bytes_allocated_managed_nonvisible_); |
718 } | 708 } |
719 | 709 |
720 // Test GpuMemoryManager's background cutoff threshoulds | |
721 TEST_F(GpuMemoryManagerTest, TestBackgroundCutoff) { | |
722 memmgr_.TestingSetAvailableGpuMemory(64); | |
723 memmgr_.TestingSetNonvisibleAvailableGpuMemory(16); | |
724 | |
725 FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); | |
726 | |
727 // stub1's requirements are not <=16, so it should just dump | |
728 // everything when it goes invisible. | |
729 stub1.SetManagedMemoryStats(GpuManagedMemoryStats(17, 24, 18, false)); | |
730 Manage(); | |
731 EXPECT_EQ(0ul, stub1.BytesWhenNotVisible()); | |
732 | |
733 // stub1 now fits, so it should have a full budget. | |
734 stub1.SetManagedMemoryStats(GpuManagedMemoryStats(16, 24, 18, false)); | |
735 Manage(); | |
736 EXPECT_EQ(memmgr_.bytes_nonvisible_available_gpu_memory_, | |
737 memmgr_.GetCurrentNonvisibleAvailableGpuMemory()); | |
738 EXPECT_EQ(memmgr_.GetCurrentNonvisibleAvailableGpuMemory(), | |
739 stub1.BytesWhenNotVisible()); | |
740 | |
741 // Background stub1. | |
742 stub1.SetManagedMemoryStats(GpuManagedMemoryStats(16, 24, 16, false)); | |
743 stub1.SetVisible(false); | |
744 | |
745 // Add stub2 that uses almost enough memory to evict | |
746 // stub1, but not quite. | |
747 FakeClient stub2(&memmgr_, GenerateUniqueSurfaceId(), true); | |
748 stub2.SetManagedMemoryStats(GpuManagedMemoryStats(16, 50, 48, false)); | |
749 Manage(); | |
750 EXPECT_EQ(memmgr_.bytes_nonvisible_available_gpu_memory_, | |
751 memmgr_.GetCurrentNonvisibleAvailableGpuMemory()); | |
752 EXPECT_EQ(memmgr_.GetCurrentNonvisibleAvailableGpuMemory(), | |
753 stub1.BytesWhenNotVisible()); | |
754 EXPECT_EQ(memmgr_.GetCurrentNonvisibleAvailableGpuMemory(), | |
755 stub2.BytesWhenNotVisible()); | |
756 | |
757 // Increase stub2 to force stub1 to be evicted. | |
758 stub2.SetManagedMemoryStats(GpuManagedMemoryStats(16, 50, 49, false)); | |
759 Manage(); | |
760 EXPECT_EQ(0ul, | |
761 stub1.BytesWhenNotVisible()); | |
762 EXPECT_EQ(memmgr_.GetCurrentNonvisibleAvailableGpuMemory(), | |
763 stub2.BytesWhenNotVisible()); | |
764 } | |
765 | |
766 // Test GpuMemoryManager's background MRU behavior | |
767 TEST_F(GpuMemoryManagerTest, TestBackgroundMru) { | |
768 memmgr_.TestingSetAvailableGpuMemory(64); | |
769 memmgr_.TestingSetNonvisibleAvailableGpuMemory(16); | |
770 | |
771 uint64 bytes_when_not_visible_expected = | |
772 memmgr_.GetCurrentNonvisibleAvailableGpuMemory(); | |
773 #if defined (OS_ANDROID) | |
774 bytes_when_not_visible_expected = 0; | |
775 #endif | |
776 | |
777 FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); | |
778 FakeClient stub2(&memmgr_, GenerateUniqueSurfaceId(), true); | |
779 FakeClient stub3(&memmgr_, GenerateUniqueSurfaceId(), true); | |
780 | |
781 // When all are visible, they should all be allowed to have memory | |
782 // should they become nonvisible. | |
783 stub1.SetManagedMemoryStats(GpuManagedMemoryStats(7, 24, 7, false)); | |
784 stub2.SetManagedMemoryStats(GpuManagedMemoryStats(7, 24, 7, false)); | |
785 stub3.SetManagedMemoryStats(GpuManagedMemoryStats(7, 24, 7, false)); | |
786 Manage(); | |
787 EXPECT_EQ(memmgr_.bytes_nonvisible_available_gpu_memory_, | |
788 memmgr_.GetCurrentNonvisibleAvailableGpuMemory()); | |
789 EXPECT_EQ(stub1.BytesWhenNotVisible(), | |
790 bytes_when_not_visible_expected); | |
791 EXPECT_EQ(stub2.BytesWhenNotVisible(), | |
792 bytes_when_not_visible_expected); | |
793 EXPECT_EQ(stub3.BytesWhenNotVisible(), | |
794 bytes_when_not_visible_expected); | |
795 | |
796 // Background stubs 1 and 2, and they should fit | |
797 stub2.SetVisible(false); | |
798 stub1.SetVisible(false); | |
799 Manage(); | |
800 EXPECT_EQ(memmgr_.bytes_nonvisible_available_gpu_memory_, | |
801 bytes_when_not_visible_expected); | |
802 EXPECT_EQ(stub1.BytesWhenNotVisible(), | |
803 bytes_when_not_visible_expected); | |
804 EXPECT_EQ(stub2.BytesWhenNotVisible(), | |
805 bytes_when_not_visible_expected); | |
806 EXPECT_EQ(stub3.BytesWhenNotVisible(), | |
807 bytes_when_not_visible_expected); | |
808 | |
809 // Now background stub 3, and it should cause stub 2 to be | |
810 // evicted because it was set non-visible first | |
811 stub3.SetVisible(false); | |
812 Manage(); | |
813 EXPECT_EQ(memmgr_.bytes_nonvisible_available_gpu_memory_, | |
814 memmgr_.GetCurrentNonvisibleAvailableGpuMemory()); | |
815 EXPECT_EQ(stub1.BytesWhenNotVisible(), | |
816 bytes_when_not_visible_expected); | |
817 EXPECT_EQ(stub2.BytesWhenNotVisible(), | |
818 0ul); | |
819 EXPECT_EQ(stub3.BytesWhenNotVisible(), | |
820 bytes_when_not_visible_expected); | |
821 } | |
822 | |
823 // Test GpuMemoryManager's tracking of unmanaged (e.g, WebGL) memory. | |
824 TEST_F(GpuMemoryManagerTest, TestUnmanagedTracking) { | |
825 memmgr_.TestingSetAvailableGpuMemory(64); | |
826 memmgr_.TestingSetNonvisibleAvailableGpuMemory(16); | |
827 memmgr_.TestingSetUnmanagedLimitStep(16); | |
828 memmgr_.TestingSetMinimumClientAllocation(8); | |
829 | |
830 FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); | |
831 | |
832 // Expect that the one stub get the maximum tab allocation. | |
833 Manage(); | |
834 EXPECT_EQ(memmgr_.GetMaximumClientAllocation(), | |
835 stub1.BytesWhenVisible()); | |
836 | |
837 // Now allocate some unmanaged memory and make sure the amount | |
838 // goes down. | |
839 memmgr_.TrackMemoryAllocatedChange( | |
840 stub1.tracking_group_.get(), | |
841 0, | |
842 48, | |
843 gpu::gles2::MemoryTracker::kUnmanaged); | |
844 Manage(); | |
845 EXPECT_GT(memmgr_.GetMaximumClientAllocation(), | |
846 stub1.BytesWhenVisible()); | |
847 | |
848 // Now allocate the entire FB worth of unmanaged memory, and | |
849 // make sure that we stay stuck at the minimum tab allocation. | |
850 memmgr_.TrackMemoryAllocatedChange( | |
851 stub1.tracking_group_.get(), | |
852 48, | |
853 64, | |
854 gpu::gles2::MemoryTracker::kUnmanaged); | |
855 Manage(); | |
856 EXPECT_EQ(memmgr_.GetMinimumClientAllocation(), | |
857 stub1.BytesWhenVisible()); | |
858 | |
859 // Far-oversubscribe the entire FB, and make sure we stay at | |
860 // the minimum allocation, and don't blow up. | |
861 memmgr_.TrackMemoryAllocatedChange( | |
862 stub1.tracking_group_.get(), | |
863 64, | |
864 999, | |
865 gpu::gles2::MemoryTracker::kUnmanaged); | |
866 Manage(); | |
867 EXPECT_EQ(memmgr_.GetMinimumClientAllocation(), | |
868 stub1.BytesWhenVisible()); | |
869 | |
870 // Delete all tracked memory so we don't hit leak checks. | |
871 memmgr_.TrackMemoryAllocatedChange( | |
872 stub1.tracking_group_.get(), | |
873 999, | |
874 0, | |
875 gpu::gles2::MemoryTracker::kUnmanaged); | |
876 } | |
877 | |
878 // Test nonvisible MRU behavior (the most recently used nonvisible clients | 710 // Test nonvisible MRU behavior (the most recently used nonvisible clients |
879 // keep their contents). | 711 // keep their contents). |
880 TEST_F(GpuMemoryManagerTestNonuniform, BackgroundMru) { | 712 TEST_F(GpuMemoryManagerTest, BackgroundMru) { |
881 // Set memory manager constants for this test | 713 // Set memory manager constants for this test. Note that the budget |
882 memmgr_.TestingSetUseNonuniformMemoryPolicy(true); | 714 // for backgrounded content will be 64/4 = 16. |
883 memmgr_.TestingSetAvailableGpuMemory(64); | 715 memmgr_.TestingSetAvailableGpuMemory(64); |
884 memmgr_.TestingSetNonvisibleAvailableGpuMemory(16); | |
885 memmgr_.TestingSetMinimumClientAllocation(8); | 716 memmgr_.TestingSetMinimumClientAllocation(8); |
886 | 717 |
887 uint64 bytes_when_not_visible_expected = 6u; | 718 uint64 bytes_when_not_visible_expected = 6u; |
888 #if defined (OS_ANDROID) | 719 #if defined (OS_ANDROID) |
889 bytes_when_not_visible_expected = 0; | 720 bytes_when_not_visible_expected = 0; |
890 #endif | 721 #endif |
891 | 722 |
892 FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); | 723 FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); |
893 FakeClient stub2(&memmgr_, GenerateUniqueSurfaceId(), true); | 724 FakeClient stub2(&memmgr_, GenerateUniqueSurfaceId(), true); |
894 FakeClient stub3(&memmgr_, GenerateUniqueSurfaceId(), true); | 725 FakeClient stub3(&memmgr_, GenerateUniqueSurfaceId(), true); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 // evicted because it was set non-visible first | 758 // evicted because it was set non-visible first |
928 stub3.SetVisible(false); | 759 stub3.SetVisible(false); |
929 Manage(); | 760 Manage(); |
930 EXPECT_GE(stub1.BytesWhenNotVisible(), bytes_when_not_visible_expected); | 761 EXPECT_GE(stub1.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
931 EXPECT_EQ(stub2.BytesWhenNotVisible(), 0u); | 762 EXPECT_EQ(stub2.BytesWhenNotVisible(), 0u); |
932 EXPECT_GE(stub3.BytesWhenNotVisible(), bytes_when_not_visible_expected); | 763 EXPECT_GE(stub3.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
933 } | 764 } |
934 | 765 |
935 // Test that once a backgrounded client has dropped its resources, it | 766 // Test that once a backgrounded client has dropped its resources, it |
936 // doesn't get them back until it becomes visible again. | 767 // doesn't get them back until it becomes visible again. |
937 TEST_F(GpuMemoryManagerTestNonuniform, BackgroundDiscardPersistent) { | 768 TEST_F(GpuMemoryManagerTest, BackgroundDiscardPersistent) { |
938 // Set memory manager constants for this test | 769 // Set memory manager constants for this test. Note that the budget |
939 memmgr_.TestingSetUseNonuniformMemoryPolicy(true); | 770 // for backgrounded content will be 64/4 = 16. |
940 memmgr_.TestingSetAvailableGpuMemory(64); | 771 memmgr_.TestingSetAvailableGpuMemory(64); |
941 memmgr_.TestingSetNonvisibleAvailableGpuMemory(16); | |
942 memmgr_.TestingSetMinimumClientAllocation(8); | 772 memmgr_.TestingSetMinimumClientAllocation(8); |
943 | 773 |
944 uint64 bytes_when_not_visible_expected = 10ul; | 774 uint64 bytes_when_not_visible_expected = 10ul; |
945 #if defined (OS_ANDROID) | 775 #if defined (OS_ANDROID) |
946 bytes_when_not_visible_expected = 0; | 776 bytes_when_not_visible_expected = 0; |
947 #endif | 777 #endif |
948 | 778 |
949 FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); | 779 FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); |
950 FakeClient stub2(&memmgr_, GenerateUniqueSurfaceId(), true); | 780 FakeClient stub2(&memmgr_, GenerateUniqueSurfaceId(), true); |
951 | 781 |
(...skipping 17 matching lines...) Expand all Loading... |
969 // retain them next time it is made nonvisible. | 799 // retain them next time it is made nonvisible. |
970 stub2.SetVisible(true); | 800 stub2.SetVisible(true); |
971 Manage(); | 801 Manage(); |
972 EXPECT_GE(stub2.BytesWhenNotVisible(), bytes_when_not_visible_expected); | 802 EXPECT_GE(stub2.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
973 stub2.SetVisible(false); | 803 stub2.SetVisible(false); |
974 Manage(); | 804 Manage(); |
975 EXPECT_GE(stub2.BytesWhenNotVisible(), bytes_when_not_visible_expected); | 805 EXPECT_GE(stub2.BytesWhenNotVisible(), bytes_when_not_visible_expected); |
976 } | 806 } |
977 | 807 |
978 // Test tracking of unmanaged (e.g, WebGL) memory. | 808 // Test tracking of unmanaged (e.g, WebGL) memory. |
979 TEST_F(GpuMemoryManagerTestNonuniform, UnmanagedTracking) { | 809 TEST_F(GpuMemoryManagerTest, UnmanagedTracking) { |
980 // Set memory manager constants for this test | 810 // Set memory manager constants for this test |
981 memmgr_.TestingSetUseNonuniformMemoryPolicy(true); | |
982 memmgr_.TestingSetAvailableGpuMemory(64); | 811 memmgr_.TestingSetAvailableGpuMemory(64); |
983 memmgr_.TestingSetNonvisibleAvailableGpuMemory(16); | |
984 memmgr_.TestingSetMinimumClientAllocation(8); | 812 memmgr_.TestingSetMinimumClientAllocation(8); |
985 memmgr_.TestingSetUnmanagedLimitStep(16); | 813 memmgr_.TestingSetUnmanagedLimitStep(16); |
986 | 814 |
987 FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); | 815 FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); |
988 | 816 |
989 // Expect that the one stub get its nicetohave level. | 817 // Expect that the one stub get its nicetohave level. |
990 SetClientStats(&stub1, 16, 32); | 818 SetClientStats(&stub1, 16, 32); |
991 Manage(); | 819 Manage(); |
992 EXPECT_GE(stub1.BytesWhenVisible(), 32u); | 820 EXPECT_GE(stub1.BytesWhenVisible(), 32u); |
993 | 821 |
(...skipping 29 matching lines...) Expand all Loading... |
1023 | 851 |
1024 // Delete all tracked memory so we don't hit leak checks. | 852 // Delete all tracked memory so we don't hit leak checks. |
1025 memmgr_.TrackMemoryAllocatedChange( | 853 memmgr_.TrackMemoryAllocatedChange( |
1026 stub1.tracking_group_.get(), | 854 stub1.tracking_group_.get(), |
1027 999, | 855 999, |
1028 0, | 856 0, |
1029 gpu::gles2::MemoryTracker::kUnmanaged); | 857 gpu::gles2::MemoryTracker::kUnmanaged); |
1030 } | 858 } |
1031 | 859 |
1032 // Test the default allocation levels are used. | 860 // Test the default allocation levels are used. |
1033 TEST_F(GpuMemoryManagerTestNonuniform, DefaultAllocation) { | 861 TEST_F(GpuMemoryManagerTest, DefaultAllocation) { |
1034 // Set memory manager constants for this test | 862 // Set memory manager constants for this test |
1035 memmgr_.TestingSetUseNonuniformMemoryPolicy(true); | |
1036 memmgr_.TestingSetAvailableGpuMemory(64); | 863 memmgr_.TestingSetAvailableGpuMemory(64); |
1037 memmgr_.TestingSetNonvisibleAvailableGpuMemory(16); | |
1038 memmgr_.TestingSetMinimumClientAllocation(8); | 864 memmgr_.TestingSetMinimumClientAllocation(8); |
1039 memmgr_.TestingSetDefaultClientAllocation(16); | 865 memmgr_.TestingSetDefaultClientAllocation(16); |
1040 | 866 |
1041 FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); | 867 FakeClient stub1(&memmgr_, GenerateUniqueSurfaceId(), true); |
1042 | 868 |
1043 // Expect that a client which has not sent stats receive at | 869 // Expect that a client which has not sent stats receive at |
1044 // least the default allocation. | 870 // least the default allocation. |
1045 Manage(); | 871 Manage(); |
1046 EXPECT_GE(stub1.BytesWhenVisible(), | 872 EXPECT_GE(stub1.BytesWhenVisible(), |
1047 memmgr_.GetDefaultClientAllocation()); | 873 memmgr_.GetDefaultClientAllocation()); |
1048 EXPECT_EQ(stub1.BytesWhenNotVisible(), 0u); | 874 EXPECT_EQ(stub1.BytesWhenNotVisible(), 0u); |
1049 } | 875 } |
1050 | 876 |
1051 } // namespace content | 877 } // namespace content |
OLD | NEW |