summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsenorblanco <senorblanco@chromium.org>2015-05-07 21:00:44 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-08 04:01:07 +0000
commit9e53d21c5715201e97c273fffd1fa8f3133c44cc (patch)
tree4c8c31fec604d16abcca088095fced6993443b07
parent189ed37693fe22897464c61e65c6d2f29213b9cd (diff)
downloadchromium_src-9e53d21c5715201e97c273fffd1fa8f3133c44cc.zip
chromium_src-9e53d21c5715201e97c273fffd1fa8f3133c44cc.tar.gz
chromium_src-9e53d21c5715201e97c273fffd1fa8f3133c44cc.tar.bz2
cc: change the GPU rasterization content veto into an MSAA trigger.
If MSAA is not supported, or does not have sufficient samples, let the content veto drop us to software rasterization as before. BUG=474727,453490 Review URL: https://codereview.chromium.org/1120773002 Cr-Commit-Position: refs/heads/master@{#328921}
-rw-r--r--cc/layers/heads_up_display_layer_impl.cc4
-rw-r--r--cc/output/delegating_renderer.cc1
-rw-r--r--cc/output/gl_renderer.cc1
-rw-r--r--cc/output/renderer.cc3
-rw-r--r--cc/output/renderer.h1
-rw-r--r--cc/test/test_web_graphics_context_3d.cc4
-rw-r--r--cc/test/test_web_graphics_context_3d.h1
-rw-r--r--cc/trees/layer_tree_host_impl.cc24
-rw-r--r--cc/trees/layer_tree_host_impl.h3
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc62
-rw-r--r--content/browser/gpu/compositor_util.cc6
-rw-r--r--content/test/data/gpu/concave_paths.html49
-rw-r--r--content/test/gpu/page_sets/gpu_rasterization_tests.py39
13 files changed, 190 insertions, 8 deletions
diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc
index 7d449b7..986c332 100644
--- a/cc/layers/heads_up_display_layer_impl.cc
+++ b/cc/layers/heads_up_display_layer_impl.cc
@@ -582,6 +582,10 @@ SkRect HeadsUpDisplayLayerImpl::DrawGpuRasterizationStatus(SkCanvas* canvas,
status = "off (viewport)";
color = SK_ColorYELLOW;
break;
+ case GpuRasterizationStatus::MSAA_CONTENT:
+ status = "MSAA (content)";
+ color = SK_ColorCYAN;
+ break;
case GpuRasterizationStatus::OFF_CONTENT:
status = "off (content)";
color = SK_ColorYELLOW;
diff --git a/cc/output/delegating_renderer.cc b/cc/output/delegating_renderer.cc
index 0944ef4..7906afa 100644
--- a/cc/output/delegating_renderer.cc
+++ b/cc/output/delegating_renderer.cc
@@ -56,6 +56,7 @@ DelegatingRenderer::DelegatingRenderer(RendererClient* client,
capabilities_.using_image = caps.gpu.image;
capabilities_.allow_rasterize_on_demand = false;
+ capabilities_.max_msaa_samples = caps.gpu.max_samples;
}
}
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 9cbb9d1..1098587 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -358,6 +358,7 @@ GLRenderer::GLRenderer(RendererClient* client,
context_caps.gpu.discard_framebuffer;
capabilities_.allow_rasterize_on_demand = true;
+ capabilities_.max_msaa_samples = context_caps.gpu.max_samples;
use_sync_query_ = context_caps.gpu.sync_query;
use_blend_equation_advanced_ = context_caps.gpu.blend_equation_advanced;
diff --git a/cc/output/renderer.cc b/cc/output/renderer.cc
index 7be8075..7fe0ffb 100644
--- a/cc/output/renderer.cc
+++ b/cc/output/renderer.cc
@@ -29,7 +29,8 @@ RendererCapabilitiesImpl::RendererCapabilitiesImpl()
using_egl_image(false),
using_image(false),
using_discard_framebuffer(false),
- allow_rasterize_on_demand(false) {
+ allow_rasterize_on_demand(false),
+ max_msaa_samples(0) {
}
RendererCapabilitiesImpl::~RendererCapabilitiesImpl() {}
diff --git a/cc/output/renderer.h b/cc/output/renderer.h
index b775285..8143e2a 100644
--- a/cc/output/renderer.h
+++ b/cc/output/renderer.h
@@ -39,6 +39,7 @@ struct RendererCapabilitiesImpl {
bool using_image;
bool using_discard_framebuffer;
bool allow_rasterize_on_demand;
+ int max_msaa_samples;
RendererCapabilities MainThreadCapabilities() const;
};
diff --git a/cc/test/test_web_graphics_context_3d.cc b/cc/test/test_web_graphics_context_3d.cc
index 6c139d1..e4dbd78 100644
--- a/cc/test/test_web_graphics_context_3d.cc
+++ b/cc/test/test_web_graphics_context_3d.cc
@@ -747,6 +747,10 @@ void TestWebGraphicsContext3D::SetMaxTransferBufferUsageBytes(
max_transfer_buffer_usage_bytes;
}
+void TestWebGraphicsContext3D::SetMaxSamples(int max_samples) {
+ test_capabilities_.gpu.max_samples = max_samples;
+}
+
TestWebGraphicsContext3D::TextureTargets::TextureTargets() {
// Initialize default bindings.
bound_textures_[GL_TEXTURE_2D] = 0;
diff --git a/cc/test/test_web_graphics_context_3d.h b/cc/test/test_web_graphics_context_3d.h
index 7ae741e..b74846d 100644
--- a/cc/test/test_web_graphics_context_3d.h
+++ b/cc/test/test_web_graphics_context_3d.h
@@ -363,6 +363,7 @@ class TestWebGraphicsContext3D {
return max_used_transfer_buffer_usage_bytes_;
}
+ void SetMaxSamples(int max_samples);
void set_test_support(TestContextSupport* test_support) {
test_support_ = test_support;
}
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index a164e8c..573ba83 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -193,6 +193,7 @@ LayerTreeHostImpl::LayerTreeHostImpl(
content_is_suitable_for_gpu_rasterization_(true),
has_gpu_rasterization_trigger_(false),
use_gpu_rasterization_(false),
+ use_msaa_(false),
gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE),
input_handler_client_(NULL),
did_lock_scrolling_layer_(false),
@@ -1604,9 +1605,19 @@ void LayerTreeHostImpl::FinishAllRendering() {
void LayerTreeHostImpl::UpdateGpuRasterizationStatus() {
bool use_gpu = false;
+ bool use_msaa = false;
+ bool using_msaa_for_complex_content =
+ renderer() && settings_.gpu_rasterization_msaa_sample_count > 0 &&
+ GetRendererCapabilities().max_msaa_samples >=
+ settings_.gpu_rasterization_msaa_sample_count;
if (settings_.gpu_rasterization_forced) {
use_gpu = true;
gpu_rasterization_status_ = GpuRasterizationStatus::ON_FORCED;
+ use_msaa = !content_is_suitable_for_gpu_rasterization_ &&
+ using_msaa_for_complex_content;
+ if (use_msaa) {
+ gpu_rasterization_status_ = GpuRasterizationStatus::MSAA_CONTENT;
+ }
} else if (!settings_.gpu_rasterization_enabled) {
gpu_rasterization_status_ = GpuRasterizationStatus::OFF_DEVICE;
} else if (!has_gpu_rasterization_trigger_) {
@@ -1614,16 +1625,20 @@ void LayerTreeHostImpl::UpdateGpuRasterizationStatus() {
} else if (content_is_suitable_for_gpu_rasterization_) {
use_gpu = true;
gpu_rasterization_status_ = GpuRasterizationStatus::ON;
+ } else if (using_msaa_for_complex_content) {
+ use_gpu = use_msaa = true;
+ gpu_rasterization_status_ = GpuRasterizationStatus::MSAA_CONTENT;
} else {
gpu_rasterization_status_ = GpuRasterizationStatus::OFF_CONTENT;
}
- if (use_gpu == use_gpu_rasterization_)
+ if (use_gpu == use_gpu_rasterization_ && use_msaa == use_msaa_)
return;
// Note that this must happen first, in case the rest of the calls want to
// query the new state of |use_gpu_rasterization_|.
use_gpu_rasterization_ = use_gpu;
+ use_msaa_ = use_msaa;
// Clean up and replace existing tile manager with another one that uses
// appropriate rasterizer.
@@ -1642,6 +1657,7 @@ void LayerTreeHostImpl::UpdateGpuRasterizationStatus() {
const RendererCapabilitiesImpl&
LayerTreeHostImpl::GetRendererCapabilities() const {
+ CHECK(renderer_);
return renderer_->Capabilities();
}
@@ -1983,6 +1999,7 @@ void LayerTreeHostImpl::CreateAndSetRenderer() {
}
DCHECK(renderer_);
+ // Since the new renderer may be capable of MSAA, update status here.
UpdateGpuRasterizationStatus();
renderer_->SetVisible(visible_);
SetFullRootLayerDamage();
@@ -2053,10 +2070,13 @@ void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool(
*resource_pool =
ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D);
+ int msaa_sample_count =
+ use_msaa_ ? settings_.gpu_rasterization_msaa_sample_count : 0;
+
*tile_task_worker_pool = GpuTileTaskWorkerPool::Create(
task_runner, task_graph_runner, context_provider,
resource_provider_.get(), settings_.use_distance_field_text,
- settings_.gpu_rasterization_msaa_sample_count);
+ msaa_sample_count);
return;
}
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index 9a37e2f..e013b6d 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -81,6 +81,7 @@ enum class GpuRasterizationStatus {
ON_FORCED,
OFF_DEVICE,
OFF_VIEWPORT,
+ MSAA_CONTENT,
OFF_CONTENT
};
@@ -329,6 +330,7 @@ class CC_EXPORT LayerTreeHostImpl
}
void UpdateGpuRasterizationStatus();
bool use_gpu_rasterization() const { return use_gpu_rasterization_; }
+ bool use_msaa() const { return use_msaa_; }
GpuRasterizationStatus gpu_rasterization_status() const {
return gpu_rasterization_status_;
@@ -649,6 +651,7 @@ class CC_EXPORT LayerTreeHostImpl
bool content_is_suitable_for_gpu_rasterization_;
bool has_gpu_rasterization_trigger_;
bool use_gpu_rasterization_;
+ bool use_msaa_;
GpuRasterizationStatus gpu_rasterization_status_;
scoped_ptr<TileTaskWorkerPool> tile_task_worker_pool_;
scoped_ptr<ResourcePool> resource_pool_;
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 86c33e0..ff1159f 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -51,6 +51,7 @@
#include "cc/test/fake_proxy.h"
#include "cc/test/fake_video_frame_provider.h"
#include "cc/test/geometry_test_utils.h"
+#include "cc/test/gpu_rasterization_enabled_settings.h"
#include "cc/test/layer_test_common.h"
#include "cc/test/layer_tree_test.h"
#include "cc/test/render_pass_test_common.h"
@@ -7696,5 +7697,66 @@ TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) {
EXPECT_TRUE(controller.begin_frame_args().IsValid());
}
+TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusModes) {
+ EXPECT_FALSE(host_impl_->use_gpu_rasterization());
+
+ host_impl_->set_has_gpu_rasterization_trigger(true);
+ host_impl_->set_content_is_suitable_for_gpu_rasterization(true);
+ host_impl_->UpdateGpuRasterizationStatus();
+ EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status());
+ EXPECT_TRUE(host_impl_->use_gpu_rasterization());
+
+ host_impl_->set_has_gpu_rasterization_trigger(false);
+ host_impl_->set_content_is_suitable_for_gpu_rasterization(true);
+ host_impl_->UpdateGpuRasterizationStatus();
+ EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT,
+ host_impl_->gpu_rasterization_status());
+ EXPECT_FALSE(host_impl_->use_gpu_rasterization());
+
+ host_impl_->set_has_gpu_rasterization_trigger(true);
+ host_impl_->set_content_is_suitable_for_gpu_rasterization(false);
+ host_impl_->UpdateGpuRasterizationStatus();
+ EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT,
+ host_impl_->gpu_rasterization_status());
+ EXPECT_FALSE(host_impl_->use_gpu_rasterization());
+ EXPECT_FALSE(host_impl_->use_msaa());
+
+ scoped_ptr<TestWebGraphicsContext3D> context_with_msaa =
+ TestWebGraphicsContext3D::Create();
+ context_with_msaa->SetMaxSamples(8);
+
+ LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings();
+ msaaSettings.gpu_rasterization_msaa_sample_count = 4;
+ EXPECT_TRUE(CreateHostImpl(
+ msaaSettings, FakeOutputSurface::Create3d(context_with_msaa.Pass())));
+ host_impl_->set_has_gpu_rasterization_trigger(true);
+ host_impl_->set_content_is_suitable_for_gpu_rasterization(false);
+ host_impl_->UpdateGpuRasterizationStatus();
+ EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT,
+ host_impl_->gpu_rasterization_status());
+ EXPECT_TRUE(host_impl_->use_gpu_rasterization());
+ EXPECT_TRUE(host_impl_->use_msaa());
+
+ LayerTreeSettings settings = DefaultSettings();
+ settings.gpu_rasterization_enabled = false;
+ EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d()));
+ host_impl_->set_has_gpu_rasterization_trigger(true);
+ host_impl_->set_content_is_suitable_for_gpu_rasterization(true);
+ host_impl_->UpdateGpuRasterizationStatus();
+ EXPECT_EQ(GpuRasterizationStatus::OFF_DEVICE,
+ host_impl_->gpu_rasterization_status());
+ EXPECT_FALSE(host_impl_->use_gpu_rasterization());
+
+ settings.gpu_rasterization_forced = true;
+ EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d()));
+
+ host_impl_->set_has_gpu_rasterization_trigger(false);
+ host_impl_->set_content_is_suitable_for_gpu_rasterization(false);
+ host_impl_->UpdateGpuRasterizationStatus();
+ EXPECT_EQ(GpuRasterizationStatus::ON_FORCED,
+ host_impl_->gpu_rasterization_status());
+ EXPECT_TRUE(host_impl_->use_gpu_rasterization());
+}
+
} // namespace
} // namespace cc
diff --git a/content/browser/gpu/compositor_util.cc b/content/browser/gpu/compositor_util.cc
index 0696d1e..a96cdea 100644
--- a/content/browser/gpu/compositor_util.cc
+++ b/content/browser/gpu/compositor_util.cc
@@ -327,7 +327,11 @@ int GpuRasterizationMSAASampleCount() {
*base::CommandLine::ForCurrentProcess();
if (!command_line.HasSwitch(switches::kGpuRasterizationMSAASampleCount))
- return 0;
+#if defined(OS_ANDROID)
+ return 4;
+#else
+ return 8;
+#endif
std::string string_value = command_line.GetSwitchValueASCII(
switches::kGpuRasterizationMSAASampleCount);
int msaa_sample_count = 0;
diff --git a/content/test/data/gpu/concave_paths.html b/content/test/data/gpu/concave_paths.html
new file mode 100644
index 0000000..af9175c
--- /dev/null
+++ b/content/test/data/gpu/concave_paths.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Concave Paths test</title>
+<script>
+var g_swapsBeforeAck = 15;
+
+function main() {
+ waitForFinish();
+}
+
+function waitForFinish()
+{
+ if (g_swapsBeforeAck == 0) {
+ domAutomationController.setAutomationId(1);
+ domAutomationController.send("SUCCESS");
+ } else {
+ g_swapsBeforeAck--;
+ document.getElementById('paths').style.zIndex = g_swapsBeforeAck + 1;
+ window.webkitRequestAnimationFrame(waitForFinish);
+ }
+}
+</script>
+</head>
+<body onload="main()">
+<svg id="paths" width="600" height="100">
+ <defs>
+ <path id="chomp" d="M100,75 A50,50 0 1 1 100,25 L50,50Z" fill="gold"/>
+ </defs>
+</g>
+<use xlink:href="#chomp"/>
+<g transform="translate(100, 0)">
+ <use xlink:href="#chomp"/>
+</g>
+<g transform="translate(200, 0)">
+ <use xlink:href="#chomp"/>
+</g>
+<g transform="translate(300, 0)">
+ <use xlink:href="#chomp"/>
+</g>
+<g transform="translate(400, 0)">
+ <use xlink:href="#chomp"/>
+</g>
+<g transform="translate(500, 0)">
+ <use xlink:href="#chomp"/>
+</g>
+</svg>
+</body>
+</html>
diff --git a/content/test/gpu/page_sets/gpu_rasterization_tests.py b/content/test/gpu/page_sets/gpu_rasterization_tests.py
index 9277415..4568965 100644
--- a/content/test/gpu/page_sets/gpu_rasterization_tests.py
+++ b/content/test/gpu/page_sets/gpu_rasterization_tests.py
@@ -5,10 +5,10 @@ from telemetry.page import page as page_module
from telemetry.page import page_set as page_set_module
-class GpuRasterizationTestsPage(page_module.Page):
+class GpuRasterizationBlueBoxPage(page_module.Page):
def __init__(self, page_set):
- super(GpuRasterizationTestsPage, self).__init__(
+ super(GpuRasterizationBlueBoxPage, self).__init__(
url='file://../../data/gpu/pixel_background.html',
page_set=page_set,
name='GpuRasterization.BlueBox')
@@ -66,11 +66,41 @@ class GpuRasterizationTestsPage(page_module.Page):
self.test_rect = [0, 0, 220, 220]
def RunNavigateSteps(self, action_runner):
- super(GpuRasterizationTestsPage, self).RunNavigateSteps(action_runner)
+ super(GpuRasterizationBlueBoxPage, self).RunNavigateSteps(action_runner)
action_runner.WaitForJavaScriptCondition(
'domAutomationController._finished', timeout_in_seconds=30)
+class GpuRasterizationConcavePathsPage(page_module.Page):
+
+ def __init__(self, page_set):
+ super(GpuRasterizationConcavePathsPage, self).__init__(
+ url='file://../../data/gpu/concave_paths.html',
+ page_set=page_set,
+ name='GpuRasterization.ConcavePaths')
+
+ self.expectations = [
+ {'comment': 'outside',
+ 'color': [255, 255, 255],
+ 'tolerance': 0,
+ 'location': [5, 5]},
+ {'comment': 'inside',
+ 'color': [255, 215, 0],
+ 'tolerance': 0,
+ 'location': [20, 50]},
+ {'comment': 'edge-1',
+ 'color': [255, 220, 32],
+ 'tolerance': 32,
+ 'location': [72, 50]},
+ ]
+ self.test_rect = [0, 0, 100, 100]
+
+ def RunNavigateSteps(self, action_runner):
+ super(GpuRasterizationConcavePathsPage, self).\
+ RunNavigateSteps(action_runner)
+ action_runner.WaitForJavaScriptCondition(
+ 'domAutomationController._finished', timeout_in_seconds=30)
+
class GpuRasterizationTestsPageSet(page_set_module.PageSet):
""" Basic test cases for GPU rasterization. """
@@ -78,4 +108,5 @@ class GpuRasterizationTestsPageSet(page_set_module.PageSet):
def __init__(self):
super(GpuRasterizationTestsPageSet, self).__init__()
- self.AddUserStory(GpuRasterizationTestsPage(self))
+ self.AddUserStory(GpuRasterizationBlueBoxPage(self))
+ self.AddUserStory(GpuRasterizationConcavePathsPage(self))