Skip to content

support faster texture updates for vulkan renderer - #72

Open
tfortes wants to merge 1 commit into
rive-app:mainfrom
tfortes:main
Open

support faster texture updates for vulkan renderer#72
tfortes wants to merge 1 commit into
rive-app:mainfrom
tfortes:main

Conversation

@tfortes

Copy link
Copy Markdown

the caller can now provide the vulkan buffer directly, avoiding an allocation and copy.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a Vulkan-specific fast path for image texture creation by allowing callers to supply an existing Vulkan staging buffer directly, avoiding an internal buffer allocation and CPU memcpy during texture uploads.

Changes:

  • Refactors vkutil::Texture2D::scheduleUpload(const void*, size_t) to allocate/copy into a temporary buffer and delegate to a new buffer-based overload.
  • Introduces vkutil::Texture2D::scheduleUpload(rcp<vkutil::Buffer>) to enable deferred uploads from caller-provided buffers.
  • Adds a RenderContextVulkanImpl::makeImageTexture(...) overload that accepts an rcp<vkutil::Buffer> containing RGBA premultiplied data.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

FileDescription
renderer/src/vulkan/vkutil.cppRefactors upload scheduling and adds a new buffer-based upload path.
renderer/include/rive/renderer/vulkan/vkutil.hppExposes the new Texture2D::scheduleUpload(rcp<vkutil::Buffer>) overload.
renderer/src/vulkan/render_context_vulkan_impl.cppAdds a Vulkan-only makeImageTexture overload that takes a pre-existing buffer.
renderer/include/rive/renderer/vulkan/render_context_vulkan_impl.hppDeclares the new Vulkan-only makeImageTexture overload.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +284 to 288
void Texture2D::scheduleUpload(rcp<vkutil::Buffer> imageBuffer)
{
m_imageUploadBuffer = imageBuffer;
m_imageUploadBuffer->flushContents();
}
Comment on lines +91 to +96
rcp<Texture> RenderContextVulkanImpl::makeImageTexture(
uint32_t width, uint32_t height, uint32_t mipLevelCount,
rcp<vkutil::Buffer> imageBufferRGBAPremul)
{
assert(imageBufferRGBAPremul->info().size >= height * width * 4);
auto texture = m_vk->makeTexture2D({
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@tfortes