Vulkan: Replace explicit command buffer submits with wrapper function

Should we ever introduce anything else that has to be done when a command
buffer is executed (e.g. invalidating constants from previous commit), we
don't have to update all the callers.
This commit is contained in:
Stenzek 2016-11-30 22:34:36 +10:00
parent 3adeacb78d
commit 6a4eba1153
5 changed files with 11 additions and 25 deletions

View File

@ -738,9 +738,7 @@ bool FramebufferManager::PopulateColorReadbackTexture()
}
// Wait until the copy is complete.
g_command_buffer_mgr->ExecuteCommandBuffer(false, true);
StateTracker::GetInstance()->InvalidateDescriptorSets();
StateTracker::GetInstance()->SetPendingRebind();
Util::ExecuteCurrentCommandsAndRestoreState(false, true);
// Map to host memory.
if (!m_color_readback_texture->IsMapped() && !m_color_readback_texture->Map())
@ -822,9 +820,7 @@ bool FramebufferManager::PopulateDepthReadbackTexture()
}
// Wait until the copy is complete.
g_command_buffer_mgr->ExecuteCommandBuffer(false, true);
StateTracker::GetInstance()->InvalidateDescriptorSets();
StateTracker::GetInstance()->SetPendingRebind();
Util::ExecuteCurrentCommandsAndRestoreState(false, true);
// Map to host memory.
if (!m_depth_readback_texture->IsMapped() && !m_depth_readback_texture->Map())
@ -1212,7 +1208,7 @@ void FramebufferManager::DrawPokeVertices(const EFBPokeVertex* vertices, size_t
{
// Kick a command buffer first.
WARN_LOG(VIDEO, "Kicking command buffer due to no EFB poke space.");
Util::ExecuteCurrentCommandsAndRestoreState(true);
Util::ExecuteCurrentCommandsAndRestoreState(false);
command_buffer = g_command_buffer_mgr->GetCurrentCommandBuffer();
if (!m_poke_vertex_stream_buffer->ReserveMemory(vertices_size, sizeof(EfbPokeData), true, true,

View File

@ -326,6 +326,7 @@ void Renderer::BeginFrame()
// Ensure that the state tracker rebinds everything, and allocates a new set
// of descriptors out of the next pool.
StateTracker::GetInstance()->InvalidateDescriptorSets();
StateTracker::GetInstance()->InvalidateConstants();
StateTracker::GetInstance()->SetPendingRebind();
}

View File

@ -710,11 +710,7 @@ bool StateTracker::Bind(bool rebind_all /*= false*/)
{
// We can fail to allocate descriptors if we exhaust the pool for this command buffer.
WARN_LOG(VIDEO, "Failed to get a descriptor set, executing buffer");
// Try again after executing the current buffer.
g_command_buffer_mgr->ExecuteCommandBuffer(false, false);
InvalidateDescriptorSets();
SetPendingRebind();
Util::ExecuteCurrentCommandsAndRestoreState(false, false);
if (!UpdateDescriptorSet())
{
// Something strange going on.
@ -777,10 +773,7 @@ void StateTracker::OnDraw()
m_scheduled_command_buffer_kicks.end(), m_draw_counter))
{
// Kick a command buffer on the background thread.
EndRenderPass();
g_command_buffer_mgr->ExecuteCommandBuffer(true, false);
InvalidateDescriptorSets();
SetPendingRebind();
Util::ExecuteCurrentCommandsAndRestoreState(true);
}
}

View File

@ -145,10 +145,10 @@ void TextureCache::CopyEFB(u8* dst, u32 format, u32 native_width, u32 bytes_per_
else
src_texture = FramebufferManager::GetInstance()->ResolveEFBColorTexture(region);
// End render pass before barrier (since we have no self-dependencies)
// End render pass before barrier (since we have no self-dependencies).
// The barrier has to happen after the render pass, not inside it, as we are going to be
// reading from the texture immediately afterwards.
StateTracker::GetInstance()->EndRenderPass();
StateTracker::GetInstance()->SetPendingRebind();
StateTracker::GetInstance()->InvalidateDescriptorSets();
StateTracker::GetInstance()->OnReadback();
// Transition to shader resource before reading.
@ -666,9 +666,7 @@ bool TextureCache::TCacheEntry::Save(const std::string& filename, unsigned int l
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
// Block until the GPU has finished copying to the staging texture.
g_command_buffer_mgr->ExecuteCommandBuffer(false, true);
StateTracker::GetInstance()->InvalidateDescriptorSets();
StateTracker::GetInstance()->SetPendingRebind();
Util::ExecuteCurrentCommandsAndRestoreState(false, true);
// Map the staging texture so we can copy the contents out.
if (staging_texture->Map())

View File

@ -121,9 +121,7 @@ void TextureEncoder::EncodeTextureToRam(VkImageView src_texture, u8* dest_ptr, u
render_width, render_height, 0, 0);
// Block until the GPU has finished copying to the staging texture.
g_command_buffer_mgr->ExecuteCommandBuffer(false, true);
StateTracker::GetInstance()->InvalidateDescriptorSets();
StateTracker::GetInstance()->SetPendingRebind();
Util::ExecuteCurrentCommandsAndRestoreState(false, true);
// Copy from staging texture to the final destination, adjusting pitch if necessary.
m_download_texture->ReadTexels(0, 0, render_width, render_height, dest_ptr, memory_stride);