Make sure we are checking for failed wrapping of semaphores.

Bug: chromium:1098902
Change-Id: I338464b6364b3e0f614e8e084a2b0382b3b975e0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300258
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
Greg Daniel 2020-07-01 17:40:12 -04:00 committed by Skia Commit-Bot
parent b5f7a07b77
commit 0106fcc8a7
8 changed files with 27 additions and 3 deletions

View File

@ -298,8 +298,12 @@ bool GrContext::wait(int numSemaphores, const GrBackendSemaphore waitSemaphores[
std::unique_ptr<GrSemaphore> sema = fResourceProvider->wrapBackendSemaphore( std::unique_ptr<GrSemaphore> sema = fResourceProvider->wrapBackendSemaphore(
waitSemaphores[i], GrResourceProvider::SemaphoreWrapType::kWillWait, waitSemaphores[i], GrResourceProvider::SemaphoreWrapType::kWillWait,
kAdopt_GrWrapOwnership); kAdopt_GrWrapOwnership);
// If we failed to wrap the semaphore it means the client didn't give us a valid semaphore
// to begin with. Therefore, it is fine to not wait on it.
if (sema) {
fGpu->waitSemaphore(sema.get()); fGpu->waitSemaphore(sema.get());
} }
}
return true; return true;
} }

View File

