Asset manager pre-caching method. Any interest?

How about a (text) file where each line has the path and file name in the assets?



At start up you could call precache(“some/path/precache.txt”) and the method would simply load those files?



One situation where this could be useful is with Nifty screens. Since all images in a screen are loaded when the XML is loaded those images would already be in the asset manager, thus helping with the loading time. Of course, it you have only a couple of images… Not really worth it.

Yeah, since its basically memory management on the small level theres not much you can do generally. No way to “just load everything” or so, it all doesn’t make too much sense to integrate as its easy to implement a call to assetManager.loadAsset(myAsset) somewhere… Still I think jMEs general performance might benefit from special handling of “standard” (mesh, texture) data loading like I outlined at some point. But its all generic OpenGL “issues” I’m afraid, you get the “GPU upload jerk” with basically all OpenGL (or GPU-based for that matter) libraries.

@madjack said:
How about a (text) file where each line has the path and file name in the assets?

At start up you could call precache("some/path/precache.txt") and the method would simply load those files?

One situation where this could be useful is with Nifty screens. Since all images in a screen are loaded when the XML is loaded those images would already be in the asset manager, thus helping with the loading time. Of course, it you have only a couple of images... Not really worth it.


You could even call that text file Something.java and then quote each line and include this header:
[java]
public class Something {
private static String[] myStuff = {
[/java]

And this footer:
[java]
};

public static void loadMyStuff( AssetManager assets ) {
for( String s : mySuff ) {
assets.loadAsset(s);
}
}
}
[/java]

:) :) :)

@normen @pspeed

Yes. I agree with your comments.



The point of doing that precaching, at least in my mind, was to have an easy way in the core to load textures in advance in memory. I know it’s easily implemented but I do think it would be nice to have that built-in.

1 Like
@madjack said:
@normen @pspeed
Yes. I agree with your comments.

The point of doing that precaching, at least in my mind, was to have an easy way in the core to load textures in advance in memory. I know it's easily implemented but I do think it would be nice to have that built-in.


But if this is where your slow-down is from then you are loading them on the render thread... and that's the issue. Don't load assets on the render thread.

If on the other hand, you are loading a bunch of assets on another thread and then bulk adding them to the scene... then that's the issue and asset manager caching won't fix that.

Otherwise, it's about caching on the GPU and you need to be very careful about that since you can end up making things much worse by bulk caching a bunch of stuff and pushing other things out.
@pspeed said:
But if this is where your slow-down is from then you are loading them on the render thread... and that's the issue. Don't load assets on the render thread.

If on the other hand, you are loading a bunch of assets on another thread and then bulk adding them to the scene... then that's the issue and asset manager caching won't fix that.


This has gone a bit farther than my own little problem, which I'm actually looking into right now.

I'm not doing any caching at all for the moment. Textures are only loaded when used in a material or a nifty screen.


Otherwise, it's about caching on the GPU and you need to be very careful about that since you can end up making things much worse by bulk caching a bunch of stuff and pushing other things out.

Not using that either.

TBH I'm not sure if we're talking about precaching or my slowdown problem. ;)
@madjack said:
This has gone a bit farther than my own little problem, which I'm actually looking into right now.

I'm not doing any caching at all for the moment. Textures are only loaded when used in a material or a nifty screen.


Not using that either.

TBH I'm not sure if we're talking about precaching or my slowdown problem. ;)


I thought we were talking about both... since one was presumed to fix the other... which I suggested (a few times) is probably not the case.

Though since you mention nifty… that might be a place where precaching helps. Since the systems are pretty isolated from one another the textures are always loaded during render. No caching of any sort so you will take a frame hit for large images in a nifty gui… but that’s not a core problem, to me. At least not generally so.