diff options
author | bsalomon <bsalomon@google.com> | 2014-07-17 07:55:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-07-17 07:55:11 -0700 |
commit | 929f29a5c1bffa7f7c1b5a376351d0762b8ac561 (patch) | |
tree | 19e2f4bedb96946a8190d01864ec687a4d2ca260 /src/gpu/gl/GrGLProgramDesc.h | |
parent | b959ec7815ae0f65f2aabdeaf280a2a2ee6db955 (diff) |
Makes GrGLProgramDesc's key store the lengths as well as offsets of the effect keys.
Makes it possible to use GrBackendEffectFactories other than GrTBEF by moving meta-key generation out of GrTBEF.
Cleans up docs around GrBackendEffectFactory.
Committed: https://skia.googlesource.com/skia/+/c0ea398aff8254e31152cbb94c9ab6150428e252
R=robertphillips@google.com, jvanverth@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/379113004
Diffstat (limited to 'src/gpu/gl/GrGLProgramDesc.h')
-rw-r--r-- | src/gpu/gl/GrGLProgramDesc.h | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/gpu/gl/GrGLProgramDesc.h b/src/gpu/gl/GrGLProgramDesc.h index d7652f473c..c8aae19503 100644 --- a/src/gpu/gl/GrGLProgramDesc.h +++ b/src/gpu/gl/GrGLProgramDesc.h @@ -172,14 +172,20 @@ private: // 1. uint32_t for total key length. // 2. uint32_t for a checksum. // 3. Header struct defined above. - // 4. uint32_t offsets to beginning of every effects' key (see 5). + // 4. An array of offsets to effect keys and their sizes (see 5). uint16_t for each + // offset and size. // 5. per-effect keys. Each effect's key is a variable length array of uint32_t. enum { + // Part 1. kLengthOffset = 0, + // Part 2. kChecksumOffset = kLengthOffset + sizeof(uint32_t), + // Part 3. kHeaderOffset = kChecksumOffset + sizeof(uint32_t), kHeaderSize = SkAlign4(sizeof(KeyHeader)), - kEffectKeyLengthsOffset = kHeaderOffset + kHeaderSize, + // Part 4. + // This is the offset in the overall key to the array of per-effect offset,length pairs. + kEffectKeyOffsetsAndLengthOffset = kHeaderOffset + kHeaderSize, }; template<typename T, size_t OFFSET> T* atOffset() { @@ -194,6 +200,16 @@ private: KeyHeader* header() { return this->atOffset<KeyHeader, kHeaderOffset>(); } + // Shared code between setRandom() and Build(). + static bool GetEffectKeyAndUpdateStats(const GrEffectStage& stage, + const GrGLCaps& caps, + bool useExplicitLocalCoords, + GrEffectKeyBuilder* b, + uint16_t* effectKeySize, + bool* setTrueIfReadsDst, + bool* setTrueIfReadsPos, + bool* setTrueIfHasVertexCode); + void finalize(); const KeyHeader& getHeader() const { return *this->atOffset<KeyHeader, kHeaderOffset>(); } @@ -212,9 +228,11 @@ private: } EffectKey get(int index) const { - const uint32_t* offsets = reinterpret_cast<const uint32_t*>(fDesc->fKey.begin() + - kEffectKeyLengthsOffset); - uint32_t offset = offsets[fBaseIndex + index]; + const uint16_t* offsets = reinterpret_cast<const uint16_t*>( + fDesc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset); + // We store two uint16_ts per effect, one for the offset to the effect's key and one for + // its length. Here we just need the offset. + uint16_t offset = offsets[2 * (fBaseIndex + index)]; return *reinterpret_cast<const EffectKey*>(fDesc->fKey.begin() + offset); } private: @@ -225,7 +243,7 @@ private: enum { kMaxPreallocEffects = 8, kIntsPerEffect = 4, // This is an overestimate of the average effect key size. - kPreAllocSize = kEffectKeyLengthsOffset + + kPreAllocSize = kEffectKeyOffsetsAndLengthOffset + kMaxPreallocEffects * sizeof(uint32_t) * kIntsPerEffect, }; |