Permalink
Browse files

Vulkan: Fix incorrect fence being assigned to staging texture

  • Loading branch information...
stenzek committed Nov 11, 2018
1 parent f1c41c9 commit a0653a1a34310d916b2a0ae0392f6171d88fa928
Showing with 15 additions and 3 deletions.
  1. +15 −3 Source/Core/VideoBackends/Vulkan/VKTexture.cpp
@@ -407,7 +407,7 @@ void VKStagingTexture::CopyFromTexture(const AbstractTexture* src,
const MathUtil::Rectangle<int>& src_rect, u32 src_layer,
u32 src_level, const MathUtil::Rectangle<int>& dst_rect)
{
ASSERT(m_type == StagingTextureType::Readback);
ASSERT(m_type == StagingTextureType::Readback || m_type == StagingTextureType::Mutable);
ASSERT(src_rect.GetWidth() == dst_rect.GetWidth() &&
src_rect.GetHeight() == dst_rect.GetHeight());
ASSERT(src_rect.left >= 0 && static_cast<u32>(src_rect.right) <= src->GetConfig().width &&
@@ -459,9 +459,15 @@ void VKStagingTexture::CopyFromTexture(Texture2D* src, const MathUtil::Rectangle
g_command_buffer_mgr->AddFencePointCallback(this,
[this](VkCommandBuffer buf, VkFence fence) {
ASSERT(m_needs_flush);
if (m_flush_fence != VK_NULL_HANDLE)
return;

m_flush_fence = fence;
},
[this](VkFence fence) {
if (m_flush_fence != fence)
return;

m_flush_fence = VK_NULL_HANDLE;
m_needs_flush = false;
g_command_buffer_mgr->RemoveFencePointCallback(
@@ -474,7 +480,7 @@ void VKStagingTexture::CopyToTexture(const MathUtil::Rectangle<int>& src_rect, A
const MathUtil::Rectangle<int>& dst_rect, u32 dst_layer,
u32 dst_level)
{
ASSERT(m_type == StagingTextureType::Upload);
ASSERT(m_type == StagingTextureType::Upload || m_type == StagingTextureType::Mutable);
ASSERT(src_rect.GetWidth() == dst_rect.GetWidth() &&
src_rect.GetHeight() == dst_rect.GetHeight());
ASSERT(src_rect.left >= 0 && static_cast<u32>(src_rect.right) <= m_config.width &&
@@ -520,9 +526,15 @@ void VKStagingTexture::CopyToTexture(const MathUtil::Rectangle<int>& src_rect, A
g_command_buffer_mgr->AddFencePointCallback(this,
[this](VkCommandBuffer buf, VkFence fence) {
ASSERT(m_needs_flush);
if (m_flush_fence != VK_NULL_HANDLE)
return;

m_flush_fence = fence;
},
[this](VkFence fence) {
if (m_flush_fence != fence)
return;

m_flush_fence = VK_NULL_HANDLE;
m_needs_flush = false;
g_command_buffer_mgr->RemoveFencePointCallback(
@@ -563,7 +575,7 @@ void VKStagingTexture::Flush()
m_needs_flush = false;

// For readback textures, invalidate the CPU cache as there is new data there.
if (m_type == StagingTextureType::Readback)
if (m_type == StagingTextureType::Readback || m_type == StagingTextureType::Mutable)
m_staging_buffer->InvalidateCPUCache();
}

0 comments on commit a0653a1

Please sign in to comment.