VulkanHostDisplay: Fix uploading of strided textures

This commit is contained in:
Connor McLaughlin 2022-09-18 12:10:36 +10:00
parent 1e6abc1d64
commit a062cc4706
4 changed files with 10 additions and 6 deletions

View File

@ -385,7 +385,7 @@ VkFramebuffer Texture::CreateFramebuffer(VkRenderPass render_pass)
}
void Texture::UpdateFromBuffer(VkCommandBuffer cmdbuf, u32 level, u32 layer, u32 x, u32 y, u32 width, u32 height,
VkBuffer buffer, u32 buffer_offset)
VkBuffer buffer, u32 buffer_offset, u32 row_length)
{
const VkImageLayout old_layout = m_layout;
const Vulkan::Util::DebugScope debugScope(cmdbuf, "Texture::UpdateFromBuffer: Lvl:%u Lyr:%u {%u,%u} %ux%u", level,
@ -393,7 +393,7 @@ void Texture::UpdateFromBuffer(VkCommandBuffer cmdbuf, u32 level, u32 layer, u32
TransitionToLayout(cmdbuf, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
const VkBufferImageCopy bic = {static_cast<VkDeviceSize>(buffer_offset),
width,
row_length,
height,
{VK_IMAGE_ASPECT_COLOR_BIT, 0u, 0u, 1u},
{static_cast<int32_t>(x), static_cast<int32_t>(y), 0},

View File

@ -60,7 +60,7 @@ public:
VkFramebuffer CreateFramebuffer(VkRenderPass render_pass);
void UpdateFromBuffer(VkCommandBuffer cmdbuf, u32 level, u32 layer, u32 x, u32 y, u32 width, u32 height,
VkBuffer buffer, u32 buffer_offset);
VkBuffer buffer, u32 buffer_offset, u32 row_length);
private:
u32 m_width = 0;

View File

@ -1878,7 +1878,8 @@ bool GPU_HW_Vulkan::BlitVRAMReplacementTexture(const TextureReplacementTexture*
// buffer -> texture
m_vram_write_replacement_texture.UpdateFromBuffer(cmdbuf, 0, 0, 0, 0, tex->GetWidth(), tex->GetHeight(),
m_texture_replacment_stream_buffer.GetBuffer(), buffer_offset);
m_texture_replacment_stream_buffer.GetBuffer(), buffer_offset,
tex->GetWidth());
// texture -> vram
const VkImageBlit blit = {

View File

@ -75,7 +75,8 @@ public:
buffer.CommitMemory(required_size);
m_texture.UpdateFromBuffer(g_vulkan_context->GetCurrentCommandBuffer(), 0, 0, x, y, width, height,
buffer.GetBuffer(), buffer_offset);
buffer.GetBuffer(), buffer_offset,
HostDisplay::GetDisplayPixelFormatSize(m_format) / width);
}
const Vulkan::Texture& GetTexture() const { return m_texture; }
@ -240,11 +241,13 @@ std::unique_ptr<HostDisplayTexture> VulkanHostDisplay::CreateTexture(u32 width,
const u32 buffer_offset = buffer.GetCurrentOffset();
buffer.CommitMemory(data_size);
texture.UpdateFromBuffer(g_vulkan_context->GetCurrentCommandBuffer(), 0, 0, 0, 0, width, height,
buffer.GetBuffer(), buffer_offset);
buffer.GetBuffer(), buffer_offset,
data_upload_pitch / GetDisplayPixelFormatSize(format));
}
else
{
use_staging:
// TODO: Drop this thing completely. It's not using the buffer copy row pitch alignment.
Vulkan::StagingTexture staging_texture;
if (!staging_texture.Create(Vulkan::StagingBuffer::Type::Upload, vk_format, width, height))
return {};