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() { ...@@ -130,4 +130,8 @@ void SkiaOutputDevice::SwapInfo::CallFeedback() {
} }
} }
std::vector<GrBackendSemaphore> SkiaOutputDevice::TakeEndPaintSemaphores() {
return std::vector<GrBackendSemaphore>();
}
} // namespace viz } // namespace viz
...@@ -31,7 +31,6 @@ class Size; ...@@ -31,7 +31,6 @@ class Size;
struct PresentationFeedback; struct PresentationFeedback;
} // namespace gfx } // namespace gfx
namespace gpu { namespace gpu {
class MemoryTracker; class MemoryTracker;
class MemoryTypeTracker; class MemoryTypeTracker;
...@@ -56,6 +55,10 @@ class SkiaOutputDevice { ...@@ -56,6 +55,10 @@ class SkiaOutputDevice {
semaphore_ = semaphore; semaphore_ = semaphore;
} }
std::vector<GrBackendSemaphore> GetEndPaintSemaphores(void) {
return device_->TakeEndPaintSemaphores();
}
private: private:
SkiaOutputDevice* const device_; SkiaOutputDevice* const device_;
SkSurface* const sk_surface_; SkSurface* const sk_surface_;
...@@ -144,6 +147,9 @@ class SkiaOutputDevice { ...@@ -144,6 +147,9 @@ class SkiaOutputDevice {
// End paint the back buffer. // End paint the back buffer.
virtual void EndPaint(const GrBackendSemaphore& semaphore) = 0; 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 // Helper method for SwapBuffers() and PostSubBuffer(). It should be called
// at the beginning of SwapBuffers() and PostSubBuffer() implementations // at the beginning of SwapBuffers() and PostSubBuffer() implementations
void StartSwapBuffers(BufferPresentedCallback feedback); void StartSwapBuffers(BufferPresentedCallback feedback);
......
...@@ -90,15 +90,24 @@ class SkiaOutputDeviceBufferQueue::Image { ...@@ -90,15 +90,24 @@ class SkiaOutputDeviceBufferQueue::Image {
return scoped_skia_write_access_->surface(); 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() { 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_); DCHECK(scoped_skia_write_access_);
GrFlushInfo flush_info = { if (!end_semaphores_.empty()) {
.fFlags = kNone_GrFlushFlags, GrFlushInfo flush_info = {
.fNumSemaphores = end_semaphores_.size(), .fFlags = kNone_GrFlushFlags,
.fSignalSemaphores = end_semaphores_.data(), .fNumSemaphores = end_semaphores_.size(),
}; .fSignalSemaphores = end_semaphores_.data(),
scoped_skia_write_access_->surface()->flush( };
SkSurface::BackendSurfaceAccess::kNoAccess, flush_info); scoped_skia_write_access_->surface()->flush(
SkSurface::BackendSurfaceAccess::kNoAccess, flush_info);
}
scoped_skia_write_access_.reset(); scoped_skia_write_access_.reset();
end_semaphores_.clear(); end_semaphores_.clear();
...@@ -505,4 +514,9 @@ void SkiaOutputDeviceBufferQueue::EndPaint( ...@@ -505,4 +514,9 @@ void SkiaOutputDeviceBufferQueue::EndPaint(
current_image_->EndWriteSkia(); current_image_->EndWriteSkia();
} }
std::vector<GrBackendSemaphore>
SkiaOutputDeviceBufferQueue::TakeEndPaintSemaphores() {
return current_image_->TakeEndWriteSkiaSemaphores();
}
} // namespace viz } // namespace viz
...@@ -51,6 +51,7 @@ class VIZ_SERVICE_EXPORT SkiaOutputDeviceBufferQueue final ...@@ -51,6 +51,7 @@ class VIZ_SERVICE_EXPORT SkiaOutputDeviceBufferQueue final
gfx::OverlayTransform transform) override; gfx::OverlayTransform transform) override;
SkSurface* BeginPaint() override; SkSurface* BeginPaint() override;
void EndPaint(const GrBackendSemaphore& semaphore) override; void EndPaint(const GrBackendSemaphore& semaphore) override;
std::vector<GrBackendSemaphore> TakeEndPaintSemaphores(void) override;
bool supports_alpha() { return true; } bool supports_alpha() { return true; }
void SchedulePrimaryPlane( void SchedulePrimaryPlane(
......
...@@ -933,15 +933,24 @@ bool SkiaOutputSurfaceImplOnGpu::FinishPaintCurrentFrame( ...@@ -933,15 +933,24 @@ bool SkiaOutputSurfaceImplOnGpu::FinishPaintCurrentFrame(
&paint); &paint);
} }
if (output_device_->need_swap_semaphore())
scoped_promise_image_access.end_semaphores().emplace_back();
GrFlushInfo flush_info; GrFlushInfo flush_info;
flush_info.fFlags = kNone_GrFlushFlags; flush_info.fFlags = kNone_GrFlushFlags;
flush_info.fNumSemaphores =
scoped_promise_image_access.end_semaphores().size(); auto end_paint_semaphores =
flush_info.fSignalSemaphores = scoped_output_device_paint_->GetEndPaintSemaphores();
scoped_promise_image_access.end_semaphores().data();
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_, gpu::AddVulkanCleanupTaskForSkiaFlush(vulkan_context_provider_,
&flush_info); &flush_info);
...@@ -950,15 +959,16 @@ bool SkiaOutputSurfaceImplOnGpu::FinishPaintCurrentFrame( ...@@ -950,15 +959,16 @@ bool SkiaOutputSurfaceImplOnGpu::FinishPaintCurrentFrame(
auto result = output_sk_surface()->flush( auto result = output_sk_surface()->flush(
SkSurface::BackendSurfaceAccess::kPresent, flush_info); SkSurface::BackendSurfaceAccess::kPresent, flush_info);
if (result != GrSemaphoresSubmitted::kYes && if (result != GrSemaphoresSubmitted::kYes &&
!(scoped_promise_image_access.begin_semaphores().empty() && !(scoped_promise_image_access.begin_semaphores().empty() &&
scoped_promise_image_access.end_semaphores().empty())) { end_paint_semaphores.empty())) {
// TODO(penghuang): handle vulkan device lost. // TODO(penghuang): handle vulkan device lost.
DLOG(ERROR) << "output_sk_surface()->flush() failed."; DLOG(ERROR) << "output_sk_surface()->flush() failed.";
return false; return false;
} }
if (output_device_->need_swap_semaphore()) { if (output_device_->need_swap_semaphore()) {
auto& semaphore = scoped_promise_image_access.end_semaphores().back(); auto& semaphore = end_paint_semaphores.back();
DCHECK(semaphore.isInitialized()); DCHECK(semaphore.isInitialized());
scoped_output_device_paint_->set_semaphore(std::move(semaphore)); 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