Commit 9152d53f authored by Aldo Culquicondor's avatar Aldo Culquicondor Committed by Commit Bot

VR: Add Skia surface provider for command buffer

This is the last piece necessary in the VR UI to support the
command buffer.

Re-enable pixeltest for Windows.

Bug: 884256, 771794
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:linux_vr;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I8c0a67021c859a88b0af519ace97266a142ec7d7
Reviewed-on: https://chromium-review.googlesource.com/1238816
Commit-Queue: Aldo Culquicondor <acondor@chromium.org>
Reviewed-by: default avatarJohn Budorick <jbudorick@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593933}
parent bc60d80b
...@@ -203,7 +203,15 @@ component("vr_ui") { ...@@ -203,7 +203,15 @@ component("vr_ui") {
] ]
if (use_command_buffer) { if (use_command_buffer) {
sources += [ "skia_surface_provider_factory_cmd_buffer.cc" ] sources += [
"cmd_buffer_surface_provider.cc",
"cmd_buffer_surface_provider.h",
"skia_surface_provider_factory_cmd_buffer.cc",
]
deps += [
"//gpu/command_buffer/client:gles2_implementation",
"//gpu/skia_bindings",
]
} else { } else {
sources += [ sources += [
"native_gl_surface_provider.cc", "native_gl_surface_provider.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/vr/cmd_buffer_surface_provider.h"
#include "base/logging.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/GrContext.h"
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
#include "ui/gfx/geometry/size.h"
namespace vr {
CmdBufferSurfaceProvider::CmdBufferSurfaceProvider() {
auto* gles2_implementation =
static_cast<gpu::gles2::GLES2Implementation*>(gles2::GetGLContext());
DCHECK(gles2_implementation);
sk_sp<const GrGLInterface> gr_interface =
skia_bindings::CreateGLES2InterfaceBindings(gles2_implementation,
gles2_implementation);
gr_context_ = GrContext::MakeGL(std::move(gr_interface));
DCHECK(gr_context_);
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &main_fbo_);
}
CmdBufferSurfaceProvider::~CmdBufferSurfaceProvider() = default;
sk_sp<SkSurface> CmdBufferSurfaceProvider::MakeSurface(const gfx::Size& size) {
return SkSurface::MakeRenderTarget(
gr_context_.get(), SkBudgeted::kNo,
SkImageInfo::MakeN32Premul(size.width(), size.height()), 0,
kTopLeft_GrSurfaceOrigin, nullptr);
}
GLuint CmdBufferSurfaceProvider::FlushSurface(SkSurface* surface,
GLuint reuse_texture_id) {
surface->getCanvas()->flush();
GrBackendTexture backend_texture =
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess);
DCHECK(backend_texture.isValid());
GrGLTextureInfo info;
bool result = backend_texture.getGLTextureInfo(&info);
DCHECK(result);
GLuint texture_id = info.fID;
DCHECK_NE(texture_id, 0u);
surface->getCanvas()->getGrContext()->resetContext();
glBindFramebuffer(GL_FRAMEBUFFER, main_fbo_);
return texture_id;
}
} // namespace vr
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_VR_CMD_BUFFER_SURFACE_PROVIDER_H_
#define CHROME_BROWSER_VR_CMD_BUFFER_SURFACE_PROVIDER_H_
#include "chrome/browser/vr/skia_surface_provider.h"
#include "chrome/browser/vr/vr_ui_export.h"
class GrContext;
namespace vr {
class VR_UI_EXPORT CmdBufferSurfaceProvider : public SkiaSurfaceProvider {
public:
CmdBufferSurfaceProvider();
~CmdBufferSurfaceProvider() override;
sk_sp<SkSurface> MakeSurface(const gfx::Size& size) override;
GLuint FlushSurface(SkSurface* surface, GLuint reuse_texture_id) override;
private:
sk_sp<GrContext> gr_context_;
GLint main_fbo_ = 0;
};
} // namespace vr
#endif // CHROME_BROWSER_VR_CMD_BUFFER_SURFACE_PROVIDER_H_
...@@ -4,14 +4,12 @@ ...@@ -4,14 +4,12 @@
#include "chrome/browser/vr/skia_surface_provider_factory.h" #include "chrome/browser/vr/skia_surface_provider_factory.h"
#include "base/logging.h" #include "chrome/browser/vr/cmd_buffer_surface_provider.h"
namespace vr { namespace vr {
std::unique_ptr<SkiaSurfaceProvider> SkiaSurfaceProviderFactory::Create() { std::unique_ptr<SkiaSurfaceProvider> SkiaSurfaceProviderFactory::Create() {
// TODO(crbug/884256): Implement a surface provider using the command buffer. return std::make_unique<CmdBufferSurfaceProvider>();
NOTIMPLEMENTED();
return nullptr;
} }
} // namespace vr } // namespace vr
...@@ -10,13 +10,9 @@ ...@@ -10,13 +10,9 @@
namespace vr { namespace vr {
TEST(GlTestEnvironmentTest, InitializeAndCleanup) { TEST(GlTestEnvironmentTest, InitializeAndCleanup) {
// TODO(crbug/771794): Test temporarily disabled on Windows because it crashes
// on trybots. Fix before enabling Windows support.
#ifndef OS_WIN
GlTestEnvironment gl_test_environment(gfx::Size(100, 100)); GlTestEnvironment gl_test_environment(gfx::Size(100, 100));
EXPECT_NE(gl_test_environment.GetFrameBufferForTesting(), 0u); EXPECT_NE(gl_test_environment.GetFrameBufferForTesting(), 0u);
EXPECT_EQ(glGetError(), (GLenum)GL_NO_ERROR); EXPECT_EQ(glGetError(), (GLenum)GL_NO_ERROR);
#endif
// We just test that clean up doesn't crash. // We just test that clean up doesn't crash.
} }
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/test/launcher/unit_test_launcher.h" #include "base/test/launcher/unit_test_launcher.h"
#include "chrome/browser/vr/test/vr_test_suite.h" #include "chrome/browser/vr/test/vr_gl_test_suite.h"
int main(int argc, char** argv) { int main(int argc, char** argv) {
vr::VrTestSuite test_suite(argc, argv); vr::VrGlTestSuite test_suite(argc, argv);
return base::LaunchUnitTestsSerially( return base::LaunchUnitTestsSerially(
argc, argv, argc, argv,
base::BindRepeating(&vr::VrTestSuite::Run, base::BindRepeating(&vr::VrGlTestSuite::Run,
base::Unretained(&test_suite))); base::Unretained(&test_suite)));
} }
...@@ -21,9 +21,6 @@ UiPixelTest::UiPixelTest() : frame_buffer_size_(kPixelHalfScreen) {} ...@@ -21,9 +21,6 @@ UiPixelTest::UiPixelTest() : frame_buffer_size_(kPixelHalfScreen) {}
UiPixelTest::~UiPixelTest() = default; UiPixelTest::~UiPixelTest() = default;
void UiPixelTest::SetUp() { void UiPixelTest::SetUp() {
// TODO(crbug/771794): Test temporarily disabled on Windows because it crashes
// on trybots. Fix before enabling Windows support.
#ifndef OS_WIN
gl_test_environment_ = gl_test_environment_ =
std::make_unique<GlTestEnvironment>(frame_buffer_size_); std::make_unique<GlTestEnvironment>(frame_buffer_size_);
...@@ -36,17 +33,12 @@ void UiPixelTest::SetUp() { ...@@ -36,17 +33,12 @@ void UiPixelTest::SetUp() {
ASSERT_EQ(glGetError(), (GLenum)GL_NO_ERROR); ASSERT_EQ(glGetError(), (GLenum)GL_NO_ERROR);
browser_ = std::make_unique<MockUiBrowserInterface>(); browser_ = std::make_unique<MockUiBrowserInterface>();
#endif
} }
void UiPixelTest::TearDown() { void UiPixelTest::TearDown() {
// TODO(crbug/771794): Test temporarily disabled on Windows because it crashes
// on trybots. Fix before enabling Windows support.
#ifndef OS_WIN
ui_.reset(); ui_.reset();
glDeleteTextures(1, &content_texture_); glDeleteTextures(1, &content_texture_);
gl_test_environment_.reset(); gl_test_environment_.reset();
#endif
} }
void UiPixelTest::MakeUi(const UiInitialState& ui_initial_state, void UiPixelTest::MakeUi(const UiInitialState& ui_initial_state,
......
...@@ -8,10 +8,11 @@ ...@@ -8,10 +8,11 @@
#include "ui/gl/test/gl_image_test_support.h" #include "ui/gl/test/gl_image_test_support.h"
#if defined(VR_USE_COMMAND_BUFFER) #if defined(VR_USE_COMMAND_BUFFER)
#include "gpu/config/gpu_info_collector.h" // nogncheck #include "gpu/command_buffer/client/gles2_lib.h" // nogncheck
#include "gpu/config/gpu_preferences.h" // nogncheck #include "gpu/config/gpu_info_collector.h" // nogncheck
#include "gpu/config/gpu_util.h" // nogncheck #include "gpu/config/gpu_preferences.h" // nogncheck
#include "gpu/ipc/in_process_command_buffer.h" // nogncheck #include "gpu/config/gpu_util.h" // nogncheck
#include "gpu/ipc/in_process_command_buffer.h" // nogncheck
#endif // defined(VR_USE_COMMAND_BUFFER) #endif // defined(VR_USE_COMMAND_BUFFER)
namespace vr { namespace vr {
...@@ -36,6 +37,7 @@ void VrGlTestSuite::Initialize() { ...@@ -36,6 +37,7 @@ void VrGlTestSuite::Initialize() {
gpu::kGpuFeatureStatusEnabled; gpu::kGpuFeatureStatusEnabled;
gpu::InProcessCommandBuffer::InitializeDefaultServiceForTesting( gpu::InProcessCommandBuffer::InitializeDefaultServiceForTesting(
gpu_feature_info); gpu_feature_info);
gles2::Initialize();
#endif // defined(VR_USE_COMMAND_BUFFER) #endif // defined(VR_USE_COMMAND_BUFFER)
} }
......
...@@ -36,6 +36,7 @@ class TextPerfTest : public testing::Test { ...@@ -36,6 +36,7 @@ class TextPerfTest : public testing::Test {
void TearDown() override { void TearDown() override {
text_element_.reset(); text_element_.reset();
provider_.reset();
gl_test_environment_.reset(); gl_test_environment_.reset();
} }
...@@ -59,8 +60,8 @@ class TextPerfTest : public testing::Test { ...@@ -59,8 +60,8 @@ class TextPerfTest : public testing::Test {
cc::LapTimer timer_; cc::LapTimer timer_;
private: private:
std::unique_ptr<GlTestEnvironment> gl_test_environment_;
std::unique_ptr<SkiaSurfaceProvider> provider_; std::unique_ptr<SkiaSurfaceProvider> provider_;
std::unique_ptr<GlTestEnvironment> gl_test_environment_;
}; };
TEST_F(TextPerfTest, RenderLoremIpsum100Chars) { TEST_F(TextPerfTest, RenderLoremIpsum100Chars) {
......
...@@ -14,19 +14,11 @@ namespace vr { ...@@ -14,19 +14,11 @@ namespace vr {
namespace { namespace {
static const gfx::Transform kIdentity; constexpr gfx::Transform kIdentity;
} // namespace } // namespace
// TODO(crbug/771794): Test temporarily disabled on Windows because it crashes TEST_F(UiPixelTest, DrawVrBrowsingMode) {
// on trybots. Fix before enabling Windows support.
#if defined(OS_WIN)
#define MAYBE(x) DISABLED_##x
#else
#define MAYBE(x) x
#endif
TEST_F(UiPixelTest, MAYBE(DrawVrBrowsingMode)) {
// Set up scene. // Set up scene.
UiInitialState ui_initial_state; UiInitialState ui_initial_state;
ui_initial_state.in_web_vr = false; ui_initial_state.in_web_vr = false;
......
...@@ -625,6 +625,18 @@ ...@@ -625,6 +625,18 @@
}, },
"test": "viz_unittests" "test": "viz_unittests"
}, },
{
"swarming": {
"can_use_on_swarming_builders": true
},
"test": "vr_common_unittests"
},
{
"swarming": {
"can_use_on_swarming_builders": true
},
"test": "vr_pixeltests"
},
{ {
"swarming": { "swarming": {
"can_use_on_swarming_builders": true "can_use_on_swarming_builders": true
...@@ -1930,6 +1942,30 @@ ...@@ -1930,6 +1942,30 @@
}, },
"test": "views_unittests" "test": "views_unittests"
}, },
{
"swarming": {
"can_use_on_swarming_builders": true,
"dimension_sets": [
{
"cpu": "x86-64",
"os": "Windows-10-15063"
}
]
},
"test": "vr_common_unittests"
},
{
"swarming": {
"can_use_on_swarming_builders": true,
"dimension_sets": [
{
"cpu": "x86-64",
"os": "Windows-10-15063"
}
]
},
"test": "vr_pixeltests"
},
{ {
"swarming": { "swarming": {
"can_use_on_swarming_builders": true, "can_use_on_swarming_builders": true,
...@@ -3924,6 +3960,12 @@ ...@@ -3924,6 +3960,12 @@
}, },
"test": "vr_common_unittests" "test": "vr_common_unittests"
}, },
{
"swarming": {
"can_use_on_swarming_builders": true
},
"test": "vr_pixeltests"
},
{ {
"swarming": { "swarming": {
"can_use_on_swarming_builders": true "can_use_on_swarming_builders": true
...@@ -4688,6 +4730,12 @@ ...@@ -4688,6 +4730,12 @@
}, },
"test": "vr_common_unittests" "test": "vr_common_unittests"
}, },
{
"swarming": {
"can_use_on_swarming_builders": true
},
"test": "vr_pixeltests"
},
{ {
"swarming": { "swarming": {
"can_use_on_swarming_builders": true "can_use_on_swarming_builders": true
......
...@@ -1286,23 +1286,10 @@ ...@@ -1286,23 +1286,10 @@
'Win10 Tests x64', 'Win10 Tests x64',
], ],
}, },
'vr_common_unittests': {
'remove_from': [
# chromium.win
'Win 7 Tests x64 (1)',
'Win10 Tests x64',
],
},
'vr_pixeltests': { 'vr_pixeltests': {
'remove_from': [ 'remove_from': [
# chromium.fyi # chromium.fyi
'VR Linux', 'VR Linux',
# chromium.win
'Win 7 Tests x64 (1)',
'Win10 Tests x64',
'Win7 Tests (1)',
'Win7 Tests (dbg)(1)',
], ],
}, },
'wayland_client_perftests': { 'wayland_client_perftests': {
......
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