From c0c3666e121ae377b2cfab7ce115f6e4c512450b Mon Sep 17 00:00:00 2001 From: Triang3l Date: Wed, 29 Jun 2022 23:41:32 +0300 Subject: [PATCH] [Vulkan] Align texture extents in loading to vector size accessed by the shader Fixes loading of the 1x1 linear 8_8_8_8 texture containing just a single #FFFFFFFF texel in 4D5307E6, which is used for screen fade and the lobby map loading bar background --- src/xenia/gpu/vulkan/vulkan_texture_cache.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/xenia/gpu/vulkan/vulkan_texture_cache.cc b/src/xenia/gpu/vulkan/vulkan_texture_cache.cc index 51c1d1b09..f2dc4ea29 100644 --- a/src/xenia/gpu/vulkan/vulkan_texture_cache.cc +++ b/src/xenia/gpu/vulkan/vulkan_texture_cache.cc @@ -1256,6 +1256,11 @@ bool VulkanTextureCache::LoadTextureDataFromResidentMemoryImpl(Texture& texture, } // TODO(Triang3l): Use a single 512 MB shared memory binding if possible. // TODO(Triang3l): Scaled resolve buffer bindings. + // Aligning because if the data for a vector in a storage buffer is provided + // partially, the value read may still be (0, 0, 0, 0), and small (especially + // linear) textures won't be loaded correctly. + uint32_t source_length_alignment = UINT32_C(1) + << load_shader_info.source_bpe_log2; VkDescriptorSet descriptor_set_source_base = VK_NULL_HANDLE; VkDescriptorSet descriptor_set_source_mips = VK_NULL_HANDLE; VkDescriptorBufferInfo write_descriptor_set_source_base_buffer_info; @@ -1273,7 +1278,7 @@ bool VulkanTextureCache::LoadTextureDataFromResidentMemoryImpl(Texture& texture, write_descriptor_set_source_base_buffer_info.offset = texture_key.base_page << 12; write_descriptor_set_source_base_buffer_info.range = - vulkan_texture.GetGuestBaseSize(); + xe::align(vulkan_texture.GetGuestBaseSize(), source_length_alignment); VkWriteDescriptorSet& write_descriptor_set_source_base = write_descriptor_sets[write_descriptor_set_count++]; write_descriptor_set_source_base.sType = @@ -1303,7 +1308,7 @@ bool VulkanTextureCache::LoadTextureDataFromResidentMemoryImpl(Texture& texture, write_descriptor_set_source_mips_buffer_info.offset = texture_key.mip_page << 12; write_descriptor_set_source_mips_buffer_info.range = - vulkan_texture.GetGuestMipsSize(); + xe::align(vulkan_texture.GetGuestMipsSize(), source_length_alignment); VkWriteDescriptorSet& write_descriptor_set_source_mips = write_descriptor_sets[write_descriptor_set_count++]; write_descriptor_set_source_mips.sType =