Repository navigation
Feature/batch texture loading - #723
Conversation
|
I am too close to the fire on this one. Need another reviewer to look at it as well as myself. |
There was a problem hiding this comment.
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 aResourceRequestcomponent and performs the loads off-thread, returning a component with aLoadedResourceIdor some such.GpuUploadSystem-> takes something like aGpuUploadcomponent and performs the upload in tandem with others, in order to best take advantage of streamingSpriteRendererSystem-> Takes theSpritecomponents, addsResourceRequestto load them,GpuUploadto 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) |
There was a problem hiding this comment.
I'm not sure this API is necessary; we should implement it as part of the sprite renderer system.
There was a problem hiding this comment.
Do you mean as a function or calling the function that loads one texture in a loop?
There was a problem hiding this comment.
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); }, |
There was a problem hiding this comment.
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 = {}; |
There was a problem hiding this comment.
Use TGraphicsBackend here instead of the Vulkan backend explicitly
|
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 |
Fair point. In that case, allow me to update my review.
It's more so that I can visualise everything in my head right now and it's hard to put into words 😅 |
|
I've had to merge main into this due to the fact its getting stale + I need changes from it |
FiniteReality
left a comment
There was a problem hiding this comment.
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.
Please check if the PR fulfills these requirements
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