Commit e8287933 authored by Sean Gilhuly's avatar Sean Gilhuly Committed by Commit Bot

Enable cc filters tests for SkiaRenderer Dawn

Initialize Vulkan for both Skia Vulkan and for Skia Dawn on Linux.
Vulkan and Dawn both require OOP-R, so replace use_vulkan() with either
use_skia_vulkan() or use_oopr(), depending on context.

Bug: 1021566
Change-Id: I68c4f789252fa700bd78ec01a44e03df6f1fc0b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135006Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Commit-Queue: Sean Gilhuly <sgilhuly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760510}
parent 7b4bfccf
......@@ -3,6 +3,7 @@
# found in the LICENSE file.
import("//build/config/sanitizers/sanitizers.gni")
import("//gpu/vulkan/features.gni")
import("//skia/features.gni")
import("//cc/cc.gni")
......@@ -817,6 +818,10 @@ cc_test("cc_unittests") {
defines += [ "ENABLE_CC_VULKAN_TESTS" ]
}
}
if (skia_use_dawn) {
defines += [ "ENABLE_CC_DAWN_TESTS" ]
}
}
cc_test("cc_perftests") {
......
......@@ -28,6 +28,7 @@ const char* LayerTreeHostPixelResourceTest::GetRendererSuffix() const {
case RENDERER_SKIA_GL:
return "skia_gl";
case RENDERER_SKIA_VK:
case RENDERER_SKIA_DAWN:
return "skia_vk";
case RENDERER_SOFTWARE:
return "sw";
......@@ -84,10 +85,9 @@ LayerTreeHostPixelResourceTest::CreateRasterBufferProvider(
EXPECT_TRUE(compositor_context_provider);
EXPECT_TRUE(worker_context_provider);
EXPECT_FALSE(use_software_renderer());
bool enable_oopr = use_vulkan();
return std::make_unique<GpuRasterBufferProvider>(
compositor_context_provider, worker_context_provider, false,
gpu_raster_format, gfx::Size(), true, enable_oopr);
gpu_raster_format, gfx::Size(), true, use_oopr());
}
case ZERO_COPY:
EXPECT_TRUE(compositor_context_provider);
......
......@@ -55,7 +55,7 @@ LayerTreePixelTest::CreateLayerTreeFrameSink(
scoped_refptr<viz::TestInProcessContextProvider> worker_context_provider;
if (!use_software_renderer()) {
// Use gpu rasterization when using vulkan.
if (use_vulkan())
if (use_oopr())
DCHECK(gpu_rasterization_);
compositor_context_provider =
base::MakeRefCounted<viz::TestInProcessContextProvider>(
......@@ -65,7 +65,7 @@ LayerTreePixelTest::CreateLayerTreeFrameSink(
worker_context_provider =
base::MakeRefCounted<viz::TestInProcessContextProvider>(
/*enable_gpu_rasterization=*/gpu_rasterization_,
/*enable_oop_rasterization=*/use_vulkan(),
/*enable_oop_rasterization=*/use_oopr(),
/*support_locking=*/true);
// Bind worker context to main thread like it is in production. This is
// needed to fully initialize the context. Compositor context is bound to
......
......@@ -125,7 +125,7 @@ class LayerTreePixelTest : public LayerTreeTest {
static const SkColor kCSSLime = 0xff00ff00;
static const SkColor kCSSBlack = 0xff000000;
bool gpu_rasterization_ = use_vulkan();
bool gpu_rasterization_ = use_oopr();
gl::DisableNullDrawGLBindings enable_pixel_output_;
std::unique_ptr<PixelComparator> pixel_comparator_;
scoped_refptr<Layer> content_root_; // Not used in layer list mode.
......
......@@ -14,7 +14,6 @@
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "build/build_config.h"
......@@ -636,14 +635,28 @@ LayerTreeTest::LayerTreeTest(LayerTreeTest::RendererType renderer_type)
if (command_line->HasSwitch(switches::kCCLayerTreeTestLongTimeout))
timeout_seconds_ = 5 * 60;
if (use_vulkan()) {
// Check if the graphics backend needs to initialize Vulkan.
bool init_vulkan = false;
if (renderer_type_ == RENDERER_SKIA_VK) {
scoped_feature_list_.InitAndEnableFeature(features::kVulkan);
init_vulkan = true;
} else if (renderer_type_ == RENDERER_SKIA_DAWN) {
scoped_feature_list_.InitAndEnableFeature(features::kSkiaDawn);
#if defined(OS_LINUX)
init_vulkan = true;
#elif defined(OS_WIN)
// TODO(sgilhuly): Initialize D3D12 for Windows.
#else
NOTREACHED();
#endif
}
if (init_vulkan) {
bool use_gpu = command_line->HasSwitch(::switches::kUseGpuInTests);
command_line->AppendSwitchASCII(
::switches::kUseVulkan,
use_gpu ? ::switches::kVulkanImplementationNameNative
: ::switches::kVulkanImplementationNameSwiftshader);
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
scoped_feature_list_->InitAndEnableFeature(features::kVulkan);
}
}
......
......@@ -6,7 +6,9 @@
#define CC_TEST_LAYER_TREE_TEST_H_
#include "base/memory/ref_counted.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread.h"
#include "build/build_config.h"
#include "cc/animation/animation_delegate.h"
#include "cc/test/property_tree_test_utils.h"
#include "cc/test/test_hooks.h"
......@@ -62,6 +64,9 @@ class LayerTreeTest : public testing::Test, public TestHooks {
RENDERER_GL,
RENDERER_SKIA_GL,
RENDERER_SKIA_VK,
// SkiaRenderer with the Dawn backend will be used; on Linux this will
// initialize Vulkan, and on Windows this will initialize D3D12.
RENDERER_SKIA_DAWN,
RENDERER_SOFTWARE,
};
......@@ -73,6 +78,8 @@ class LayerTreeTest : public testing::Test, public TestHooks {
return "Skia GL";
case RENDERER_SKIA_VK:
return "Skia Vulkan";
case RENDERER_SKIA_DAWN:
return "Skia Dawn";
case RENDERER_SOFTWARE:
return "Software";
}
......@@ -208,12 +215,24 @@ class LayerTreeTest : public testing::Test, public TestHooks {
bool use_skia_renderer() const {
return renderer_type_ == RENDERER_SKIA_GL ||
renderer_type_ == RENDERER_SKIA_VK;
renderer_type_ == RENDERER_SKIA_VK ||
renderer_type_ == RENDERER_SKIA_DAWN;
}
bool use_software_renderer() const {
return renderer_type_ == RENDERER_SOFTWARE;
}
bool use_vulkan() const { return renderer_type_ == RENDERER_SKIA_VK; }
bool use_skia_vulkan() const { return renderer_type_ == RENDERER_SKIA_VK; }
bool use_oopr() const {
return renderer_type_ == RENDERER_SKIA_VK ||
renderer_type_ == RENDERER_SKIA_DAWN;
}
bool use_d3d12() const {
#if defined(OS_WIN)
return renderer_type_ == RENDERER_SKIA_DAWN;
#else
return false;
#endif
}
const RendererType renderer_type_;
......@@ -245,7 +264,7 @@ class LayerTreeTest : public testing::Test, public TestHooks {
// |scoped_feature_list_| must be the first member to ensure that it is
// destroyed after any member that might be using it.
std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_;
base::test::ScopedFeatureList scoped_feature_list_;
viz::TestGpuServiceHolder::ScopedResetter gpu_service_resetter_;
LayerTreeSettings settings_;
......
......@@ -36,6 +36,8 @@ class LayerTreeHostFiltersPixelTest
return "skia_gl";
case RENDERER_SKIA_VK:
return "skia_vk";
case RENDERER_SKIA_DAWN:
return "skia_dawn";
case RENDERER_SOFTWARE:
return "sw";
}
......@@ -72,13 +74,15 @@ class LayerTreeHostFiltersPixelTest
LayerTreeTest::RendererType const kRendererTypes[] = {
#if !defined(GL_NOT_ON_PLATFORM)
LayerTreeTest::RENDERER_GL,
LayerTreeTest::RENDERER_SKIA_GL,
LayerTreeTest::RENDERER_GL, LayerTreeTest::RENDERER_SKIA_GL,
#endif // !defined(GL_NOT_ON_PLATFORM)
LayerTreeTest::RENDERER_SOFTWARE,
#if defined(ENABLE_CC_VULKAN_TESTS)
LayerTreeTest::RENDERER_SKIA_VK,
#endif // defined(ENABLE_CC_VULKAN_TESTS)
#if defined(ENABLE_CC_DAWN_TESTS)
LayerTreeTest::RENDERER_SKIA_DAWN,
#endif // defined(ENABLE_CC_DAWN_TESTS)
};
INSTANTIATE_TEST_SUITE_P(All,
......@@ -87,7 +91,8 @@ INSTANTIATE_TEST_SUITE_P(All,
using LayerTreeHostFiltersPixelTestGPU = LayerTreeHostFiltersPixelTest;
#if !defined(GL_NOT_ON_PLATFORM) || defined(ENABLE_CC_VULKAN_TESTS)
#if !defined(GL_NOT_ON_PLATFORM) || defined(ENABLE_CC_VULKAN_TESTS) || \
defined(ENABLE_CC_DAWN_TESTS)
LayerTreeTest::RendererType const kRendererTypesGpu[] = {
#if !defined(GL_NOT_ON_PLATFORM)
LayerTreeTest::RENDERER_GL,
......@@ -96,12 +101,16 @@ LayerTreeTest::RendererType const kRendererTypesGpu[] = {
#if defined(ENABLE_CC_VULKAN_TESTS)
LayerTreeTest::RENDERER_SKIA_VK,
#endif // defined(ENABLE_CC_VULKAN_TESTS)
#if defined(ENABLE_CC_DAWN_TESTS)
LayerTreeTest::RENDERER_SKIA_DAWN,
#endif // defined(ENABLE_CC_DAWN_TESTS)
};
INSTANTIATE_TEST_SUITE_P(All,
LayerTreeHostFiltersPixelTestGPU,
::testing::ValuesIn(kRendererTypesGpu));
#endif // !defined(GL_NOT_ON_PLATFORM) || defined(ENABLE_CC_VULKAN_TESTS)
#endif // !defined(GL_NOT_ON_PLATFORM) || defined(ENABLE_CC_VULKAN_TESTS) ||
// defined(ENABLE_CC_DAWN_TESTS)
TEST_P(LayerTreeHostFiltersPixelTest, BackdropFilterBlurRect) {
scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
......@@ -196,6 +205,9 @@ TEST_P(LayerTreeHostFiltersPixelTest, BackdropFilterBlurRadius) {
float average_error_allowed_in_bad_pixels = 1.f;
int large_error_allowed = 1;
int small_error_allowed = 0;
// Windows using Dawn D3D12 has 2982 pixels off by 1.
if (use_d3d12())
percentage_pixels_large_error = 1.864f; // 2982px / (400*400)
pixel_comparator_.reset(new FuzzyPixelComparator(
true, // discard_alpha
percentage_pixels_large_error, percentage_pixels_small_error,
......@@ -296,7 +308,7 @@ TEST_P(LayerTreeHostFiltersPixelTest, BackdropFilterBlurOutsets) {
large_error_allowed,
small_error_allowed));
#else
if (use_vulkan())
if (use_skia_vulkan())
pixel_comparator_ = std::make_unique<FuzzyPixelOffByOneComparator>(true);
#endif
......@@ -426,9 +438,21 @@ class LayerTreeHostBlurFiltersPixelTestGPULayerList
};
#if !defined(GL_NOT_ON_PLATFORM) || defined(ENABLE_CC_VULKAN_TESTS)
// TODO(sgilhuly): Enable these tests for Skia Dawn, and switch over to using
// kRendererTypesGpu.
LayerTreeTest::RendererType const kRendererTypesGpuNonDawn[] = {
#if !defined(GL_NOT_ON_PLATFORM)
LayerTreeTest::RENDERER_GL,
LayerTreeTest::RENDERER_SKIA_GL,
#endif // !defined(GL_NOT_ON_PLATFORM)
#if defined(ENABLE_CC_VULKAN_TESTS)
LayerTreeTest::RENDERER_SKIA_VK,
#endif // defined(ENABLE_CC_VULKAN_TESTS)
};
INSTANTIATE_TEST_SUITE_P(PixelResourceTest,
LayerTreeHostBlurFiltersPixelTestGPULayerList,
::testing::ValuesIn(kRendererTypesGpu));
::testing::ValuesIn(kRendererTypesGpuNonDawn));
#endif // !defined(GL_NOT_ON_PLATFORM) || defined(ENABLE_CC_VULKAN_TESTS)
TEST_P(LayerTreeHostBlurFiltersPixelTestGPULayerList,
......@@ -453,7 +477,7 @@ TEST_P(LayerTreeHostBlurFiltersPixelTestGPULayerList,
large_error_allowed,
small_error_allowed));
#else
if (use_vulkan())
if (use_skia_vulkan())
pixel_comparator_ = std::make_unique<FuzzyPixelOffByOneComparator>(true);
#endif
......@@ -645,6 +669,11 @@ TEST_P(LayerTreeHostFiltersPixelTest, ImageFilterScaled) {
// Windows has 153 pixels off by at most 2: crbug.com/225027
float percentage_pixels_large_error = 0.3825f; // 153px / (200*200)
int large_error_allowed = 2;
// Windows using Dawn D3D12 has 166 pixels off by 1.
if (use_d3d12()) {
percentage_pixels_large_error = 0.415f; // 166px / (200*200)
large_error_allowed = 1;
}
#elif defined(_MIPS_ARCH_LOONGSON)
// Loongson has 2 pixels off by at most 2: crbug.com/819075
float percentage_pixels_large_error = 0.005f; // 2px / (200*200)
......@@ -755,20 +784,27 @@ TEST_P(LayerTreeHostFiltersPixelTest, ImageRenderSurfaceScaled) {
background->AddChild(render_surface_layer);
// Software has some huge differences in the AA'd pixels on the different
// trybots. See crbug.com/452198.
float percentage_pixels_large_error = 0.0f;
float percentage_pixels_small_error = 0.0f;
float average_error_allowed_in_bad_pixels = 0.0f;
int large_error_allowed = 0;
int small_error_allowed = 0;
if (use_software_renderer()) {
float percentage_pixels_large_error = 0.686f;
float percentage_pixels_small_error = 0.0f;
float average_error_allowed_in_bad_pixels = 16.f;
int large_error_allowed = 17;
int small_error_allowed = 0;
pixel_comparator_.reset(new FuzzyPixelComparator(
true, // discard_alpha
percentage_pixels_large_error, percentage_pixels_small_error,
average_error_allowed_in_bad_pixels, large_error_allowed,
small_error_allowed));
// Software has some huge differences in the AA'd pixels on the different
// trybots. See crbug.com/452198.
percentage_pixels_large_error = 0.686f;
average_error_allowed_in_bad_pixels = 16.f;
large_error_allowed = 17;
} else if (use_d3d12()) {
// Windows using Dawn D3D12 has 25 pixels off by 1.
percentage_pixels_large_error = 0.028;
average_error_allowed_in_bad_pixels = 1.f;
large_error_allowed = 1;
}
pixel_comparator_.reset(new FuzzyPixelComparator(
/*discard_alpha=*/true, percentage_pixels_large_error,
percentage_pixels_small_error, average_error_allowed_in_bad_pixels,
large_error_allowed, small_error_allowed));
RunPixelTest(
background,
......@@ -776,7 +812,26 @@ TEST_P(LayerTreeHostFiltersPixelTest, ImageRenderSurfaceScaled) {
.InsertBeforeExtensionASCII(GetRendererSuffix()));
}
TEST_P(LayerTreeHostFiltersPixelTest, ZoomFilter) {
// TODO(sgilhuly): Enable these tests for Skia Dawn, and switch over to using
// kRendererTypes.
using LayerTreeHostFiltersPixelTestNonDawn = LayerTreeHostFiltersPixelTest;
LayerTreeTest::RendererType const kRendererTypesNonDawn[] = {
#if !defined(GL_NOT_ON_PLATFORM)
LayerTreeTest::RENDERER_GL,
LayerTreeTest::RENDERER_SKIA_GL,
#endif // !defined(GL_NOT_ON_PLATFORM)
LayerTreeTest::RENDERER_SOFTWARE,
#if defined(ENABLE_CC_VULKAN_TESTS)
LayerTreeTest::RENDERER_SKIA_VK,
#endif // defined(ENABLE_CC_VULKAN_TESTS)
};
INSTANTIATE_TEST_SUITE_P(All,
LayerTreeHostFiltersPixelTestNonDawn,
::testing::ValuesIn(kRendererTypesNonDawn));
TEST_P(LayerTreeHostFiltersPixelTestNonDawn, ZoomFilter) {
scoped_refptr<SolidColorLayer> root =
CreateSolidColorLayer(gfx::Rect(300, 300), SK_ColorWHITE);
......@@ -879,6 +934,9 @@ TEST_P(LayerTreeHostFiltersPixelTest, RotatedFilter) {
float percentage_pixels_large_error = 0.00111112f; // 1px / (300*300)
float average_error_allowed_in_bad_pixels = 1.f;
int large_error_allowed = 1;
// Windows using Dawn D3D12 has 104 pixels off by 1.
if (use_d3d12())
percentage_pixels_large_error = 0.115556f; // 104px / (300*300)
#else
float percentage_pixels_large_error = 0.0f; // 1px / (300*300)
float average_error_allowed_in_bad_pixels = 0.0f;
......@@ -936,6 +994,9 @@ TEST_P(LayerTreeHostFiltersPixelTest, RotatedDropShadowFilter) {
float percentage_pixels_large_error = 0.00333334f; // 3px / (300*300)
float average_error_allowed_in_bad_pixels = 1.f;
int large_error_allowed = 1;
// Windows using Dawn D3D12 has 22 pixels off by 1.
if (use_d3d12())
percentage_pixels_large_error = 0.02445; // 22px / (300*300)
#endif
float percentage_pixels_small_error = 0.0f;
int small_error_allowed = 0;
......@@ -945,7 +1006,7 @@ TEST_P(LayerTreeHostFiltersPixelTest, RotatedDropShadowFilter) {
average_error_allowed_in_bad_pixels, large_error_allowed,
small_error_allowed));
#else
if (use_vulkan())
if (use_skia_vulkan())
pixel_comparator_ = std::make_unique<FuzzyPixelOffByOneComparator>(true);
#endif
......@@ -989,7 +1050,7 @@ TEST_P(LayerTreeHostFiltersPixelTest, TranslatedFilter) {
parent->AddChild(child);
clip->AddChild(parent);
if (use_software_renderer())
if (use_software_renderer() || renderer_type_ == RENDERER_SKIA_DAWN)
pixel_comparator_ = std::make_unique<FuzzyPixelOffByOneComparator>(true);
RunPixelTest(clip, base::FilePath(
......@@ -1225,6 +1286,18 @@ class BackdropFilterInvertTest : public LayerTreeHostFiltersPixelTest {
base::NumberToString(device_scale_factor) + "x");
if (use_software_renderer()) {
expected_result = expected_result.InsertBeforeExtensionASCII("_sw");
} else if (use_d3d12()) {
// Windows using Dawn D3D12 has 16 pixels off by 1.
float percentage_pixels_large_error = 0.04f; // 16px / (200*200)
float average_error_allowed_in_bad_pixels = 1.f;
int large_error_allowed = 1;
float percentage_pixels_small_error = 0.0f;
int small_error_allowed = 0;
pixel_comparator_.reset(new FuzzyPixelComparator(
true, // discard_alpha
percentage_pixels_large_error, percentage_pixels_small_error,
average_error_allowed_in_bad_pixels, large_error_allowed,
small_error_allowed));
}
RunPixelTest(std::move(root), expected_result);
}
......
......@@ -585,7 +585,7 @@ TEST_P(LayerTreeHostMasksForBackdropFiltersPixelTestWithLayerList, Test) {
? base::FilePath(FILE_PATH_LITERAL("mask_of_backdrop_filter_gpu.png"))
: base::FilePath(FILE_PATH_LITERAL("mask_of_backdrop_filter.png"));
if (use_vulkan() && raster_type() == GPU) {
if (use_skia_vulkan() && raster_type() == GPU) {
// Vulkan with GPU raster has 4 pixels errors (the circle mask shape is
// slight different).
float percentage_pixels_large_error = 0.04f; // 4px / (100*100)
......@@ -644,7 +644,7 @@ TEST_P(LayerTreeHostMasksForBackdropFiltersPixelTestWithLayerTree, Test) {
? base::FilePath(FILE_PATH_LITERAL("mask_of_backdrop_filter_gpu.png"))
: base::FilePath(FILE_PATH_LITERAL("mask_of_backdrop_filter.png"));
if (use_vulkan() && raster_type() == GPU) {
if (use_skia_vulkan() && raster_type() == GPU) {
// Vulkan with GPU raster has 4 pixels errors (the circle mask shape is
// slight different).
float percentage_pixels_large_error = 0.04f; // 4px / (100*100)
......
......@@ -72,10 +72,8 @@ TEST_P(LayerTreeHostMirrorPixelTest, MirrorLayer) {
max_abs_error_limit, small_error_threshold);
}
#if defined(ENABLE_CC_VULKAN_TESTS) && defined(OS_LINUX)
if (use_vulkan())
if (use_skia_vulkan())
pixel_comparator_ = std::make_unique<FuzzyPixelOffByOneComparator>(true);
#endif
RunPixelTest(background,
base::FilePath(FILE_PATH_LITERAL("mirror_layer.png")));
......
......@@ -188,7 +188,7 @@ TEST_P(LayerTreeHostScrollbarsPixelTest, MAYBE_HugeTransformScale) {
pixel_comparator_ = std::make_unique<FuzzyPixelOffByOneComparator>(true);
RunPixelTest(background,
use_vulkan()
use_skia_vulkan()
? base::FilePath(FILE_PATH_LITERAL("spiral_64_scale_vk.png"))
: base::FilePath(FILE_PATH_LITERAL("spiral_64_scale.png")));
}
......
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