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

@tfortes tfortes commented Oct 3, 2025

Copy link
Copy Markdown

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

Copilot AI 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.

File Description
renderer/src/vulkan/vkutil.cpp Refactors upload scheduling and adds a new buffer-based upload path.
renderer/include/rive/renderer/vulkan/vkutil.hpp Exposes the new Texture2D::scheduleUpload(rcp<vkutil::Buffer>) overload.
renderer/src/vulkan/render_context_vulkan_impl.cpp Adds a Vulkan-only makeImageTexture overload that takes a pre-existing buffer.
renderer/include/rive/renderer/vulkan/render_context_vulkan_impl.hpp Declares 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 free to 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