am 6c833986
: Merge "Generate the SurfaceFlinger shader cache on initialization" into lmp-mr1-dev
* commit '6c8339867438c27e468a03995b98481e9e49b274': Generate the SurfaceFlinger shader cache on initialization
This commit is contained in:
commit
36a4d17104
@ -77,13 +77,44 @@ Formatter& dedent(Formatter& f) {
|
|||||||
|
|
||||||
ANDROID_SINGLETON_STATIC_INSTANCE(ProgramCache)
|
ANDROID_SINGLETON_STATIC_INSTANCE(ProgramCache)
|
||||||
|
|
||||||
|
|
||||||
ProgramCache::ProgramCache() {
|
ProgramCache::ProgramCache() {
|
||||||
|
// Until surfaceflinger has a dependable blob cache on the filesystem,
|
||||||
|
// generate shaders on initialization so as to avoid jank.
|
||||||
|
primeCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgramCache::~ProgramCache() {
|
ProgramCache::~ProgramCache() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProgramCache::primeCache() {
|
||||||
|
uint32_t shaderCount = 0;
|
||||||
|
uint32_t keyMask = Key::BLEND_MASK | Key::OPACITY_MASK |
|
||||||
|
Key::PLANE_ALPHA_MASK | Key::TEXTURE_MASK;
|
||||||
|
// Prime the cache for all combinations of the above masks,
|
||||||
|
// leaving off the experimental color matrix mask options.
|
||||||
|
|
||||||
|
nsecs_t timeBefore = systemTime();
|
||||||
|
for (uint32_t keyVal = 0; keyVal <= keyMask; keyVal++) {
|
||||||
|
Key shaderKey;
|
||||||
|
shaderKey.set(keyMask, keyVal);
|
||||||
|
uint32_t tex = shaderKey.getTextureTarget();
|
||||||
|
if (tex != Key::TEXTURE_OFF &&
|
||||||
|
tex != Key::TEXTURE_EXT &&
|
||||||
|
tex != Key::TEXTURE_2D) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Program* program = mCache.valueFor(shaderKey);
|
||||||
|
if (program == NULL) {
|
||||||
|
program = generateProgram(shaderKey);
|
||||||
|
mCache.add(shaderKey, program);
|
||||||
|
shaderCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nsecs_t timeAfter = systemTime();
|
||||||
|
float compileTimeMs = static_cast<float>(timeAfter - timeBefore) / 1.0E6;
|
||||||
|
ALOGD("shader cache generated - %u shaders in %f ms\n", shaderCount, compileTimeMs);
|
||||||
|
}
|
||||||
|
|
||||||
ProgramCache::Key ProgramCache::computeKey(const Description& description) {
|
ProgramCache::Key ProgramCache::computeKey(const Description& description) {
|
||||||
Key needs;
|
Key needs;
|
||||||
needs.set(Key::TEXTURE_MASK,
|
needs.set(Key::TEXTURE_MASK,
|
||||||
|
@ -112,6 +112,8 @@ public:
|
|||||||
void useProgram(const Description& description);
|
void useProgram(const Description& description);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Generate shaders to populate the cache
|
||||||
|
void primeCache();
|
||||||
// compute a cache Key from a Description
|
// compute a cache Key from a Description
|
||||||
static Key computeKey(const Description& description);
|
static Key computeKey(const Description& description);
|
||||||
// generates a program from the Key
|
// generates a program from the Key
|
||||||
|
Loading…
Reference in New Issue
Block a user