@ -673,7 +673,11 @@ void GrGpu::executeFlushInfo(GrSurfaceProxy* proxies[],
info.fSignalSemaphores[i], info.fSignalSemaphores[i],
GrResourceProvider::SemaphoreWrapType::kWillSignal, GrResourceProvider::SemaphoreWrapType::kWillSignal,
kBorrow_GrWrapOwnership); kBorrow_GrWrapOwnership);
// If we failed to wrap the semaphore it means the client didn't give us a valid
// semaphore to begin with. Therefore, it is fine to not signal it.
if (semaphores[i]) {
this->insertSemaphore(semaphores[i].get()); this->insertSemaphore(semaphores[i].get());
}
} else { } else {
semaphores[i] = resourceProvider->makeSemaphore(false); semaphores[i] = resourceProvider->makeSemaphore(false);
if (semaphores[i]) { if (semaphores[i]) {

View File

@ -24,7 +24,12 @@ void GrWaitRenderTask::gatherProxyIntervals(GrResourceAllocator* alloc) const {
bool GrWaitRenderTask::onExecute(GrOpFlushState* flushState) { bool GrWaitRenderTask::onExecute(GrOpFlushState* flushState) {
for (int i = 0; i < fNumSemaphores; ++i) { for (int i = 0; i < fNumSemaphores; ++i) {
// If we don't have a semaphore here it means we failed to wrap it. That happens if the
// client didn't give us a valid semaphore to begin with. Therefore, it is fine to not wait
// on it.
if (fSemaphores[i].get()) {
flushState->gpu()->waitSemaphore(fSemaphores[i].get()); flushState->gpu()->waitSemaphore(fSemaphores[i].get());
} }
}
return true; return true;
} }

View File

@ -1188,12 +1188,14 @@ std::unique_ptr<GrSemaphore> GrD3DGpu::wrapBackendSemaphore(
} }
void GrD3DGpu::insertSemaphore(GrSemaphore* semaphore) { void GrD3DGpu::insertSemaphore(GrSemaphore* semaphore) {
SkASSERT(semaphore);
GrD3DSemaphore* d3dSem = static_cast<GrD3DSemaphore*>(semaphore); GrD3DSemaphore* d3dSem = static_cast<GrD3DSemaphore*>(semaphore);
// TODO: Do we need to track the lifetime of this? How do we know it's done? // TODO: Do we need to track the lifetime of this? How do we know it's done?
fQueue->Signal(d3dSem->fence(), d3dSem->value()); fQueue->Signal(d3dSem->fence(), d3dSem->value());
} }
void GrD3DGpu::waitSemaphore(GrSemaphore* semaphore) { void GrD3DGpu::waitSemaphore(GrSemaphore* semaphore) {
SkASSERT(semaphore);
GrD3DSemaphore* d3dSem = static_cast<GrD3DSemaphore*>(semaphore); GrD3DSemaphore* d3dSem = static_cast<GrD3DSemaphore*>(semaphore);
// TODO: Do we need to track the lifetime of this? // TODO: Do we need to track the lifetime of this?
fQueue->Wait(d3dSem->fence(), d3dSem->value()); fQueue->Wait(d3dSem->fence(), d3dSem->value());

View File

@ -3948,6 +3948,7 @@ std::unique_ptr<GrSemaphore> GrGLGpu::wrapBackendSemaphore(
} }
void GrGLGpu::insertSemaphore(GrSemaphore* semaphore) { void GrGLGpu::insertSemaphore(GrSemaphore* semaphore) {
SkASSERT(semaphore);
GrGLSemaphore* glSem = static_cast<GrGLSemaphore*>(semaphore); GrGLSemaphore* glSem = static_cast<GrGLSemaphore*>(semaphore);
GrGLsync sync; GrGLsync sync;
@ -3957,6 +3958,7 @@ void GrGLGpu::insertSemaphore(GrSemaphore* semaphore) {
} }
void GrGLGpu::waitSemaphore(GrSemaphore* semaphore) { void GrGLGpu::waitSemaphore(GrSemaphore* semaphore) {
SkASSERT(semaphore);
GrGLSemaphore* glSem = static_cast<GrGLSemaphore*>(semaphore); GrGLSemaphore* glSem = static_cast<GrGLSemaphore*>(semaphore);
GL_CALL(WaitSync(glSem->sync(), 0, GR_GL_TIMEOUT_IGNORED)); GL_CALL(WaitSync(glSem->sync(), 0, GR_GL_TIMEOUT_IGNORED));

View File

@ -1352,6 +1352,7 @@ std::unique_ptr<GrSemaphore> GrMtlGpu::wrapBackendSemaphore(
void GrMtlGpu::insertSemaphore(GrSemaphore* semaphore) { void GrMtlGpu::insertSemaphore(GrSemaphore* semaphore) {
if (@available(macOS 10.14, iOS 12.0, *)) { if (@available(macOS 10.14, iOS 12.0, *)) {
SkASSERT(semaphore);
GrMtlSemaphore* mtlSem = static_cast<GrMtlSemaphore*>(semaphore); GrMtlSemaphore* mtlSem = static_cast<GrMtlSemaphore*>(semaphore);
this->commandBuffer()->encodeSignalEvent(mtlSem->event(), mtlSem->value()); this->commandBuffer()->encodeSignalEvent(mtlSem->event(), mtlSem->value());
@ -1360,6 +1361,7 @@ void GrMtlGpu::insertSemaphore(GrSemaphore* semaphore) {
void GrMtlGpu::waitSemaphore(GrSemaphore* semaphore) { void GrMtlGpu::waitSemaphore(GrSemaphore* semaphore) {
if (@available(macOS 10.14, iOS 12.0, *)) { if (@available(macOS 10.14, iOS 12.0, *)) {
SkASSERT(semaphore);
GrMtlSemaphore* mtlSem = static_cast<GrMtlSemaphore*>(semaphore); GrMtlSemaphore* mtlSem = static_cast<GrMtlSemaphore*>(semaphore);
this->commandBuffer()->encodeWaitForEvent(mtlSem->event(), mtlSem->value()); this->commandBuffer()->encodeWaitForEvent(mtlSem->event(), mtlSem->value());

View File

@ -2570,6 +2570,8 @@ std::unique_ptr<GrSemaphore> GrVkGpu::wrapBackendSemaphore(
} }
void GrVkGpu::insertSemaphore(GrSemaphore* semaphore) { void GrVkGpu::insertSemaphore(GrSemaphore* semaphore) {
SkASSERT(semaphore);
GrVkSemaphore* vkSem = static_cast<GrVkSemaphore*>(semaphore); GrVkSemaphore* vkSem = static_cast<GrVkSemaphore*>(semaphore);
GrVkSemaphore::Resource* resource = vkSem->getResource(); GrVkSemaphore::Resource* resource = vkSem->getResource();
@ -2580,6 +2582,8 @@ void GrVkGpu::insertSemaphore(GrSemaphore* semaphore) {
} }
void GrVkGpu::waitSemaphore(GrSemaphore* semaphore) { void GrVkGpu::waitSemaphore(GrSemaphore* semaphore) {
SkASSERT(semaphore);
GrVkSemaphore* vkSem = static_cast<GrVkSemaphore*>(semaphore); GrVkSemaphore* vkSem = static_cast<GrVkSemaphore*>(semaphore);
GrVkSemaphore::Resource* resource = vkSem->getResource(); GrVkSemaphore::Resource* resource = vkSem->getResource();

View File

@ -38,6 +38,7 @@ std::unique_ptr<GrVkSemaphore> GrVkSemaphore::MakeWrapped(GrVkGpu* gpu,
WrapType wrapType, WrapType wrapType,
GrWrapOwnership ownership) { GrWrapOwnership ownership) {
if (VK_NULL_HANDLE == semaphore) { if (VK_NULL_HANDLE == semaphore) {
SkDEBUGFAIL("Trying to wrap an invalid VkSemaphore");
return nullptr; return nullptr;
} }
bool prohibitSignal = WrapType::kWillWait == wrapType; bool prohibitSignal = WrapType::kWillWait == wrapType;