From 3999d63ffce27da5a971702f35698bfc042fece6 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 16 May 2023 12:41:00 -0700 Subject: [PATCH] [Impelller] fix flickering due to synchronization issues in compute tessellator. --- .../renderer/compute_subgroup_unittests.cc | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/impeller/renderer/compute_subgroup_unittests.cc b/impeller/renderer/compute_subgroup_unittests.cc index 0be2af75d814d..0850b884fb81d 100644 --- a/impeller/renderer/compute_subgroup_unittests.cc +++ b/impeller/renderer/compute_subgroup_unittests.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include #include #include "compute_tessellator.h" @@ -77,6 +78,9 @@ TEST_P(ComputeSubgroupTest, PathPlayground) { SkPath sk_path; if (SkParsePath::FromSVGString(svg_path_data, &sk_path)) { + std::promise promise; + auto future = promise.get_future(); + auto path = skia_conversions::ToPath(sk_path); auto status = ComputeTessellator{} @@ -84,16 +88,15 @@ TEST_P(ComputeSubgroupTest, PathPlayground) { .Tessellate( path, context, vertex_buffer->AsBufferView(), vertex_buffer_count->AsBufferView(), - [vertex_buffer_count, - &vertex_count](CommandBuffer::Status status) { + [vertex_buffer_count, &vertex_count, + &promise](CommandBuffer::Status status) { vertex_count = reinterpret_cast( vertex_buffer_count->AsBufferView().contents) ->count; + promise.set_value(status == + CommandBuffer::Status::kCompleted); }); - if (vertex_count > 0) { - ImGui::Text("Vertex count: %zu", vertex_count); - } switch (status) { case ComputeTessellator::Status::kCommandInvalid: ImGui::Text("Failed to submit compute job (invalid command)"); @@ -104,6 +107,13 @@ TEST_P(ComputeSubgroupTest, PathPlayground) { case ComputeTessellator::Status::kOk: break; } + if (!future.get()) { + ImGui::Text("Failed to submit compute job."); + return false; + } + if (vertex_count > 0) { + ImGui::Text("Vertex count: %zu", vertex_count); + } } else { ImGui::Text("Failed to parse path data"); }