Commit 188d11b3 authored by alokp@chromium.org's avatar alokp@chromium.org

cc: Do not limit number of raster tasks for upload limit.

BUG=368936

Review URL: https://codereview.chromium.org/270333003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269617 0039d316-1c4b-4281-b951-d872f2087c98
parent 7a4f405c
...@@ -369,14 +369,12 @@ scoped_ptr<TileManager> TileManager::Create( ...@@ -369,14 +369,12 @@ scoped_ptr<TileManager> TileManager::Create(
ResourcePool* resource_pool, ResourcePool* resource_pool,
Rasterizer* rasterizer, Rasterizer* rasterizer,
Rasterizer* gpu_rasterizer, Rasterizer* gpu_rasterizer,
size_t max_raster_usage_bytes,
bool use_rasterize_on_demand, bool use_rasterize_on_demand,
RenderingStatsInstrumentation* rendering_stats_instrumentation) { RenderingStatsInstrumentation* rendering_stats_instrumentation) {
return make_scoped_ptr(new TileManager(client, return make_scoped_ptr(new TileManager(client,
resource_pool, resource_pool,
rasterizer, rasterizer,
gpu_rasterizer, gpu_rasterizer,
max_raster_usage_bytes,
use_rasterize_on_demand, use_rasterize_on_demand,
rendering_stats_instrumentation)); rendering_stats_instrumentation));
} }
...@@ -386,7 +384,6 @@ TileManager::TileManager( ...@@ -386,7 +384,6 @@ TileManager::TileManager(
ResourcePool* resource_pool, ResourcePool* resource_pool,
Rasterizer* rasterizer, Rasterizer* rasterizer,
Rasterizer* gpu_rasterizer, Rasterizer* gpu_rasterizer,
size_t max_raster_usage_bytes,
bool use_rasterize_on_demand, bool use_rasterize_on_demand,
RenderingStatsInstrumentation* rendering_stats_instrumentation) RenderingStatsInstrumentation* rendering_stats_instrumentation)
: client_(client), : client_(client),
...@@ -398,7 +395,6 @@ TileManager::TileManager( ...@@ -398,7 +395,6 @@ TileManager::TileManager(
memory_nice_to_have_bytes_(0), memory_nice_to_have_bytes_(0),
bytes_releasable_(0), bytes_releasable_(0),
resources_releasable_(0), resources_releasable_(0),
max_raster_usage_bytes_(max_raster_usage_bytes),
ever_exceeded_memory_budget_(false), ever_exceeded_memory_budget_(false),
rendering_stats_instrumentation_(rendering_stats_instrumentation), rendering_stats_instrumentation_(rendering_stats_instrumentation),
did_initialize_visible_tile_(false), did_initialize_visible_tile_(false),
...@@ -829,14 +825,6 @@ void TileManager::AssignGpuMemoryToTiles( ...@@ -829,14 +825,6 @@ void TileManager::AssignGpuMemoryToTiles(
bool oomed_hard = false; bool oomed_hard = false;
bool have_hit_soft_memory = false; // Soft memory comes after hard. bool have_hit_soft_memory = false; // Soft memory comes after hard.
// Memory we assign to raster tasks now will be deducted from our memory
// in future iterations if priorities change. By assigning at most half
// the raster limit, we will always have another 50% left even if priorities
// change completely (assuming we check for completed/cancelled rasters
// between each call to this function).
size_t max_raster_bytes = max_raster_usage_bytes_ / 2;
size_t raster_bytes = 0;
unsigned schedule_priority = 1u; unsigned schedule_priority = 1u;
for (PrioritizedTileSet::Iterator it(tiles, true); it; ++it) { for (PrioritizedTileSet::Iterator it(tiles, true); it; ++it) {
Tile* tile = *it; Tile* tile = *it;
...@@ -861,7 +849,6 @@ void TileManager::AssignGpuMemoryToTiles( ...@@ -861,7 +849,6 @@ void TileManager::AssignGpuMemoryToTiles(
const bool tile_uses_hard_limit = mts.bin <= NOW_BIN; const bool tile_uses_hard_limit = mts.bin <= NOW_BIN;
const size_t bytes_if_allocated = BytesConsumedIfAllocated(tile); const size_t bytes_if_allocated = BytesConsumedIfAllocated(tile);
const size_t raster_bytes_if_rastered = raster_bytes + bytes_if_allocated;
const size_t tile_bytes_left = const size_t tile_bytes_left =
(tile_uses_hard_limit) ? hard_bytes_left : soft_bytes_left; (tile_uses_hard_limit) ? hard_bytes_left : soft_bytes_left;
...@@ -885,7 +872,9 @@ void TileManager::AssignGpuMemoryToTiles( ...@@ -885,7 +872,9 @@ void TileManager::AssignGpuMemoryToTiles(
// Allow lower priority tiles with initialized resources to keep // Allow lower priority tiles with initialized resources to keep
// their memory by only assigning memory to new raster tasks if // their memory by only assigning memory to new raster tasks if
// they can be scheduled. // they can be scheduled.
if (raster_bytes_if_rastered <= max_raster_bytes) { bool reached_scheduled_raster_tasks_limit =
tiles_that_need_to_be_rasterized->size() >= kScheduledRasterTasksLimit;
if (!reached_scheduled_raster_tasks_limit) {
// If we don't have the required version, and it's not in flight // If we don't have the required version, and it's not in flight
// then we'll have to pay to create a new task. // then we'll have to pay to create a new task.
if (!tile_version.resource_ && !tile_version.raster_task_) { if (!tile_version.resource_ && !tile_version.raster_task_) {
...@@ -929,8 +918,7 @@ void TileManager::AssignGpuMemoryToTiles( ...@@ -929,8 +918,7 @@ void TileManager::AssignGpuMemoryToTiles(
// 2. Tiles with existing raster task could otherwise incorrectly // 2. Tiles with existing raster task could otherwise incorrectly
// be added as they are not affected by |bytes_allocatable|. // be added as they are not affected by |bytes_allocatable|.
bool can_schedule_tile = bool can_schedule_tile =
!oomed_soft && raster_bytes_if_rastered <= max_raster_bytes && !oomed_soft && !reached_scheduled_raster_tasks_limit;
tiles_that_need_to_be_rasterized->size() < kScheduledRasterTasksLimit;
if (!can_schedule_tile) { if (!can_schedule_tile) {
all_tiles_that_need_to_be_rasterized_have_memory_ = false; all_tiles_that_need_to_be_rasterized_have_memory_ = false;
...@@ -940,7 +928,6 @@ void TileManager::AssignGpuMemoryToTiles( ...@@ -940,7 +928,6 @@ void TileManager::AssignGpuMemoryToTiles(
continue; continue;
} }
raster_bytes = raster_bytes_if_rastered;
tiles_that_need_to_be_rasterized->push_back(tile); tiles_that_need_to_be_rasterized->push_back(tile);
} }
......
...@@ -158,7 +158,6 @@ class CC_EXPORT TileManager : public RasterizerClient, ...@@ -158,7 +158,6 @@ class CC_EXPORT TileManager : public RasterizerClient,
ResourcePool* resource_pool, ResourcePool* resource_pool,
Rasterizer* rasterizer, Rasterizer* rasterizer,
Rasterizer* gpu_rasterizer, Rasterizer* gpu_rasterizer,
size_t max_raster_usage_bytes,
bool use_rasterize_on_demand, bool use_rasterize_on_demand,
RenderingStatsInstrumentation* rendering_stats_instrumentation); RenderingStatsInstrumentation* rendering_stats_instrumentation);
virtual ~TileManager(); virtual ~TileManager();
...@@ -230,7 +229,6 @@ class CC_EXPORT TileManager : public RasterizerClient, ...@@ -230,7 +229,6 @@ class CC_EXPORT TileManager : public RasterizerClient,
ResourcePool* resource_pool, ResourcePool* resource_pool,
Rasterizer* rasterizer, Rasterizer* rasterizer,
Rasterizer* gpu_rasterizer, Rasterizer* gpu_rasterizer,
size_t max_raster_usage_bytes,
bool use_rasterize_on_demand, bool use_rasterize_on_demand,
RenderingStatsInstrumentation* rendering_stats_instrumentation); RenderingStatsInstrumentation* rendering_stats_instrumentation);
...@@ -308,7 +306,6 @@ class CC_EXPORT TileManager : public RasterizerClient, ...@@ -308,7 +306,6 @@ class CC_EXPORT TileManager : public RasterizerClient,
size_t bytes_releasable_; size_t bytes_releasable_;
size_t resources_releasable_; size_t resources_releasable_;
size_t max_raster_usage_bytes_;
bool ever_exceeded_memory_budget_; bool ever_exceeded_memory_budget_;
MemoryHistory::Entry memory_stats_from_last_assign_; MemoryHistory::Entry memory_stats_from_last_assign_;
......
...@@ -51,9 +51,8 @@ class TileManagerPerfTest : public testing::Test { ...@@ -51,9 +51,8 @@ class TileManagerPerfTest : public testing::Test {
false); false);
resource_pool_ = ResourcePool::Create( resource_pool_ = ResourcePool::Create(
resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888); resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888);
size_t raster_task_limit_bytes = 32 * 1024 * 1024; // 16-64MB in practice. tile_manager_ = make_scoped_ptr(
tile_manager_ = make_scoped_ptr(new FakeTileManager( new FakeTileManager(&tile_manager_client_, resource_pool_.get()));
&tile_manager_client_, resource_pool_.get(), raster_task_limit_bytes));
picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile(); picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile();
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "cc/test/fake_tile_manager.h" #include "cc/test/fake_tile_manager.h"
#include <deque> #include <deque>
#include <limits>
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "cc/resources/rasterizer.h" #include "cc/resources/rasterizer.h"
...@@ -67,7 +66,6 @@ FakeTileManager::FakeTileManager(TileManagerClient* client) ...@@ -67,7 +66,6 @@ FakeTileManager::FakeTileManager(TileManagerClient* client)
NULL, NULL,
g_fake_rasterizer.Pointer(), g_fake_rasterizer.Pointer(),
g_fake_rasterizer.Pointer(), g_fake_rasterizer.Pointer(),
std::numeric_limits<unsigned>::max(),
true, true,
NULL) {} NULL) {}
...@@ -77,7 +75,6 @@ FakeTileManager::FakeTileManager(TileManagerClient* client, ...@@ -77,7 +75,6 @@ FakeTileManager::FakeTileManager(TileManagerClient* client,
resource_pool, resource_pool,
g_fake_rasterizer.Pointer(), g_fake_rasterizer.Pointer(),
g_fake_rasterizer.Pointer(), g_fake_rasterizer.Pointer(),
std::numeric_limits<unsigned>::max(),
true, true,
NULL) {} NULL) {}
...@@ -88,21 +85,9 @@ FakeTileManager::FakeTileManager(TileManagerClient* client, ...@@ -88,21 +85,9 @@ FakeTileManager::FakeTileManager(TileManagerClient* client,
resource_pool, resource_pool,
g_fake_rasterizer.Pointer(), g_fake_rasterizer.Pointer(),
g_fake_rasterizer.Pointer(), g_fake_rasterizer.Pointer(),
std::numeric_limits<unsigned>::max(),
allow_on_demand_raster, allow_on_demand_raster,
NULL) {} NULL) {}
FakeTileManager::FakeTileManager(TileManagerClient* client,
ResourcePool* resource_pool,
size_t raster_task_limit_bytes)
: TileManager(client,
resource_pool,
g_fake_rasterizer.Pointer(),
g_fake_rasterizer.Pointer(),
raster_task_limit_bytes,
true,
NULL) {}
FakeTileManager::~FakeTileManager() {} FakeTileManager::~FakeTileManager() {}
void FakeTileManager::AssignMemoryToTiles( void FakeTileManager::AssignMemoryToTiles(
......
...@@ -19,9 +19,6 @@ class FakeTileManager : public TileManager { ...@@ -19,9 +19,6 @@ class FakeTileManager : public TileManager {
FakeTileManager(TileManagerClient* client, FakeTileManager(TileManagerClient* client,
ResourcePool* resource_pool, ResourcePool* resource_pool,
bool allow_on_demand_raster); bool allow_on_demand_raster);
FakeTileManager(TileManagerClient* client,
ResourcePool* resource_pool,
size_t raster_task_limit_bytes);
virtual ~FakeTileManager(); virtual ~FakeTileManager();
bool HasBeenAssignedMemory(Tile* tile); bool HasBeenAssignedMemory(Tile* tile);
......
...@@ -67,7 +67,6 @@ TestWebGraphicsContext3D::TestWebGraphicsContext3D() ...@@ -67,7 +67,6 @@ TestWebGraphicsContext3D::TestWebGraphicsContext3D()
next_insert_sync_point_(1), next_insert_sync_point_(1),
last_waited_sync_point_(0), last_waited_sync_point_(0),
bound_buffer_(0), bound_buffer_(0),
peak_transfer_buffer_memory_used_bytes_(0),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
CreateNamespace(); CreateNamespace();
} }
...@@ -503,10 +502,6 @@ void TestWebGraphicsContext3D::bufferData(GLenum target, ...@@ -503,10 +502,6 @@ void TestWebGraphicsContext3D::bufferData(GLenum target,
buffer->size = size; buffer->size = size;
if (data != NULL) if (data != NULL)
memcpy(buffer->pixels.get(), data, size); memcpy(buffer->pixels.get(), data, size);
peak_transfer_buffer_memory_used_bytes_ =
std::max(peak_transfer_buffer_memory_used_bytes_,
GetTransferBufferMemoryUsedBytes());
} }
void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target, void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target,
...@@ -522,10 +517,6 @@ void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target, ...@@ -522,10 +517,6 @@ void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target,
--times_map_buffer_chromium_succeeds_; --times_map_buffer_chromium_succeeds_;
} }
peak_transfer_buffer_memory_used_bytes_ =
std::max(peak_transfer_buffer_memory_used_bytes_,
GetTransferBufferMemoryUsedBytes());
return buffers.get(bound_buffer_)->pixels.get(); return buffers.get(bound_buffer_)->pixels.get();
} }
......
...@@ -325,9 +325,6 @@ class TestWebGraphicsContext3D { ...@@ -325,9 +325,6 @@ class TestWebGraphicsContext3D {
size_t GetTransferBufferMemoryUsedBytes() const; size_t GetTransferBufferMemoryUsedBytes() const;
void SetMaxTransferBufferUsageBytes(size_t max_transfer_buffer_usage_bytes); void SetMaxTransferBufferUsageBytes(size_t max_transfer_buffer_usage_bytes);
size_t GetPeakTransferBufferMemoryUsedBytes() const {
return peak_transfer_buffer_memory_used_bytes_;
}
void set_test_support(TestContextSupport* test_support) { void set_test_support(TestContextSupport* test_support) {
test_support_ = test_support; test_support_ = test_support;
...@@ -439,8 +436,6 @@ class TestWebGraphicsContext3D { ...@@ -439,8 +436,6 @@ class TestWebGraphicsContext3D {
unsigned bound_buffer_; unsigned bound_buffer_;
TextureTargets texture_targets_; TextureTargets texture_targets_;
size_t peak_transfer_buffer_memory_used_bytes_;
scoped_refptr<Namespace> namespace_; scoped_refptr<Namespace> namespace_;
static Namespace* shared_namespace_; static Namespace* shared_namespace_;
......
...@@ -103,14 +103,6 @@ size_t GetMaxTransferBufferUsageBytes(cc::ContextProvider* context_provider) { ...@@ -103,14 +103,6 @@ size_t GetMaxTransferBufferUsageBytes(cc::ContextProvider* context_provider) {
kMaxTransferBufferUsageBytes); kMaxTransferBufferUsageBytes);
} }
size_t GetMaxRasterTasksUsageBytes(cc::ContextProvider* context_provider) {
// Transfer-buffer/raster-tasks limits are different but related. We make
// equal here, as this is ideal when using transfer buffers. When not using
// transfer buffers we should still limit raster to something similar, to
// preserve caching behavior (and limit memory waste when priorities change).
return GetMaxTransferBufferUsageBytes(context_provider);
}
unsigned GetMapImageTextureTarget(cc::ContextProvider* context_provider) { unsigned GetMapImageTextureTarget(cc::ContextProvider* context_provider) {
if (!context_provider) if (!context_provider)
return GL_TEXTURE_2D; return GL_TEXTURE_2D;
...@@ -1904,7 +1896,6 @@ void LayerTreeHostImpl::CreateAndSetTileManager( ...@@ -1904,7 +1896,6 @@ void LayerTreeHostImpl::CreateAndSetTileManager(
resource_pool_.get(), resource_pool_.get(),
raster_worker_pool_->AsRasterizer(), raster_worker_pool_->AsRasterizer(),
direct_raster_worker_pool_->AsRasterizer(), direct_raster_worker_pool_->AsRasterizer(),
GetMaxRasterTasksUsageBytes(context_provider),
allow_rasterize_on_demand, allow_rasterize_on_demand,
rendering_stats_instrumentation_); rendering_stats_instrumentation_);
......
...@@ -4511,7 +4511,6 @@ class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest { ...@@ -4511,7 +4511,6 @@ class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest {
protected: protected:
virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
settings->impl_side_painting = true; settings->impl_side_painting = true;
settings->default_tile_size = gfx::Size(128, 128);
} }
virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
...@@ -4542,10 +4541,7 @@ class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest { ...@@ -4542,10 +4541,7 @@ class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest {
// Expect that the transfer buffer memory used is equal to the // Expect that the transfer buffer memory used is equal to the
// MaxTransferBufferUsageBytes value set in CreateOutputSurface. // MaxTransferBufferUsageBytes value set in CreateOutputSurface.
// NOTE: This is now 1/2 due to raster memory limit in TileManager. EXPECT_EQ(1024 * 1024u, context->GetTransferBufferMemoryUsedBytes());
// Only half the limit will be reached unless the task set
// thrashes to a completly new set of tiles.
EXPECT_EQ(512 * 1024u, context->GetPeakTransferBufferMemoryUsedBytes());
EndTest(); EndTest();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment