Skip to content

Commit

Permalink
Revert of Allow one-copy task tile worker pool to use compressed text…
Browse files Browse the repository at this point in the history
…ures. (patchset chromium#14 id:260001 of https://codereview.chromium.org/1379783002/ )

Reason for revert:
Resulted in linux-release/sizes/chrome-si/initializers failure:

https://build.chromium.org/p/chromium/builders/Mac/builds/9905
https://build.chromium.org/p/chromium/builders/Linux/builds/69200

26a27
> # texture_compressor_etc1_sse.cc _GLOBAL__sub_I_texture_compressor_etc1_sse.cc+0xb
29c30
< # Found 28 static initializers in 8 files.
---
> # Found 29 static initializers in 9 files.

If this is intended, please update corresponding performance test expectations.

Original issue's description:
> Allow one-copy and zero-copy task tile worker pools to use compressed textures.
>
> BUG=434699
> CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
>
> Committed: https://crrev.com/7d60ce9a132a88ead407a2a58c91edc431e68259
> Cr-Commit-Position: refs/heads/master@{#364326}

TBR=reveman@chromium.org,nyquist@chromium.org,piman@chromium.org,sievers@chromium.org,christiank@opera.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=434699

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

Cr-Commit-Position: refs/heads/master@{#364342}
  • Loading branch information
engedy authored and Commit bot committed Dec 10, 2015
1 parent 5eb722f commit ce04862
Show file tree
Hide file tree
Showing 27 changed files with 116 additions and 250 deletions.
3 changes: 1 addition & 2 deletions blimp/client/compositor/blimp_layer_tree_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ void PopulateCommonLayerTreeSettings(cc::LayerTreeSettings* settings) {
settings->renderer_settings.highp_threshold_min = 2048;
settings->ignore_root_layer_flings = false;
bool use_low_memory_policy = base::SysInfo::IsLowEndDevice();
settings->renderer_settings.use_rgba_4444_textures = use_low_memory_policy;
if (use_low_memory_policy) {
// On low-end we want to be very carefull about killing other
// apps. So initially we use 50% more memory to avoid flickering
// or raster-on-demand.
settings->max_memory_for_prepaint_percentage = 67;

settings->renderer_settings.preferred_tile_format = cc::RGBA_4444;
} else {
// On other devices we have increased memory excessively to avoid
// raster-on-demand already, so now we reserve 50% _only_ to avoid
Expand Down
3 changes: 0 additions & 3 deletions cc/base/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ const char kStrictLayerPropertyChangeChecking[] =
const char kEnablePropertyTreeVerification[] =
"enable-property-tree-verification";

// Compress tile textures for GPUs supporting it.
const char kEnableTileCompression[] = "enable-tile-compression";

// Use a BeginFrame signal from browser to renderer to schedule rendering.
const char kEnableBeginFrameScheduling[] = "enable-begin-frame-scheduling";

Expand Down
1 change: 0 additions & 1 deletion cc/base/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ CC_EXPORT extern const char kTopControlsShowThreshold[];
CC_EXPORT extern const char kSlowDownRasterScaleFactor[];
CC_EXPORT extern const char kStrictLayerPropertyChangeChecking[];
CC_EXPORT extern const char kEnablePropertyTreeVerification[];
CC_EXPORT extern const char kEnableTileCompression[];

// Switches for both the renderer and ui compositors.
CC_EXPORT extern const char kEnableBeginFrameScheduling[];
Expand Down
8 changes: 0 additions & 8 deletions cc/layers/picture_layer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ const int kMinHeightForGpuRasteredTile = 256;
// of using the same tile size.
const int kTileRoundUp = 64;

// For performance reasons and to support compressed tile textures, tile
// width and height should be an even multiple of 4 in size.
const int kTileMinimalAlignment = 4;

} // namespace

namespace cc {
Expand Down Expand Up @@ -771,10 +767,6 @@ gfx::Size PictureLayerImpl::CalculateTileSize(
tile_height = std::min(tile_height, default_tile_height);
}

// Ensure that tile width and height are properly aligned.
tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileMinimalAlignment);
tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileMinimalAlignment);

// Under no circumstance should we be larger than the max texture size.
tile_width = std::min(tile_width, max_texture_size);
tile_height = std::min(tile_height, max_texture_size);
Expand Down
10 changes: 4 additions & 6 deletions cc/layers/picture_layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4984,18 +4984,16 @@ TEST_F(TileSizeTest, TileSizes) {

layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size());
result = layer->CalculateTileSize(gfx::Size(10000, 10000));
EXPECT_EQ(result.width(),
MathUtil::UncheckedRoundUp(
2000 + 2 * PictureLayerTiling::kBorderTexels, 4));
EXPECT_EQ(result.height(), 504); // 500 + 2, 4-byte aligned.
EXPECT_EQ(result.width(), 2000 + 2 * PictureLayerTiling::kBorderTexels);
EXPECT_EQ(result.height(), 500 + 2);

// Clamp and round-up, when smaller than viewport.
// Tile-height doubles to 50% when width shrinks to <= 50%.
host_impl_.SetViewportSize(gfx::Size(1000, 1000));
layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size());
result = layer->CalculateTileSize(gfx::Size(447, 10000));
EXPECT_EQ(result.width(), 448);
EXPECT_EQ(result.height(), 504); // 500 + 2, 4-byte aliged.
EXPECT_EQ(result.height(), 500 + 2);

// Largest layer is 50% of viewport width (rounded up), and
// 50% of viewport in height.
Expand All @@ -5004,7 +5002,7 @@ TEST_F(TileSizeTest, TileSizes) {
EXPECT_EQ(result.height(), 448);
result = layer->CalculateTileSize(gfx::Size(500, 499));
EXPECT_EQ(result.width(), 512);
EXPECT_EQ(result.height(), 504); // 500 + 2, 4-byte aligned.
EXPECT_EQ(result.height(), 500 + 2);
}

TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) {
Expand Down
17 changes: 6 additions & 11 deletions cc/output/renderer_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "base/logging.h"
#include "cc/proto/renderer_settings.pb.h"
#include "cc/resources/platform_color.h"

namespace cc {

Expand All @@ -23,9 +22,9 @@ RendererSettings::RendererSettings()
delay_releasing_overlay_resources(false),
refresh_rate(60.0),
highp_threshold_min(0),
use_rgba_4444_textures(false),
texture_id_allocation_chunk_size(64),
use_gpu_memory_buffer_resources(false),
preferred_tile_format(PlatformColor::BestTextureFormat()) {}
use_gpu_memory_buffer_resources(false) {}

RendererSettings::~RendererSettings() {
}
Expand All @@ -42,9 +41,9 @@ void RendererSettings::ToProtobuf(proto::RendererSettings* proto) const {
delay_releasing_overlay_resources);
proto->set_refresh_rate(refresh_rate);
proto->set_highp_threshold_min(highp_threshold_min);
proto->set_use_rgba_4444_textures(use_rgba_4444_textures);
proto->set_texture_id_allocation_chunk_size(texture_id_allocation_chunk_size);
proto->set_use_gpu_memory_buffer_resources(use_gpu_memory_buffer_resources);
proto->set_preferred_tile_format(preferred_tile_format);
}

void RendererSettings::FromProtobuf(const proto::RendererSettings& proto) {
Expand All @@ -58,13 +57,9 @@ void RendererSettings::FromProtobuf(const proto::RendererSettings& proto) {
delay_releasing_overlay_resources = proto.delay_releasing_overlay_resources();
refresh_rate = proto.refresh_rate();
highp_threshold_min = proto.highp_threshold_min();
use_rgba_4444_textures = proto.use_rgba_4444_textures();
texture_id_allocation_chunk_size = proto.texture_id_allocation_chunk_size();
use_gpu_memory_buffer_resources = proto.use_gpu_memory_buffer_resources();

DCHECK_LE(proto.preferred_tile_format(),
static_cast<uint32_t>(RESOURCE_FORMAT_MAX));
preferred_tile_format =
static_cast<ResourceFormat>(proto.preferred_tile_format());
}

bool RendererSettings::operator==(const RendererSettings& other) const {
Expand All @@ -79,11 +74,11 @@ bool RendererSettings::operator==(const RendererSettings& other) const {
other.delay_releasing_overlay_resources &&
refresh_rate == other.refresh_rate &&
highp_threshold_min == other.highp_threshold_min &&
use_rgba_4444_textures == other.use_rgba_4444_textures &&
texture_id_allocation_chunk_size ==
other.texture_id_allocation_chunk_size &&
use_gpu_memory_buffer_resources ==
other.use_gpu_memory_buffer_resources &&
preferred_tile_format == other.preferred_tile_format;
other.use_gpu_memory_buffer_resources;
}

} // namespace cc
3 changes: 1 addition & 2 deletions cc/output/renderer_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include "base/basictypes.h"
#include "cc/base/cc_export.h"
#include "cc/resources/resource_format.h"

namespace cc {

Expand All @@ -30,9 +29,9 @@ class CC_EXPORT RendererSettings {
bool delay_releasing_overlay_resources;
double refresh_rate;
int highp_threshold_min;
bool use_rgba_4444_textures;
size_t texture_id_allocation_chunk_size;
bool use_gpu_memory_buffer_resources;
ResourceFormat preferred_tile_format;

void ToProtobuf(proto::RendererSettings* proto) const;
void FromProtobuf(const proto::RendererSettings& proto);
Expand Down
4 changes: 2 additions & 2 deletions cc/output/renderer_settings_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ TEST(RendererSettingsTest, AllFieldsFlipped) {
settings.delay_releasing_overlay_resources = true;
settings.refresh_rate = 6.0;
settings.highp_threshold_min = 1;
settings.use_rgba_4444_textures = true;
settings.texture_id_allocation_chunk_size = 46;
settings.use_gpu_memory_buffer_resources = true;
settings.preferred_tile_format = RGBA_4444;
VerifySerializeAndDeserializeProto(settings);
}

Expand All @@ -48,9 +48,9 @@ TEST(RendererSettingsTest, ArbitraryFieldValues) {
settings.delay_releasing_overlay_resources = true;
settings.refresh_rate = 999.0;
settings.highp_threshold_min = 1;
settings.use_rgba_4444_textures = true;
settings.texture_id_allocation_chunk_size = 12;
settings.use_gpu_memory_buffer_resources = true;
settings.preferred_tile_format = RGBA_4444;
VerifySerializeAndDeserializeProto(settings);
}

Expand Down
6 changes: 3 additions & 3 deletions cc/proto/renderer_settings.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ message RendererSettings {
optional bool delay_releasing_overlay_resources = 8;
optional double refresh_rate = 9;
optional uint32 highp_threshold_min = 10;
optional uint32 texture_id_allocation_chunk_size = 11;
optional bool use_gpu_memory_buffer_resources = 12;
optional uint32 preferred_tile_format = 13;
optional bool use_rgba_4444_textures = 11;
optional uint32 texture_id_allocation_chunk_size = 12;
optional bool use_gpu_memory_buffer_resources = 13;
}
79 changes: 33 additions & 46 deletions cc/raster/one_copy_tile_task_worker_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ scoped_ptr<TileTaskWorkerPool> OneCopyTileTaskWorkerPool::Create(
int max_copy_texture_chromium_size,
bool use_partial_raster,
int max_staging_buffer_usage_in_bytes,
ResourceFormat preferred_tile_format) {
bool use_rgba_4444_texture_format) {
return make_scoped_ptr<TileTaskWorkerPool>(new OneCopyTileTaskWorkerPool(
task_runner, task_graph_runner, resource_provider,
max_copy_texture_chromium_size, use_partial_raster,
max_staging_buffer_usage_in_bytes, preferred_tile_format));
max_staging_buffer_usage_in_bytes, use_rgba_4444_texture_format));
}

OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool(
Expand All @@ -195,7 +195,7 @@ OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool(
int max_copy_texture_chromium_size,
bool use_partial_raster,
int max_staging_buffer_usage_in_bytes,
ResourceFormat preferred_tile_format)
bool use_rgba_4444_texture_format)
: task_runner_(task_runner),
task_graph_runner_(task_graph_runner),
namespace_token_(task_graph_runner->GetNamespaceToken()),
Expand All @@ -208,7 +208,7 @@ OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool(
use_partial_raster_(use_partial_raster),
bytes_scheduled_since_last_flush_(0),
max_staging_buffer_usage_in_bytes_(max_staging_buffer_usage_in_bytes),
preferred_tile_format_(preferred_tile_format),
use_rgba_4444_texture_format_(use_rgba_4444_texture_format),
staging_buffer_usage_in_bytes_(0),
free_staging_buffer_usage_in_bytes_(0),
staging_buffer_expiration_delay_(
Expand Down Expand Up @@ -281,13 +281,9 @@ void OneCopyTileTaskWorkerPool::CheckForCompletedTasks() {

ResourceFormat OneCopyTileTaskWorkerPool::GetResourceFormat(
bool must_support_alpha) const {
if (resource_provider_->IsResourceFormatSupported(preferred_tile_format_) &&
(DoesResourceFormatSupportAlpha(preferred_tile_format_) ||
!must_support_alpha)) {
return preferred_tile_format_;
}

return resource_provider_->best_texture_format();
return use_rgba_4444_texture_format_
? RGBA_4444
: resource_provider_->best_texture_format();
}

bool OneCopyTileTaskWorkerPool::GetResourceRequiresSwizzle(
Expand Down Expand Up @@ -431,41 +427,32 @@ void OneCopyTileTaskWorkerPool::PlaybackAndCopyOnWorkerThread(
#endif
}

// Since compressed texture's cannot be pre-allocated we might have an
// unallocated resource in which case we need to perform a full size copy.
if (IsResourceFormatCompressed(resource->format())) {
gl->CompressedCopyTextureCHROMIUM(GL_TEXTURE_2D,
staging_buffer->texture_id,
resource_lock->texture_id());
} else {
int bytes_per_row =
(BitsPerPixel(resource->format()) * resource->size().width()) / 8;
int chunk_size_in_rows =
std::max(1, max_bytes_per_copy_operation_ / bytes_per_row);
// Align chunk size to 4. Required to support compressed texture formats.
chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4);
int y = 0;
int height = resource->size().height();
while (y < height) {
// Copy at most |chunk_size_in_rows|.
int rows_to_copy = std::min(chunk_size_in_rows, height - y);
DCHECK_GT(rows_to_copy, 0);

gl->CopySubTextureCHROMIUM(GL_TEXTURE_2D, staging_buffer->texture_id,
resource_lock->texture_id(), 0, y, 0, y,
resource->size().width(), rows_to_copy,
false, false, false);
y += rows_to_copy;

// Increment |bytes_scheduled_since_last_flush_| by the amount of memory
// used for this copy operation.
bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row;

if (bytes_scheduled_since_last_flush_ >=
max_bytes_per_copy_operation_) {
gl->ShallowFlushCHROMIUM();
bytes_scheduled_since_last_flush_ = 0;
}
int bytes_per_row =
(BitsPerPixel(resource->format()) * resource->size().width()) / 8;
int chunk_size_in_rows =
std::max(1, max_bytes_per_copy_operation_ / bytes_per_row);
// Align chunk size to 4. Required to support compressed texture formats.
chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4);
int y = 0;
int height = resource->size().height();
while (y < height) {
// Copy at most |chunk_size_in_rows|.
int rows_to_copy = std::min(chunk_size_in_rows, height - y);
DCHECK_GT(rows_to_copy, 0);

gl->CopySubTextureCHROMIUM(GL_TEXTURE_2D, staging_buffer->texture_id,
resource_lock->texture_id(), 0, y, 0, y,
resource->size().width(), rows_to_copy, false,
false, false);
y += rows_to_copy;

// Increment |bytes_scheduled_since_last_flush_| by the amount of memory
// used for this copy operation.
bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row;

if (bytes_scheduled_since_last_flush_ >= max_bytes_per_copy_operation_) {
gl->ShallowFlushCHROMIUM();
bytes_scheduled_since_last_flush_ = 0;
}
}

Expand Down
6 changes: 3 additions & 3 deletions cc/raster/one_copy_tile_task_worker_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CC_EXPORT OneCopyTileTaskWorkerPool
int max_copy_texture_chromium_size,
bool use_partial_raster,
int max_staging_buffer_usage_in_bytes,
ResourceFormat preferred_tile_format);
bool use_rgba_4444_texture_format);

// Overridden from TileTaskWorkerPool:
TileTaskRunner* AsTileTaskRunner() override;
Expand Down Expand Up @@ -92,7 +92,7 @@ class CC_EXPORT OneCopyTileTaskWorkerPool
int max_copy_texture_chromium_size,
bool use_partial_raster,
int max_staging_buffer_usage_in_bytes,
ResourceFormat preferred_tile_format);
bool use_rgba_4444_texture_format);

private:
struct StagingBuffer {
Expand Down Expand Up @@ -149,7 +149,7 @@ class CC_EXPORT OneCopyTileTaskWorkerPool
StagingBufferDeque busy_buffers_;
int bytes_scheduled_since_last_flush_;
const int max_staging_buffer_usage_in_bytes_;
ResourceFormat preferred_tile_format_;
bool use_rgba_4444_texture_format_;
int staging_buffer_usage_in_bytes_;
int free_staging_buffer_usage_in_bytes_;
const base::TimeDelta staging_buffer_expiration_delay_;
Expand Down
Loading

0 comments on commit ce04862

Please sign in to comment.