From fa62d395fd5a074cee0610cc2bce3b36e84b6139 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Tue, 22 Mar 2022 21:51:02 +0300 Subject: [PATCH] [Vulkan] InitializeSubresourceRange: Use return, not reference --- src/xenia/gpu/vulkan/vulkan_command_processor.cc | 16 ++++++++-------- src/xenia/ui/vulkan/vulkan_immediate_drawer.cc | 5 +++-- src/xenia/ui/vulkan/vulkan_presenter.cc | 2 +- src/xenia/ui/vulkan/vulkan_util.h | 5 +++-- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/xenia/gpu/vulkan/vulkan_command_processor.cc b/src/xenia/gpu/vulkan/vulkan_command_processor.cc index be7268329..14cce000e 100644 --- a/src/xenia/gpu/vulkan/vulkan_command_processor.cc +++ b/src/xenia/gpu/vulkan/vulkan_command_processor.cc @@ -404,8 +404,8 @@ void VulkanCommandProcessor::IssueSwap(uint32_t frontbuffer_ptr, acquire_image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; acquire_image_memory_barrier.image = texture->image; - ui::vulkan::util::InitializeSubresourceRange( - acquire_image_memory_barrier.subresourceRange); + acquire_image_memory_barrier.subresourceRange = + ui::vulkan::util::InitializeSubresourceRange(); } { acquire_barrier_dst_stages |= @@ -427,8 +427,8 @@ void VulkanCommandProcessor::IssueSwap(uint32_t frontbuffer_ptr, acquire_image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; acquire_image_memory_barrier.image = vulkan_context.image(); - ui::vulkan::util::InitializeSubresourceRange( - acquire_image_memory_barrier.subresourceRange); + acquire_image_memory_barrier.subresourceRange = + ui::vulkan::util::InitializeSubresourceRange(); if (vulkan_context.image_ever_written_previously()) { acquire_barrier_src_stages |= ui::vulkan::VulkanPresenter::kGuestOutputInternalStageMask; @@ -496,8 +496,8 @@ void VulkanCommandProcessor::IssueSwap(uint32_t frontbuffer_ptr, release_image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; release_image_memory_barrier.image = texture->image; - ui::vulkan::util::InitializeSubresourceRange( - release_image_memory_barrier.subresourceRange); + release_image_memory_barrier.subresourceRange = + ui::vulkan::util::InitializeSubresourceRange(); } { release_barrier_src_stages |= @@ -523,8 +523,8 @@ void VulkanCommandProcessor::IssueSwap(uint32_t frontbuffer_ptr, release_image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; release_image_memory_barrier.image = vulkan_context.image(); - ui::vulkan::util::InitializeSubresourceRange( - release_image_memory_barrier.subresourceRange); + release_image_memory_barrier.subresourceRange = + ui::vulkan::util::InitializeSubresourceRange(); } assert_not_zero(release_barrier_src_stages); assert_not_zero(release_barrier_dst_stages); diff --git a/src/xenia/ui/vulkan/vulkan_immediate_drawer.cc b/src/xenia/ui/vulkan/vulkan_immediate_drawer.cc index b8fecdaa1..a90f530d9 100644 --- a/src/xenia/ui/vulkan/vulkan_immediate_drawer.cc +++ b/src/xenia/ui/vulkan/vulkan_immediate_drawer.cc @@ -426,7 +426,8 @@ void VulkanImmediateDrawer::End() { image_memory_barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; image_memory_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - util::InitializeSubresourceRange(image_memory_barrier.subresourceRange); + image_memory_barrier.subresourceRange = + util::InitializeSubresourceRange(); for (const PendingTextureUpload& pending_texture_upload : texture_uploads_pending_) { image_memory_barriers.emplace_back(image_memory_barrier).image = @@ -913,7 +914,7 @@ bool VulkanImmediateDrawer::CreateTextureResource( image_view_create_info.components.g = swizzle; image_view_create_info.components.b = swizzle; image_view_create_info.components.a = swizzle; - util::InitializeSubresourceRange(image_view_create_info.subresourceRange); + image_view_create_info.subresourceRange = util::InitializeSubresourceRange(); VkImageView image_view; if (dfn.vkCreateImageView(device, &image_view_create_info, nullptr, &image_view) != VK_SUCCESS) { diff --git a/src/xenia/ui/vulkan/vulkan_presenter.cc b/src/xenia/ui/vulkan/vulkan_presenter.cc index bf129b103..f1353bf3e 100644 --- a/src/xenia/ui/vulkan/vulkan_presenter.cc +++ b/src/xenia/ui/vulkan/vulkan_presenter.cc @@ -313,7 +313,7 @@ bool VulkanPresenter::CaptureGuestOutput(RawImage& image_out) { image_memory_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; image_memory_barrier.image = guest_output_image->image(); - util::InitializeSubresourceRange(image_memory_barrier.subresourceRange); + image_memory_barrier.subresourceRange = util::InitializeSubresourceRange(); dfn.vkCmdPipelineBarrier(command_buffer, kGuestOutputInternalStageMask, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); diff --git a/src/xenia/ui/vulkan/vulkan_util.h b/src/xenia/ui/vulkan/vulkan_util.h index 0eb2532d0..b566e26bb 100644 --- a/src/xenia/ui/vulkan/vulkan_util.h +++ b/src/xenia/ui/vulkan/vulkan_util.h @@ -124,17 +124,18 @@ inline VkExtent2D GetMax2DFramebufferExtent(const VulkanProvider& provider) { return max_extent; } -inline void InitializeSubresourceRange( - VkImageSubresourceRange& range, +inline VkImageSubresourceRange InitializeSubresourceRange( VkImageAspectFlags aspect_mask = VK_IMAGE_ASPECT_COLOR_BIT, uint32_t base_mip_level = 0, uint32_t level_count = VK_REMAINING_MIP_LEVELS, uint32_t base_array_layer = 0, uint32_t layer_count = VK_REMAINING_ARRAY_LAYERS) { + VkImageSubresourceRange range; range.aspectMask = aspect_mask; range.baseMipLevel = base_mip_level; range.levelCount = level_count; range.baseArrayLayer = base_array_layer; range.layerCount = layer_count; + return range; } // Creates a buffer backed by a dedicated allocation. The allocation size will