Add wait function on GrContext to wait on semaphores.

This behaves like the SkSurface::wait call but is not tied to a specific
surface.

Change-Id: Ic572296e0f581204bf69a7178645d99e365c0692
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209648
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2019-04-22 15:53:23 -04:00 committed by Skia Commit-Bot
parent dd15d69e1f
commit 06be079791
3 changed files with 25 additions and 1 deletions

View File

@ -242,6 +242,16 @@ public:
///////////////////////////////////////////////////////////////////////////
// Misc.
/**
* Inserts a list of GPU semaphores that the current GPU-backed API must wait on before
* executing any more commands on the GPU. Skia will take ownership of the underlying semaphores
* and delete them once they have been signaled and waited on. If this call returns false, then
* the GPU back-end will not wait on any passed in semaphores, and the client will still own the
* semaphores.
*/
bool wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores);
/**
* Call to ensure all drawing to the context has been issued to the underlying 3D API.
*/

View File

@ -239,6 +239,21 @@ int GrContext::maxSurfaceSampleCountForColorType(SkColorType colorType) const {
////////////////////////////////////////////////////////////////////////////////
bool GrContext::wait(int numSemaphores, const GrBackendSemaphore waitSemaphores[]) {
if (!fGpu || fGpu->caps()->fenceSyncSupport()) {
return false;
}
for (int i = 0; i < numSemaphores; ++i) {
sk_sp<GrSemaphore> sema = fResourceProvider->wrapBackendSemaphore(
waitSemaphores[i], GrResourceProvider::SemaphoreWrapType::kWillWait,
kAdopt_GrWrapOwnership);
fGpu->waitSemaphore(std::move(sema));
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
GrSemaphoresSubmitted GrContext::flush(const GrFlushInfo& info) {
ASSERT_SINGLE_OWNER
if (this->abandoned()) {

View File

@ -1774,7 +1774,6 @@ bool GrRenderTargetContext::waitOnSemaphores(int numSemaphores,
auto resourceProvider = direct->priv().resourceProvider();
SkTArray<sk_sp<GrSemaphore>> semaphores(numSemaphores);
for (int i = 0; i < numSemaphores; ++i) {
sk_sp<GrSemaphore> sema = resourceProvider->wrapBackendSemaphore(
waitSemaphores[i], GrResourceProvider::SemaphoreWrapType::kWillWait,