From 70c3a4d60527f5439bda35a9644eaa5e30a4b6d9 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Tue, 4 Oct 2022 15:12:32 +0000 Subject: [PATCH] vulkan: Move handling texture wait requirements to SubmitPendingCommands This moves handling the wait semaphores to the same place that the signal semaphores are handled. It fixes a bug where the semaphores are never waited on and never deleted if a texture is imported and then exported without being used. Bug: chromium:1359106 Change-Id: If226a38946d4a16598d78841e7b204ea91f8bbea Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104541 Kokoro: Kokoro Reviewed-by: Corentin Wallez Commit-Queue: Austin Eng Reviewed-by: Loko Kung --- src/dawn/native/vulkan/DeviceVk.cpp | 3 +++ src/dawn/native/vulkan/TextureVk.cpp | 8 ++++---- src/dawn/native/vulkan/TextureVk.h | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/dawn/native/vulkan/DeviceVk.cpp b/src/dawn/native/vulkan/DeviceVk.cpp index 9c99b62e2c..26d638e008 100644 --- a/src/dawn/native/vulkan/DeviceVk.cpp +++ b/src/dawn/native/vulkan/DeviceVk.cpp @@ -304,6 +304,9 @@ MaybeError Device::SubmitPendingCommands() { // Transition eagerly all used external textures for export. for (auto* texture : mRecordingContext.externalTexturesForEagerTransition) { texture->TransitionEagerlyForExport(&mRecordingContext); + std::vector waitRequirements = texture->AcquireWaitRequirements(); + mRecordingContext.waitSemaphores.insert(mRecordingContext.waitSemaphores.end(), + waitRequirements.begin(), waitRequirements.end()); } DAWN_TRY( diff --git a/src/dawn/native/vulkan/TextureVk.cpp b/src/dawn/native/vulkan/TextureVk.cpp index 8fbc0552e7..1d0ba84adb 100644 --- a/src/dawn/native/vulkan/TextureVk.cpp +++ b/src/dawn/native/vulkan/TextureVk.cpp @@ -867,6 +867,10 @@ void Texture::TransitionEagerlyForExport(CommandRecordingContext* recordingConte nullptr, 0, nullptr, 1, &barrier); } +std::vector Texture::AcquireWaitRequirements() { + return std::move(mWaitRequirements); +} + MaybeError Texture::ExportExternalTexture(VkImageLayout desiredLayout, ExternalSemaphoreHandle* handle, VkImageLayout* releasedOldLayout, @@ -1051,10 +1055,6 @@ void Texture::TweakTransitionForExternalUsage(CommandRecordingContext* recording } mLastExternalState = mExternalState; - - recordingContext->waitSemaphores.insert(recordingContext->waitSemaphores.end(), - mWaitRequirements.begin(), mWaitRequirements.end()); - mWaitRequirements.clear(); } bool Texture::CanReuseWithoutBarrier(wgpu::TextureUsage lastUsage, wgpu::TextureUsage usage) { diff --git a/src/dawn/native/vulkan/TextureVk.h b/src/dawn/native/vulkan/TextureVk.h index 3ddd7d27f0..b0a2c00fa3 100644 --- a/src/dawn/native/vulkan/TextureVk.h +++ b/src/dawn/native/vulkan/TextureVk.h @@ -82,6 +82,7 @@ class Texture final : public TextureBase { // Eagerly transition the texture for export. void TransitionEagerlyForExport(CommandRecordingContext* recordingContext); + std::vector AcquireWaitRequirements(); void EnsureSubresourceContentInitialized(CommandRecordingContext* recordingContext, const SubresourceRange& range);