Get going again
This commit is contained in:
parent
07ec8465d0
commit
66d501fd7f
|
@ -703,6 +703,18 @@ int main(int argc, char** argv)
|
|||
{
|
||||
for (auto& upload : imageUploads)
|
||||
{
|
||||
VkImageMemoryBarrier transferBarrier =
|
||||
{
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||
.srcAccessMask = 0,
|
||||
.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
.image = upload.to,
|
||||
.subresourceRange = FirstColorMipSubresourceRange,
|
||||
};
|
||||
vkCmdPipelineBarrier(cmdBuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &transferBarrier);
|
||||
|
||||
VkBufferImageCopy region =
|
||||
{
|
||||
.bufferOffset = upload.from.offset,
|
||||
|
@ -715,7 +727,19 @@ int main(int argc, char** argv)
|
|||
},
|
||||
.imageExtent = upload.extent,
|
||||
};
|
||||
vkCmdCopyBufferToImage(cmdBuf, upload.from.buffer, upload.to, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, 1, ®ion);
|
||||
vkCmdCopyBufferToImage(cmdBuf, upload.from.buffer, upload.to, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion);
|
||||
|
||||
VkImageMemoryBarrier optimalBarrier =
|
||||
{
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||
.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT,
|
||||
.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
.image = upload.to,
|
||||
.subresourceRange = FirstColorMipSubresourceRange,
|
||||
};
|
||||
vkCmdPipelineBarrier(cmdBuf, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, nullptr, 1, &optimalBarrier);
|
||||
}
|
||||
imageUploads.clear();
|
||||
|
||||
|
|
|
@ -188,6 +188,8 @@ namespace orange
|
|||
|
||||
void Swapchain::Present()
|
||||
{
|
||||
VkResult res = VK_SUCCESS;
|
||||
|
||||
vkResetFences(m_ctx.Device(), 1, &m_inFlightFences[m_currentFrame]);
|
||||
|
||||
const VkPipelineStageFlags waitStage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
|
@ -204,8 +206,8 @@ namespace orange
|
|||
};
|
||||
|
||||
// TODO: Handle failure properly.
|
||||
if (vkQueueSubmit(m_ctx.Queue(), 1, &submitInfo, m_inFlightFences[m_currentFrame]) != VK_SUCCESS) {
|
||||
log::err("Failed to submit work");
|
||||
if ((res = vkQueueSubmit(m_ctx.Queue(), 1, &submitInfo, m_inFlightFences[m_currentFrame])) != VK_SUCCESS) {
|
||||
log::err("Failed to submit work: %d", res);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -219,8 +221,9 @@ namespace orange
|
|||
.pImageIndices = &m_currentImage,
|
||||
};
|
||||
|
||||
if (vkQueuePresentKHR(m_ctx.Queue(), &presentInfo) != VK_SUCCESS) {
|
||||
log::err("Failed to submit present");
|
||||
res = vkQueuePresentKHR(m_ctx.Queue(), &presentInfo);
|
||||
if (res != VK_SUCCESS && res != VK_SUBOPTIMAL_KHR) {
|
||||
log::err("Failed to submit present: %d", res);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue