From 99689176bcb928c1ebdb03f7d4b1f21ff91af057 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Thu, 28 Jul 2016 00:07:06 -0500 Subject: [PATCH] Vulkan: Fix a few validation errors --- src/xenia/gpu/vulkan/render_cache.cc | 22 ++++++------------- .../ui/vulkan/vulkan_immediate_drawer.cc | 1 + src/xenia/ui/vulkan/vulkan_swap_chain.cc | 16 +++++++++----- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/xenia/gpu/vulkan/render_cache.cc b/src/xenia/gpu/vulkan/render_cache.cc index f3d3288a7..99c730fc1 100644 --- a/src/xenia/gpu/vulkan/render_cache.cc +++ b/src/xenia/gpu/vulkan/render_cache.cc @@ -374,7 +374,7 @@ CachedRenderPass::CachedRenderPass(VkDevice device, // As we set layout(location=RT) in shaders we must always provide 4. VkAttachmentDescription attachments[5]; for (int i = 0; i < 4; ++i) { - attachments[i].flags = 0; + attachments[i].flags = VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT; attachments[i].format = VK_FORMAT_UNDEFINED; attachments[i].samples = sample_count; attachments[i].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; @@ -1114,26 +1114,22 @@ void RenderCache::BlitToImage(VkCommandBuffer command_buffer, nullptr, 1, &image_barrier); // If we overflow we'll lose the device here. - assert_true(extents.width <= key.tile_width * tile_width); - assert_true(extents.height <= key.tile_height * tile_height); + // assert_true(extents.width <= key.tile_width * tile_width); + // assert_true(extents.height <= key.tile_height * tile_height); // Now issue the blit to the destination. if (tile_view->sample_count == VK_SAMPLE_COUNT_1_BIT) { VkImageBlit image_blit; image_blit.srcSubresource = {0, 0, 0, 1}; image_blit.srcSubresource.aspectMask = - color_or_depth - ? VK_IMAGE_ASPECT_COLOR_BIT - : VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + color_or_depth ? VK_IMAGE_ASPECT_COLOR_BIT : VK_IMAGE_ASPECT_DEPTH_BIT; image_blit.srcOffsets[0] = {0, 0, offset.z}; image_blit.srcOffsets[1] = {int32_t(extents.width), int32_t(extents.height), int32_t(extents.depth)}; image_blit.dstSubresource = {0, 0, 0, 1}; image_blit.dstSubresource.aspectMask = - color_or_depth - ? VK_IMAGE_ASPECT_COLOR_BIT - : VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + color_or_depth ? VK_IMAGE_ASPECT_COLOR_BIT : VK_IMAGE_ASPECT_DEPTH_BIT; image_blit.dstOffsets[0] = offset; image_blit.dstOffsets[1] = {offset.x + int32_t(extents.width), offset.y + int32_t(extents.height), @@ -1144,16 +1140,12 @@ void RenderCache::BlitToImage(VkCommandBuffer command_buffer, VkImageResolve image_resolve; image_resolve.srcSubresource = {0, 0, 0, 1}; image_resolve.srcSubresource.aspectMask = - color_or_depth - ? VK_IMAGE_ASPECT_COLOR_BIT - : VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + color_or_depth ? VK_IMAGE_ASPECT_COLOR_BIT : VK_IMAGE_ASPECT_DEPTH_BIT; image_resolve.srcOffset = {0, 0, 0}; image_resolve.dstSubresource = {0, 0, 0, 1}; image_resolve.dstSubresource.aspectMask = - color_or_depth - ? VK_IMAGE_ASPECT_COLOR_BIT - : VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + color_or_depth ? VK_IMAGE_ASPECT_COLOR_BIT : VK_IMAGE_ASPECT_DEPTH_BIT; image_resolve.dstOffset = offset; image_resolve.extent = extents; diff --git a/src/xenia/ui/vulkan/vulkan_immediate_drawer.cc b/src/xenia/ui/vulkan/vulkan_immediate_drawer.cc index 49b0cbc4d..7c2811589 100644 --- a/src/xenia/ui/vulkan/vulkan_immediate_drawer.cc +++ b/src/xenia/ui/vulkan/vulkan_immediate_drawer.cc @@ -495,6 +495,7 @@ VulkanImmediateDrawer::VulkanImmediateDrawer(VulkanContext* graphics_context) vertex_state_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; vertex_state_info.pNext = nullptr; + vertex_state_info.flags = 0; VkVertexInputBindingDescription vertex_binding_descrs[1]; vertex_binding_descrs[0].binding = 0; vertex_binding_descrs[0].stride = sizeof(ImmediateVertex); diff --git a/src/xenia/ui/vulkan/vulkan_swap_chain.cc b/src/xenia/ui/vulkan/vulkan_swap_chain.cc index ad383f32f..ab32c2837 100644 --- a/src/xenia/ui/vulkan/vulkan_swap_chain.cc +++ b/src/xenia/ui/vulkan/vulkan_swap_chain.cc @@ -134,7 +134,8 @@ bool VulkanSwapChain::Initialize(VkSurfaceKHR surface) { create_info.imageExtent.width = extent.width; create_info.imageExtent.height = extent.height; create_info.imageArrayLayers = 1; - create_info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; + create_info.imageUsage = + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; create_info.queueFamilyIndexCount = 0; create_info.pQueueFamilyIndices = nullptr; @@ -297,6 +298,7 @@ bool VulkanSwapChain::InitializeBuffer(Buffer* buffer, VkImage target_image) { VkFramebufferCreateInfo framebuffer_info; framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; framebuffer_info.pNext = nullptr; + framebuffer_info.flags = 0; framebuffer_info.renderPass = render_pass_; framebuffer_info.attachmentCount = static_cast(xe::countof(attachments)); @@ -377,8 +379,12 @@ bool VulkanSwapChain::Begin() { VkSubmitInfo wait_submit_info; wait_submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; wait_submit_info.pNext = nullptr; + + VkPipelineStageFlags wait_dst_stage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; wait_submit_info.waitSemaphoreCount = 1; wait_submit_info.pWaitSemaphores = &image_available_semaphore_; + wait_submit_info.pWaitDstStageMask = &wait_dst_stage; + wait_submit_info.commandBufferCount = 0; wait_submit_info.pCommandBuffers = nullptr; wait_submit_info.signalSemaphoreCount = 0; @@ -425,8 +431,8 @@ bool VulkanSwapChain::Begin() { pre_image_memory_barrier.subresourceRange.levelCount = 1; pre_image_memory_barrier.subresourceRange.baseArrayLayer = 0; pre_image_memory_barrier.subresourceRange.layerCount = 1; - vkCmdPipelineBarrier(copy_cmd_buffer_, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, - VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0, nullptr, 0, + vkCmdPipelineBarrier(copy_cmd_buffer_, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, nullptr, 1, &pre_image_memory_barrier); // First: Issue a command to clear the render target. @@ -451,8 +457,8 @@ bool VulkanSwapChain::Begin() { pre_image_memory_barrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; pre_image_memory_barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; pre_image_memory_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; - vkCmdPipelineBarrier(render_cmd_buffer_, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, - VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0, nullptr, 0, + vkCmdPipelineBarrier(render_cmd_buffer_, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, nullptr, 1, &pre_image_memory_barrier); // Begin render pass.