Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: include/gpu/GrTBackendEffectFactory.h

Issue 356513003: Step towards variable length effect keys. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweak comment Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/gpu/GrTBackendEffectFactory.h
diff --git a/include/gpu/GrTBackendEffectFactory.h b/include/gpu/GrTBackendEffectFactory.h
index fd14b4fa8ecc5bfa6f5216ce10be50db5aec9861..cd4c0a49e96a40aa16622606027717aad03784d1 100644
--- a/include/gpu/GrTBackendEffectFactory.h
+++ b/include/gpu/GrTBackendEffectFactory.h
@@ -26,39 +26,30 @@ public:
*/
virtual const char* name() const SK_OVERRIDE { return EffectClass::Name(); }
- /** Returns a value that identifies the GLSL shader code generated by
- a GrEffect. This enables caching of generated shaders. Part of the
- id identifies the GrEffect subclass. The remainder is based
- on the aspects of the GrEffect object's configuration that affect
- GLSL code generation. */
- virtual EffectKey glEffectKey(const GrDrawEffect& drawEffect,
- const GrGLCaps& caps) const SK_OVERRIDE {
+ /** Generates an effect's key. This enables caching of generated shaders. Part of the
+ id identifies the GrEffect subclass. The remainder is based on the aspects of the
+ GrEffect object's configuration that affect GLSL code generation. If this fails
+ then program generation should be aborted. Failure occurs if the effect uses more
+ transforms, attributes, or textures than the key has space for. */
+ virtual bool getGLEffectKey(const GrDrawEffect& drawEffect,
+ const GrGLCaps& caps,
+ GrEffectKeyBuilder* b) const SK_OVERRIDE {
SkASSERT(kIllegalEffectClassID != fEffectClassID);
EffectKey effectKey = GLEffect::GenKey(drawEffect, caps);
EffectKey textureKey = GrGLProgramEffects::GenTextureKey(drawEffect, caps);
EffectKey transformKey = GrGLProgramEffects::GenTransformKey(drawEffect);
EffectKey attribKey = GrGLProgramEffects::GenAttribKey(drawEffect);
jvanverth1 2014/07/11 15:33:12 It took me a while to figure out what this is doin
-#ifdef SK_DEBUG
- static const EffectKey kIllegalEffectKeyMask = (uint16_t) (~((1U << kEffectKeyBits) - 1));
- SkASSERT(!(kIllegalEffectKeyMask & effectKey));
-
- static const EffectKey kIllegalTextureKeyMask = (uint16_t) (~((1U << kTextureKeyBits) - 1));
- SkASSERT(!(kIllegalTextureKeyMask & textureKey));
-
- static const EffectKey kIllegalTransformKeyMask = (uint16_t) (~((1U << kTransformKeyBits) - 1));
- SkASSERT(!(kIllegalTransformKeyMask & transformKey));
-
- static const EffectKey kIllegalAttribKeyMask = (uint16_t) (~((1U << kAttribKeyBits) - 1));
- SkASSERT(!(kIllegalAttribKeyMask & textureKey));
+ static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16);
+ if ((textureKey | transformKey | attribKey | fEffectClassID) & kMetaKeyInvalidMask) {
+ return false;
+ }
- static const EffectKey kIllegalClassIDMask = (uint16_t) (~((1U << kClassIDBits) - 1));
- SkASSERT(!(kIllegalClassIDMask & fEffectClassID));
-#endif
- return (fEffectClassID << (kEffectKeyBits+kTextureKeyBits+kTransformKeyBits+kAttribKeyBits)) |
- (attribKey << (kEffectKeyBits+kTextureKeyBits+kTransformKeyBits)) |
- (transformKey << (kEffectKeyBits+kTextureKeyBits)) |
- (textureKey << kEffectKeyBits) |
- (effectKey);
+ // effectKey must be first because it is what will be returned by
+ // GrGLProgramDesc::EffectKeyProvider and passed to the GrGLEffect as its key.
+ b->add32(effectKey);
+ b->add32(textureKey << 16 | transformKey);
+ b->add32(fEffectClassID << 16 | attribKey);
+ return true;
}
/** Returns a new instance of the appropriate *GL* implementation class

Powered by Google App Engine
This is Rietveld 408576698