Skip to content

Feature/batch texture loading - #723

Merged
RubyNova merged 6 commits into
novelrt:mainfrom
WaggingWalrus:feature/batch-texture-loading
Nov 24, 2026
Merged

RubyNova merged 6 commits into
novelrt:mainfrom
WaggingWalrus:feature/batch-texture-loading

Conversation

@WaggingWalrus

@WaggingWalrus WaggingWalrus commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
feature

Is there an open issue that this resolves? If so, please link it here.
Resolves #639

What is the current behavior? (You can also link to an open issue here)
#639

What is the new behavior (if this is a feature change)?
Batches the texture loading and cmdlist uploading

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
No

Other information:
I need help with setting up clang formatting on windows

@RubyNova

RubyNova commented Nov 1, 2026

Copy link
Copy Markdown
Member

I am too close to the fire on this one. Need another reviewer to look at it as well as myself.

@FiniteReality FiniteReality 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.

This is mostly fine as a "quick fix"; just a few minor changes I'd like to see.

Old review, please ignore I'm not sure this is the right way to do this. My gut feeling is telling me that we should instead separate this out into more reusable components and avoid trying to handle and upload sprites in the same code that renders them.

My thought is that we should instead have:

  • ResourceLoadingSystem -> takes something like a ResourceRequest component and performs the loads off-thread, returning a component with a LoadedResourceId or some such.
  • GpuUploadSystem -> takes something like a GpuUpload component and performs the upload in tandem with others, in order to best take advantage of streaming
  • SpriteRendererSystem -> Takes the Sprite components, adds ResourceRequest to load them, GpuUpload to upload them, and renders them.

Is it okay if I take this, after I've finished with the Fabulist tasks? The approach I have in mind should allow us to better take advantage of the GPU long-term.

return LoadTexture(GetGuidsToFilePathsMap().at(assetId));
}

std::vector<TextureMetadata> DesktopResourceLoader::LoadTextures(const std::span<const uuids::uuid> assetIds)

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.

I'm not sure this API is necessary; we should implement it as part of the sprite renderer system.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you mean as a function or calling the function that loads one texture in a loop?

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.

Yeah, in the SpriteRendererSystem we'd just do this instead:

[this, assetIds]() {
    std::vector<TextureMetadata> result(assetIds.size());
    std::transform(assetIds.begin(), assetIds.end(), result.begin(), [_resourceLoader](auto& assetId){ return _resourceLoader->LoadTexture(assetId); });
    return result;
}

ResourceManagement::TextureMetadata textureMetadata)
[this, assetIds]() {
const std::span<const uuids::uuid> assetSpan(assetIds);
return _resourceLoader->LoadTextures(assetSpan); },

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.

nit: missing newline after the semicolon

textureMetadata.height);
std::vector<TextureCache> newTextures;
size_t totalSize = 0;
std::vector<std::shared_ptr<NovelRT::Graphics::GraphicsTexture<NovelRT::Graphics::Vulkan::VulkanGraphicsBackend>>> texture2DVector = {};

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.

Use TGraphicsBackend here instead of the Vulkan backend explicitly

@RubyNova

RubyNova commented Nov 2, 2026

Copy link
Copy Markdown
Member

I explicitly gave Karl this task as a learning exercise. What you have proposed is technically better but out of scope of what the original ticket asked and what I told Karl to do IMHO. If you have rendering work for me I can just probably do this myself anyway, or get Karl to do it at a later date :P I don't want to constantly bother you with changes I could be making or someone who originally authored the change could be making

@FiniteReality

Copy link
Copy Markdown
Contributor

I explicitly gave Karl this task as a learning exercise. What you have proposed is technically better but out of scope of what the original ticket asked and what I told Karl to do IMHO.

Fair point. In that case, allow me to update my review.

If you have rendering work for me [blah blah blah]

It's more so that I can visualise everything in my head right now and it's hard to put into words 😅

@RubyNova

Copy link
Copy Markdown
Member

I've had to merge main into this due to the fact its getting stale + I need changes from it

@FiniteReality FiniteReality 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.

Good work - it took a little longer than expected (my fault entirely!) but this should hopefully reduce the number of direct GPU uploads we do.

@WaggingWalrus
WaggingWalrus marked this pull request as ready for review November 24, 2026 18:04
@RubyNova
RubyNova merged commit 111a870 into novelrt:main Nov 24, 2026
10 checks passed
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.

Reduce number of buffer uploads in SpriteRendererSystem

3 participants