Commit 75c9fe22 authored by Weiliang Chen's avatar Weiliang Chen Committed by Commit Bot

viz: Only Create SyncQueryCollect in SkiaRenderer Optionally

Trying to access GL will crash vulkan build. Only create sync queries
when it can be used.

R=enne

Bug: 644851
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: Ibffe46608195541ab094aae9de4161871c1ab2b1
Reviewed-on: https://chromium-review.googlesource.com/941383Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Reviewed-by: default avatarenne <enne@chromium.org>
Commit-Queue: weiliangc <weiliangc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539961}
parent db076935
......@@ -58,15 +58,16 @@ namespace viz {
SkiaRenderer::SkiaRenderer(const RendererSettings* settings,
OutputSurface* output_surface,
cc::DisplayResourceProvider* resource_provider)
: DirectRenderer(settings, output_surface, resource_provider),
sync_queries_(output_surface->context_provider()->ContextGL()) {
: DirectRenderer(settings, output_surface, resource_provider) {
#if BUILDFLAG(ENABLE_VULKAN)
use_swap_with_bounds_ = false;
#else
const auto& context_caps =
output_surface_->context_provider()->ContextCapabilities();
use_swap_with_bounds_ = context_caps.swap_buffers_with_bounds;
use_sync_query_ = context_caps.sync_query;
if (context_caps.sync_query)
sync_queries_ = base::Optional<SyncQueryCollection>(
output_surface->context_provider()->ContextGL());
#endif
}
......@@ -93,8 +94,8 @@ void SkiaRenderer::BeginDrawingFrame() {
#else
// Copied from GLRenderer.
scoped_refptr<ResourceFence> read_lock_fence;
if (use_sync_query_) {
read_lock_fence = sync_queries_.StartNewFrame();
if (sync_queries_) {
read_lock_fence = sync_queries_->StartNewFrame();
} else {
read_lock_fence =
base::MakeRefCounted<cc::DisplayResourceProvider::SynchronousFence>(
......@@ -115,8 +116,8 @@ void SkiaRenderer::BeginDrawingFrame() {
void SkiaRenderer::FinishDrawingFrame() {
TRACE_EVENT0("viz", "SkiaRenderer::FinishDrawingFrame");
if (use_sync_query_) {
sync_queries_.EndCurrentFrame();
if (sync_queries_) {
sync_queries_->EndCurrentFrame();
}
if (settings_->show_overdraw_feedback) {
......
......@@ -129,8 +129,7 @@ class VIZ_SERVICE_EXPORT SkiaRenderer : public DirectRenderer {
SkCanvas* current_canvas_ = nullptr;
SkPaint current_paint_;
bool use_sync_query_ = false;
SyncQueryCollection sync_queries_;
base::Optional<SyncQueryCollection> sync_queries_;
bool use_swap_with_bounds_ = false;
gfx::Rect swap_buffer_rect_;
......
......@@ -111,6 +111,9 @@ SyncQueryCollection::SyncQueryCollection(gpu::gles2::GLES2Interface* gl)
: gl_(gl) {}
SyncQueryCollection::~SyncQueryCollection() = default;
SyncQueryCollection::SyncQueryCollection(SyncQueryCollection&&) = default;
SyncQueryCollection& SyncQueryCollection::operator=(SyncQueryCollection&&) =
default;
scoped_refptr<ResourceFence> SyncQueryCollection::StartNewFrame() {
// Block until oldest sync query has passed if the number of pending queries
......
......@@ -23,6 +23,8 @@ class ResourceFence;
class SyncQueryCollection {
public:
explicit SyncQueryCollection(gpu::gles2::GLES2Interface* gl);
SyncQueryCollection(SyncQueryCollection&&);
SyncQueryCollection& operator=(SyncQueryCollection&&);
~SyncQueryCollection();
scoped_refptr<ResourceFence> StartNewFrame();
void EndCurrentFrame();
......
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