public class ProgramCache
extends java.lang.Object
saveToCache(java.lang.String, com.jme3.opencl.Program)
.
On the next run, the stored programs can then be loaded
with loadFromCache(java.lang.String, java.lang.String)
.
id = <full name of the class using the program>.<unique identifier within that class>
.Constructor and Description |
---|
ProgramCache()
Creates a "disabled" program cache, no caching is done.
|
ProgramCache(Context context)
Creates a new program cache using the first device from the specified
context.
|
ProgramCache(Context context,
Device device)
Creates a new program cache associated with the specified context and
devices.
|
Modifier and Type | Method and Description |
---|---|
void |
clearCache()
Clears the cache.
|
protected java.lang.String |
getCleanFileName(java.lang.String id) |
Program |
loadFromCache(java.lang.String id)
Calls
loadFromCache(java.lang.String, java.lang.String)
with the additional build arguments set to "" . |
Program |
loadFromCache(java.lang.String id,
java.lang.String buildArgs)
Loads the program from the cache and builds it against the current device.
|
void |
saveToCache(java.lang.String id,
Program program)
Saves the specified program in the cache.
|
public ProgramCache()
loadFromCache(java.lang.String)
will always return null
and saveToCache(java.lang.String, com.jme3.opencl.Program)
does
nothing.public ProgramCache(Context context, Device device)
context
- the OpenCL contextdevice
- the OpenCL devicepublic ProgramCache(Context context)
context
- the contextProgramCache(com.jme3.opencl.Context, com.jme3.opencl.Device)
protected java.lang.String getCleanFileName(java.lang.String id)
public Program loadFromCache(java.lang.String id, java.lang.String buildArgs)
buildArgs
.
The cached program is identified by the specified id.
This id must be unique, otherwise collisions within the cache occur.
Therefore, the following naming schema is recommended:
id = <full name of the class using the program>.<unique identifier within that class>
.
If the program can't be loaded, built or any other exception happened,
null
is returned.
id
- the unique identifier of this programbuildArgs
- additional build arguments, can be null
null
saveToCache(java.lang.String, com.jme3.opencl.Program)
public Program loadFromCache(java.lang.String id)
loadFromCache(java.lang.String, java.lang.String)
with the additional build arguments set to ""
.id
- a unique identifier of the programnull
if this
program could not be loaded from the cacheloadFromCache(java.lang.String, java.lang.String)
public void saveToCache(java.lang.String id, Program program)
id
denotes the name of the program. Under this id,
the program is then loaded again by loadFromCache(java.lang.String, java.lang.String)
.
id = <full name of the class using the program>.<unique identifier within that class>
.id
- the program idprogram
- the program to store in the cachepublic void clearCache()