Commit 78f68988 authored by Nazih Almalki's avatar Nazih Almalki Committed by Commit Bot

Combine the flush for FinishPaint with EndWrikeSkia

FinishPaintCurrentFrame and EndWriteSkia
(SkiaOutputDeviceBufferQueue) both do a flush right after each
other.

The CL combines the flush from both, and get it done in
FinishPaintCurrentFrame.

The FinishPaintCurrentFrame, calls GetEndPaintSemaphore, that is combined
with the FinishPaintCurrentFrame, and flushed.

EndWriteSkia, Checks if the semaphore has been flushed, if not, it will
flush it.

Bug: 1043114

Change-Id: I541f0a9b5c31e7bfaee7b83a6be99d98323f0f28
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2024919Reviewed-by: default avatarVasiliy Telezhnikov <vasilyt@chromium.org>
Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Commit-Queue: Nazih Almalki <nalmalki@google.com>
Cr-Commit-Position: refs/heads/master@{#736501}
parent b11af76b
......@@ -130,4 +130,8 @@ void SkiaOutputDevice::SwapInfo::CallFeedback() {
}
}
std::vector<GrBackendSemaphore> SkiaOutputDevice::TakeEndPaintSemaphores() {
return std::vector<GrBackendSemaphore>();
}
} // namespace viz
......@@ -31,7 +31,6 @@ class Size;
struct PresentationFeedback;
} // namespace gfx
namespace gpu {
class MemoryTracker;
class MemoryTypeTracker;
......@@ -56,6 +55,10 @@ class SkiaOutputDevice {
semaphore_ = semaphore;
}
std::vector<GrBackendSemaphore> GetEndPaintSemaphores(void) {
return device_->TakeEndPaintSemaphores();
}
private:
SkiaOutputDevice* const device_;
SkSurface* const sk_surface_;
......@@ -144,6 +147,9 @@ class SkiaOutputDevice {
// End paint the back buffer.
virtual void EndPaint(const GrBackendSemaphore& semaphore) = 0;
// Get End paint semaphore buffer.
virtual std::vector<GrBackendSemaphore> TakeEndPaintSemaphores();
// Helper method for SwapBuffers() and PostSubBuffer(). It should be called
// at the beginning of SwapBuffers() and PostSubBuffer() implementations
void StartSwapBuffers(BufferPresentedCallback feedback);
......
......@@ -90,8 +90,16 @@ class SkiaOutputDeviceBufferQueue::Image {
return scoped_skia_write_access_->surface();
}
std::vector<GrBackendSemaphore> TakeEndWriteSkiaSemaphores() {
std::vector<GrBackendSemaphore> temp_vector;
temp_vector.swap(end_semaphores_);
return temp_vector;
}
void EndWriteSkia() {
// The Flush now takes place in finishPaintCurrentBuffer on the CPU side.
// check if end_semaphores is not empty then flash here
DCHECK(scoped_skia_write_access_);
if (!end_semaphores_.empty()) {
GrFlushInfo flush_info = {
.fFlags = kNone_GrFlushFlags,
.fNumSemaphores = end_semaphores_.size(),
......@@ -99,6 +107,7 @@ class SkiaOutputDeviceBufferQueue::Image {
};
scoped_skia_write_access_->surface()->flush(
SkSurface::BackendSurfaceAccess::kNoAccess, flush_info);
}
scoped_skia_write_access_.reset();
end_semaphores_.clear();
......@@ -505,4 +514,9 @@ void SkiaOutputDeviceBufferQueue::EndPaint(
current_image_->EndWriteSkia();
}
std::vector<GrBackendSemaphore>
SkiaOutputDeviceBufferQueue::TakeEndPaintSemaphores() {
return current_image_->TakeEndWriteSkiaSemaphores();
}
} // namespace viz
......@@ -51,6 +51,7 @@ class VIZ_SERVICE_EXPORT SkiaOutputDeviceBufferQueue final
gfx::OverlayTransform transform) override;
SkSurface* BeginPaint() override;
void EndPaint(const GrBackendSemaphore& semaphore) override;
std::vector<GrBackendSemaphore> TakeEndPaintSemaphores(void) override;
bool supports_alpha() { return true; }
void SchedulePrimaryPlane(
......
......@@ -933,15 +933,24 @@ bool SkiaOutputSurfaceImplOnGpu::FinishPaintCurrentFrame(
&paint);
}
if (output_device_->need_swap_semaphore())
scoped_promise_image_access.end_semaphores().emplace_back();
GrFlushInfo flush_info;
flush_info.fFlags = kNone_GrFlushFlags;
flush_info.fNumSemaphores =
scoped_promise_image_access.end_semaphores().size();
flush_info.fSignalSemaphores =
scoped_promise_image_access.end_semaphores().data();
auto end_paint_semaphores =
scoped_output_device_paint_->GetEndPaintSemaphores();
end_paint_semaphores.insert(
end_paint_semaphores.end(),
std::make_move_iterator(
scoped_promise_image_access.end_semaphores().begin()),
std::make_move_iterator(
scoped_promise_image_access.end_semaphores().end()));
if (output_device_->need_swap_semaphore())
end_paint_semaphores.emplace_back();
// update the size and data pointer
flush_info.fNumSemaphores = end_paint_semaphores.size();
flush_info.fSignalSemaphores = end_paint_semaphores.data();
gpu::AddVulkanCleanupTaskForSkiaFlush(vulkan_context_provider_,
&flush_info);
......@@ -950,15 +959,16 @@ bool SkiaOutputSurfaceImplOnGpu::FinishPaintCurrentFrame(
auto result = output_sk_surface()->flush(
SkSurface::BackendSurfaceAccess::kPresent, flush_info);
if (result != GrSemaphoresSubmitted::kYes &&
!(scoped_promise_image_access.begin_semaphores().empty() &&
scoped_promise_image_access.end_semaphores().empty())) {
end_paint_semaphores.empty())) {
// TODO(penghuang): handle vulkan device lost.
DLOG(ERROR) << "output_sk_surface()->flush() failed.";
return false;
}
if (output_device_->need_swap_semaphore()) {
auto& semaphore = scoped_promise_image_access.end_semaphores().back();
auto& semaphore = end_paint_semaphores.back();
DCHECK(semaphore.isInitialized());
scoped_output_device_paint_->set_semaphore(std::move(semaphore));
}
......
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