[Vulkan UI] WaitAndSignalSemaphore -> WaitOnSemaphore

Fix a would-be bug dealing with pWaitDstStageMask
This commit is contained in:
DrChat 2018-03-01 10:20:07 -06:00
parent b3626a039b
commit 6e5f70d39f
2 changed files with 13 additions and 11 deletions

View File

@ -448,8 +448,8 @@ VkResult VulkanSwapChain::Reinitialize() {
return Initialize(surface); return Initialize(surface);
} }
void VulkanSwapChain::WaitAndSignalSemaphore(VkSemaphore sem) { void VulkanSwapChain::WaitOnSemaphore(VkSemaphore sem) {
wait_and_signal_semaphores_.push_back(sem); wait_semaphores_.push_back(sem);
} }
void VulkanSwapChain::Shutdown() { void VulkanSwapChain::Shutdown() {
@ -491,7 +491,7 @@ void VulkanSwapChain::Shutdown() {
} }
VkResult VulkanSwapChain::Begin() { VkResult VulkanSwapChain::Begin() {
wait_and_signal_semaphores_.clear(); wait_semaphores_.clear();
VkResult status; VkResult status;
@ -729,12 +729,14 @@ VkResult VulkanSwapChain::End() {
return status; return status;
} }
VkPipelineStageFlags wait_dst_stage = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
std::vector<VkSemaphore> semaphores; std::vector<VkSemaphore> semaphores;
for (size_t i = 0; i < wait_and_signal_semaphores_.size(); i++) { std::vector<VkPipelineStageFlags> wait_dst_stages;
semaphores.push_back(wait_and_signal_semaphores_[i]); for (size_t i = 0; i < wait_semaphores_.size(); i++) {
semaphores.push_back(wait_semaphores_[i]);
wait_dst_stages.push_back(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
} }
semaphores.push_back(image_usage_semaphore_); semaphores.push_back(image_usage_semaphore_);
wait_dst_stages.push_back(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT);
// Submit commands. // Submit commands.
// Wait on the image usage semaphore (signaled when an image is available) // Wait on the image usage semaphore (signaled when an image is available)
@ -743,11 +745,11 @@ VkResult VulkanSwapChain::End() {
render_submit_info.pNext = nullptr; render_submit_info.pNext = nullptr;
render_submit_info.waitSemaphoreCount = uint32_t(semaphores.size()); render_submit_info.waitSemaphoreCount = uint32_t(semaphores.size());
render_submit_info.pWaitSemaphores = semaphores.data(); render_submit_info.pWaitSemaphores = semaphores.data();
render_submit_info.pWaitDstStageMask = &wait_dst_stage; render_submit_info.pWaitDstStageMask = wait_dst_stages.data();
render_submit_info.commandBufferCount = 1; render_submit_info.commandBufferCount = 1;
render_submit_info.pCommandBuffers = &cmd_buffer_; render_submit_info.pCommandBuffers = &cmd_buffer_;
render_submit_info.signalSemaphoreCount = uint32_t(semaphores.size()) - 1; render_submit_info.signalSemaphoreCount = 0;
render_submit_info.pSignalSemaphores = semaphores.data(); render_submit_info.pSignalSemaphores = nullptr;
if (presentation_queue_mutex_) { if (presentation_queue_mutex_) {
presentation_queue_mutex_->lock(); presentation_queue_mutex_->lock();
} }

View File

@ -55,7 +55,7 @@ class VulkanSwapChain {
VkResult Reinitialize(); VkResult Reinitialize();
// Waits on and signals a semaphore in this operation. // Waits on and signals a semaphore in this operation.
void WaitAndSignalSemaphore(VkSemaphore sem); void WaitOnSemaphore(VkSemaphore sem);
// Begins the swap operation, preparing state for rendering. // Begins the swap operation, preparing state for rendering.
VkResult Begin(); VkResult Begin();
@ -96,7 +96,7 @@ class VulkanSwapChain {
VkSemaphore image_usage_semaphore_ = nullptr; VkSemaphore image_usage_semaphore_ = nullptr;
uint32_t current_buffer_index_ = 0; uint32_t current_buffer_index_ = 0;
std::vector<Buffer> buffers_; std::vector<Buffer> buffers_;
std::vector<VkSemaphore> wait_and_signal_semaphores_; std::vector<VkSemaphore> wait_semaphores_;
}; };
} // namespace vulkan } // namespace vulkan