Move Ganesh flush calls from drawLayersInternal to flushAndSubmit
While calling skgpu::ganesh::Flush won't cause any harm in Graphite, it
doesn't make sense to call it from the shared SkiaRenderEngine.
Additionally, making flushAndSubmit accept a destination SkSurface to
support this move will also be required for GraphiteVkRenderEngine.
GaneshVkRenderEngine could probably get away with just one flush call,
but this approach keeps functional parity (and keeps traces equivalent
FWIW).
Unfortunately, drawLayersInternal still needs to call
skgpu::ganesh::Flush when kGaneshFlushAfterEveryLayer is locally
enabled. This could be moved to some abstraction on either
SkiaGpuContext, or the child implementation of SkiaRenderEngine.
However, I'd like to minimize the number of abstracted functions that
*look* load bearing, but actually no-op in Graphite. Since I believe
this is only used for locally investigating shader priming stuff, I
would rather just leave it in a weird (but documented) state until it's
removed.
While moving the call to flushAndSubmit, I also changed it to the
equivalent non-static variant that is called directly on a context,
instead of finding the context from the surface. I feel this might help
differentiate the intent of "maybe flush" in drawLayersInternal vs.
"definitely flush on this context" in flushAndSubmit.
Test: manual validation (GL+VK) & existing tests (refactor)
Bug: b/293371537
Change-Id: Ia78cd8457aa47d6bb80ad5e81eb9d79b7eed5e79
diff --git a/libs/renderengine/skia/GaneshVkRenderEngine.cpp b/libs/renderengine/skia/GaneshVkRenderEngine.cpp
index e76a4c3..673ddf3 100644
--- a/libs/renderengine/skia/GaneshVkRenderEngine.cpp
+++ b/libs/renderengine/skia/GaneshVkRenderEngine.cpp
@@ -23,6 +23,7 @@
#include <log/log_main.h>
#include <sync/sync.h>
+#include <utils/Trace.h>
namespace android::renderengine::skia {
@@ -51,11 +52,18 @@
context->grDirectContext()->wait(1, &beSemaphore, kDeleteAfterWait);
}
-base::unique_fd GaneshVkRenderEngine::flushAndSubmit(SkiaGpuContext* context) {
+base::unique_fd GaneshVkRenderEngine::flushAndSubmit(SkiaGpuContext* context,
+ sk_sp<SkSurface> dstSurface) {
sk_sp<GrDirectContext> grContext = context->grDirectContext();
+ {
+ ATRACE_NAME("flush surface");
+ // TODO: Investigate feasibility of combining this "surface flush" into the "context flush"
+ // below.
+ context->grDirectContext()->flush(dstSurface.get());
+ }
+
VulkanInterface& vi = getVulkanInterface(isProtected());
VkSemaphore semaphore = vi.createExportableSemaphore();
-
GrBackendSemaphore backendSemaphore = GrBackendSemaphores::MakeVk(semaphore);
GrFlushInfo flushInfo;