mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 23:55:40 +00:00
Vulkan/Texture: Add UpdateFromBuffer method
This commit is contained in:
parent
ebaad0f35a
commit
a66f14b5c3
|
@ -371,4 +371,22 @@ VkFramebuffer Texture::CreateFramebuffer(VkRenderPass render_pass)
|
||||||
return fb;
|
return fb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Texture::UpdateFromBuffer(VkCommandBuffer cmdbuf, u32 level, u32 layer, u32 x, u32 y, u32 width, u32 height,
|
||||||
|
VkBuffer buffer, u32 buffer_offset)
|
||||||
|
{
|
||||||
|
const VkImageLayout old_layout = m_layout;
|
||||||
|
TransitionToLayout(cmdbuf, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||||
|
|
||||||
|
const VkBufferImageCopy bic = {static_cast<VkDeviceSize>(buffer_offset),
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
{VK_IMAGE_ASPECT_COLOR_BIT, 0u, 0u, 1u},
|
||||||
|
{static_cast<int32_t>(x), static_cast<int32_t>(y), 0},
|
||||||
|
{width, height, 1u}};
|
||||||
|
|
||||||
|
vkCmdCopyBufferToImage(cmdbuf, buffer, m_image, m_layout, 1, &bic);
|
||||||
|
|
||||||
|
TransitionToLayout(cmdbuf, old_layout);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|
|
@ -54,6 +54,9 @@ public:
|
||||||
|
|
||||||
VkFramebuffer CreateFramebuffer(VkRenderPass render_pass);
|
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);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u32 m_width = 0;
|
u32 m_width = 0;
|
||||||
u32 m_height = 0;
|
u32 m_height = 0;
|
||||||
|
|
Loading…
Reference in a new issue