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

Unified Diff: src/gpu/gl/GrGLProgramDesc.h

Issue 379113004: Makes GrGLProgramDesc's key store the lengths as well as offsets of the effect keys. (Closed) Base URL: https://skia.googlesource.com/skia.git@key
Patch Set: Fix sizeof(uint32_t) bug 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
« no previous file with comments | « include/gpu/GrTBackendEffectFactory.h ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLProgramDesc.h
diff --git a/src/gpu/gl/GrGLProgramDesc.h b/src/gpu/gl/GrGLProgramDesc.h
index d7652f473c6eddf75daf5d2aa0acd9ac29ff68ca..c8aae19503ff6a1654e5976112d07d6972c5dfad 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,
};
« no previous file with comments | « include/gpu/GrTBackendEffectFactory.h ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698