So to be fair we have experienced this back in 5.4- however looking at the code in 5.7 I don’t see this changed (though maybe it’s no longer relevant).
We implemented a widget that’s able to stream a virtual texture- this is useful for stuff like rendering large prerendered map images in the UI, etc. (and I would highly encourage Epic to ship something like this themselves- there is already code doing something similar in the World Partition Minimap widget (though last I checked the areas of the VT it was requesting to load were actually calculated incorrectly)- putting this into a dedicated UMG/Slate widget would be useful for everyone). As part of this we need to do the following to request the VT tiles for the texture being rendered to actually load:
ENQUEUE_RENDER_COMMAND(SVTImage_RequestVTTiles)(
[InFeatureLevel, VTResource, ScreenSpaceSize, ViewportPositon, ViewportSize, UV0, UV1, MipLevel](FRHICommandListImmediate& RHICmdList)
{
// AcquireAllocatedVT() must happen on render thread
IAllocatedVirtualTexture* AllocatedVT = VTResource->AcquireAllocatedVT();
IRendererModule& RenderModule = GetRendererModule();
RenderModule.RequestVirtualTextureTiles(AllocatedVT, ScreenSpaceSize, -ViewportPositon, ViewportSize, UV0, UV1, MipLevel);
RenderModule.LoadPendingVirtualTextureTiles(RHICmdList, InFeatureLevel, true);
})
This is pretty similar to code throughout the engine that tries to load VT tiles- however we have an extra param we have modded here-
virtual void LoadPendingVirtualTextureTiles(FRHICommandListImmediate& RHICmdList, ERHIFeatureLevel::Type FeatureLevel, bool bAsync = false) = 0;
If you follow the code down for LoadPendingVirtualTextureTiles you eventually get into FVirtualTextureSystem::LoadPendingTiles, which has a call to FVirtualTextureSystem::SubmitRequests that passes a hardcoded ‘false’ for bAsync. This causes LoadPendingTiles to generally hitch when requesting tiles- making this pretty unusable for runtime code. It’s trivial to just add a bool (and default it to false for back compat) to LoadPendingVirtualTextureTiles on whether or not the submit should be async (pass it down to FVirtualTextureSystem::LoadPendingTiles, which then passes it down to FVirtualTextureSystem::SubmitRequests).
Is this something Epic would consider adding themselves so we can remove our modification? It’s a simple modification (adding and passing a bool down a couple functions) that adds a bit of flexibility to the render / VT API and makes trying to manually load VTs at runtime a bit easier.
(Also, again, Epic should implement their own image widget capable of streaming a VT texture- but that’s beyond what I’m asking here.)
[Attachment Removed]